diff options
author | dim <dim@FreeBSD.org> | 2014-12-11 19:27:27 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-12-11 19:27:27 +0000 |
commit | da65ea02a341dd797c46b6987753bc1453982b36 (patch) | |
tree | d9a72217c1d2c4dcfef27a2fd2078dd4b3f69a64 /contrib/file/src/magic.c | |
parent | 4cba228708753c1128b75a2c25c0dda582a9913a (diff) | |
parent | dc1c036751105b0a801375ba642278a13543bf7c (diff) | |
download | FreeBSD-src-da65ea02a341dd797c46b6987753bc1453982b36.zip FreeBSD-src-da65ea02a341dd797c46b6987753bc1453982b36.tar.gz |
Merge ^/head r275685 through r275714.
Diffstat (limited to 'contrib/file/src/magic.c')
-rw-r--r-- | contrib/file/src/magic.c | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/contrib/file/src/magic.c b/contrib/file/src/magic.c index e4bd12b..b0cf11c 100644 --- a/contrib/file/src/magic.c +++ b/contrib/file/src/magic.c @@ -33,7 +33,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.84 2014/05/14 23:15:42 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.90 2014/12/04 15:56:46 christos Exp $") #endif /* lint */ #include "magic.h" @@ -128,6 +128,7 @@ out: #else char *hmagicp; char *tmppath = NULL; + LPTSTR dllpath; hmagicpath = NULL; #define APPENDPATH() \ @@ -173,7 +174,7 @@ out: } /* Third, try to get magic file relative to dll location */ - LPTSTR dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1)); + dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1)); dllpath[MAX_PATH] = 0; /* just in case long path gets truncated and not null terminated */ if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){ PathRemoveFileSpecA(dllpath); @@ -257,6 +258,20 @@ magic_load(struct magic_set *ms, const char *magicfile) return file_apprentice(ms, magicfile, FILE_LOAD); } +#ifndef COMPILE_ONLY +/* + * Install a set of compiled magic buffers. + */ +public int +magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes, + size_t nbufs) +{ + if (ms == NULL) + return -1; + return buffer_apprentice(ms, (struct magic **)bufs, sizes, nbufs); +} +#endif + public int magic_compile(struct magic_set *ms, const char *magicfile) { @@ -522,3 +537,47 @@ magic_version(void) { return MAGIC_VERSION; } + +public int +magic_setparam(struct magic_set *ms, int param, const void *val) +{ + switch (param) { + case MAGIC_PARAM_INDIR_MAX: + ms->indir_max = *(const size_t *)val; + return 0; + case MAGIC_PARAM_NAME_MAX: + ms->name_max = *(const size_t *)val; + return 0; + case MAGIC_PARAM_ELF_PHNUM_MAX: + ms->elf_phnum_max = *(const size_t *)val; + return 0; + case MAGIC_PARAM_ELF_SHNUM_MAX: + ms->elf_shnum_max = *(const size_t *)val; + return 0; + default: + errno = EINVAL; + return -1; + } +} + +public int +magic_getparam(struct magic_set *ms, int param, void *val) +{ + switch (param) { + case MAGIC_PARAM_INDIR_MAX: + *(size_t *)val = ms->indir_max; + return 0; + case MAGIC_PARAM_NAME_MAX: + *(size_t *)val = ms->name_max; + return 0; + case MAGIC_PARAM_ELF_PHNUM_MAX: + *(size_t *)val = ms->elf_phnum_max; + return 0; + case MAGIC_PARAM_ELF_SHNUM_MAX: + *(size_t *)val = ms->elf_shnum_max; + return 0; + default: + errno = EINVAL; + return -1; + } +} |