version 1.15, 2015/08/11 22:35:54 |
version 1.16, 2015/08/11 22:48:09 |
|
|
*cp = '\0'; |
*cp = '\0'; |
|
|
ml->type = MAGIC_TYPE_NONE; |
ml->type = MAGIC_TYPE_NONE; |
ml->type_string = xstrdup(s); |
|
|
|
ml->type_operator = ' '; |
ml->type_operator = ' '; |
ml->type_operand = 0; |
ml->type_operand = 0; |
|
|
if (strncmp(s, "string", (sizeof "string") - 1) == 0) { |
if (strncmp(s, "string", (sizeof "string") - 1) == 0 || |
|
strncmp(s, "ustring", (sizeof "ustring") - 1) == 0) { |
|
if (*s == 'u') |
|
ml->type_string = xstrdup(s + 1); |
|
else |
|
ml->type_string = xstrdup(s); |
ml->type = MAGIC_TYPE_STRING; |
ml->type = MAGIC_TYPE_STRING; |
magic_mark_text(ml, 0); |
magic_mark_text(ml, 0); |
goto done; |
goto done; |
} |
} |
if (strncmp(s, "search", (sizeof "search") - 1) == 0) { |
if (strncmp(s, "pstring", (sizeof "pstring") - 1) == 0 || |
|
strncmp(s, "upstring", (sizeof "upstring") - 1) == 0) { |
|
if (*s == 'u') |
|
ml->type_string = xstrdup(s + 1); |
|
else |
|
ml->type_string = xstrdup(s); |
|
ml->type = MAGIC_TYPE_PSTRING; |
|
magic_mark_text(ml, 0); |
|
goto done; |
|
} |
|
if (strncmp(s, "search", (sizeof "search") - 1) == 0 || |
|
strncmp(s, "usearch", (sizeof "usearch") - 1) == 0) { |
|
if (*s == 'u') |
|
ml->type_string = xstrdup(s + 1); |
|
else |
|
ml->type_string = xstrdup(s); |
ml->type = MAGIC_TYPE_SEARCH; |
ml->type = MAGIC_TYPE_SEARCH; |
goto done; |
goto done; |
} |
} |
if (strncmp(s, "regex", (sizeof "regex") - 1) == 0) { |
if (strncmp(s, "regex", (sizeof "regex") - 1) == 0 || |
|
strncmp(s, "uregex", (sizeof "uregex") - 1) == 0) { |
|
if (*s == 'u') |
|
ml->type_string = xstrdup(s + 1); |
|
else |
|
ml->type_string = xstrdup(s); |
ml->type = MAGIC_TYPE_REGEX; |
ml->type = MAGIC_TYPE_REGEX; |
goto done; |
goto done; |
} |
} |
|
ml->type_string = xstrdup(s); |
|
|
cp = &s[strcspn(s, "+-&/%*")]; |
cp = &s[strcspn(s, "+-&/%*")]; |
if (*cp != '\0') { |
if (*cp != '\0') { |
|
|
ml->type = MAGIC_TYPE_ULONG; |
ml->type = MAGIC_TYPE_ULONG; |
else if (strcmp(s, "uquad") == 0) |
else if (strcmp(s, "uquad") == 0) |
ml->type = MAGIC_TYPE_UQUAD; |
ml->type = MAGIC_TYPE_UQUAD; |
else if (strcmp(s, "float") == 0) |
else if (strcmp(s, "float") == 0 || strcmp(s, "ufloat") == 0) |
ml->type = MAGIC_TYPE_FLOAT; |
ml->type = MAGIC_TYPE_FLOAT; |
else if (strcmp(s, "double") == 0) |
else if (strcmp(s, "double") == 0 || strcmp(s, "udouble") == 0) |
ml->type = MAGIC_TYPE_DOUBLE; |
ml->type = MAGIC_TYPE_DOUBLE; |
else if (strcmp(s, "pstring") == 0) |
|
ml->type = MAGIC_TYPE_PSTRING; |
|
else if (strcmp(s, "date") == 0) |
else if (strcmp(s, "date") == 0) |
ml->type = MAGIC_TYPE_DATE; |
ml->type = MAGIC_TYPE_DATE; |
else if (strcmp(s, "qdate") == 0) |
else if (strcmp(s, "qdate") == 0) |
|
|
ml->type = MAGIC_TYPE_UBELONG; |
ml->type = MAGIC_TYPE_UBELONG; |
else if (strcmp(s, "ubequad") == 0) |
else if (strcmp(s, "ubequad") == 0) |
ml->type = MAGIC_TYPE_UBEQUAD; |
ml->type = MAGIC_TYPE_UBEQUAD; |
else if (strcmp(s, "befloat") == 0) |
else if (strcmp(s, "befloat") == 0 || strcmp(s, "ubefloat") == 0) |
ml->type = MAGIC_TYPE_BEFLOAT; |
ml->type = MAGIC_TYPE_BEFLOAT; |
else if (strcmp(s, "bedouble") == 0) |
else if (strcmp(s, "bedouble") == 0 || strcmp(s, "ubedouble") == 0) |
ml->type = MAGIC_TYPE_BEDOUBLE; |
ml->type = MAGIC_TYPE_BEDOUBLE; |
else if (strcmp(s, "bedate") == 0) |
else if (strcmp(s, "bedate") == 0) |
ml->type = MAGIC_TYPE_BEDATE; |
ml->type = MAGIC_TYPE_BEDATE; |
|
|
ml->type = MAGIC_TYPE_UBELDATE; |
ml->type = MAGIC_TYPE_UBELDATE; |
else if (strcmp(s, "ubeqldate") == 0) |
else if (strcmp(s, "ubeqldate") == 0) |
ml->type = MAGIC_TYPE_UBEQLDATE; |
ml->type = MAGIC_TYPE_UBEQLDATE; |
else if (strcmp(s, "bestring16") == 0) |
else if (strcmp(s, "bestring16") == 0 || strcmp(s, "ubestring16") == 0) |
ml->type = MAGIC_TYPE_BESTRING16; |
ml->type = MAGIC_TYPE_BESTRING16; |
else if (strcmp(s, "leshort") == 0) |
else if (strcmp(s, "leshort") == 0) |
ml->type = MAGIC_TYPE_LESHORT; |
ml->type = MAGIC_TYPE_LESHORT; |
|
|
ml->type = MAGIC_TYPE_ULELONG; |
ml->type = MAGIC_TYPE_ULELONG; |
else if (strcmp(s, "ulequad") == 0) |
else if (strcmp(s, "ulequad") == 0) |
ml->type = MAGIC_TYPE_ULEQUAD; |
ml->type = MAGIC_TYPE_ULEQUAD; |
else if (strcmp(s, "lefloat") == 0) |
else if (strcmp(s, "lefloat") == 0 || strcmp(s, "ulefloat") == 0) |
ml->type = MAGIC_TYPE_LEFLOAT; |
ml->type = MAGIC_TYPE_LEFLOAT; |
else if (strcmp(s, "ledouble") == 0) |
else if (strcmp(s, "ledouble") == 0 || strcmp(s, "uledouble") == 0) |
ml->type = MAGIC_TYPE_LEDOUBLE; |
ml->type = MAGIC_TYPE_LEDOUBLE; |
else if (strcmp(s, "ledate") == 0) |
else if (strcmp(s, "ledate") == 0) |
ml->type = MAGIC_TYPE_LEDATE; |
ml->type = MAGIC_TYPE_LEDATE; |
|
|
ml->type = MAGIC_TYPE_ULELDATE; |
ml->type = MAGIC_TYPE_ULELDATE; |
else if (strcmp(s, "uleqldate") == 0) |
else if (strcmp(s, "uleqldate") == 0) |
ml->type = MAGIC_TYPE_ULEQLDATE; |
ml->type = MAGIC_TYPE_ULEQLDATE; |
else if (strcmp(s, "lestring16") == 0) |
else if (strcmp(s, "lestring16") == 0 || strcmp(s, "ulestring16") == 0) |
ml->type = MAGIC_TYPE_LESTRING16; |
ml->type = MAGIC_TYPE_LESTRING16; |
else if (strcmp(s, "melong") == 0) |
else if (strcmp(s, "melong") == 0 || strcmp(s, "umelong") == 0) |
ml->type = MAGIC_TYPE_MELONG; |
ml->type = MAGIC_TYPE_MELONG; |
else if (strcmp(s, "medate") == 0) |
else if (strcmp(s, "medate") == 0 || strcmp(s, "umedate") == 0) |
ml->type = MAGIC_TYPE_MEDATE; |
ml->type = MAGIC_TYPE_MEDATE; |
else if (strcmp(s, "meldate") == 0) |
else if (strcmp(s, "meldate") == 0 || strcmp(s, "umeldate") == 0) |
ml->type = MAGIC_TYPE_MELDATE; |
ml->type = MAGIC_TYPE_MELDATE; |
else if (strcmp(s, "default") == 0) |
else if (strcmp(s, "default") == 0 || strcmp(s, "udefault") == 0) |
ml->type = MAGIC_TYPE_DEFAULT; |
ml->type = MAGIC_TYPE_DEFAULT; |
else { |
else { |
magic_warn(ml, "unknown type: %s", s); |
magic_warn(ml, "unknown type: %s", s); |