svn_magic.h revision 299742
1/** 2 * @copyright 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 * 23 * @file svn_magic.h 24 * @brief Subversion interface to libmagic. 25 */ 26 27#ifndef SVN_MAGIC_H 28#define SVN_MAGIC_H 29 30/* An opaque struct that wraps a libmagic cookie. */ 31typedef struct svn_magic__cookie_t svn_magic__cookie_t; 32 33/* This routine initialises libmagic. CONFIG is a config hash and 34 * may be NULL. 35 * Upon success a new *MAGIC_COOKIE is allocated in RESULT_POOL. 36 * On failure *MAGIC_COOKIE is set to NULL. 37 * All resources used by libmagic are freed by a cleanup handler 38 * installed on RESULT_POOL, i.e. *MAGIC_COOKIE becomes invalid when 39 * the pool is cleared! */ 40svn_error_t * 41svn_magic__init(svn_magic__cookie_t **magic_cookie, 42 apr_hash_t *config, 43 apr_pool_t *result_pool); 44 45/* Detect the mime-type of the file at LOCAL_ABSPATH using MAGIC_COOKIE. 46 * If the mime-type is binary return the result in *MIMETYPE. 47 * If the file is not a binary file or if its mime-type cannot be determined 48 * set *MIMETYPE to NULL. Allocate *MIMETYPE in RESULT_POOL. 49 * Use SCRATCH_POOL for temporary allocations. */ 50svn_error_t * 51svn_magic__detect_binary_mimetype(const char **mimetype, 52 const char *local_abspath, 53 svn_magic__cookie_t *magic_cookie, 54 apr_pool_t *result_pool, 55 apr_pool_t *scratch_pool); 56 57#endif /* SVN_MAGIC_H */ 58