1251881Speter/**
2251881Speter * @copyright
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter * @endcopyright
22251881Speter *
23251881Speter * @file svn_magic.h
24251881Speter * @brief Subversion interface to libmagic.
25251881Speter */
26251881Speter
27251881Speter#ifndef SVN_MAGIC_H
28251881Speter#define SVN_MAGIC_H
29251881Speter
30251881Speter/* An opaque struct that wraps a libmagic cookie. */
31251881Spetertypedef struct svn_magic__cookie_t svn_magic__cookie_t;
32251881Speter
33289180Speter/* This routine initialises libmagic.  CONFIG is a config hash and
34289180Speter * may be NULL.
35251881Speter * Upon success a new *MAGIC_COOKIE is allocated in RESULT_POOL.
36251881Speter * On failure *MAGIC_COOKIE is set to NULL.
37251881Speter * All resources used by libmagic are freed by a cleanup handler
38251881Speter * installed on RESULT_POOL, i.e. *MAGIC_COOKIE becomes invalid when
39251881Speter * the pool is cleared! */
40289180Spetersvn_error_t *
41251881Spetersvn_magic__init(svn_magic__cookie_t **magic_cookie,
42289180Speter                apr_hash_t *config,
43251881Speter                apr_pool_t *result_pool);
44251881Speter
45251881Speter/* Detect the mime-type of the file at LOCAL_ABSPATH using MAGIC_COOKIE.
46251881Speter * If the mime-type is binary return the result in *MIMETYPE.
47251881Speter * If the file is not a binary file or if its mime-type cannot be determined
48251881Speter * set *MIMETYPE to NULL. Allocate *MIMETYPE in RESULT_POOL.
49251881Speter * Use SCRATCH_POOL for temporary allocations. */
50251881Spetersvn_error_t *
51251881Spetersvn_magic__detect_binary_mimetype(const char **mimetype,
52251881Speter                                  const char *local_abspath,
53251881Speter                                  svn_magic__cookie_t *magic_cookie,
54251881Speter                                  apr_pool_t *result_pool,
55251881Speter                                  apr_pool_t *scratch_pool);
56251881Speter
57251881Speter#endif /* SVN_MAGIC_H */
58