diff options
author | Christos Zoulas <christos@zoulas.com> | 2022-12-26 17:31:14 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2022-12-26 17:31:14 +0000 |
commit | 65792853b868b5b5ee2c9e7d7b72efbf09c35e61 (patch) | |
tree | be3a2bbdd59b632c3d66fb7c38fd3aa682a47be6 /src | |
parent | 245faa5b481ba7fb86ab92fbf7afb89712da343c (diff) | |
download | file-git-65792853b868b5b5ee2c9e7d7b72efbf09c35e61.tar.gz |
prefix public/private/protected with file_
Diffstat (limited to 'src')
-rw-r--r-- | src/apprentice.c | 206 | ||||
-rw-r--r-- | src/apptype.c | 8 | ||||
-rw-r--r-- | src/ascmagic.c | 14 | ||||
-rw-r--r-- | src/compress.c | 52 | ||||
-rw-r--r-- | src/encoding.c | 40 | ||||
-rw-r--r-- | src/file.c | 68 | ||||
-rw-r--r-- | src/file.h | 156 | ||||
-rw-r--r-- | src/fsmagic.c | 8 | ||||
-rw-r--r-- | src/funcs.c | 66 | ||||
-rw-r--r-- | src/getline.c | 4 | ||||
-rw-r--r-- | src/is_tar.c | 14 | ||||
-rw-r--r-- | src/magic.c | 54 | ||||
-rw-r--r-- | src/print.c | 16 | ||||
-rw-r--r-- | src/readcdf.c | 24 | ||||
-rw-r--r-- | src/readelf.c | 52 | ||||
-rw-r--r-- | src/softmagic.c | 88 | ||||
-rw-r--r-- | src/tar.h | 4 |
17 files changed, 437 insertions, 437 deletions
diff --git a/src/apprentice.c b/src/apprentice.c index 3cc18300..db217875 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.338 2022/10/23 13:21:42 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.339 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -112,25 +112,25 @@ const size_t file_nformats = FILE_NAMES_SIZE; const char *file_names[FILE_NAMES_SIZE]; const size_t file_nnames = FILE_NAMES_SIZE; -private int getvalue(struct magic_set *ms, struct magic *, const char **, int); -private int hextoint(int); -private const char *getstr(struct magic_set *, struct magic *, const char *, +file_private int getvalue(struct magic_set *ms, struct magic *, const char **, int); +file_private int hextoint(int); +file_private const char *getstr(struct magic_set *, struct magic *, const char *, int); -private int parse(struct magic_set *, struct magic_entry *, const char *, +file_private int parse(struct magic_set *, struct magic_entry *, const char *, size_t, int); -private void eatsize(const char **); -private int apprentice_1(struct magic_set *, const char *, int); -private ssize_t apprentice_magic_strength_1(const struct magic *); -private size_t apprentice_magic_strength(const struct magic *, size_t); -private int apprentice_sort(const void *, const void *); -private void apprentice_list(struct mlist *, int ); -private struct magic_map *apprentice_load(struct magic_set *, +file_private void eatsize(const char **); +file_private int apprentice_1(struct magic_set *, const char *, int); +file_private ssize_t apprentice_magic_strength_1(const struct magic *); +file_private size_t apprentice_magic_strength(const struct magic *, size_t); +file_private int apprentice_sort(const void *, const void *); +file_private void apprentice_list(struct mlist *, int ); +file_private struct magic_map *apprentice_load(struct magic_set *, const char *, int); -private struct mlist *mlist_alloc(void); -private void mlist_free_all(struct magic_set *); -private void mlist_free(struct mlist *); -private void byteswap(struct magic *, uint32_t); -private void bs1(struct magic *); +file_private struct mlist *mlist_alloc(void); +file_private void mlist_free_all(struct magic_set *); +file_private void mlist_free(struct mlist *); +file_private void byteswap(struct magic *, uint32_t); +file_private void bs1(struct magic *); #if defined(HAVE_BYTESWAP_H) #define swap2(x) bswap_16(x) @@ -141,37 +141,37 @@ private void bs1(struct magic *); #define swap4(x) bswap32(x) #define swap8(x) bswap64(x) #else -private uint16_t swap2(uint16_t); -private uint32_t swap4(uint32_t); -private uint64_t swap8(uint64_t); +file_private uint16_t swap2(uint16_t); +file_private uint32_t swap4(uint32_t); +file_private uint64_t swap8(uint64_t); #endif -private char *mkdbname(struct magic_set *, const char *, int); -private struct magic_map *apprentice_buf(struct magic_set *, struct magic *, +file_private char *mkdbname(struct magic_set *, const char *, int); +file_private struct magic_map *apprentice_buf(struct magic_set *, struct magic *, size_t); -private struct magic_map *apprentice_map(struct magic_set *, const char *); -private int check_buffer(struct magic_set *, struct magic_map *, const char *); -private void apprentice_unmap(struct magic_map *); -private int apprentice_compile(struct magic_set *, struct magic_map *, +file_private struct magic_map *apprentice_map(struct magic_set *, const char *); +file_private int check_buffer(struct magic_set *, struct magic_map *, const char *); +file_private void apprentice_unmap(struct magic_map *); +file_private int apprentice_compile(struct magic_set *, struct magic_map *, const char *); -private int check_format_type(const char *, int, const char **); -private int check_format(struct magic_set *, struct magic *); -private int get_op(char); -private int parse_mime(struct magic_set *, struct magic_entry *, const char *, +file_private int check_format_type(const char *, int, const char **); +file_private int check_format(struct magic_set *, struct magic *); +file_private int get_op(char); +file_private int parse_mime(struct magic_set *, struct magic_entry *, const char *, size_t); -private int parse_strength(struct magic_set *, struct magic_entry *, +file_private int parse_strength(struct magic_set *, struct magic_entry *, const char *, size_t); -private int parse_apple(struct magic_set *, struct magic_entry *, const char *, +file_private int parse_apple(struct magic_set *, struct magic_entry *, const char *, size_t); -private int parse_ext(struct magic_set *, struct magic_entry *, const char *, +file_private int parse_ext(struct magic_set *, struct magic_entry *, const char *, size_t); -private size_t magicsize = sizeof(struct magic); +file_private size_t magicsize = sizeof(struct magic); -private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc"; +file_private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc"; -private struct { +file_private struct { const char *name; size_t len; int (*fun)(struct magic_set *, struct magic_entry *, const char *, @@ -313,7 +313,7 @@ static const struct type_tbl_s special_tbl[] = { # undef XX # undef XX_NULL -private int +file_private int get_type(const struct type_tbl_s *tbl, const char *l, const char **t) { const struct type_tbl_s *p; @@ -328,7 +328,7 @@ get_type(const struct type_tbl_s *tbl, const char *l, const char **t) return p->type; } -private off_t +file_private off_t maxoff_t(void) { if (/*CONSTCOND*/sizeof(off_t) == sizeof(int)) return CAST(off_t, INT_MAX); @@ -337,7 +337,7 @@ maxoff_t(void) { return 0x7fffffff; } -private int +file_private int get_standard_integer_type(const char *l, const char **t) { int type; @@ -422,7 +422,7 @@ get_standard_integer_type(const char *l, const char **t) return type; } -private void +file_private void init_file_tables(void) { static int done = 0; @@ -440,7 +440,7 @@ init_file_tables(void) assert(p - type_tbl == FILE_NAMES_SIZE); } -private int +file_private int add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx) { struct mlist *ml; @@ -471,7 +471,7 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx) /* * Handle one file or directory. */ -private int +file_private int apprentice_1(struct magic_set *ms, const char *fn, int action) { struct magic_map *map; @@ -530,7 +530,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action) #endif /* COMPILE_ONLY */ } -protected void +file_protected void file_ms_free(struct magic_set *ms) { size_t i; @@ -547,7 +547,7 @@ file_ms_free(struct magic_set *ms) free(ms); } -protected struct magic_set * +file_protected struct magic_set * file_ms_alloc(int flags) { struct magic_set *ms; @@ -593,7 +593,7 @@ free: return NULL; } -private void +file_private void apprentice_unmap(struct magic_map *map) { size_t i; @@ -627,7 +627,7 @@ apprentice_unmap(struct magic_map *map) free(map); } -private struct mlist * +file_private struct mlist * mlist_alloc(void) { struct mlist *mlist; @@ -638,7 +638,7 @@ mlist_alloc(void) return mlist; } -private void +file_private void mlist_free_all(struct magic_set *ms) { size_t i; @@ -649,7 +649,7 @@ mlist_free_all(struct magic_set *ms) } } -private void +file_private void mlist_free_one(struct mlist *ml) { size_t i; @@ -669,7 +669,7 @@ mlist_free_one(struct mlist *ml) free(ml); } -private void +file_private void mlist_free(struct mlist *mlist) { struct mlist *ml, *next; @@ -687,7 +687,7 @@ mlist_free(struct mlist *mlist) #ifndef COMPILE_ONLY /* void **bufs: an array of compiled magic files */ -protected int +file_protected int buffer_apprentice(struct magic_set *ms, struct magic **bufs, size_t *sizes, size_t nbufs) { @@ -730,7 +730,7 @@ fail: #endif /* const char *fn: list of magic files and directories */ -protected int +file_protected int file_apprentice(struct magic_set *ms, const char *fn, int action) { char *p, *mfn; @@ -820,7 +820,7 @@ file_apprentice(struct magic_set *ms, const char *fn, int action) * - regular characters or escaped magic characters count 1 * - 0 length expressions count as one */ -private size_t +file_private size_t nonmagic(const char *str) { const char *p; @@ -860,7 +860,7 @@ nonmagic(const char *str) } -private size_t +file_private size_t typesize(int type) { switch (type) { @@ -930,7 +930,7 @@ typesize(int type) /* * Get weight of this magic entry, for sorting purposes. */ -private ssize_t +file_private ssize_t apprentice_magic_strength_1(const struct magic *m) { #define MULT 10U @@ -1067,7 +1067,7 @@ apprentice_magic_strength_1(const struct magic *m) /*ARGSUSED*/ -private size_t +file_private size_t apprentice_magic_strength(const struct magic *m, size_t nmagic __attribute__((__unused__))) { @@ -1128,7 +1128,7 @@ apprentice_magic_strength(const struct magic *m, /* * Sort callback for sorting entries by "strength" (basically length) */ -private int +file_private int apprentice_sort(const void *a, const void *b) { const struct magic_entry *ma = CAST(const struct magic_entry *, a); @@ -1146,7 +1146,7 @@ apprentice_sort(const void *a, const void *b) /* * Shows sorted patterns list in the order which is used for the matching */ -private void +file_private void apprentice_list(struct mlist *mlist, int mode) { uint32_t magindex, descindex, mimeindex, lineindex; @@ -1188,7 +1188,7 @@ apprentice_list(struct mlist *mlist, int mode) } } -private void +file_private void set_test_type(struct magic *mstart, struct magic *m) { switch (m->type) { @@ -1279,7 +1279,7 @@ set_test_type(struct magic *mstart, struct magic *m) } } -private int +file_private int addentry(struct magic_set *ms, struct magic_entry *me, struct magic_entry_set *mset) { @@ -1308,7 +1308,7 @@ addentry(struct magic_set *ms, struct magic_entry *me, /* * Load and parse one file. */ -private void +file_private void load_1(struct magic_set *ms, int action, const char *fn, int *errs, struct magic_entry_set *mset) { @@ -1396,14 +1396,14 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs, * parse a file or directory of files * const char *fn: name of magic file or directory */ -private int +file_private int cmpstrp(const void *p1, const void *p2) { return strcmp(*RCAST(char *const *, p1), *RCAST(char *const *, p2)); } -private uint32_t +file_private uint32_t set_text_binary(struct magic_set *ms, struct magic_entry *me, uint32_t nme, uint32_t starttest) { @@ -1436,7 +1436,7 @@ set_text_binary(struct magic_set *ms, struct magic_entry *me, uint32_t nme, return i; } -private void +file_private void set_last_default(struct magic_set *ms, struct magic_entry *me, uint32_t nme) { uint32_t i; @@ -1457,7 +1457,7 @@ set_last_default(struct magic_set *ms, struct magic_entry *me, uint32_t nme) } } -private int +file_private int coalesce_entries(struct magic_set *ms, struct magic_entry *me, uint32_t nme, struct magic **ma, uint32_t *nma) { @@ -1489,7 +1489,7 @@ coalesce_entries(struct magic_set *ms, struct magic_entry *me, uint32_t nme, return 0; } -private void +file_private void magic_entry_free(struct magic_entry *me, uint32_t nme) { uint32_t i; @@ -1500,7 +1500,7 @@ magic_entry_free(struct magic_entry *me, uint32_t nme) free(me); } -private struct magic_map * +file_private struct magic_map * apprentice_load(struct magic_set *ms, const char *fn, int action) { int errs = 0; @@ -1626,7 +1626,7 @@ out: /* * extend the sign bit if the comparison is to be signed */ -protected uint64_t +file_protected uint64_t file_signextend(struct magic_set *ms, struct magic *m, uint64_t v) { if (!(m->flag & UNSIGNED)) { @@ -1712,7 +1712,7 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v) return v; } -private int +file_private int string_modifier_check(struct magic_set *ms, struct magic *m) { if ((ms->flags & MAGIC_CHECK) == 0) @@ -1771,7 +1771,7 @@ string_modifier_check(struct magic_set *ms, struct magic *m) return 0; } -private int +file_private int get_op(char c) { switch (c) { @@ -1797,7 +1797,7 @@ get_op(char c) } #ifdef ENABLE_CONDITIONALS -private int +file_private int get_cond(const char *l, const char **t) { static const struct cond_tbl_s { @@ -1823,7 +1823,7 @@ get_cond(const char *l, const char **t) return p->cond; } -private int +file_private int check_cond(struct magic_set *ms, int cond, uint32_t cont_level) { int last_cond; @@ -1867,7 +1867,7 @@ check_cond(struct magic_set *ms, int cond, uint32_t cont_level) } #endif /* ENABLE_CONDITIONALS */ -private int +file_private int parse_indirect_modifier(struct magic_set *ms, struct magic *m, const char **lp) { const char *l = *lp; @@ -1888,7 +1888,7 @@ parse_indirect_modifier(struct magic_set *ms, struct magic *m, const char **lp) return 0; } -private void +file_private void parse_op_modifier(struct magic_set *ms, struct magic *m, const char **lp, int op) { @@ -1905,7 +1905,7 @@ parse_op_modifier(struct magic_set *ms, struct magic *m, const char **lp, *lp = l; } -private int +file_private int parse_string_modifier(struct magic_set *ms, struct magic *m, const char **lp) { const char *l = *lp; @@ -2012,7 +2012,7 @@ out: /* * parse one line from magic file, put into magic[index++] if valid */ -private int +file_private int parse(struct magic_set *ms, struct magic_entry *me, const char *line, size_t lineno, int action) { @@ -2429,7 +2429,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, * if valid */ /*ARGSUSED*/ -private int +file_private int parse_strength(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len __attribute__((__unused__))) { @@ -2489,13 +2489,13 @@ out: return -1; } -private int +file_private int goodchar(unsigned char x, const char *extra) { return (isascii(x) && isalnum(x)) || strchr(extra, x); } -private int +file_private int parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line, size_t llen, off_t off, size_t len, const char *name, const char *extra, int nt) @@ -2548,7 +2548,7 @@ parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line, * Parse an Apple CREATOR/TYPE annotation from magic file and put it into * magic[index - 1] */ -private int +file_private int parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { @@ -2560,7 +2560,7 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line, /* * Parse a comma-separated list of extensions */ -private int +file_private int parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { @@ -2573,7 +2573,7 @@ parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line, * parse a MIME annotation line from magic file, put into magic[index - 1] * if valid */ -private int +file_private int parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { @@ -2582,7 +2582,7 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line, sizeof(me->mp[0].mimetype), "MIME", "+-/.$?:{}", 1); } -private int +file_private int check_format_type(const char *ptr, int type, const char **estr) { int quad = 0, h; @@ -2776,7 +2776,7 @@ toolong: * Check that the optional printf format in description matches * the type of the magic. */ -private int +file_private int check_format(struct magic_set *ms, struct magic *m) { char *ptr; @@ -2832,7 +2832,7 @@ check_format(struct magic_set *ms, struct magic *m) * pointer, according to the magic type. Update the string pointer to point * just after the number read. Return 0 for success, non-zero for failure. */ -private int +file_private int getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) { char *ep; @@ -2963,7 +2963,7 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) * Copy the converted version to "m->value.s", and the length in m->vallen. * Return updated scan pointer as function result. Warn if set. */ -private const char * +file_private const char * getstr(struct magic_set *ms, struct magic *m, const char *s, int warn) { const char *origs = s; @@ -3141,7 +3141,7 @@ out: /* Single hex char to int; -1 if not a hex char. */ -private int +file_private int hextoint(int c) { if (!isascii(CAST(unsigned char, c))) @@ -3159,7 +3159,7 @@ hextoint(int c) /* * Print a string containing C character escapes. */ -protected void +file_protected void file_showstr(FILE *fp, const char *s, size_t len) { char c; @@ -3219,7 +3219,7 @@ file_showstr(FILE *fp, const char *s, size_t len) /* * eatsize(): Eat the size spec from a number [eg. 10UL] */ -private void +file_private void eatsize(const char **p) { const char *l = *p; @@ -3245,7 +3245,7 @@ eatsize(const char **p) /* * handle a buffer containing a compiled file. */ -private struct magic_map * +file_private struct magic_map * apprentice_buf(struct magic_set *ms, struct magic *buf, size_t len) { struct magic_map *map; @@ -3268,7 +3268,7 @@ apprentice_buf(struct magic_set *ms, struct magic *buf, size_t len) * handle a compiled file. */ -private struct magic_map * +file_private struct magic_map * apprentice_map(struct magic_set *ms, const char *fn) { int fd; @@ -3344,7 +3344,7 @@ error: return rv; } -private int +file_private int check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname) { uint32_t *ptr; @@ -3403,7 +3403,7 @@ check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname) /* * handle an mmaped file. */ -private int +file_private int apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) { static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS; @@ -3456,11 +3456,11 @@ out: return rv; } -private const char ext[] = ".mgc"; +file_private const char ext[] = ".mgc"; /* * make a dbname */ -private char * +file_private char * mkdbname(struct magic_set *ms, const char *fn, int strip) { const char *p, *q; @@ -3507,7 +3507,7 @@ mkdbname(struct magic_set *ms, const char *fn, int strip) /* * Byteswap an mmap'ed file if needed */ -private void +file_private void byteswap(struct magic *magic, uint32_t nmagic) { uint32_t i; @@ -3519,7 +3519,7 @@ byteswap(struct magic *magic, uint32_t nmagic) /* * swap a short */ -private uint16_t +file_private uint16_t swap2(uint16_t sv) { uint16_t rv; @@ -3533,7 +3533,7 @@ swap2(uint16_t sv) /* * swap an int */ -private uint32_t +file_private uint32_t swap4(uint32_t sv) { uint32_t rv; @@ -3549,7 +3549,7 @@ swap4(uint32_t sv) /* * swap a quad */ -private uint64_t +file_private uint64_t swap8(uint64_t sv) { uint64_t rv; @@ -3578,7 +3578,7 @@ swap8(uint64_t sv) } #endif -protected uintmax_t +file_protected uintmax_t file_varint2uintmax_t(const unsigned char *us, int t, size_t *l) { uintmax_t x = 0; @@ -3611,7 +3611,7 @@ file_varint2uintmax_t(const unsigned char *us, int t, size_t *l) /* * byteswap a single magic entry */ -private void +file_private void bs1(struct magic *m) { m->cont_level = swap2(m->cont_level); @@ -3628,7 +3628,7 @@ bs1(struct magic *m) } } -protected size_t +file_protected size_t file_pstring_length_size(struct magic_set *ms, const struct magic *m) { switch (m->str_flags & PSTRING_LEN) { @@ -3647,7 +3647,7 @@ file_pstring_length_size(struct magic_set *ms, const struct magic *m) return FILE_BADSIZE; } } -protected size_t +file_protected size_t file_pstring_get_length(struct magic_set *ms, const struct magic *m, const char *ss) { @@ -3700,7 +3700,7 @@ file_pstring_get_length(struct magic_set *ms, const struct magic *m, return len; } -protected int +file_protected int file_magicfind(struct magic_set *ms, const char *name, struct mlist *v) { uint32_t i, j; diff --git a/src/apptype.c b/src/apptype.c index 74c52d6d..94736275 100644 --- a/src/apptype.c +++ b/src/apptype.c @@ -1,6 +1,6 @@ /* * Adapted from: apptype.c, Written by Eberhard Mattes and put into the - * public domain + * file_public domain * * Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous * searches. @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apptype.c,v 1.16 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: apptype.c,v 1.17 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include <stdlib.h> @@ -41,7 +41,7 @@ FILE_RCSID("@(#)$File: apptype.c,v 1.16 2022/09/24 20:30:13 christos Exp $") #include <os2.h> typedef ULONG APPTYPE; -protected int +file_protected int file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf, size_t nb) { @@ -116,7 +116,7 @@ file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf, return -1; } else if (type & FAPPTYP_DLL) { if (type & FAPPTYP_PROTDLL) - if (file_printf(ms, "protected ") == -1) + if (file_printf(ms, "file_protected ") == -1) return -1; if (file_printf(ms, "DLL") == -1) return -1; diff --git a/src/ascmagic.c b/src/ascmagic.c index 18d3b882..487f55dd 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.112 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.113 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -50,15 +50,15 @@ FILE_RCSID("@(#)$File: ascmagic.c,v 1.112 2022/09/24 20:30:13 christos Exp $") #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ || (x) == 0x85 || (x) == '\f') -private unsigned char *encode_utf8(unsigned char *, size_t, file_unichar_t *, +file_private unsigned char *encode_utf8(unsigned char *, size_t, file_unichar_t *, size_t); -private size_t trim_nuls(const unsigned char *, size_t); +file_private size_t trim_nuls(const unsigned char *, size_t); /* * Undo the NUL-termination kindly provided by process() * but leave at least one byte to look at */ -private size_t +file_private size_t trim_nuls(const unsigned char *buf, size_t nbytes) { while (nbytes > 1 && buf[nbytes - 1] == '\0') @@ -67,7 +67,7 @@ trim_nuls(const unsigned char *buf, size_t nbytes) return nbytes; } -protected int +file_protected int file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) { file_unichar_t *ubuf = NULL; @@ -101,7 +101,7 @@ file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) return rv; } -protected int +file_protected int file_ascmagic_with_encoding(struct magic_set *ms, const struct buffer *b, file_unichar_t *ubuf, size_t ulen, const char *code, const char *type, int text) @@ -339,7 +339,7 @@ done: * Encode Unicode string as UTF-8, returning pointer to character * after end of string, or NULL if an invalid character is found. */ -private unsigned char * +file_private unsigned char * encode_utf8(unsigned char *buf, size_t len, file_unichar_t *ubuf, size_t ulen) { size_t i; diff --git a/src/compress.c b/src/compress.c index ada72ff3..00f23ecf 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.152 2022/10/31 13:22:26 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.153 2022/12/26 17:31:14 christos Exp $") #endif #include "magic.h" @@ -174,7 +174,7 @@ static const char *zstd_args[] = { #define do_zlib NULL #define do_bzlib NULL -private const struct { +file_private const struct { union { const char *magic; int (*func)(const unsigned char *); @@ -217,39 +217,39 @@ private const struct { #define NODATA 1 #define ERRDATA 2 -private ssize_t swrite(int, const void *, size_t); +file_private ssize_t swrite(int, const void *, size_t); #if HAVE_FORK -private size_t ncompr = __arraycount(compr); -private int uncompressbuf(int, size_t, size_t, int, const unsigned char *, +file_private size_t ncompr = __arraycount(compr); +file_private int uncompressbuf(int, size_t, size_t, int, const unsigned char *, unsigned char **, size_t *); #ifdef BUILTIN_DECOMPRESS -private int uncompresszlib(const unsigned char *, unsigned char **, size_t, +file_private int uncompresszlib(const unsigned char *, unsigned char **, size_t, size_t *, int); -private int uncompressgzipped(const unsigned char *, unsigned char **, size_t, +file_private int uncompressgzipped(const unsigned char *, unsigned char **, size_t, size_t *, int); #endif #ifdef BUILTIN_BZLIB -private int uncompressbzlib(const unsigned char *, unsigned char **, size_t, +file_private int uncompressbzlib(const unsigned char *, unsigned char **, size_t, size_t *, int); #endif #ifdef BUILTIN_XZLIB -private int uncompressxzlib(const unsigned char *, unsigned char **, size_t, +file_private int uncompressxzlib(const unsigned char *, unsigned char **, size_t, size_t *, int); #endif #ifdef BUILTIN_ZSTDLIB -private int uncompresszstd(const unsigned char *, unsigned char **, size_t, +file_private int uncompresszstd(const unsigned char *, unsigned char **, size_t, size_t *, int); #endif #ifdef BUILTIN_LZLIB -private int uncompresslzlib(const unsigned char *, unsigned char **, size_t, +file_private int uncompresslzlib(const unsigned char *, unsigned char **, size_t, size_t *, int); #endif static int makeerror(unsigned char **, size_t *, const char *, ...) __attribute__((__format__(__printf__, 3, 4))); -private const char *methodname(size_t); +file_private const char *methodname(size_t); -private int +file_private int format_decompression_error(struct magic_set *ms, size_t i, unsigned char *buf) { unsigned char *p; @@ -266,7 +266,7 @@ format_decompression_error(struct magic_set *ms, size_t i, unsigned char *buf) methodname(i), buf); } -protected int +file_protected int file_zmagic(struct magic_set *ms, const struct buffer *b, const char *name) { unsigned char *newbuf = NULL; @@ -379,7 +379,7 @@ out: /* * `safe' write for sockets and pipes. */ -private ssize_t +file_private ssize_t swrite(int fd, const void *buf, size_t n) { ssize_t rv; @@ -404,7 +404,7 @@ swrite(int fd, const void *buf, size_t n) /* * `safe' read for sockets and pipes. */ -protected ssize_t +file_protected ssize_t sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__))) { ssize_t rv; @@ -469,7 +469,7 @@ nocheck: return rn; } -protected int +file_protected int file_pipe2file(struct magic_set *ms, int fd, const void *startbuf, size_t nbytes) { @@ -561,7 +561,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf, #define FCOMMENT (1 << 4) -private int +file_private int uncompressgzipped(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int extra __attribute__((__unused__))) { @@ -602,7 +602,7 @@ err: return makeerror(newch, n, "File too short"); } -private int +file_private int uncompresszlib(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int zlib) { @@ -643,7 +643,7 @@ err: #endif #ifdef BUILTIN_BZLIB -private int +file_private int uncompressbzlib(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int extra __attribute__((__unused__))) { @@ -683,7 +683,7 @@ err: #endif #ifdef BUILTIN_XZLIB -private int +file_private int uncompressxzlib(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int extra __attribute__((__unused__))) { @@ -720,7 +720,7 @@ err: #endif #ifdef BUILTIN_ZSTDLIB -private int +file_private int uncompresszstd(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int extra __attribute__((__unused__))) { @@ -764,7 +764,7 @@ err: #endif #ifdef BUILTIN_LZLIB -private int +file_private int uncompresslzlib(const unsigned char *old, unsigned char **newch, size_t bytes_max, size_t *n, int extra __attribute__((__unused__))) { @@ -975,7 +975,7 @@ filter_error(unsigned char *ubuf, ssize_t n) return n; } -private const char * +file_private const char * methodname(size_t method) { switch (method) { @@ -1006,7 +1006,7 @@ methodname(size_t method) } } -private int (* +file_private int (* getdecompressor(int method))(const unsigned char *, unsigned char **, size_t, size_t *, int) { @@ -1039,7 +1039,7 @@ getdecompressor(int method))(const unsigned char *, unsigned char **, size_t, } } -private int +file_private int uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork, const unsigned char *old, unsigned char **newch, size_t* n) { diff --git a/src/encoding.c b/src/encoding.c index 0aea1236..9dbb9dd9 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: encoding.c,v 1.41 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: encoding.c,v 1.42 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -43,21 +43,21 @@ FILE_RCSID("@(#)$File: encoding.c,v 1.41 2022/09/24 20:30:13 christos Exp $") #include <stdlib.h> -private int looks_ascii(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_ascii(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_utf8_with_BOM(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_utf8_with_BOM(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_utf7(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_utf7(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_ucs16(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_ucs16(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_ucs32(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_ucs32(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_latin1(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_latin1(const unsigned char *, size_t, file_unichar_t *, size_t *); -private int looks_extended(const unsigned char *, size_t, file_unichar_t *, +file_private int looks_extended(const unsigned char *, size_t, file_unichar_t *, size_t *); -private void from_ebcdic(const unsigned char *, size_t, unsigned char *); +file_private void from_ebcdic(const unsigned char *, size_t, unsigned char *); #ifdef DEBUG_ENCODING #define DPRINTF(a) printf a @@ -71,7 +71,7 @@ private void from_ebcdic(const unsigned char *, size_t, unsigned char *); * the text converted into one-file_unichar_t-per-character Unicode in * ubuf, and the number of characters converted in ulen. */ -protected int +file_protected int file_encoding(struct magic_set *ms, const struct buffer *b, file_unichar_t **ubuf, size_t *ulen, const char **code, const char **code_mime, const char **type) @@ -237,7 +237,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, #define I 2 /* character appears in ISO-8859 text */ #define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */ -private char text_chars[256] = { +file_private char text_chars[256] = { /* BEL BS HT LF VT FF CR */ F, F, F, F, F, F, F, T, T, T, T, T, T, T, F, F, /* 0x0X */ /* ESC */ @@ -260,7 +260,7 @@ private char text_chars[256] = { }; #define LOOKS(NAME, COND) \ -private int \ +file_private int \ looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \ size_t *ulen) \ { \ @@ -346,7 +346,7 @@ struct accept_range { { LOCB, 0x8F }, }; -protected int +file_protected int file_looks_utf8(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, size_t *ulen) { @@ -427,7 +427,7 @@ done: * BOM, return -1; otherwise return the result of looks_utf8 on the * rest of the text. */ -private int +file_private int looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, size_t *ulen) { @@ -437,7 +437,7 @@ looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, return -1; } -private int +file_private int looks_utf7(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, size_t *ulen) { @@ -461,7 +461,7 @@ looks_utf7(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, #define UCS16_HISURR(c) ((c) >= 0xd800 && (c) <= 0xdbff) #define UCS16_LOSURR(c) ((c) >= 0xdc00 && (c) <= 0xdfff) -private int +file_private int looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, size_t *ulen) { @@ -521,7 +521,7 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, return 1 + bigend; } -private int +file_private int looks_ucs32(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, size_t *ulen) { @@ -590,7 +590,7 @@ looks_ucs32(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, * between old-style and internationalized examples of text. */ -private unsigned char ebcdic_to_ascii[] = { +file_private unsigned char ebcdic_to_ascii[] = { 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15, 16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31, 128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7, @@ -624,7 +624,7 @@ private unsigned char ebcdic_to_ascii[] = { * cases for the NEL character can be taken out of the code. */ -private unsigned char ebcdic_1047_to_8859[] = { +file_private unsigned char ebcdic_1047_to_8859[] = { 0x00,0x01,0x02,0x03,0x9C,0x09,0x86,0x7F,0x97,0x8D,0x8E,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x9D,0x0A,0x08,0x87,0x18,0x19,0x92,0x8F,0x1C,0x1D,0x1E,0x1F, 0x80,0x81,0x82,0x83,0x84,0x85,0x17,0x1B,0x88,0x89,0x8A,0x8B,0x8C,0x05,0x06,0x07, @@ -647,7 +647,7 @@ private unsigned char ebcdic_1047_to_8859[] = { /* * Copy buf[0 ... nbytes-1] into out[], translating EBCDIC to ASCII. */ -private void +file_private void from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out) { size_t i; @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: file.c,v 1.212 2022/10/26 18:09:26 christos Exp $") +FILE_RCSID("@(#)$File: file.c,v 1.213 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -97,14 +97,14 @@ int getopt_long(int, char * const *, const char *, " %s -C [-m <magicfiles>]\n" \ " %s [--help]\n" -private int /* Global command-line options */ +file_private int /* Global command-line options */ bflag = 0, /* brief output format */ nopad = 0, /* Don't pad output */ nobuffer = 0, /* Do not buffer stdout */ nulsep = 0; /* Append '\0' to the separator */ -private const char *separator = ":"; /* Default field separator */ -private const struct option long_options[] = { +file_private const char *separator = ":"; /* Default field separator */ +file_private const struct option long_options[] = { #define OPT_HELP 1 #define OPT_APPLE 2 #define OPT_EXTENSIONS 3 @@ -121,7 +121,7 @@ private const struct option long_options[] = { {0, 0, NULL, 0} }; -private const struct { +file_private const struct { const char *name; int value; } nv[] = { @@ -139,7 +139,7 @@ private const struct { { "tokens", MAGIC_NO_CHECK_TOKENS }, /* OBSOLETE: ignored for backwards compatibility */ }; -private struct { +file_private struct { const char *name; size_t value; size_t def; @@ -165,23 +165,23 @@ private struct { MAGIC_PARAM_REGEX_MAX, 0 }, }; -private int posixly; +file_private int posixly; #ifdef __dead __dead #endif -private void usage(void); -private void docprint(const char *, int); +file_private void usage(void); +file_private void docprint(const char *, int); #ifdef __dead __dead #endif -private void help(void); +file_private void help(void); -private int unwrap(struct magic_set *, const char *); -private int process(struct magic_set *ms, const char *, int); -private struct magic_set *load(const char *, int); -private void setparam(const char *); -private void applyparam(magic_t); +file_private int unwrap(struct magic_set *, const char *); +file_private int process(struct magic_set *ms, const char *, int); +file_private struct magic_set *load(const char *, int); +file_private void setparam(const char *); +file_private void applyparam(magic_t); /* @@ -448,7 +448,7 @@ out: return e; } -private void +file_private void applyparam(magic_t magic) { size_t i; @@ -461,7 +461,7 @@ applyparam(magic_t magic) } } -private void +file_private void setparam(const char *p) { size_t i; @@ -481,7 +481,7 @@ badparm: file_errx(EXIT_FAILURE, "Unknown param %s", p); } -private struct magic_set * +file_private struct magic_set * /*ARGSUSED*/ load(const char *magicfile, int flags) { @@ -505,7 +505,7 @@ load(const char *magicfile, int flags) /* * unwrap -- read a file of filenames, do each one. */ -private int +file_private int unwrap(struct magic_set *ms, const char *fn) { FILE *f; @@ -568,7 +568,7 @@ unwrap(struct magic_set *ms, const char *fn) return e; } -private void +file_private void file_octal(unsigned char c) { (void)putc('\\', stdout); @@ -577,7 +577,7 @@ file_octal(unsigned char c) (void)putc(((c >> 0) & 7) + '0', stdout); } -private void +file_private void fname_print(const char *inname) { size_t n = strlen(inname); @@ -623,7 +623,7 @@ fname_print(const char *inname) /* * Called for each input file on the command line (or in a list of files) */ -private int +file_private int process(struct magic_set *ms, const char *inname, int wid) { const char *type, c = nulsep > 1 ? '\0' : '\n'; @@ -657,7 +657,7 @@ process(struct magic_set *ms, const char *inname, int wid) return haderror || type == NULL; } -protected size_t +file_protected size_t file_mbswidth(struct magic_set *ms, const char *s) { size_t width = 0; @@ -694,7 +694,7 @@ file_mbswidth(struct magic_set *ms, const char *s) return width; } -private void +file_private void usage(void) { const char *pn = file_getprogname(); @@ -702,7 +702,7 @@ usage(void) exit(EXIT_FAILURE); } -private void +file_private void defprint(int def) { if (!def) @@ -712,7 +712,7 @@ defprint(int def) (void)putc('\n', stdout); } -private void +file_private void docprint(const char *opts, int def) { size_t i; @@ -760,7 +760,7 @@ docprint(const char *opts, int def) } -private void +file_private void help(void) { (void)fputs( @@ -780,21 +780,21 @@ help(void) exit(EXIT_SUCCESS); } -private const char *file_progname; +file_private const char *file_progname; -protected void +file_protected void file_setprogname(const char *progname) { file_progname = progname; } -protected const char * +file_protected const char * file_getprogname(void) { return file_progname; } -protected void +file_protected void file_err(int e, const char *fmt, ...) { va_list ap; @@ -811,7 +811,7 @@ file_err(int e, const char *fmt, ...) exit(e); } -protected void +file_protected void file_errx(int e, const char *fmt, ...) { va_list ap; @@ -824,7 +824,7 @@ file_errx(int e, const char *fmt, ...) exit(e); } -protected void +file_protected void file_warn(const char *fmt, ...) { va_list ap; @@ -841,7 +841,7 @@ file_warn(const char *fmt, ...) errno = se; } -protected void +file_protected void file_warnx(const char *fmt, ...) { va_list ap; @@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.240 2022/10/02 12:53:28 christos Exp $ + * @(#)$File: file.h,v 1.241 2022/12/26 17:31:14 christos Exp $ */ #ifndef __file_h__ @@ -105,17 +105,17 @@ #define PATHSEP ':' #endif -#define private static +#define file_private static #if HAVE_VISIBILITY && !defined(WIN32) -#define public __attribute__ ((__visibility__("default"))) -#ifndef protected -#define protected __attribute__ ((__visibility__("hidden"))) +#define file_public __attribute__ ((__visibility__("default"))) +#ifndef file_protected +#define file_protected __attribute__ ((__visibility__("hidden"))) #endif #else -#define public -#ifndef protected -#define protected +#define file_public +#ifndef file_protected +#define file_protected #endif #endif @@ -507,99 +507,99 @@ typedef unsigned long file_unichar_t; struct stat; #define FILE_T_LOCAL 1 #define FILE_T_WINDOWS 2 -protected const char *file_fmtdatetime(char *, size_t, uint64_t, int); -protected const char *file_fmtdate(char *, size_t, uint16_t); -protected const char *file_fmttime(char *, size_t, uint16_t); -protected const char *file_fmtvarint(char *, size_t, const unsigned char *, +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); -protected const char *file_fmtnum(char *, size_t, const char *, int); -protected struct magic_set *file_ms_alloc(int); -protected void file_ms_free(struct magic_set *); -protected int file_default(struct magic_set *, size_t); -protected int file_buffer(struct magic_set *, int, struct stat *, const char *, +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_default(struct magic_set *, size_t); +file_protected int file_buffer(struct magic_set *, int, struct stat *, const char *, const void *, size_t); -protected int file_fsmagic(struct magic_set *, const char *, struct stat *); -protected int file_pipe2file(struct magic_set *, int, const void *, size_t); -protected int file_vprintf(struct magic_set *, const char *, va_list) +file_protected int file_fsmagic(struct magic_set *, const char *, struct stat *); +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))); -protected int file_separator(struct magic_set *); -protected char *file_copystr(char *, size_t, size_t, const char *); -protected int file_checkfmt(char *, size_t, const char *); -protected size_t file_printedlen(const struct magic_set *); -protected int file_print_guid(char *, size_t, const uint64_t *); -protected int file_parse_guid(const char *, uint64_t *); -protected int file_replace(struct magic_set *, const char *, const char *); -protected int file_printf(struct magic_set *, const char *, ...) +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))); -protected int file_reset(struct magic_set *, int); -protected int file_tryelf(struct magic_set *, const struct buffer *); -protected int file_trycdf(struct magic_set *, const struct buffer *); +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 *); #if HAVE_FORK -protected int file_zmagic(struct magic_set *, const struct buffer *, +file_protected int file_zmagic(struct magic_set *, const struct buffer *, const char *); #endif -protected int file_ascmagic(struct magic_set *, const struct buffer *, +file_protected int file_ascmagic(struct magic_set *, const struct buffer *, int); -protected int file_ascmagic_with_encoding(struct magic_set *, +file_protected int file_ascmagic_with_encoding(struct magic_set *, const struct buffer *, file_unichar_t *, size_t, const char *, const char *, int); -protected int file_encoding(struct magic_set *, const struct buffer *, +file_protected int file_encoding(struct magic_set *, const struct buffer *, file_unichar_t **, size_t *, const char **, const char **, const char **); -protected int file_is_json(struct magic_set *, const struct buffer *); -protected int file_is_csv(struct magic_set *, const struct buffer *, int); -protected int file_is_tar(struct magic_set *, const struct buffer *); -protected int file_softmagic(struct magic_set *, const struct buffer *, +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); +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); -protected int file_apprentice(struct magic_set *, const char *, int); -protected int buffer_apprentice(struct magic_set *, struct magic **, +file_protected int file_apprentice(struct magic_set *, const char *, int); +file_protected int buffer_apprentice(struct magic_set *, struct magic **, size_t *, size_t); -protected int file_magicfind(struct magic_set *, const char *, struct mlist *); -protected uint64_t file_signextend(struct magic_set *, struct magic *, +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); -protected uintmax_t file_varint2uintmax_t(const unsigned char *, int, size_t *); +file_protected uintmax_t file_varint2uintmax_t(const unsigned char *, int, size_t *); -protected void file_badread(struct magic_set *); -protected void file_badseek(struct magic_set *); -protected void file_oomem(struct magic_set *, size_t); -protected void file_error(struct magic_set *, int, const char *, ...) +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))); -protected void file_magerror(struct magic_set *, const char *, ...) +file_protected void file_magerror(struct magic_set *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -protected void file_magwarn(struct magic_set *, const char *, ...) +file_protected void file_magwarn(struct magic_set *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -protected void file_mdump(struct magic *); -protected void file_showstr(FILE *, const char *, size_t); -protected size_t file_mbswidth(struct magic_set *, const char *); -protected const char *file_getbuffer(struct magic_set *); -protected ssize_t sread(int, void *, size_t, int); -protected int file_check_mem(struct magic_set *, unsigned int); -protected int file_looks_utf8(const unsigned char *, size_t, file_unichar_t *, +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 *); -protected size_t file_pstring_length_size(struct magic_set *, +file_protected size_t file_pstring_length_size(struct magic_set *, const struct magic *); -protected size_t file_pstring_get_length(struct magic_set *, +file_protected size_t file_pstring_get_length(struct magic_set *, const struct magic *, const char *); -protected char * file_printable(struct magic_set *, char *, size_t, +file_protected char * file_printable(struct magic_set *, char *, size_t, const char *, size_t); #ifdef __EMX__ -protected int file_os2_apptype(struct magic_set *, const char *, const void *, +file_protected int file_os2_apptype(struct magic_set *, const char *, const void *, size_t); #endif /* __EMX__ */ -protected int file_pipe_closexec(int *); -protected int file_clear_closexec(int); -protected char *file_strtrim(char *); +file_protected int file_pipe_closexec(int *); +file_protected int file_clear_closexec(int); +file_protected char *file_strtrim(char *); -protected void buffer_init(struct buffer *, int, const struct stat *, +file_protected void buffer_init(struct buffer *, int, const struct stat *, const void *, size_t); -protected void buffer_fini(struct buffer *); -protected int buffer_fill(const struct buffer *); +file_protected void buffer_fini(struct buffer *); +file_protected int buffer_fill(const struct buffer *); -protected int file_regcomp(struct magic_set *, file_regex_t *, const char *, +file_protected int file_regcomp(struct magic_set *, file_regex_t *, const char *, int); -protected int file_regexec(struct magic_set *, file_regex_t *, const char *, +file_protected int file_regexec(struct magic_set *, file_regex_t *, const char *, size_t, regmatch_t *, int); -protected void file_regfree(file_regex_t *); +file_protected void file_regfree(file_regex_t *); typedef struct { char *buf; @@ -607,8 +607,8 @@ typedef struct { uint32_t offset; } file_pushbuf_t; -protected file_pushbuf_t *file_push_buffer(struct magic_set *); -protected char *file_pop_buffer(struct magic_set *, 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 *); #ifndef COMPILE_ONLY extern const char *file_names[]; @@ -670,15 +670,15 @@ int enable_sandbox_basic(void); int enable_sandbox_full(void); #endif -protected const char *file_getprogname(void); -protected void file_setprogname(const char *); -protected void file_err(int, const char *, ...) +file_protected const char *file_getprogname(void); +file_protected void file_setprogname(const char *); +file_protected void file_err(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3), __noreturn__)); -protected void file_errx(int, const char *, ...) +file_protected void file_errx(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3), __noreturn__)); -protected void file_warn(const char *, ...) +file_protected void file_warn(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); -protected void file_warnx(const char *, ...) +file_protected void file_warnx(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK) diff --git a/src/fsmagic.c b/src/fsmagic.c index 14e247e6..5a13dbda 100644 --- a/src/fsmagic.c +++ b/src/fsmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: fsmagic.c,v 1.84 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: fsmagic.c,v 1.85 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -67,7 +67,7 @@ FILE_RCSID("@(#)$File: fsmagic.c,v 1.84 2022/09/24 20:30:13 christos Exp $") #endif #undef HAVE_MAJOR #ifdef S_IFLNK -private int +file_private int bad_link(struct magic_set *ms, int err, char *buf) { int mime = ms->flags & MAGIC_MIME; @@ -87,7 +87,7 @@ bad_link(struct magic_set *ms, int err, char *buf) return 1; } #endif -private int +file_private int handle_mime(struct magic_set *ms, int mime, const char *str) { if ((mime & MAGIC_MIME_TYPE)) { @@ -102,7 +102,7 @@ handle_mime(struct magic_set *ms, int mime, const char *str) return 0; } -protected int +file_protected int file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) { int ret, did = 0; diff --git a/src/funcs.c b/src/funcs.c index 68da733c..d4fefcdd 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.135 2022/10/09 13:44:47 christos Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.136 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -51,7 +51,7 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.135 2022/10/09 13:44:47 christos Exp $") #define SIZE_MAX ((size_t)~0) #endif -protected char * +file_protected char * file_copystr(char *buf, size_t blen, size_t width, const char *str) { if (blen == 0) @@ -63,7 +63,7 @@ file_copystr(char *buf, size_t blen, size_t width, const char *str) return buf; } -private void +file_private void file_clearbuf(struct magic_set *ms) { free(ms->o.buf); @@ -71,7 +71,7 @@ file_clearbuf(struct magic_set *ms) ms->o.blen = 0; } -private int +file_private int file_checkfield(char *msg, size_t mlen, const char *what, const char **pp) { const char *p = *pp; @@ -90,7 +90,7 @@ file_checkfield(char *msg, size_t mlen, const char *what, const char **pp) return 0; } -protected int +file_protected int file_checkfmt(char *msg, size_t mlen, const char *fmt) { const char *p; @@ -129,7 +129,7 @@ file_checkfmt(char *msg, size_t mlen, const char *fmt) /* * Like printf, only we append to a buffer. */ -protected int +file_protected int file_vprintf(struct magic_set *ms, const char *fmt, va_list ap) { int len; @@ -172,7 +172,7 @@ out: return -1; } -protected int +file_protected int file_printf(struct magic_set *ms, const char *fmt, ...) { int rv; @@ -189,7 +189,7 @@ file_printf(struct magic_set *ms, const char *fmt, ...) */ /*VARARGS*/ __attribute__((__format__(__printf__, 3, 0))) -private void +file_private void file_error_core(struct magic_set *ms, int error, const char *f, va_list va, size_t lineno) { @@ -210,7 +210,7 @@ file_error_core(struct magic_set *ms, int error, const char *f, va_list va, } /*VARARGS*/ -protected void +file_protected void file_error(struct magic_set *ms, int error, const char *f, ...) { va_list va; @@ -223,7 +223,7 @@ file_error(struct magic_set *ms, int error, const char *f, ...) * Print an error with magic line number. */ /*VARARGS*/ -protected void +file_protected void file_magerror(struct magic_set *ms, const char *f, ...) { va_list va; @@ -232,20 +232,20 @@ file_magerror(struct magic_set *ms, const char *f, ...) va_end(va); } -protected void +file_protected void file_oomem(struct magic_set *ms, size_t len) { file_error(ms, errno, "cannot allocate %" SIZE_T_FORMAT "u bytes", len); } -protected void +file_protected void file_badseek(struct magic_set *ms) { file_error(ms, errno, "error seeking"); } -protected void +file_protected void file_badread(struct magic_set *ms) { file_error(ms, errno, "error reading"); @@ -254,7 +254,7 @@ file_badread(struct magic_set *ms) #ifndef COMPILE_ONLY #define FILE_SEPARATOR "\n- " -protected int +file_protected int file_separator(struct magic_set *ms) { return file_printf(ms, FILE_SEPARATOR); @@ -289,7 +289,7 @@ checkdone(struct magic_set *ms, int *rv) return 0; } -protected int +file_protected int file_default(struct magic_set *ms, size_t nb) { if (ms->flags & MAGIC_MIME) { @@ -319,7 +319,7 @@ file_default(struct magic_set *ms, size_t nb) * -1: error */ /*ARGSUSED*/ -protected int +file_protected int file_buffer(struct magic_set *ms, int fd, struct stat *st, const char *inname __attribute__ ((__unused__)), const void *buf, size_t nb) @@ -500,7 +500,7 @@ simple: } #endif -protected int +file_protected int file_reset(struct magic_set *ms, int checkloaded) { if (checkloaded && ms->mlist[0] == NULL) { @@ -525,7 +525,7 @@ file_reset(struct magic_set *ms, int checkloaded) *(n)++ = ((CAST(uint32_t, *(o)) >> 0) & 7) + '0', \ (o)++) -protected const char * +file_protected const char * file_getbuffer(struct magic_set *ms) { char *pbuf, *op, *np; @@ -603,7 +603,7 @@ file_getbuffer(struct magic_set *ms) return ms->o.pbuf; } -protected int +file_protected int file_check_mem(struct magic_set *ms, unsigned int level) { size_t len; @@ -626,13 +626,13 @@ file_check_mem(struct magic_set *ms, unsigned int level) return 0; } -protected size_t +file_protected size_t file_printedlen(const struct magic_set *ms) { return ms->o.blen; } -protected int +file_protected int file_replace(struct magic_set *ms, const char *pat, const char *rep) { file_regex_t rx; @@ -656,7 +656,7 @@ out: return rv; } -private int +file_private int check_regex(struct magic_set *ms, const char *pat) { char sbuf[512]; @@ -686,7 +686,7 @@ check_regex(struct magic_set *ms, const char *pat) return 0; } -protected int +file_protected int file_regcomp(struct magic_set *ms file_locale_used, file_regex_t *rx, const char *pat, int flags) { @@ -721,7 +721,7 @@ file_regcomp(struct magic_set *ms file_locale_used, file_regex_t *rx, } /*ARGSUSED*/ -protected int +file_protected int file_regexec(struct magic_set *ms file_locale_used, file_regex_t *rx, const char *str, size_t nmatch, regmatch_t* pmatch, int eflags) { @@ -746,13 +746,13 @@ file_regexec(struct magic_set *ms file_locale_used, file_regex_t *rx, return rc; } -protected void +file_protected void file_regfree(file_regex_t *rx) { regfree(rx); } -protected file_pushbuf_t * +file_protected file_pushbuf_t * file_push_buffer(struct magic_set *ms) { file_pushbuf_t *pb; @@ -774,7 +774,7 @@ file_push_buffer(struct magic_set *ms) return pb; } -protected char * +file_protected char * file_pop_buffer(struct magic_set *ms, file_pushbuf_t *pb) { char *rbuf; @@ -798,7 +798,7 @@ file_pop_buffer(struct magic_set *ms, file_pushbuf_t *pb) /* * convert string to ascii printable format. */ -protected char * +file_protected char * file_printable(struct magic_set *ms, char *buf, size_t bufsiz, const char *str, size_t slen) { @@ -829,7 +829,7 @@ struct guid { uint8_t data4[8]; }; -protected int +file_protected int file_parse_guid(const char *s, uint64_t *guid) { struct guid *g = CAST(struct guid *, CAST(void *, guid)); @@ -854,7 +854,7 @@ file_parse_guid(const char *s, uint64_t *guid) #endif } -protected int +file_protected int file_print_guid(char *str, size_t len, const uint64_t *guid) { const struct guid *g = CAST(const struct guid *, @@ -875,7 +875,7 @@ file_print_guid(char *str, size_t len, const uint64_t *guid) #endif } -protected int +file_protected int file_pipe_closexec(int *fds) { #ifdef HAVE_PIPE2 @@ -891,7 +891,7 @@ file_pipe_closexec(int *fds) #endif } -protected int +file_protected int file_clear_closexec(int fd) { #ifdef F_SETFD return fcntl(fd, F_SETFD, 0); @@ -900,7 +900,7 @@ file_clear_closexec(int fd) { #endif } -protected char * +file_protected char * file_strtrim(char *str) { char *last; diff --git a/src/getline.c b/src/getline.c index b00de01b..21a290ed 100644 --- a/src/getline.c +++ b/src/getline.c @@ -37,7 +37,7 @@ #include <errno.h> #include <string.h> -public ssize_t +file_public ssize_t getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) { char *ptr, *eptr; @@ -80,7 +80,7 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) } } -public ssize_t +file_public ssize_t getline(char **buf, size_t *bufsiz, FILE *fp) { return getdelim(buf, bufsiz, '\n', fp); diff --git a/src/is_tar.c b/src/is_tar.c index c45facc8..fa83e1e2 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -28,7 +28,7 @@ /* * is_tar() -- figure out whether file is a tar archive. * - * Stolen (by the author!) from the public domain tar program: + * Stolen (by the author!) from the file_public domain tar program: * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). * * @(#)list.c 1.18 9/23/86 Public Domain - gnu @@ -40,7 +40,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: is_tar.c,v 1.49 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: is_tar.c,v 1.50 2022/12/26 17:31:14 christos Exp $") #endif #include "magic.h" @@ -50,8 +50,8 @@ FILE_RCSID("@(#)$File: is_tar.c,v 1.49 2022/09/24 20:30:13 christos Exp $") #define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) -private int is_tar(const unsigned char *, size_t); -private int from_oct(const char *, size_t); /* Decode octal number */ +file_private int is_tar(const unsigned char *, size_t); +file_private int from_oct(const char *, size_t); /* Decode octal number */ static const char tartype[][32] = { /* should be equal to messages */ "tar archive", /* found in ../magic/Magdir/archive */ @@ -59,7 +59,7 @@ static const char tartype[][32] = { /* should be equal to messages */ "POSIX tar archive (GNU)", /* */ }; -protected int +file_protected int file_is_tar(struct magic_set *ms, const struct buffer *b) { const unsigned char *buf = CAST(const unsigned char *, b->fbuf); @@ -95,7 +95,7 @@ file_is_tar(struct magic_set *ms, const struct buffer *b) * 2 for Unix Std (POSIX) tar file, * 3 for GNU tar file. */ -private int +file_private int is_tar(const unsigned char *buf, size_t nbytes) { static const char gpkg_match[] = "/gpkg-1"; @@ -153,7 +153,7 @@ is_tar(const unsigned char *buf, size_t nbytes) * * Result is -1 if the field is invalid (all blank, or non-octal). */ -private int +file_private int from_oct(const char *where, size_t digs) { int value; diff --git a/src/magic.c b/src/magic.c index 916eea23..80555da3 100644 --- a/src/magic.c +++ b/src/magic.c @@ -33,7 +33,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.119 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.120 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -69,12 +69,12 @@ FILE_RCSID("@(#)$File: magic.c,v 1.119 2022/09/24 20:30:13 christos Exp $") #endif #endif -private void close_and_restore(const struct magic_set *, const char *, int, +file_private void close_and_restore(const struct magic_set *, const char *, int, const struct stat *); -private int unreadable_info(struct magic_set *, mode_t, const char *); -private const char* get_default_magic(void); +file_private int unreadable_info(struct magic_set *, mode_t, const char *); +file_private const char* get_default_magic(void); #ifndef COMPILE_ONLY -private const char *file_or_fd(struct magic_set *, const char *, int); +file_private const char *file_or_fd(struct magic_set *, const char *, int); #endif #ifndef STDIN_FILENO @@ -171,7 +171,7 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, #endif #endif -private const char * +file_private const char * get_default_magic(void) { static const char hmagic[] = "/.magic/magic.mgc"; @@ -250,7 +250,7 @@ out: #endif } -public const char * +file_public const char * magic_getpath(const char *magicfile, int action) { if (magicfile != NULL) @@ -263,13 +263,13 @@ magic_getpath(const char *magicfile, int action) return action == FILE_LOAD ? get_default_magic() : MAGIC; } -public struct magic_set * +file_public struct magic_set * magic_open(int flags) { return file_ms_alloc(flags); } -private int +file_private int unreadable_info(struct magic_set *ms, mode_t md, const char *file) { if (file) { @@ -302,7 +302,7 @@ unreadable_info(struct magic_set *ms, mode_t md, const char *file) return 0; } -public void +file_public void magic_close(struct magic_set *ms) { if (ms == NULL) @@ -313,7 +313,7 @@ magic_close(struct magic_set *ms) /* * load a magic file */ -public int +file_public int magic_load(struct magic_set *ms, const char *magicfile) { if (ms == NULL) @@ -325,7 +325,7 @@ magic_load(struct magic_set *ms, const char *magicfile) /* * Install a set of compiled magic buffers. */ -public int +file_public int magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes, size_t nbufs) { @@ -336,7 +336,7 @@ magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes, } #endif -public int +file_public int magic_compile(struct magic_set *ms, const char *magicfile) { if (ms == NULL) @@ -344,7 +344,7 @@ magic_compile(struct magic_set *ms, const char *magicfile) return file_apprentice(ms, magicfile, FILE_COMPILE); } -public int +file_public int magic_check(struct magic_set *ms, const char *magicfile) { if (ms == NULL) @@ -352,7 +352,7 @@ magic_check(struct magic_set *ms, const char *magicfile) return file_apprentice(ms, magicfile, FILE_CHECK); } -public int +file_public int magic_list(struct magic_set *ms, const char *magicfile) { if (ms == NULL) @@ -360,7 +360,7 @@ magic_list(struct magic_set *ms, const char *magicfile) return file_apprentice(ms, magicfile, FILE_LIST); } -private void +file_private void close_and_restore(const struct magic_set *ms, const char *name, int fd, const struct stat *sb) { @@ -398,7 +398,7 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd, /* * find type of descriptor */ -public const char * +file_public const char * magic_descriptor(struct magic_set *ms, int fd) { if (ms == NULL) @@ -409,7 +409,7 @@ magic_descriptor(struct magic_set *ms, int fd) /* * find type of named file */ -public const char * +file_public const char * magic_file(struct magic_set *ms, const char *inname) { if (ms == NULL) @@ -417,7 +417,7 @@ magic_file(struct magic_set *ms, const char *inname) return file_or_fd(ms, inname, STDIN_FILENO); } -private const char * +file_private const char * file_or_fd(struct magic_set *ms, const char *inname, int fd) { int rv = -1; @@ -545,7 +545,7 @@ out: } -public const char * +file_public const char * magic_buffer(struct magic_set *ms, const void *buf, size_t nb) { if (ms == NULL) @@ -563,7 +563,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb) } #endif -public const char * +file_public const char * magic_error(struct magic_set *ms) { if (ms == NULL) @@ -571,7 +571,7 @@ magic_error(struct magic_set *ms) return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL; } -public int +file_public int magic_errno(struct magic_set *ms) { if (ms == NULL) @@ -579,7 +579,7 @@ magic_errno(struct magic_set *ms) return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0; } -public int +file_public int magic_getflags(struct magic_set *ms) { if (ms == NULL) @@ -588,7 +588,7 @@ magic_getflags(struct magic_set *ms) return ms->flags; } -public int +file_public int magic_setflags(struct magic_set *ms, int flags) { if (ms == NULL) @@ -601,13 +601,13 @@ magic_setflags(struct magic_set *ms, int flags) return 0; } -public int +file_public int magic_version(void) { return MAGIC_VERSION; } -public int +file_public int magic_setparam(struct magic_set *ms, int param, const void *val) { if (ms == NULL) @@ -643,7 +643,7 @@ magic_setparam(struct magic_set *ms, int param, const void *val) } } -public int +file_public int magic_getparam(struct magic_set *ms, int param, void *val) { if (ms == NULL) diff --git a/src/print.c b/src/print.c index 66d32d5e..18f42a05 100644 --- a/src/print.c +++ b/src/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.96 2022/09/27 01:58:20 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.97 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include <string.h> @@ -46,7 +46,7 @@ FILE_RCSID("@(#)$File: print.c,v 1.96 2022/09/27 01:58:20 christos Exp $") #include "cdf.h" #ifndef COMPILE_ONLY -protected void +file_protected void file_mdump(struct magic *m) { static const char optyp[] = { FILE_OPS }; @@ -242,7 +242,7 @@ file_mdump(struct magic *m) #endif /*VARARGS*/ -protected void +file_protected void file_magwarn(struct magic_set *ms, const char *f, ...) { va_list va; @@ -260,7 +260,7 @@ file_magwarn(struct magic_set *ms, const char *f, ...) (void) fputc('\n', stderr); } -protected const char * +file_protected const char * file_fmtvarint(char *buf, size_t blen, const unsigned char *us, int t) { snprintf(buf, blen, "%jd", CAST(intmax_t, @@ -268,7 +268,7 @@ file_fmtvarint(char *buf, size_t blen, const unsigned char *us, int t) return buf; } -protected const char * +file_protected const char * file_fmtdatetime(char *buf, size_t bsize, uint64_t v, int flags) { char *pp; @@ -307,7 +307,7 @@ out: * https://docs.microsoft.com/en-us/windows/win32/api/winbase/\ * nf-winbase-dosdatetimetofiletime?redirectedfrom=MSDN */ -protected const char * +file_protected const char * file_fmtdate(char *buf, size_t bsize, uint16_t v) { struct tm tm; @@ -326,7 +326,7 @@ out: return buf; } -protected const char * +file_protected const char * file_fmttime(char *buf, size_t bsize, uint16_t v) { struct tm tm; @@ -346,7 +346,7 @@ out: } -protected const char * +file_protected const char * file_fmtnum(char *buf, size_t blen, const char *us, int base) { char *endptr; diff --git a/src/readcdf.c b/src/readcdf.c index b631723a..1e2593a9 100644 --- a/src/readcdf.c +++ b/src/readcdf.c @@ -26,7 +26,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readcdf.c,v 1.78 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: readcdf.c,v 1.79 2022/12/26 17:31:14 christos Exp $") #endif #include <assert.h> @@ -92,7 +92,7 @@ static const struct cv { }, }; -private const char * +file_private const char * cdf_clsid_to_mime(const uint64_t clsid[2], const struct cv *cv) { size_t i; @@ -107,7 +107,7 @@ cdf_clsid_to_mime(const uint64_t clsid[2], const struct cv *cv) return NULL; } -private const char * +file_private const char * cdf_app_to_mime(const char *vbuf, const struct nv *nv) { size_t i; @@ -144,7 +144,7 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv) return rv; } -private int +file_private int cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, size_t count, const cdf_directory_t *root_storage) { @@ -262,7 +262,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, return 1; } -private int +file_private int cdf_file_catalog(struct magic_set *ms, const cdf_header_t *h, const cdf_stream_t *sst) { @@ -293,7 +293,7 @@ cdf_file_catalog(struct magic_set *ms, const cdf_header_t *h, return 1; } -private int +file_private int cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, const cdf_stream_t *sst, const cdf_directory_t *root_storage) { @@ -352,7 +352,7 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, } #ifdef notdef -private char * +file_private char * format_clsid(char *buf, size_t len, const uint64_t uuid[2]) { snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.12" PRIx64, @@ -365,7 +365,7 @@ format_clsid(char *buf, size_t len, const uint64_t uuid[2]) { } #endif -private int +file_private int cdf_file_catalog_info(struct magic_set *ms, const cdf_info_t *info, const cdf_header_t *h, const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst, const cdf_dir_t *dir, cdf_stream_t *scn) @@ -383,7 +383,7 @@ cdf_file_catalog_info(struct magic_set *ms, const cdf_info_t *info, return i; } -private int +file_private int cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, const cdf_header_t *h, const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst, const cdf_dir_t *dir, cdf_stream_t *scn, @@ -431,7 +431,7 @@ cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, return i; } -private struct sinfo { +file_private struct sinfo { const char *name; const char *mime; const char *sections[5]; @@ -508,7 +508,7 @@ private struct sinfo { }, }; -private int +file_private int cdf_file_dir_info(struct magic_set *ms, const cdf_dir_t *dir) { size_t sd, j; @@ -537,7 +537,7 @@ cdf_file_dir_info(struct magic_set *ms, const cdf_dir_t *dir) return -1; } -protected int +file_protected int file_trycdf(struct magic_set *ms, const struct buffer *b) { int fd = b->fd; diff --git a/src/readelf.c b/src/readelf.c index 7c55b8b0..97d14513 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.186 2022/09/24 20:30:13 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.187 2022/12/26 17:31:14 christos Exp $") #endif #ifdef BUILTIN_ELF @@ -42,30 +42,30 @@ FILE_RCSID("@(#)$File: readelf.c,v 1.186 2022/09/24 20:30:13 christos Exp $") #include "magic.h" #ifdef ELFCORE -private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t, +file_private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int *, uint16_t *); #endif -private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, +file_private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int, int *, uint16_t *); -private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, +file_private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int, int, int *, uint16_t *); -private size_t donote(struct magic_set *, void *, size_t, size_t, int, +file_private size_t donote(struct magic_set *, void *, size_t, size_t, int, int, size_t, int *, uint16_t *, int, off_t, int, off_t); #define ELF_ALIGN(a) ((((a) + align - 1) / align) * align) #define isquote(c) (strchr("'\"`", (c)) != NULL) -private uint16_t getu16(int, uint16_t); -private uint32_t getu32(int, uint32_t); -private uint64_t getu64(int, uint64_t); +file_private uint16_t getu16(int, uint16_t); +file_private uint32_t getu32(int, uint32_t); +file_private uint64_t getu64(int, uint64_t); #define MAX_PHNUM 128 #define MAX_SHNUM 32768 #define MAX_SHSIZE (64 * 1024 * 1024) #define SIZE_UNKNOWN CAST(off_t, -1) -private int +file_private int toomany(struct magic_set *ms, const char *name, uint16_t num) { if (ms->flags & MAGIC_MIME) @@ -75,7 +75,7 @@ toomany(struct magic_set *ms, const char *name, uint16_t num) return 1; } -private uint16_t +file_private uint16_t getu16(int swap, uint16_t value) { union { @@ -94,7 +94,7 @@ getu16(int swap, uint16_t value) return value; } -private uint32_t +file_private uint32_t getu32(int swap, uint32_t value) { union { @@ -115,7 +115,7 @@ getu32(int swap, uint32_t value) return value; } -private uint64_t +file_private uint64_t getu64(int swap, uint64_t value) { union { @@ -326,7 +326,7 @@ static const size_t prpsoffsets64[] = { #define OS_STYLE_FREEBSD 1 #define OS_STYLE_NETBSD 2 -private const char os_style_names[][8] = { +file_private const char os_style_names[][8] = { "SVR4", "FreeBSD", "NetBSD", @@ -346,7 +346,7 @@ private const char os_style_names[][8] = { #define FLAGS_IS_CORE 0x0800 #define FLAGS_DID_AUXV 0x1000 -private int +file_private int dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, size_t size, off_t fsize, int *flags, uint16_t *notecount) { @@ -547,7 +547,7 @@ do_note_freebsd_version(struct magic_set *ms, int swap, void *v) return 0; } -private int +file_private int /*ARGSUSED*/ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int swap __attribute__((__unused__)), uint32_t namesz, uint32_t descsz, @@ -593,7 +593,7 @@ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, return 0; } -private int +file_private int do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int swap, uint32_t namesz, uint32_t descsz, size_t noff, size_t doff, int *flags) @@ -692,7 +692,7 @@ do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, return 0; } -private int +file_private int do_pax_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int swap, uint32_t namesz, uint32_t descsz, size_t noff, size_t doff, int *flags) @@ -732,7 +732,7 @@ do_pax_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, return 0; } -private int +file_private int do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int swap, uint32_t namesz, uint32_t descsz, size_t noff, size_t doff, int *flags, size_t size, int clazz) @@ -944,7 +944,7 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, return 0; } -private off_t +file_private off_t get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd, off_t off, int num, off_t fsize, uint64_t virtaddr) { @@ -978,7 +978,7 @@ get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd, return 0; } -private size_t +file_private size_t get_string_on_virtaddr(struct magic_set *ms, int swap, int clazz, int fd, off_t ph_off, int ph_num, off_t fsize, uint64_t virtaddr, char *buf, ssize_t buflen) @@ -1012,7 +1012,7 @@ get_string_on_virtaddr(struct magic_set *ms, /*ARGSUSED*/ -private int +file_private int do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int swap, uint32_t namesz __attribute__((__unused__)), uint32_t descsz __attribute__((__unused__)), @@ -1119,7 +1119,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, #endif } -private size_t +file_private size_t dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size, int clazz, int swap, int *pie, size_t *need) { @@ -1155,7 +1155,7 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size, } -private size_t +file_private size_t donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, int clazz, int swap, size_t align, int *flags, uint16_t *notecount, int fd, off_t ph_off, int ph_num, off_t fsize) @@ -1348,7 +1348,7 @@ static const cap_desc_t cap_desc_386[] = { { 0, NULL } }; -private int +file_private int doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, size_t size, off_t fsize, int mach, int strtab, int *flags, uint16_t *notecount) @@ -1654,7 +1654,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, * it is pie, and does not have an interpreter or needed libraries, we * call it static pie. */ -private int +file_private int dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, size_t size, off_t fsize, int sh_num, int *flags, uint16_t *notecount) @@ -1813,7 +1813,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, } -protected int +file_protected int file_tryelf(struct magic_set *ms, const struct buffer *b) { int fd = b->fd; diff --git a/src/softmagic.c b/src/softmagic.c index e5cacb4b..e0e839f4 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.338 2022/12/24 22:30:01 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.339 2022/12/26 17:31:14 christos Exp $") #endif /* lint */ #include "magic.h" @@ -44,29 +44,29 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.338 2022/12/24 22:30:01 christos Exp $") #include <time.h> #include "der.h" -private int match(struct magic_set *, struct magic *, file_regex_t **, size_t, +file_private int match(struct magic_set *, struct magic *, file_regex_t **, size_t, const struct buffer *, size_t, int, int, int, uint16_t *, uint16_t *, int *, int *, int *, int *, int *); -private int mget(struct magic_set *, struct magic *, const struct buffer *, +file_private int mget(struct magic_set *, struct magic *, const struct buffer *, const unsigned char *, size_t, size_t, unsigned int, int, int, int, uint16_t *, uint16_t *, int *, int *, int *, int *, int *); -private int msetoffset(struct magic_set *, struct magic *, struct buffer *, +file_private int msetoffset(struct magic_set *, struct magic *, struct buffer *, const struct buffer *, size_t, unsigned int); -private int magiccheck(struct magic_set *, struct magic *, file_regex_t **); -private int mprint(struct magic_set *, struct magic *); -private int moffset(struct magic_set *, struct magic *, const struct buffer *, +file_private int magiccheck(struct magic_set *, struct magic *, file_regex_t **); +file_private int mprint(struct magic_set *, struct magic *); +file_private int moffset(struct magic_set *, struct magic *, const struct buffer *, int32_t *); -private void mdebug(uint32_t, const char *, size_t); -private int mcopy(struct magic_set *, union VALUETYPE *, int, int, +file_private void mdebug(uint32_t, const char *, size_t); +file_private int mcopy(struct magic_set *, union VALUETYPE *, int, int, const unsigned char *, uint32_t, size_t, struct magic *); -private int mconvert(struct magic_set *, struct magic *, int); -private int print_sep(struct magic_set *, int); -private int handle_annotation(struct magic_set *, struct magic *, int); -private int cvt_8(union VALUETYPE *, const struct magic *); -private int cvt_16(union VALUETYPE *, const struct magic *); -private int cvt_32(union VALUETYPE *, const struct magic *); -private int cvt_64(union VALUETYPE *, const struct magic *); +file_private int mconvert(struct magic_set *, struct magic *, int); +file_private int print_sep(struct magic_set *, int); +file_private int handle_annotation(struct magic_set *, struct magic *, int); +file_private int cvt_8(union VALUETYPE *, const struct magic *); +file_private int cvt_16(union VALUETYPE *, const struct magic *); +file_private int cvt_32(union VALUETYPE *, const struct magic *); +file_private int cvt_64(union VALUETYPE *, const struct magic *); #define OFFSET_OOB(n, o, i) ((n) < CAST(uint32_t, (o)) || (i) > ((n) - (o))) #define BE64(p) ( \ @@ -114,7 +114,7 @@ private int cvt_64(union VALUETYPE *, const struct magic *); * Passed the name and FILE * of one file to be typed. */ /*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */ -protected int +file_protected int file_softmagic(struct magic_set *ms, const struct buffer *b, uint16_t *indir_count, uint16_t *name_count, int mode, int text) { @@ -156,7 +156,7 @@ file_softmagic(struct magic_set *ms, const struct buffer *b, #ifdef FILE_FMTDEBUG #define F(a, b, c) file_fmtcheck((a), (b), (c), __FILE__, __LINE__) -private const char * __attribute__((__format_arg__(3))) +file_private const char * __attribute__((__format_arg__(3))) file_fmtcheck(struct magic_set *ms, const char *desc, const char *def, const char *file, size_t line) { @@ -203,7 +203,7 @@ file_fmtcheck(struct magic_set *ms, const char *desc, const char *def, * If a continuation matches, we bump the current continuation level * so that higher-level continuations are processed. */ -private int +file_private int match(struct magic_set *ms, struct magic *magic, file_regex_t **magic_rxcomp, size_t nmagic, const struct buffer *b, size_t offset, int mode, int text, int flip, uint16_t *indir_count, uint16_t *name_count, @@ -482,7 +482,7 @@ flush: return *returnval; } -private int +file_private int check_fmt(struct magic_set *ms, const char *fmt) { file_regex_t rx; @@ -578,7 +578,7 @@ varexpand(struct magic_set *ms, char *buf, size_t len, const char *str) } -private int +file_private int mprint(struct magic_set *ms, struct magic *m) { uint64_t v; @@ -829,7 +829,7 @@ mprint(struct magic_set *ms, struct magic *m) return 0; } -private int +file_private int moffset(struct magic_set *ms, struct magic *m, const struct buffer *b, int32_t *op) { @@ -982,7 +982,7 @@ moffset(struct magic_set *ms, struct magic *m, const struct buffer *b, return 1; } -private uint32_t +file_private uint32_t cvt_id3(struct magic_set *ms, uint32_t v) { v = ((((v >> 0) & 0x7f) << 0) | @@ -994,7 +994,7 @@ cvt_id3(struct magic_set *ms, uint32_t v) return v; } -private int +file_private int cvt_flip(int type, int flip) { if (flip == 0) @@ -1079,28 +1079,28 @@ cvt_flip(int type, int flip) if (m->mask_op & FILE_OPINVERSE) \ p->fld = ~p->fld \ -private int +file_private int cvt_8(union VALUETYPE *p, const struct magic *m) { DO_CVT(b, uint8_t); return 0; } -private int +file_private int cvt_16(union VALUETYPE *p, const struct magic *m) { DO_CVT(h, uint16_t); return 0; } -private int +file_private int cvt_32(union VALUETYPE *p, const struct magic *m) { DO_CVT(l, uint32_t); return 0; } -private int +file_private int cvt_64(union VALUETYPE *p, const struct magic *m) { DO_CVT(q, uint64_t); @@ -1126,14 +1126,14 @@ cvt_64(union VALUETYPE *p, const struct magic *m) break; \ } \ -private int +file_private int cvt_float(union VALUETYPE *p, const struct magic *m) { DO_CVT2(f, float); return 0; } -private int +file_private int cvt_double(union VALUETYPE *p, const struct magic *m) { DO_CVT2(d, double); @@ -1145,7 +1145,7 @@ cvt_double(union VALUETYPE *p, const struct magic *m) * While we're here, let's apply the mask operation * (unless you have a better idea) */ -private int +file_private int mconvert(struct magic_set *ms, struct magic *m, int flip) { union VALUETYPE *p = &ms->ms_value; @@ -1308,7 +1308,7 @@ out: } -private void +file_private void mdebug(uint32_t offset, const char *str, size_t len) { (void) fprintf(stderr, "mget/%" SIZE_T_FORMAT "u @%d: ", len, offset); @@ -1317,7 +1317,7 @@ mdebug(uint32_t offset, const char *str, size_t len) (void) fputc('\n', stderr); } -private int +file_private int mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) { @@ -1454,7 +1454,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, return 0; } -private int +file_private int do_ops(struct magic *m, uint32_t *rv, intmax_t lhs, intmax_t off) { intmax_t offset; @@ -1504,7 +1504,7 @@ do_ops(struct magic *m, uint32_t *rv, intmax_t lhs, intmax_t off) return 0; } -private int +file_private int msetoffset(struct magic_set *ms, struct magic *m, struct buffer *bb, const struct buffer *b, size_t o, unsigned int cont_level) { @@ -1554,7 +1554,7 @@ normal: return 0; } -private int +file_private int save_cont(struct magic_set *ms, struct cont *c) { size_t len; @@ -1569,14 +1569,14 @@ save_cont(struct magic_set *ms, struct cont *c) return 0; } -private void +file_private void restore_cont(struct magic_set *ms, struct cont *c) { free(ms->c.li); ms->c = *c; } -private int +file_private int mget(struct magic_set *ms, struct magic *m, const struct buffer *b, const unsigned char *s, size_t nbytes, size_t o, unsigned int cont_level, int mode, int text, int flip, uint16_t *indir_count, uint16_t *name_count, @@ -1973,7 +1973,7 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b, return 1; } -private uint64_t +file_private uint64_t file_strncmp(const char *s1, const char *s2, size_t len, size_t maxlen, uint32_t flags) { @@ -2050,7 +2050,7 @@ file_strncmp(const char *s1, const char *s2, size_t len, size_t maxlen, return v; } -private uint64_t +file_private uint64_t file_strncmp16(const char *a, const char *b, size_t len, size_t maxlen, uint32_t flags) { @@ -2063,7 +2063,7 @@ file_strncmp16(const char *a, const char *b, size_t len, size_t maxlen, return file_strncmp(a, b, len, maxlen, flags); } -private file_regex_t * +file_private file_regex_t * alloc_regex(struct magic_set *ms, struct magic *m) { int rc; @@ -2084,7 +2084,7 @@ alloc_regex(struct magic_set *ms, struct magic *m) return NULL; } -private int +file_private int magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache) { uint64_t l = m->value.q; @@ -2460,7 +2460,7 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache) return matched; } -private int +file_private int handle_annotation(struct magic_set *ms, struct magic *m, int firstline) { if ((ms->flags & MAGIC_APPLE) && m->apple[0]) { @@ -2493,7 +2493,7 @@ handle_annotation(struct magic_set *ms, struct magic *m, int firstline) return 0; } -private int +file_private int print_sep(struct magic_set *ms, int firstline) { if (firstline) @@ -26,13 +26,13 @@ * SUCH DAMAGE. */ /* - * Header file for public domain tar (tape archive) program. + * Header file for file_public domain tar (tape archive) program. * * @(#)tar.h 1.20 86/10/29 Public Domain. * * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. * - * $File: tar.h,v 1.15 2022/09/24 20:30:13 christos Exp $ # checkin only + * $File: tar.h,v 1.16 2022/12/26 17:31:14 christos Exp $ # checkin only */ /* |