Lines Matching refs:m

107 file_fmtcheck(struct magic_set *ms, const struct magic *m, const char *def,  in file_fmtcheck()  argument
110 const char *ptr = fmtcheck(m->desc, def); in file_fmtcheck()
114 " with `%s'", file, line, m->desc, def); in file_fmtcheck()
170 struct magic *m = &magic[magindex]; in match() local
172 if (m->type != FILE_NAME) in match()
173 if ((IS_LIBMAGIC_STRING(m->type) && in match()
175 ((text && (m->str_flags & FLT) == STRING_BINTEST) || in match()
176 (!text && (m->str_flags & FLT) == STRING_TEXTTEST))) || in match()
177 (m->flag & mode) != mode) { in match()
186 ms->offset = m->offset; in match()
187 ms->line = m->lineno; in match()
190 switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text, in match()
196 flush = m->reln != '!'; in match()
199 if (m->type == FILE_INDIRECT) in match()
202 switch (magiccheck(ms, m)) { in match()
225 if ((e = handle_annotation(ms, m)) != 0) { in match()
235 if (*m->desc) { in match()
243 if (print && mprint(ms, m) == -1) in match()
246 ms->c.li[cont_level].off = moffset(ms, m); in match()
254 m = &magic[++magindex]; in match()
255 ms->line = m->lineno; /* for messages */ in match()
257 if (cont_level < m->cont_level) in match()
259 if (cont_level > m->cont_level) { in match()
264 cont_level = m->cont_level; in match()
266 ms->offset = m->offset; in match()
267 if (m->flag & OFFADD) { in match()
273 if (m->cond == COND_ELSE || in match()
274 m->cond == COND_ELIF) { in match()
279 switch (mget(ms, s, m, nbytes, offset, cont_level, mode, in match()
285 if (m->reln != '!') in match()
290 if (m->type == FILE_INDIRECT) in match()
296 switch (flush ? 1 : magiccheck(ms, m)) { in match()
308 if (m->type == FILE_CLEAR) in match()
311 if (m->type == FILE_DEFAULT) in match()
315 if ((e = handle_annotation(ms, m)) != 0) { in match()
325 if (*m->desc) { in match()
341 && ((m->flag & NOSPACE) == 0) in match()
342 && *m->desc) { in match()
348 if (print && mprint(ms, m) == -1) in match()
351 ms->c.li[cont_level].off = moffset(ms, m); in match()
353 if (*m->desc) in match()
380 check_fmt(struct magic_set *ms, struct magic *m) in check_fmt() argument
387 if (strchr(m->desc, '%') == NULL) in check_fmt()
395 rv = !pcre_exec(pce, re_extra, m->desc, strlen(m->desc), 0, re_options, NULL, 0); in check_fmt()
403 mprint(struct magic_set *ms, struct magic *m) in mprint() argument
412 switch (m->type) { in mprint()
414 v = file_signextend(ms, m, (uint64_t)p->b); in mprint()
415 switch (check_fmt(ms, m)) { in mprint()
421 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
425 if (file_printf(ms, F(ms, m, "%d"), in mprint()
436 v = file_signextend(ms, m, (uint64_t)p->h); in mprint()
437 switch (check_fmt(ms, m)) { in mprint()
443 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
447 if (file_printf(ms, F(ms, m, "%u"), in mprint()
459 v = file_signextend(ms, m, (uint64_t)p->l); in mprint()
460 switch (check_fmt(ms, m)) { in mprint()
465 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
469 if (file_printf(ms, F(ms, m, "%u"), (uint32_t) v) == -1) in mprint()
479 v = file_signextend(ms, m, p->q); in mprint()
480 switch (check_fmt(ms, m)) { in mprint()
486 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
490 if (file_printf(ms, F(ms, m, "%" INT64_T_FORMAT "u"), in mprint()
502 if (m->reln == '=' || m->reln == '!') { in mprint()
503 if (file_printf(ms, F(ms, m, "%s"), in mprint()
504 file_printable(sbuf, sizeof(sbuf), m->value.s)) in mprint()
507 t = ms->offset + m->vallen; in mprint()
515 if (*m->value.s == '\0') in mprint()
518 if (m->str_flags & STRING_TRIM) { in mprint()
531 if (file_printf(ms, F(ms, m, "%s"), in mprint()
535 if (m->type == FILE_PSTRING) in mprint()
536 t += file_pstring_length_size(m); in mprint()
544 if (file_printf(ms, F(ms, m, "%s"), in mprint()
554 if (file_printf(ms, F(ms, m, "%s"), in mprint()
563 if (file_printf(ms, F(ms, m, "%s"), in mprint()
572 if (file_printf(ms, F(ms, m, "%s"), in mprint()
581 if (file_printf(ms, F(ms, m, "%s"), in mprint()
591 switch (check_fmt(ms, m)) { in mprint()
596 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
600 if (file_printf(ms, F(ms, m, "%g"), vf) == -1) in mprint()
611 switch (check_fmt(ms, m)) { in mprint()
616 if (file_printf(ms, F(ms, m, "%s"), buf) == -1) in mprint()
620 if (file_printf(ms, F(ms, m, "%g"), vd) == -1) in mprint()
636 rval = file_printf(ms, F(ms, m, "%s"), in mprint()
643 if ((m->str_flags & REGEX_OFFSET_START)) in mprint()
651 if (file_printf(ms, F(ms, m, "%s"), m->value.s) == -1) in mprint()
653 if ((m->str_flags & REGEX_OFFSET_START)) in mprint()
656 t = ms->search.offset + m->vallen; in mprint()
661 if (file_printf(ms, "%s", m->desc) == -1) in mprint()
673 file_magerror(ms, "invalid m->type (%d) in mprint()", m->type); in mprint()
680 moffset(struct magic_set *ms, struct magic *m) in moffset() argument
682 switch (m->type) { in moffset()
706 if (m->reln == '=' || m->reln == '!') in moffset()
707 return ms->offset + m->vallen; in moffset()
712 if (*m->value.s == '\0') in moffset()
715 if (m->type == FILE_PSTRING) in moffset()
716 t += (uint32_t)file_pstring_length_size(m); in moffset()
753 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
760 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
763 return CAST(int32_t, (ms->search.offset + m->vallen)); in moffset()
826 if (m->num_mask) \
827 switch (m->mask_op & FILE_OPS_MASK) { \
829 p->fld &= cast m->num_mask; \
832 p->fld |= cast m->num_mask; \
835 p->fld ^= cast m->num_mask; \
838 p->fld += cast m->num_mask; \
841 p->fld -= cast m->num_mask; \
844 p->fld *= cast m->num_mask; \
847 p->fld /= cast m->num_mask; \
850 p->fld %= cast m->num_mask; \
853 if (m->mask_op & FILE_OPINVERSE) \
857 cvt_8(union VALUETYPE *p, const struct magic *m) in cvt_8() argument
863 cvt_16(union VALUETYPE *p, const struct magic *m) in cvt_16() argument
869 cvt_32(union VALUETYPE *p, const struct magic *m) in cvt_32() argument
875 cvt_64(union VALUETYPE *p, const struct magic *m) in cvt_64() argument
881 if (m->num_mask) \
882 switch (m->mask_op & FILE_OPS_MASK) { \
884 p->fld += cast (int64_t)m->num_mask; \
887 p->fld -= cast (int64_t)m->num_mask; \
890 p->fld *= cast (int64_t)m->num_mask; \
893 p->fld /= cast (int64_t)m->num_mask; \
898 cvt_float(union VALUETYPE *p, const struct magic *m) in cvt_float() argument
904 cvt_double(union VALUETYPE *p, const struct magic *m) in cvt_double() argument
915 mconvert(struct magic_set *ms, struct magic *m, int flip) in mconvert() argument
920 switch (type = cvt_flip(m->type, flip)) { in mconvert()
922 cvt_8(p, m); in mconvert()
925 cvt_16(p, m); in mconvert()
930 cvt_32(p, m); in mconvert()
936 cvt_64(p, m); in mconvert()
946 size_t sz = file_pstring_length_size(m); in mconvert()
948 size_t len = file_pstring_get_length(m, ptr1); in mconvert()
968 cvt_16(p, m); in mconvert()
975 cvt_32(p, m); in mconvert()
986 cvt_64(p, m); in mconvert()
990 cvt_16(p, m); in mconvert()
997 cvt_32(p, m); in mconvert()
1008 cvt_64(p, m); in mconvert()
1015 cvt_32(p, m); in mconvert()
1018 cvt_float(p, m); in mconvert()
1023 cvt_float(p, m); in mconvert()
1028 cvt_float(p, m); in mconvert()
1031 cvt_double(p, m); in mconvert()
1038 cvt_double(p, m); in mconvert()
1045 cvt_double(p, m); in mconvert()
1055 file_magerror(ms, "invalid type %d in mconvert()", m->type); in mconvert()
1072 const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) in mcopy() argument
1102 linecnt = m->str_range; in mcopy()
1199 mget(struct magic_set *ms, const unsigned char *s, struct magic *m, in mget() argument
1224 if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o), in mget()
1225 (uint32_t)nbytes, m) == -1) in mget()
1232 m->type, m->flag, offset, o, nbytes, in mget()
1237 if (m->flag & INDIR) { in mget()
1238 int off = m->in_offset; in mget()
1239 if (m->in_op & FILE_OPINDIRECT) { in mget()
1242 switch (cvt_flip(m->in_type, flip)) { in mget()
1276 switch (in_type = cvt_flip(m->in_type, flip)) { in mget()
1281 switch (m->in_op & FILE_OPS_MASK) { in mget()
1309 if (m->in_op & FILE_OPINVERSE) in mget()
1317 switch (m->in_op & FILE_OPS_MASK) { in mget()
1345 if (m->in_op & FILE_OPINVERSE) in mget()
1353 switch (m->in_op & FILE_OPS_MASK) { in mget()
1381 if (m->in_op & FILE_OPINVERSE) in mget()
1388 switch (m->in_op & FILE_OPS_MASK) { in mget()
1417 if (m->in_op & FILE_OPINVERSE) in mget()
1427 switch (m->in_op & FILE_OPS_MASK) { in mget()
1455 if (m->in_op & FILE_OPINVERSE) in mget()
1465 switch (m->in_op & FILE_OPS_MASK) { in mget()
1493 if (m->in_op & FILE_OPINVERSE) in mget()
1502 switch (m->in_op & FILE_OPS_MASK) { in mget()
1530 if (m->in_op & FILE_OPINVERSE) in mget()
1537 switch (m->in_op & FILE_OPS_MASK) { in mget()
1565 if (m->in_op & FILE_OPINVERSE) in mget()
1586 if (m->flag & INDIROFFADD) { in mget()
1597 if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1) in mget()
1608 switch (m->type) { in mget()
1650 if (OFFSET_OOB(nbytes, offset, m->vallen)) in mget()
1660 if (m->str_flags & INDIRECT_RELATIVE) in mget()
1683 file_printf(ms, F(ms, m, "%u"), offset) == -1) { in mget()
1698 rbuf = m->value.s; in mget()
1709 if (m->flag & NOSPACE) in mget()
1719 if (file_printf(ms, "%s", m->desc) == -1) in mget()
1727 if (!mconvert(ms, m, flip)) in mget()
1843 magiccheck(struct magic_set *ms, struct magic *m) in magiccheck() argument
1845 uint64_t l = m->value.q; in magiccheck()
1852 switch (m->type) { in magiccheck()
1896 fl = m->value.f; in magiccheck()
1898 switch (m->reln) { in magiccheck()
1921 m->reln); in magiccheck()
1929 dl = m->value.d; in magiccheck()
1931 switch (m->reln) { in magiccheck()
1953 file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln); in magiccheck()
1967 v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags); in magiccheck()
1973 v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags); in magiccheck()
1983 slen = MIN(m->vallen, sizeof(m->value.s)); in magiccheck()
1987 for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) { in magiccheck()
1991 v = file_strncmp(m->value.s, ms->search.s + idx, slen, in magiccheck()
1992 m->str_flags); in magiccheck()
1995 ms->search.rm_len = m->str_range - idx; in magiccheck()
2008 if (m->str_flags & STRING_IGNORE_CASE) { in magiccheck()
2012 convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); in magiccheck()
2080 file_magerror(ms, "invalid type %d in magiccheck()", m->type); in magiccheck()
2084 v = file_signextend(ms, m, v); in magiccheck()
2086 switch (m->reln) { in magiccheck()
2111 if (m->flag & UNSIGNED) { in magiccheck()
2129 if (m->flag & UNSIGNED) { in magiccheck()
2168 m->reln); in magiccheck()
2176 handle_annotation(struct magic_set *ms, struct magic *m) in handle_annotation() argument
2179 if (file_printf(ms, "%.8s", m->apple) == -1) in handle_annotation()
2183 if ((ms->flags & MAGIC_MIME_TYPE) && m->mimetype[0]) { in handle_annotation()
2184 if (file_printf(ms, "%s", m->mimetype) == -1) in handle_annotation()