version 1.12, 2015/08/11 22:18:43 |
version 1.13, 2015/08/11 22:23:51 |
|
|
int n; |
int n; |
size_t size; |
size_t size; |
|
|
|
if (ml->type == MAGIC_TYPE_NONE) |
|
return (0); |
|
|
if (ml->test_not || ml->test_operator == 'x') |
if (ml->test_not || ml->test_operator == 'x') |
return (1); |
return (1); |
|
|
|
|
return (-1); |
return (-1); |
} |
} |
|
|
static void |
|
magic_free_line(struct magic_line *ml) |
|
{ |
|
free((void *)ml->type_string); |
|
|
|
free((void *)ml->mimetype); |
|
free((void *)ml->result); |
|
|
|
free(ml); |
|
} |
|
|
|
int |
int |
magic_compare(struct magic_line *ml1, struct magic_line *ml2) |
magic_compare(struct magic_line *ml1, struct magic_line *ml2) |
{ |
{ |
|
|
TAILQ_INIT(&ml->children); |
TAILQ_INIT(&ml->children); |
ml->text = 1; |
ml->text = 1; |
|
|
|
/* |
|
* At this point n is the level we want, level is the current |
|
* level. parent0 is the last line at the same level and parent |
|
* is the last line at the previous level. |
|
*/ |
if (n == level + 1) { |
if (n == level + 1) { |
parent = parent0; |
parent = parent0; |
} else if (n < level) { |
} else if (n < level) { |
|
|
magic_parse_type(ml, &line) != 0 || |
magic_parse_type(ml, &line) != 0 || |
magic_parse_value(ml, &line) != 0 || |
magic_parse_value(ml, &line) != 0 || |
magic_set_result(ml, line) != 0) { |
magic_set_result(ml, line) != 0) { |
magic_free_line(ml); |
/* |
|
* An invalid line still needs to appear in the tree in |
|
* case it has any children. |
|
*/ |
|
ml->type = MAGIC_TYPE_NONE; |
ml = NULL; |
ml = NULL; |
continue; |
continue; |
} |
} |