Lines Matching refs:m
131 struct magic *m = &magic[magindex]; in match() local
133 if ((IS_LIBMAGIC_STRING(m->type) && in match()
134 ((text && (m->str_flags & (STRING_BINTEST | STRING_TEXTTEST)) == STRING_BINTEST) || in match()
135 (!text && (m->str_flags & (STRING_TEXTTEST | STRING_BINTEST)) == STRING_TEXTTEST))) || in match()
136 (m->flag & mode) != mode) { in match()
144 ms->offset = m->offset; in match()
145 ms->line = m->lineno; in match()
148 switch (mget(ms, s, m, nbytes, cont_level, text)) { in match()
152 flush = m->reln != '!'; in match()
155 if (m->type == FILE_INDIRECT) in match()
158 switch (magiccheck(ms, m)) { in match()
181 if ((e = handle_annotation(ms, m)) != 0) in match()
187 if (*m->desc) { in match()
195 if (print && mprint(ms, m) == -1) in match()
198 ms->c.li[cont_level].off = moffset(ms, m); in match()
206 m = &magic[magindex]; in match()
207 ms->line = m->lineno; /* for messages */ in match()
209 if (cont_level < m->cont_level) in match()
211 if (cont_level > m->cont_level) { in match()
216 cont_level = m->cont_level; in match()
218 ms->offset = m->offset; in match()
219 if (m->flag & OFFADD) { in match()
224 if (m->cond == COND_ELSE || in match()
225 m->cond == COND_ELIF) { in match()
230 switch (mget(ms, s, m, nbytes, cont_level, text)) { in match()
234 if (m->reln != '!') in match()
239 if (m->type == FILE_INDIRECT) in match()
245 switch (flush ? 1 : magiccheck(ms, m)) { in match()
257 if (m->type != FILE_DEFAULT) in match()
263 if ((e = handle_annotation(ms, m)) != 0) in match()
269 if (*m->desc) { in match()
285 && ((m->flag & NOSPACE) == 0) in match()
286 && *m->desc) { in match()
292 if (print && mprint(ms, m) == -1) in match()
295 ms->c.li[cont_level].off = moffset(ms, m); in match()
297 if (*m->desc) in match()
323 check_fmt(struct magic_set *ms, struct magic *m) in check_fmt() argument
330 if (strchr(m->desc, '%') == NULL) { in check_fmt()
337 return !pcre_exec(pce, re_extra, m->desc, strlen(m->desc), 0, re_options, NULL, 0); in check_fmt()
342 mprint(struct magic_set *ms, struct magic *m) in mprint() argument
351 switch (m->type) { in mprint()
353 v = file_signextend(ms, m, (uint64_t)p->b); in mprint()
354 switch (check_fmt(ms, m)) { in mprint()
360 if (file_printf(ms, m->desc, buf) == -1) in mprint()
364 if (file_printf(ms, m->desc, (unsigned char) v) == -1) in mprint()
374 v = file_signextend(ms, m, (uint64_t)p->h); in mprint()
375 switch (check_fmt(ms, m)) { in mprint()
381 if (file_printf(ms, m->desc, buf) == -1) in mprint()
386 file_printf(ms, m->desc, (unsigned short) v) == -1) in mprint()
397 v = file_signextend(ms, m, (uint64_t)p->l); in mprint()
398 switch (check_fmt(ms, m)) { in mprint()
403 if (file_printf(ms, m->desc, buf) == -1) in mprint()
407 if (file_printf(ms, m->desc, (uint32_t) v) == -1) in mprint()
417 v = file_signextend(ms, m, p->q); in mprint()
418 if (file_printf(ms, m->desc, (uint64_t) v) == -1) in mprint()
427 if (m->reln == '=' || m->reln == '!') { in mprint()
428 if (file_printf(ms, m->desc, m->value.s) == -1) in mprint()
430 t = ms->offset + m->vallen; in mprint()
433 if (*m->value.s == '\0') in mprint()
435 if (file_printf(ms, m->desc, p->s) == -1) in mprint()
438 if (m->type == FILE_PSTRING) in mprint()
439 t += file_pstring_length_size(m); in mprint()
447 if (file_printf(ms, m->desc, file_fmttime(p->l, 1)) == -1) in mprint()
456 if (file_printf(ms, m->desc, file_fmttime(p->l, 0)) == -1) in mprint()
464 if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, in mprint()
473 if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, in mprint()
483 switch (check_fmt(ms, m)) { in mprint()
488 if (file_printf(ms, m->desc, buf) == -1) in mprint()
492 if (file_printf(ms, m->desc, vf) == -1) in mprint()
503 switch (check_fmt(ms, m)) { in mprint()
508 if (file_printf(ms, m->desc, buf) == -1) in mprint()
512 if (file_printf(ms, m->desc, vd) == -1) in mprint()
525 rval = file_printf(ms, m->desc, cp); in mprint()
531 if ((m->str_flags & REGEX_OFFSET_START)) in mprint()
539 if (file_printf(ms, m->desc, m->value.s) == -1) in mprint()
541 if ((m->str_flags & REGEX_OFFSET_START)) in mprint()
544 t = ms->search.offset + m->vallen; in mprint()
548 if (file_printf(ms, m->desc, m->value.s) == -1) in mprint()
558 file_magerror(ms, "invalid m->type (%d) in mprint()", m->type); in mprint()
565 moffset(struct magic_set *ms, struct magic *m) in moffset() argument
567 switch (m->type) { in moffset()
591 if (m->reln == '=' || m->reln == '!') in moffset()
592 return ms->offset + m->vallen; in moffset()
597 if (*m->value.s == '\0') in moffset()
600 if (m->type == FILE_PSTRING) in moffset()
601 t += file_pstring_length_size(m); in moffset()
638 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
645 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
648 return CAST(int32_t, (ms->search.offset + m->vallen)); in moffset()
662 if (m->num_mask) \
663 switch (m->mask_op & FILE_OPS_MASK) { \
665 p->fld &= cast m->num_mask; \
668 p->fld |= cast m->num_mask; \
671 p->fld ^= cast m->num_mask; \
674 p->fld += cast m->num_mask; \
677 p->fld -= cast m->num_mask; \
680 p->fld *= cast m->num_mask; \
683 p->fld /= cast m->num_mask; \
686 p->fld %= cast m->num_mask; \
689 if (m->mask_op & FILE_OPINVERSE) \
693 cvt_8(union VALUETYPE *p, const struct magic *m) in cvt_8() argument
699 cvt_16(union VALUETYPE *p, const struct magic *m) in cvt_16() argument
705 cvt_32(union VALUETYPE *p, const struct magic *m) in cvt_32() argument
711 cvt_64(union VALUETYPE *p, const struct magic *m) in cvt_64() argument
717 if (m->num_mask) \
718 switch (m->mask_op & FILE_OPS_MASK) { \
720 p->fld += cast (int64_t)m->num_mask; \
723 p->fld -= cast (int64_t)m->num_mask; \
726 p->fld *= cast (int64_t)m->num_mask; \
729 p->fld /= cast (int64_t)m->num_mask; \
734 cvt_float(union VALUETYPE *p, const struct magic *m) in cvt_float() argument
740 cvt_double(union VALUETYPE *p, const struct magic *m) in cvt_double() argument
751 mconvert(struct magic_set *ms, struct magic *m) in mconvert() argument
755 switch (m->type) { in mconvert()
757 cvt_8(p, m); in mconvert()
760 cvt_16(p, m); in mconvert()
765 cvt_32(p, m); in mconvert()
770 cvt_64(p, m); in mconvert()
780 size_t sz = file_pstring_length_size(m); in mconvert()
782 size_t len = file_pstring_get_length(m, ptr1); in mconvert()
799 cvt_16(p, m); in mconvert()
806 cvt_32(p, m); in mconvert()
816 cvt_64(p, m); in mconvert()
820 cvt_16(p, m); in mconvert()
827 cvt_32(p, m); in mconvert()
837 cvt_64(p, m); in mconvert()
844 cvt_32(p, m); in mconvert()
847 cvt_float(p, m); in mconvert()
852 cvt_float(p, m); in mconvert()
857 cvt_float(p, m); in mconvert()
860 cvt_double(p, m); in mconvert()
867 cvt_double(p, m); in mconvert()
874 cvt_double(p, m); in mconvert()
881 file_magerror(ms, "invalid type %d in mconvert()", m->type); in mconvert()
1008 struct magic *m, size_t nbytes, unsigned int cont_level, int text) in mget() argument
1011 uint32_t count = m->str_range; in mget()
1014 if (mcopy(ms, p, m->type, m->flag & INDIR, s, offset, nbytes, count) == -1) in mget()
1021 if (m->flag & INDIR) { in mget()
1022 int off = m->in_offset; in mget()
1023 if (m->in_op & FILE_OPINDIRECT) { in mget()
1026 switch (m->in_type) { in mget()
1058 switch (m->in_type) { in mget()
1063 switch (m->in_op & FILE_OPS_MASK) { in mget()
1091 if (m->in_op & FILE_OPINVERSE) in mget()
1098 switch (m->in_op & FILE_OPS_MASK) { in mget()
1143 if (m->in_op & FILE_OPINVERSE) in mget()
1150 switch (m->in_op & FILE_OPS_MASK) { in mget()
1195 if (m->in_op & FILE_OPINVERSE) in mget()
1202 switch (m->in_op & FILE_OPS_MASK) { in mget()
1231 if (m->in_op & FILE_OPINVERSE) in mget()
1239 switch (m->in_op & FILE_OPS_MASK) { in mget()
1302 if (m->in_op & FILE_OPINVERSE) in mget()
1310 switch (m->in_op & FILE_OPS_MASK) { in mget()
1373 if (m->in_op & FILE_OPINVERSE) in mget()
1380 switch (m->in_op & FILE_OPS_MASK) { in mget()
1443 if (m->in_op & FILE_OPINVERSE) in mget()
1450 switch (m->in_op & FILE_OPS_MASK) { in mget()
1478 if (m->in_op & FILE_OPINVERSE) in mget()
1483 switch (m->in_type) { in mget()
1495 if (m->flag & INDIROFFADD) { in mget()
1498 if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1) in mget()
1509 switch (m->type) { in mget()
1551 if (nbytes < (offset + m->vallen)) in mget()
1562 file_printf(ms, "%s", m->desc) == -1) in mget()
1573 if (!mconvert(ms, m)) in mget()
1690 magiccheck(struct magic_set *ms, struct magic *m) argument
1692 uint64_t l = m->value.q;
1699 switch (m->type) {
1740 fl = m->value.f;
1742 switch (m->reln) {
1766 m->reln);
1774 dl = m->value.d;
1776 switch (m->reln) {
1799 file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
1812 v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
1818 v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
1828 slen = MIN(m->vallen, sizeof(m->value.s));
1832 for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) {
1836 v = file_strncmp(m->value.s, ms->search.s + idx, slen, m->str_flags);
1851 ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0);
1855 if (m->str_flags & STRING_IGNORE_CASE) {
2003 file_magerror(ms, "invalid type %d in magiccheck()", m->type);
2007 v = file_signextend(ms, m, v);
2009 switch (m->reln) {
2034 if (m->flag & UNSIGNED) {
2052 if (m->flag & UNSIGNED) {
2092 m->reln);
2100 handle_annotation(struct magic_set *ms, struct magic *m) argument
2103 if (file_printf(ms, "%.8s", m->apple) == -1)
2107 if ((ms->flags & MAGIC_MIME_TYPE) && m->mimetype[0]) {
2108 if (file_printf(ms, "%s", m->mimetype) == -1)