version 1.32, 2014/10/26 04:10:26 |
version 1.33, 2015/01/16 08:24:04 |
|
|
* apprentice - make one pass through /etc/magic, learning its secrets. |
* apprentice - make one pass through /etc/magic, learning its secrets. |
*/ |
*/ |
|
|
#include <sys/param.h> |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
|
#define MAP_FILE 0 |
#define MAP_FILE 0 |
#endif |
#endif |
|
|
#ifndef MAXPATHLEN |
#ifndef PATH_MAX |
#define MAXPATHLEN 1024 |
#define PATH_MAX 1024 |
#endif |
#endif |
|
|
struct magic_entry { |
struct magic_entry { |
|
|
int errs = 0; |
int errs = 0; |
struct magic_entry *marray; |
struct magic_entry *marray; |
uint32_t marraycount, i, mentrycount = 0, starttest; |
uint32_t marraycount, i, mentrycount = 0, starttest; |
char subfn[MAXPATHLEN]; |
char subfn[PATH_MAX]; |
struct stat st; |
struct stat st; |
DIR *dir; |
DIR *dir; |
struct dirent *d; |
struct dirent *d; |
|
|
} |
} |
|
|
(void)asprintf(buf, "%s%s", fn, ext); |
(void)asprintf(buf, "%s%s", fn, ext); |
if (*buf && strlen(*buf) > MAXPATHLEN) { |
if (*buf && strlen(*buf) > PATH_MAX) { |
free(*buf); |
free(*buf); |
*buf = NULL; |
*buf = NULL; |
} |
} |