diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-09-02 08:54:31 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-09-02 08:54:31 +0000 |
commit | 10429269fbeb9442be4c5592b9111ccedbfefd0d (patch) | |
tree | ec492f5b26d71445da74668b4c967621e9ebc556 /src/file.h | |
parent | 670c2bbcffe873a2b8589ed140c12e7923ef20c0 (diff) | |
download | file-master.tar.gz |
Diffstat (limited to 'src/file.h')
-rw-r--r-- | src/file.h | 74 |
1 files changed, 49 insertions, 25 deletions
@@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.164 2015/01/01 17:07:34 christos Exp $ + * @(#)$File: file.h,v 1.183 2017/08/28 13:39:18 christos Exp $ */ #ifndef __file_h__ @@ -36,6 +36,10 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif +#ifdef HAVE_STDINT_H +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif #ifdef WIN32 #ifdef _WIN64 @@ -44,20 +48,18 @@ #define SIZE_T_FORMAT "" #endif #define INT64_T_FORMAT "I64" + #define INTMAX_T_FORMAT "I64" #else #define SIZE_T_FORMAT "z" #define INT64_T_FORMAT "ll" + #define INTMAX_T_FORMAT "j" +#endif +#include <stdint.h> #endif #include <stdio.h> /* Include that here, to make sure __P gets defined */ #include <errno.h> #include <fcntl.h> /* For open and flags */ -#ifdef HAVE_STDINT_H -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#include <stdint.h> -#endif #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif @@ -125,18 +127,18 @@ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif -#ifndef HOWMANY -# define HOWMANY (256 * 1024) /* how much of the file to look at */ +#ifndef FILE_BYTES_MAX +# define FILE_BYTES_MAX (1024 * 1024) /* how much of the file to look at */ #endif #define MAXMAGIS 8192 /* max entries in any one magic file or directory */ #define MAXDESC 64 /* max len of text description/MIME type */ #define MAXMIME 80 /* max len of text MIME type */ -#define MAXstring 64 /* max len of "string" types */ +#define MAXstring 96 /* max len of "string" types */ #define MAGICNO 0xF11E041C -#define VERSIONNO 12 -#define FILE_MAGICSIZE 248 +#define VERSIONNO 14 +#define FILE_MAGICSIZE 344 #define FILE_LOAD 0 #define FILE_CHECK 1 @@ -225,7 +227,8 @@ struct magic { #define FILE_NAME 45 #define FILE_USE 46 #define FILE_CLEAR 47 -#define FILE_NAMES_SIZE 48 /* size of array to contain all names */ +#define FILE_DER 48 +#define FILE_NAMES_SIZE 49 /* size of array to contain all names */ #define IS_STRING(t) \ ((t) == FILE_STRING || \ @@ -272,7 +275,7 @@ struct magic { #define FILE_OPS_MASK 0x07 /* mask for above ops */ #define FILE_UNUSED_1 0x08 #define FILE_UNUSED_2 0x10 -#define FILE_UNUSED_3 0x20 +#define FILE_OPSIGNED 0x20 #define FILE_OPINVERSE 0x40 #define FILE_OPINDIRECT 0x80 @@ -300,14 +303,16 @@ struct magic { #define num_mask _u._mask #define str_range _u._s._count #define str_flags _u._s._flags - /* Words 9-16 */ + /* Words 9-24 */ union VALUETYPE value; /* either number or string */ - /* Words 17-32 */ + /* Words 25-40 */ char desc[MAXDESC]; /* description */ - /* Words 33-52 */ + /* Words 41-60 */ char mimetype[MAXMIME]; /* MIME type */ - /* Words 53-54 */ - char apple[8]; + /* Words 61-62 */ + char apple[8]; /* APPLE CREATOR/TYPE */ + /* Words 63-78 */ + char ext[64]; /* Popular extensions */ }; #define BIT(A) (1 << (A)) @@ -361,9 +366,11 @@ struct mlist { #ifdef __cplusplus #define CAST(T, b) static_cast<T>(b) #define RCAST(T, b) reinterpret_cast<T>(b) +#define CCAST(T, b) const_cast<T>(b) #else -#define CAST(T, b) (T)(b) -#define RCAST(T, b) (T)(b) +#define CAST(T, b) ((T)(b)) +#define RCAST(T, b) ((T)(b)) +#define CCAST(T, b) ((T)(uintptr_t)(b)) #endif struct level_info { @@ -411,11 +418,14 @@ struct magic_set { uint16_t elf_shnum_max; uint16_t elf_phnum_max; uint16_t elf_notes_max; -#define FILE_INDIR_MAX 15 + uint16_t regex_max; + size_t bytes_max; /* number of bytes to read from file */ +#define FILE_INDIR_MAX 50 #define FILE_NAME_MAX 30 #define FILE_ELF_SHNUM_MAX 32768 -#define FILE_ELF_PHNUM_MAX 128 +#define FILE_ELF_PHNUM_MAX 2048 #define FILE_ELF_NOTES_MAX 256 +#define FILE_REGEX_MAX 8192 }; /* Type for Unicode characters */ @@ -437,7 +447,7 @@ protected size_t file_printedlen(const struct magic_set *); protected int file_replace(struct magic_set *, const char *, const char *); protected int file_printf(struct magic_set *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -protected int file_reset(struct magic_set *); +protected int file_reset(struct magic_set *, int); protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t); protected int file_trycdf(struct magic_set *, int, const unsigned char *, @@ -455,7 +465,7 @@ protected int file_encoding(struct magic_set *, const unsigned char *, size_t, unichar **, size_t *, const char **, const char **, const char **); protected int file_is_tar(struct magic_set *, const unsigned char *, size_t); protected int file_softmagic(struct magic_set *, const unsigned char *, size_t, - uint16_t, uint16_t *, int, int); + uint16_t *, uint16_t *, int, int); protected int file_apprentice(struct magic_set *, const char *, int); protected int buffer_apprentice(struct magic_set *, struct magic **, size_t *, size_t); @@ -500,6 +510,8 @@ typedef struct { #define USE_C_LOCALE locale_t old_lc_ctype; locale_t c_lc_ctype; +#else + char *old_lc_ctype; #endif int rc; regex_t rx; @@ -544,6 +556,9 @@ int vasprintf(char **, const char *, va_list); #ifndef HAVE_ASPRINTF int asprintf(char **, const char *, ...); #endif +#ifndef HAVE_DPRINTF +int dprintf(int, const char *, ...); +#endif #ifndef HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); @@ -564,6 +579,12 @@ char *ctime_r(const time_t *, char *); #ifndef HAVE_ASCTIME_R char *asctime_r(const struct tm *, char *); #endif +#ifndef HAVE_GMTIME_R +struct tm *gmtime_r(const time_t *, struct tm *); +#endif +#ifndef HAVE_LOCALTIME_R +struct tm *localtime_r(const time_t *, struct tm *); +#endif #ifndef HAVE_FMTCHECK const char *fmtcheck(const char *, const char *) __attribute__((__format_arg__(2))); @@ -590,5 +611,8 @@ static const char *rcsid(const char *p) { \ #else #define FILE_RCSID(id) #endif +#ifndef __RCSID +#define __RCSID(a) +#endif #endif /* __file_h__ */ |