Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:41:43

0001 /*
0002  * Copyright (c) Christos Zoulas 2003.
0003  * All Rights Reserved.
0004  *
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 1. Redistributions of source code must retain the above copyright
0009  *    notice immediately at the beginning of the file, without modification,
0010  *    this list of conditions, and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
0016  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
0019  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0020  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0021  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0022  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0023  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0024  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0025  * SUCH DAMAGE.
0026  */
0027 #ifndef _MAGIC_H
0028 #define _MAGIC_H
0029 
0030 #include <sys/types.h>
0031 
0032 #define MAGIC_NONE      0x0000000 /* No flags */
0033 #define MAGIC_DEBUG     0x0000001 /* Turn on debugging */
0034 #define MAGIC_SYMLINK       0x0000002 /* Follow symlinks */
0035 #define MAGIC_COMPRESS      0x0000004 /* Check inside compressed files */
0036 #define MAGIC_DEVICES       0x0000008 /* Look at the contents of devices */
0037 #define MAGIC_MIME_TYPE     0x0000010 /* Return the MIME type */
0038 #define MAGIC_CONTINUE      0x0000020 /* Return all matches */
0039 #define MAGIC_CHECK     0x0000040 /* Print warnings to stderr */
0040 #define MAGIC_PRESERVE_ATIME    0x0000080 /* Restore access time on exit */
0041 #define MAGIC_RAW       0x0000100 /* Don't convert unprintable chars */
0042 #define MAGIC_ERROR     0x0000200 /* Handle ENOENT etc as real errors */
0043 #define MAGIC_MIME_ENCODING 0x0000400 /* Return the MIME encoding */
0044 #define MAGIC_MIME      (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
0045 #define MAGIC_APPLE     0x0000800 /* Return the Apple creator/type */
0046 #define MAGIC_EXTENSION     0x1000000 /* Return a /-separated list of
0047                        * extensions */
0048 #define MAGIC_COMPRESS_TRANSP   0x2000000 /* Check inside compressed files
0049                        * but not report compression */
0050 #define MAGIC_NO_COMPRESS_FORK  0x4000000 /* Don't allow decompression that
0051                        * needs to fork */
0052 #define MAGIC_NODESC        (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE)
0053 
0054 #define MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */
0055 #define MAGIC_NO_CHECK_TAR  0x0002000 /* Don't check for tar files */
0056 #define MAGIC_NO_CHECK_SOFT 0x0004000 /* Don't check magic entries */
0057 #define MAGIC_NO_CHECK_APPTYPE  0x0008000 /* Don't check application type */
0058 #define MAGIC_NO_CHECK_ELF  0x0010000 /* Don't check for elf details */
0059 #define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */
0060 #define MAGIC_NO_CHECK_CDF  0x0040000 /* Don't check for cdf files */
0061 #define MAGIC_NO_CHECK_CSV  0x0080000 /* Don't check for CSV files */
0062 #define MAGIC_NO_CHECK_TOKENS   0x0100000 /* Don't check tokens */
0063 #define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
0064 #define MAGIC_NO_CHECK_JSON 0x0400000 /* Don't check for JSON files */
0065 #define MAGIC_NO_CHECK_SIMH 0x0800000 /* Don't check for SIMH tape files */
0066 
0067 /* No built-in tests; only consult the magic file */
0068 #define MAGIC_NO_CHECK_BUILTIN  ( \
0069     MAGIC_NO_CHECK_COMPRESS | \
0070     MAGIC_NO_CHECK_TAR  | \
0071 /*  MAGIC_NO_CHECK_SOFT | */ \
0072     MAGIC_NO_CHECK_APPTYPE  | \
0073     MAGIC_NO_CHECK_ELF  | \
0074     MAGIC_NO_CHECK_TEXT | \
0075     MAGIC_NO_CHECK_CSV  | \
0076     MAGIC_NO_CHECK_CDF  | \
0077     MAGIC_NO_CHECK_TOKENS   | \
0078     MAGIC_NO_CHECK_ENCODING | \
0079     MAGIC_NO_CHECK_JSON | \
0080     MAGIC_NO_CHECK_SIMH | \
0081     0             \
0082 )
0083 
0084 #define MAGIC_SNPRINTB "\177\020\
0085 b\0debug\0\
0086 b\1symlink\0\
0087 b\2compress\0\
0088 b\3devices\0\
0089 b\4mime_type\0\
0090 b\5continue\0\
0091 b\6check\0\
0092 b\7preserve_atime\0\
0093 b\10raw\0\
0094 b\11error\0\
0095 b\12mime_encoding\0\
0096 b\13apple\0\
0097 b\14no_check_compress\0\
0098 b\15no_check_tar\0\
0099 b\16no_check_soft\0\
0100 b\17no_check_apptype\0\
0101 b\20no_check_elf\0\
0102 b\21no_check_text\0\
0103 b\22no_check_cdf\0\
0104 b\23no_check_csv\0\
0105 b\24no_check_tokens\0\
0106 b\25no_check_encoding\0\
0107 b\26no_check_json\0\
0108 b\27no_check_simh\0\
0109 b\30extension\0\
0110 b\31transp_compression\0\
0111 "
0112 
0113 /* Defined for backwards compatibility (renamed) */
0114 #define MAGIC_NO_CHECK_ASCII    MAGIC_NO_CHECK_TEXT
0115 
0116 /* Defined for backwards compatibility; do nothing */
0117 #define MAGIC_NO_CHECK_FORTRAN  0x000000 /* Don't check ascii/fortran */
0118 #define MAGIC_NO_CHECK_TROFF    0x000000 /* Don't check ascii/troff */
0119 
0120 #define MAGIC_VERSION       546 /* This implementation */
0121 
0122 
0123 #ifdef __cplusplus
0124 extern "C" {
0125 #endif
0126 
0127 typedef struct magic_set *magic_t;
0128 magic_t magic_open(int);
0129 void magic_close(magic_t);
0130 
0131 const char *magic_getpath(const char *, int);
0132 const char *magic_file(magic_t, const char *);
0133 const char *magic_descriptor(magic_t, int);
0134 const char *magic_buffer(magic_t, const void *, size_t);
0135 
0136 const char *magic_error(magic_t);
0137 int magic_getflags(magic_t);
0138 int magic_setflags(magic_t, int);
0139 
0140 int magic_version(void);
0141 int magic_load(magic_t, const char *);
0142 int magic_load_buffers(magic_t, void **, size_t *, size_t);
0143 
0144 int magic_compile(magic_t, const char *);
0145 int magic_check(magic_t, const char *);
0146 int magic_list(magic_t, const char *);
0147 int magic_errno(magic_t);
0148 
0149 #define MAGIC_PARAM_INDIR_MAX       0
0150 #define MAGIC_PARAM_NAME_MAX        1
0151 #define MAGIC_PARAM_ELF_PHNUM_MAX   2
0152 #define MAGIC_PARAM_ELF_SHNUM_MAX   3
0153 #define MAGIC_PARAM_ELF_NOTES_MAX   4
0154 #define MAGIC_PARAM_REGEX_MAX       5
0155 #define MAGIC_PARAM_BYTES_MAX       6
0156 #define MAGIC_PARAM_ENCODING_MAX    7
0157 #define MAGIC_PARAM_ELF_SHSIZE_MAX  8
0158 #define MAGIC_PARAM_MAGWARN_MAX     9
0159 
0160 int magic_setparam(magic_t, int, const void *);
0161 int magic_getparam(magic_t, int, void *);
0162 
0163 #ifdef __cplusplus
0164 };
0165 #endif
0166 
0167 #endif /* _MAGIC_H */