Download src/php/php-src/ext/fileinfo/libmagic/file.h from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 21 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/fileinfo/libmagic/file.h
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/fileinfo/libmagic/file.h
-
curl -L -o file.h https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/fileinfo/libmagic/file.h
21 kB
| /* | |
| * Copyright (c) Ian F. Darwin 1986-1995. | |
| * Software written by Ian F. Darwin and others; | |
| * maintained 1995-present by Christos Zoulas and others. | |
| * | |
| * Redistribution and use in source and binary forms, with or without | |
| * modification, are permitted provided that the following conditions | |
| * are met: | |
| * 1. Redistributions of source code must retain the above copyright | |
| * notice immediately at the beginning of the file, without modification, | |
| * this list of conditions, and the following disclaimer. | |
| * 2. Redistributions in binary form must reproduce the above copyright | |
| * notice, this list of conditions and the following disclaimer in the | |
| * documentation and/or other materials provided with the distribution. | |
| * | |
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
| * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR | |
| * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| * SUCH DAMAGE. | |
| */ | |
| /* | |
| * file.h - definitions for file(1) program | |
| * @(#)$File: file.h,v 1.257 2024/11/25 22:31:53 christos Exp $ | |
| */ | |
| /* Do this here and now, because struct stat gets re-defined on solaris */ | |
| /* | |
| * Dec 31, 23:59:59 9999 | |
| * we need to make sure that we don't exceed 9999 because some libc | |
| * implementations like muslc crash otherwise. If you are unlucky | |
| * to be running on a system with a 32 bit time_t, then it is even less. | |
| */ | |
| struct buffer { | |
| int fd; | |
| zend_stat_t st; | |
| const void *fbuf; | |
| size_t flen; | |
| zend_off_t eoff; | |
| void *ebuf; | |
| size_t elen; | |
| }; | |
| union VALUETYPE { | |
| uint8_t b; | |
| uint16_t h; | |
| uint32_t l; | |
| uint64_t q; | |
| uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */ | |
| uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */ | |
| uint8_t hq[8]; /* 8 bytes of a fixed-endian "quad" */ | |
| char s[MAXstring]; /* the search string or regex pattern */ | |
| unsigned char us[MAXstring]; | |
| uint64_t guid[2]; | |
| float f; | |
| double d; | |
| }; | |
| struct magic { | |
| /* Word 1 */ | |
| uint16_t cont_level; /* level of ">" */ | |
| uint8_t flag; | |
| uint8_t factor; | |
| /* Word 2 */ | |
| uint8_t reln; /* relation (0=eq, '>'=gt, etc) */ | |
| uint8_t vallen; /* length of string value, if any */ | |
| uint8_t type; /* comparison type (FILE_*) */ | |
| uint8_t in_type; /* type of indirection */ | |
| /* Word 3 */ | |
| uint8_t in_op; /* operator for indirection */ | |
| uint8_t mask_op; /* operator for mask */ | |
| uint8_t cond; /* conditional type */ | |
| uint8_t dummy; | |
| uint8_t factor_op; | |
| /* Word 4 */ | |
| int32_t offset; /* offset to magic number */ | |
| /* Word 5 */ | |
| int32_t in_offset; /* offset from indirection */ | |
| /* Word 6 */ | |
| uint32_t lineno; /* line number in magic file */ | |
| /* Word 7,8 */ | |
| union { | |
| uint64_t _mask; /* for use with numeric and date types */ | |
| struct { | |
| uint32_t _count; /* repeat/line count */ | |
| uint32_t _flags; /* modifier flags */ | |
| } _s; /* for use with string types */ | |
| } _u; | |
| /* Words 9-24 */ | |
| union VALUETYPE value; /* either number or string */ | |
| /* Words 25-40 */ | |
| char desc[MAXDESC]; /* description */ | |
| /* Words 41-60 */ | |
| char mimetype[MAXMIME]; /* MIME type */ | |
| /* Words 61-62 */ | |
| char apple[8]; /* APPLE CREATOR/TYPE */ | |
| /* Words 63-78 */ | |
| char ext[MAXEXT]; /* Popular extensions from old 64 raised by 56 for sqlite/sqlite3/... */ | |
| }; | |
| /* list of magic entries */ | |
| struct mlist { | |
| struct magic *magic; /* array of magic entries */ | |
| size_t nmagic; /* number of entries in array */ | |
| void *map; /* internal resources used by entry */ | |
| struct mlist *next, *prev; | |
| }; | |
| struct level_info { | |
| int32_t off; | |
| int got_match; | |
| int last_match; | |
| int last_cond; /* used for error checking by parse() */ | |
| }; | |
| struct cont { | |
| size_t len; | |
| struct level_info *li; | |
| }; | |
| struct magic_set { | |
| struct mlist *mlist[MAGIC_SETS]; /* list of regular entries */ | |
| struct cont c; | |
| struct out { | |
| char *buf; /* Accumulation buffer */ | |
| size_t blen; /* Length of buffer */ | |
| char *pbuf; /* Printable buffer */ | |
| } o; | |
| uint32_t offset; /* a copy of m->offset while we */ | |
| /* are working on the magic entry */ | |
| uint32_t eoffset; /* offset from end of file */ | |
| int error; | |
| int flags; /* Control magic tests. */ | |
| int event_flags; /* Note things that happened. */ | |
| const char *file; | |
| size_t line; /* current magic line number */ | |
| mode_t mode; /* copy of current stat mode */ | |
| uint16_t magwarn; /* current number of warnings */ | |
| /* data for searches */ | |
| struct { | |
| const char *s; /* start of search in original source */ | |
| size_t s_len; /* length of search region */ | |
| size_t offset; /* starting offset in source: XXX - should this be off_t? */ | |
| size_t rm_len; /* match length */ | |
| } search; | |
| /* FIXME: Make the string dynamically allocated so that e.g. | |
| strings matched in files can be longer than MAXstring */ | |
| union VALUETYPE ms_value; /* either number or string */ | |
| uint16_t indir_max; | |
| uint16_t name_max; | |
| uint16_t elf_shnum_max; | |
| uint16_t elf_phnum_max; | |
| uint16_t elf_notes_max; | |
| uint16_t regex_max; | |
| uint16_t magwarn_max; | |
| size_t bytes_max; /* number of bytes to read from file */ | |
| size_t encoding_max; /* bytes to look for encoding */ | |
| size_t elf_shsize_max; | |
| locale_t c_lc_ctype; | |
| }; | |
| /* Type for Unicode characters */ | |
| typedef unsigned long file_unichar_t; | |
| struct stat; | |
| file_protected const char *file_fmtdatetime(char *, size_t, uint64_t, int); | |
| file_protected const char *file_fmtdate(char *, size_t, uint16_t); | |
| file_protected const char *file_fmttime(char *, size_t, uint16_t); | |
| file_protected const char *file_fmtvarint(char *, size_t, const unsigned char *, | |
| int); | |
| file_protected const char *file_fmtnum(char *, size_t, const char *, int); | |
| file_protected struct magic_set *file_ms_alloc(int); | |
| file_protected void file_ms_free(struct magic_set *); | |
| file_protected int file_buffer(struct magic_set *, php_stream *, zend_stat_t *, const char *, const void *, | |
| size_t); | |
| file_protected int file_fsmagic(struct magic_set *, const char *, zend_stat_t *); | |
| file_protected int file_pipe2file(struct magic_set *, int, const void *, | |
| size_t); | |
| file_protected int file_vprintf(struct magic_set *, const char *, va_list) | |
| __attribute__((__format__(__printf__, 2, 0))); | |
| file_protected int file_separator(struct magic_set *); | |
| file_protected char *file_copystr(char *, size_t, size_t, const char *); | |
| file_protected int file_checkfmt(char *, size_t, const char *); | |
| file_protected size_t file_printedlen(const struct magic_set *); | |
| file_protected int file_print_guid(char *, size_t, const uint64_t *); | |
| file_protected int file_parse_guid(const char *, uint64_t *); | |
| file_protected int file_replace(struct magic_set *, const char *, const char *); | |
| file_protected int file_printf(struct magic_set *, const char *, ...) | |
| __attribute__((__format__(__printf__, 2, 3))); | |
| file_protected int file_reset(struct magic_set *, int); | |
| file_protected int file_tryelf(struct magic_set *, const struct buffer *); | |
| file_protected int file_trycdf(struct magic_set *, const struct buffer *); | |
| file_protected int file_zmagic(struct magic_set *, const struct buffer *, | |
| const char *); | |
| file_protected int file_ascmagic(struct magic_set *, const struct buffer *, | |
| int); | |
| file_protected int file_ascmagic_with_encoding(struct magic_set *, | |
| const struct buffer *, file_unichar_t *, size_t, const char *, const char *, int); | |
| file_protected int file_encoding(struct magic_set *, const struct buffer *, | |
| file_unichar_t **, size_t *, const char **, const char **, const char **); | |
| file_protected int file_is_json(struct magic_set *, const struct buffer *); | |
| file_protected int file_is_csv(struct magic_set *, const struct buffer *, int, | |
| const char *); | |
| file_protected int file_is_simh(struct magic_set *, const struct buffer *); | |
| file_protected int file_is_tar(struct magic_set *, const struct buffer *); | |
| file_protected int file_softmagic(struct magic_set *, const struct buffer *, | |
| uint16_t *, uint16_t *, int, int); | |
| file_protected int file_apprentice(struct magic_set *, const char *, int); | |
| file_protected size_t file_magic_strength(const struct magic *, size_t); | |
| file_protected int buffer_apprentice(struct magic_set *, struct magic **, | |
| size_t *, size_t); | |
| file_protected int file_magicfind(struct magic_set *, const char *, | |
| struct mlist *); | |
| file_protected uint64_t file_signextend(struct magic_set *, struct magic *, | |
| uint64_t); | |
| file_protected uintmax_t file_varint2uintmax_t(const unsigned char *, int, | |
| size_t *); | |
| file_protected void file_badread(struct magic_set *); | |
| file_protected void file_badseek(struct magic_set *); | |
| file_protected void file_oomem(struct magic_set *, size_t); | |
| file_protected void file_error(struct magic_set *, int, const char *, ...) | |
| __attribute__((__format__(__printf__, 3, 4))); | |
| file_protected void file_magerror(struct magic_set *, const char *, ...) | |
| __attribute__((__format__(__printf__, 2, 3))); | |
| file_protected void file_magwarn(struct magic_set *, const char *, ...) | |
| __attribute__((__format__(__printf__, 2, 3))); | |
| file_protected void file_magwarn1(const char *, ...) | |
| __attribute__((__format__(__printf__, 1, 2))); | |
| file_protected void file_mdump(struct magic *); | |
| file_protected void file_showstr(FILE *, const char *, size_t); | |
| file_protected size_t file_mbswidth(struct magic_set *, const char *); | |
| file_protected const char *file_getbuffer(struct magic_set *); | |
| file_protected ssize_t sread(int, void *, size_t, int); | |
| file_protected int file_check_mem(struct magic_set *, unsigned int); | |
| file_protected int file_looks_utf8(const unsigned char *, size_t, | |
| file_unichar_t *, size_t *); | |
| file_protected size_t file_pstring_length_size(struct magic_set *, | |
| const struct magic *); | |
| file_protected size_t file_pstring_get_length(struct magic_set *, | |
| const struct magic *, const char *); | |
| file_protected char * file_printable(struct magic_set *, char *, size_t, | |
| const char *, size_t); | |
| file_protected int file_os2_apptype(struct magic_set *, const char *, | |
| const void *, size_t); | |
| file_protected int file_pipe_closexec(int *); | |
| file_protected int file_clear_closexec(int); | |
| file_protected char *file_strtrim(char *); | |
| file_protected void buffer_init(struct buffer *, int, const zend_stat_t *, | |
| const void *, size_t); | |
| file_protected void buffer_fini(struct buffer *); | |
| file_protected int buffer_fill(const struct buffer *); | |
| typedef struct { | |
| char *buf; | |
| size_t blen; | |
| uint32_t offset; | |
| } file_pushbuf_t; | |
| file_protected file_pushbuf_t *file_push_buffer(struct magic_set *); | |
| file_protected char *file_pop_buffer(struct magic_set *, file_pushbuf_t *); | |
| extern file_protected const char *file_names[]; | |
| extern file_protected const size_t file_nnames; | |
| size_t strlcpy(char *, const char *, size_t); | |
| size_t strlcat(char *, const char *, size_t); | |
| char *strcasestr(const char *, const char *); | |
| ssize_t getline(char **, size_t *, FILE *); | |
| ssize_t getdelim(char **, size_t *, int, FILE *); | |
| char *ctime_r(const time_t *, char *); | |
| char *asctime_r(const struct tm *, char *); | |