magic.h.in revision 288143
1267843Sdelphij/* 2267843Sdelphij * Copyright (c) Christos Zoulas 2003. 3267843Sdelphij * All Rights Reserved. 4267843Sdelphij * 5267843Sdelphij * Redistribution and use in source and binary forms, with or without 6267843Sdelphij * modification, are permitted provided that the following conditions 7267843Sdelphij * are met: 8267843Sdelphij * 1. Redistributions of source code must retain the above copyright 9267843Sdelphij * notice immediately at the beginning of the file, without modification, 10267843Sdelphij * this list of conditions, and the following disclaimer. 11267843Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 12267843Sdelphij * notice, this list of conditions and the following disclaimer in the 13267843Sdelphij * documentation and/or other materials provided with the distribution. 14267843Sdelphij * 15267843Sdelphij * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16267843Sdelphij * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17267843Sdelphij * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18267843Sdelphij * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 19267843Sdelphij * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20267843Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21267843Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22267843Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23267843Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24267843Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25267843Sdelphij * SUCH DAMAGE. 26267843Sdelphij */ 27267843Sdelphij#ifndef _MAGIC_H 28267843Sdelphij#define _MAGIC_H 29267843Sdelphij 30267843Sdelphij#include <sys/types.h> 31267843Sdelphij 32284237Sdelphij#define MAGIC_NONE 0x0000000 /* No flags */ 33284237Sdelphij#define MAGIC_DEBUG 0x0000001 /* Turn on debugging */ 34284237Sdelphij#define MAGIC_SYMLINK 0x0000002 /* Follow symlinks */ 35284237Sdelphij#define MAGIC_COMPRESS 0x0000004 /* Check inside compressed files */ 36284237Sdelphij#define MAGIC_DEVICES 0x0000008 /* Look at the contents of devices */ 37284237Sdelphij#define MAGIC_MIME_TYPE 0x0000010 /* Return the MIME type */ 38284237Sdelphij#define MAGIC_CONTINUE 0x0000020 /* Return all matches */ 39284237Sdelphij#define MAGIC_CHECK 0x0000040 /* Print warnings to stderr */ 40284237Sdelphij#define MAGIC_PRESERVE_ATIME 0x0000080 /* Restore access time on exit */ 41284237Sdelphij#define MAGIC_RAW 0x0000100 /* Don't convert unprintable chars */ 42284237Sdelphij#define MAGIC_ERROR 0x0000200 /* Handle ENOENT etc as real errors */ 43284237Sdelphij#define MAGIC_MIME_ENCODING 0x0000400 /* Return the MIME encoding */ 44267843Sdelphij#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING) 45284237Sdelphij#define MAGIC_APPLE 0x0000800 /* Return the Apple creator/type */ 46284237Sdelphij#define MAGIC_EXTENSION 0x1000000 /* Return a /-separated list of 47284237Sdelphij * extensions */ 48284237Sdelphij#define MAGIC_COMPRESS_TRANSP 0x2000000 /* Check inside compressed files 49284237Sdelphij * but not report compression */ 50284237Sdelphij#define MAGIC_NODESC (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE) 51267843Sdelphij 52284237Sdelphij#define MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */ 53284237Sdelphij#define MAGIC_NO_CHECK_TAR 0x0002000 /* Don't check for tar files */ 54284237Sdelphij#define MAGIC_NO_CHECK_SOFT 0x0004000 /* Don't check magic entries */ 55284237Sdelphij#define MAGIC_NO_CHECK_APPTYPE 0x0008000 /* Don't check application type */ 56284237Sdelphij#define MAGIC_NO_CHECK_ELF 0x0010000 /* Don't check for elf details */ 57284237Sdelphij#define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */ 58284237Sdelphij#define MAGIC_NO_CHECK_CDF 0x0040000 /* Don't check for cdf files */ 59284237Sdelphij#define MAGIC_NO_CHECK_TOKENS 0x0100000 /* Don't check tokens */ 60284237Sdelphij#define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */ 61267843Sdelphij 62267843Sdelphij/* No built-in tests; only consult the magic file */ 63267843Sdelphij#define MAGIC_NO_CHECK_BUILTIN ( \ 64267843Sdelphij MAGIC_NO_CHECK_COMPRESS | \ 65267843Sdelphij MAGIC_NO_CHECK_TAR | \ 66267843Sdelphij/* MAGIC_NO_CHECK_SOFT | */ \ 67267843Sdelphij MAGIC_NO_CHECK_APPTYPE | \ 68267843Sdelphij MAGIC_NO_CHECK_ELF | \ 69267843Sdelphij MAGIC_NO_CHECK_TEXT | \ 70267843Sdelphij MAGIC_NO_CHECK_CDF | \ 71267843Sdelphij MAGIC_NO_CHECK_TOKENS | \ 72267843Sdelphij MAGIC_NO_CHECK_ENCODING | \ 73267843Sdelphij 0 \ 74267843Sdelphij) 75267843Sdelphij 76267843Sdelphij/* Defined for backwards compatibility (renamed) */ 77267843Sdelphij#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT 78267843Sdelphij 79267843Sdelphij/* Defined for backwards compatibility; do nothing */ 80267843Sdelphij#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */ 81267843Sdelphij#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */ 82267843Sdelphij 83267843Sdelphij#define MAGIC_VERSION X.YY /* This implementation */ 84267843Sdelphij 85267843Sdelphij 86267843Sdelphij#ifdef __cplusplus 87267843Sdelphijextern "C" { 88267843Sdelphij#endif 89267843Sdelphij 90267843Sdelphijtypedef struct magic_set *magic_t; 91267843Sdelphijmagic_t magic_open(int); 92267843Sdelphijvoid magic_close(magic_t); 93267843Sdelphij 94267843Sdelphijconst char *magic_getpath(const char *, int); 95267843Sdelphijconst char *magic_file(magic_t, const char *); 96267843Sdelphijconst char *magic_descriptor(magic_t, int); 97267843Sdelphijconst char *magic_buffer(magic_t, const void *, size_t); 98267843Sdelphij 99267843Sdelphijconst char *magic_error(magic_t); 100267843Sdelphijint magic_setflags(magic_t, int); 101267843Sdelphij 102267843Sdelphijint magic_version(void); 103267843Sdelphijint magic_load(magic_t, const char *); 104275698Sdelphijint magic_load_buffers(magic_t, void **, size_t *, size_t); 105275698Sdelphij 106267843Sdelphijint magic_compile(magic_t, const char *); 107267843Sdelphijint magic_check(magic_t, const char *); 108267843Sdelphijint magic_list(magic_t, const char *); 109267843Sdelphijint magic_errno(magic_t); 110267843Sdelphij 111275698Sdelphij#define MAGIC_PARAM_INDIR_MAX 0 112275698Sdelphij#define MAGIC_PARAM_NAME_MAX 1 113275698Sdelphij#define MAGIC_PARAM_ELF_PHNUM_MAX 2 114275698Sdelphij#define MAGIC_PARAM_ELF_SHNUM_MAX 3 115276577Sdelphij#define MAGIC_PARAM_ELF_NOTES_MAX 4 116288143Sdelphij#define MAGIC_PARAM_REGEX_MAX 5 117275698Sdelphij 118275698Sdelphijint magic_setparam(magic_t, int, const void *); 119275698Sdelphijint magic_getparam(magic_t, int, void *); 120275698Sdelphij 121267843Sdelphij#ifdef __cplusplus 122267843Sdelphij}; 123267843Sdelphij#endif 124267843Sdelphij 125267843Sdelphij#endif /* _MAGIC_H */ 126