Lines Matching refs:m

195 		struct magic *m = &magic[magindex];  in match()  local
197 if (m->type != FILE_NAME) in match()
198 if ((IS_LIBMAGIC_STRING(m->type) && in match()
200 ((text && (m->str_flags & FLT) == STRING_BINTEST) || in match()
201 (!text && (m->str_flags & FLT) == STRING_TEXTTEST))) || in match()
202 (m->flag & mode) != mode) { in match()
212 if (msetoffset(ms, m, &bb, b, offset, cont_level) == -1) in match()
214 ms->line = m->lineno; in match()
217 switch (mget(ms, m, b, bb.fbuf, bb.flen, offset, cont_level, in match()
223 flush = m->reln != '!'; in match()
226 if (m->type == FILE_INDIRECT) in match()
229 switch (magiccheck(ms, m)) { in match()
249 if ((e = handle_annotation(ms, m, b, firstline)) != 0) { in match()
260 if (*m->desc) { in match()
267 if (print && mprint(ms, m, b) == -1) in match()
270 switch (moffset(ms, m, &bb, &ms->c.li[cont_level].off)) { in match()
284 m = &magic[++magindex]; in match()
285 ms->line = m->lineno; /* for messages */ in match()
287 if (cont_level < m->cont_level) in match()
289 if (cont_level > m->cont_level) { in match()
294 cont_level = m->cont_level; in match()
296 if (msetoffset(ms, m, &bb, b, offset, cont_level) == -1) in match()
298 if (m->flag & OFFADD) { in match()
304 if (m->cond == COND_ELSE || in match()
305 m->cond == COND_ELIF) { in match()
310 switch (mget(ms, m, b, bb.fbuf, bb.flen, offset, in match()
317 if (m->reln != '!') in match()
322 if (m->type == FILE_INDIRECT) in match()
328 switch (flush ? 1 : magiccheck(ms, m)) { in match()
340 if (m->type == FILE_CLEAR) in match()
343 if (m->type == FILE_DEFAULT) in match()
348 if ((e = handle_annotation(ms, m, b, firstline)) in match()
359 if (*m->desc) { in match()
375 && ((m->flag & NOSPACE) == 0) in match()
376 && *m->desc) { in match()
382 if (print && mprint(ms, m, b) == -1) in match()
385 switch (moffset(ms, m, &bb, in match()
396 if (*m->desc) in match()
503 mprint(struct magic_set *ms, struct magic *m, const struct buffer *b) in mprint() argument
513 if (varexpand(ebuf, sizeof(ebuf), b, m->desc) == -1) in mprint()
514 desc = m->desc; in mprint()
518 switch (m->type) { in mprint()
520 v = file_signextend(ms, m, (uint64_t)p->b); in mprint()
542 v = file_signextend(ms, m, (uint64_t)p->h); in mprint()
565 v = file_signextend(ms, m, (uint64_t)p->l); in mprint()
585 v = file_signextend(ms, m, p->q); in mprint()
608 if (m->reln == '=' || m->reln == '!') { in mprint()
610 file_printable(sbuf, sizeof(sbuf), m->value.s)) in mprint()
613 t = ms->offset + m->vallen; in mprint()
621 if (*m->value.s == '\0') in mprint()
624 if (m->str_flags & STRING_TRIM) { in mprint()
641 if (m->type == FILE_PSTRING) in mprint()
642 t += file_pstring_length_size(m); in mprint()
746 if ((m->str_flags & REGEX_OFFSET_START)) in mprint()
755 if (file_printf(ms, "%s", m->desc) == -1) in mprint()
772 file_magerror(ms, "invalid m->type (%d) in mprint()", m->type); in mprint()
779 moffset(struct magic_set *ms, struct magic *m, const struct buffer *b, in moffset() argument
785 switch (m->type) { in moffset()
813 if (m->reln == '=' || m->reln == '!') { in moffset()
814 o = ms->offset + m->vallen; in moffset()
818 if (*m->value.s == '\0') in moffset()
821 if (m->type == FILE_PSTRING) in moffset()
822 o += (uint32_t)file_pstring_length_size(m); in moffset()
865 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
873 if ((m->str_flags & REGEX_OFFSET_START) != 0) in moffset()
876 o = CAST(int32_t, (ms->search.offset + m->vallen)); in moffset()
887 o = der_offs(ms, m, nbytes); in moffset()
979 if (m->num_mask) \
980 switch (m->mask_op & FILE_OPS_MASK) { \
982 p->fld &= cast m->num_mask; \
985 p->fld |= cast m->num_mask; \
988 p->fld ^= cast m->num_mask; \
991 p->fld += cast m->num_mask; \
994 p->fld -= cast m->num_mask; \
997 p->fld *= cast m->num_mask; \
1000 if (cast m->num_mask == 0) \
1002 p->fld /= cast m->num_mask; \
1005 if (cast m->num_mask == 0) \
1007 p->fld %= cast m->num_mask; \
1010 if (m->mask_op & FILE_OPINVERSE) \
1014 cvt_8(union VALUETYPE *p, const struct magic *m) in cvt_8() argument
1021 cvt_16(union VALUETYPE *p, const struct magic *m) in cvt_16() argument
1028 cvt_32(union VALUETYPE *p, const struct magic *m) in cvt_32() argument
1035 cvt_64(union VALUETYPE *p, const struct magic *m) in cvt_64() argument
1042 if (m->num_mask) \
1043 switch (m->mask_op & FILE_OPS_MASK) { \
1045 p->fld += cast m->num_mask; \
1048 p->fld -= cast m->num_mask; \
1051 p->fld *= cast m->num_mask; \
1054 if (cast m->num_mask == 0) \
1056 p->fld /= cast m->num_mask; \
1061 cvt_float(union VALUETYPE *p, const struct magic *m) in cvt_float() argument
1068 cvt_double(union VALUETYPE *p, const struct magic *m) in cvt_double() argument
1080 mconvert(struct magic_set *ms, struct magic *m, int flip) in mconvert() argument
1084 switch (cvt_flip(m->type, flip)) { in mconvert()
1086 if (cvt_8(p, m) == -1) in mconvert()
1090 if (cvt_16(p, m) == -1) in mconvert()
1096 if (cvt_32(p, m) == -1) in mconvert()
1103 if (cvt_64(p, m) == -1) in mconvert()
1114 size_t sz = file_pstring_length_size(m); in mconvert()
1116 size_t len = file_pstring_get_length(m, ptr1); in mconvert()
1136 if (cvt_16(p, m) == -1) in mconvert()
1143 if (cvt_32(p, m) == -1) in mconvert()
1151 if (cvt_64(p, m) == -1) in mconvert()
1156 if (cvt_16(p, m) == -1) in mconvert()
1163 if (cvt_32(p, m) == -1) in mconvert()
1171 if (cvt_64(p, m) == -1) in mconvert()
1178 if (cvt_32(p, m) == -1) in mconvert()
1182 if (cvt_float(p, m) == -1) in mconvert()
1187 if (cvt_float(p, m) == -1) in mconvert()
1192 if (cvt_float(p, m) == -1) in mconvert()
1196 if (cvt_double(p, m) == -1) in mconvert()
1201 if (cvt_double(p, m) == -1) in mconvert()
1206 if (cvt_double(p, m) == -1) in mconvert()
1218 file_magerror(ms, "invalid type %d in mconvert()", m->type); in mconvert()
1238 const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m) in mcopy() argument
1269 if (m->str_flags & REGEX_LINE_COUNT) { in mcopy()
1270 linecnt = m->str_range; in mcopy()
1274 bytecnt = m->str_range; in mcopy()
1362 do_ops(struct magic *m, intmax_t lhs, intmax_t off) in do_ops() argument
1366 switch (m->in_op & FILE_OPS_MASK) { in do_ops()
1394 if (m->in_op & FILE_OPINVERSE) in do_ops()
1401 msetoffset(struct magic_set *ms, struct magic *m, struct buffer *bb, in msetoffset() argument
1404 if (m->offset < 0) { in msetoffset()
1406 if (m->flag & (OFFADD|INDIROFFADD)) in msetoffset()
1410 "level %u", m->offset, cont_level); in msetoffset()
1422 if ((size_t)-m->offset > b->elen) in msetoffset()
1425 ms->eoffset = ms->offset = b->elen + m->offset; in msetoffset()
1431 ms->offset = m->offset; in msetoffset()
1434 ms->offset = ms->eoffset + m->offset; in msetoffset()
1440 m->offset, cont_level); in msetoffset()
1446 mget(struct magic_set *ms, struct magic *m, const struct buffer *b, in mget() argument
1472 if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o), in mget()
1473 (uint32_t)nbytes, m) == -1) in mget()
1480 m->type, m->flag, offset, o, nbytes, in mget()
1485 if (m->flag & INDIR) { in mget()
1486 intmax_t off = m->in_offset; in mget()
1487 const int sgn = m->in_op & FILE_OPSIGNED; in mget()
1488 if (m->in_op & FILE_OPINDIRECT) { in mget()
1493 switch (cvt_flip(m->in_type, flip)) { in mget()
1524 switch (in_type = cvt_flip(m->in_type, flip)) { in mget()
1528 offset = do_ops(m, SEXT(sgn,8,p->b), off); in mget()
1533 offset = do_ops(m, SEXT(sgn,16,BE16(p)), off); in mget()
1538 offset = do_ops(m, SEXT(sgn,16,LE16(p)), off); in mget()
1543 offset = do_ops(m, SEXT(sgn,16,p->h), off); in mget()
1552 offset = do_ops(m, SEXT(sgn,32,lhs), off); in mget()
1561 offset = do_ops(m, SEXT(sgn,32,lhs), off); in mget()
1566 offset = do_ops(m, SEXT(sgn,32,ME32(p)), off); in mget()
1571 offset = do_ops(m, SEXT(sgn,32,p->l), off); in mget()
1577 if (m->flag & INDIROFFADD) { in mget()
1588 if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1) in mget()
1599 switch (m->type) { in mget()
1641 if (OFFSET_OOB(nbytes, offset, m->vallen)) in mget()
1651 if (m->str_flags & INDIRECT_RELATIVE) in mget()
1678 file_printf(ms, F(ms, m->desc, "%u"), offset) == -1) { in mget()
1693 rbuf = m->value.s; in mget()
1704 if (m->flag & NOSPACE) in mget()
1716 if (file_printf(ms, "%s", m->desc) == -1) in mget()
1725 if (!mconvert(ms, m, flip)) in mget()
1846 magiccheck(struct magic_set *ms, struct magic *m) in magiccheck() argument
1848 uint64_t l = m->value.q; in magiccheck()
1855 switch (m->type) { in magiccheck()
1899 fl = m->value.f; in magiccheck()
1901 switch (m->reln) { in magiccheck()
1924 m->reln); in magiccheck()
1932 dl = m->value.d; in magiccheck()
1934 switch (m->reln) { in magiccheck()
1956 file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln); in magiccheck()
1970 v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags); in magiccheck()
1976 v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags); in magiccheck()
1986 slen = MIN(m->vallen, sizeof(m->value.s)); in magiccheck()
1990 for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) { in magiccheck()
1994 v = file_strncmp(m->value.s, ms->search.s + idx, slen, in magiccheck()
1995 m->str_flags); in magiccheck()
2011 if (m->str_flags & STRING_IGNORE_CASE) { in magiccheck()
2015 convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); in magiccheck()
2083 matched = der_cmp(ms, m); in magiccheck()
2093 file_magerror(ms, "invalid type %d in magiccheck()", m->type); in magiccheck()
2097 v = file_signextend(ms, m, v); in magiccheck()
2099 switch (m->reln) { in magiccheck()
2124 if (m->flag & UNSIGNED) { in magiccheck()
2142 if (m->flag & UNSIGNED) { in magiccheck()
2181 m->reln); in magiccheck()
2189 handle_annotation(struct magic_set *ms, struct magic *m, const struct buffer *b, in handle_annotation() argument
2192 if ((ms->flags & MAGIC_APPLE) && m->apple[0]) { in handle_annotation()
2195 if (file_printf(ms, "%.8s", m->apple) == -1) in handle_annotation()
2199 if ((ms->flags & MAGIC_EXTENSION) && m->ext[0]) { in handle_annotation()
2202 if (file_printf(ms, "%s", m->ext) == -1) in handle_annotation()
2206 if ((ms->flags & MAGIC_MIME_TYPE) && m->mimetype[0]) { in handle_annotation()
2211 if (varexpand(buf, sizeof(buf), b, m->mimetype) == -1) in handle_annotation()
2212 p = m->mimetype; in handle_annotation()