version 1.25, 2017/07/01 14:34:29 |
version 1.26, 2017/07/02 10:58:15 |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <ctype.h> |
#include <ctype.h> |
|
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <limits.h> |
#include <limits.h> |
#include <regex.h> |
#include <regex.h> |
|
|
struct magic_line *ml = NULL, *parent, *parent0; |
struct magic_line *ml = NULL, *parent, *parent0; |
char *line, *tmp; |
char *line, *tmp; |
size_t size; |
size_t size; |
|
ssize_t slen; |
u_int at, level, n, i; |
u_int at, level, n, i; |
|
|
m = xcalloc(1, sizeof *m); |
m = xcalloc(1, sizeof *m); |
|
|
|
|
at = 0; |
at = 0; |
tmp = NULL; |
tmp = NULL; |
while ((line = fgetln(f, &size))) { |
size = 0; |
if (line[size - 1] == '\n') |
while ((slen = getline(&tmp, &size, f)) != -1) { |
line[size - 1] = '\0'; |
line = tmp; |
else { |
if (line[slen - 1] == '\n') |
tmp = xmalloc(size + 1); |
line[slen - 1] = '\0'; |
memcpy(tmp, line, size); |
|
tmp[size] = '\0'; |
|
line = tmp; |
|
} |
|
at++; |
at++; |
|
|
while (isspace((u_char)*line)) |
while (isspace((u_char)*line)) |
|
|
parent0 = ml; |
parent0 = ml; |
} |
} |
free(tmp); |
free(tmp); |
|
if (ferror(f)) |
|
err(1, "%s", path); |
|
|
return (m); |
return (m); |
} |
} |