MCPcopy Create free account
hub / github.com/apache/httpd / match

Function match

modules/metadata/mod_mime_magic.c:1529–1689  ·  view source on GitHub ↗

* Go through the whole list, stopping if you find a match. Process all the * continuations of that match before returning. * * We support multi-level continuations: * * At any time when processing a successful top-level match, there is a current * continuation level; it represents the level of the last successfully * matched continuation. * * Continuations above that level are skipped as

Source from the content-addressed store, hash-verified

1527 * higher-level continuations are processed.
1528 */
1529static int match(request_rec *r, unsigned char *s, apr_size_t nbytes)
1530{
1531#if MIME_MAGIC_DEBUG
1532 int rule_counter = 0;
1533#endif
1534 int cont_level = 0;
1535 int need_separator = 0;
1536 union VALUETYPE p;
1537 magic_server_config_rec *conf = (magic_server_config_rec *)
1538 ap_get_module_config(r->server->module_config, &mime_magic_module);
1539 struct magic *m;
1540
1541#if MIME_MAGIC_DEBUG
1542 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01529)
1543 MODNAME ": match conf=%pp file=%s m=%s m->next=%s last=%s",
1544 conf,
1545 conf->magicfile ? conf->magicfile : "NULL",
1546 conf->magic ? "set" : "NULL",
1547 (conf->magic && conf->magic->next) ? "set" : "NULL",
1548 conf->last ? "set" : "NULL");
1549#endif
1550
1551#if MIME_MAGIC_DEBUG
1552 for (m = conf->magic; m; m = m->next) {
1553 if (apr_isprint((((unsigned long) m) >> 24) & 255) &&
1554 apr_isprint((((unsigned long) m) >> 16) & 255) &&
1555 apr_isprint((((unsigned long) m) >> 8) & 255) &&
1556 apr_isprint(((unsigned long) m) & 255)) {
1557 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01530)
1558 MODNAME ": match: POINTER CLOBBERED! "
1559 "m=\"%c%c%c%c\"",
1560 (((unsigned long) m) >> 24) & 255,
1561 (((unsigned long) m) >> 16) & 255,
1562 (((unsigned long) m) >> 8) & 255,
1563 ((unsigned long) m) & 255);
1564 break;
1565 }
1566 }
1567#endif
1568
1569 for (m = conf->magic; m; m = m->next) {
1570#if MIME_MAGIC_DEBUG
1571 rule_counter++;
1572 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01531)
1573 MODNAME ": line=%d desc=%s", m->lineno, m->desc);
1574#endif
1575
1576 /* check if main entry matches */
1577 if (!mget(r, &p, s, m, nbytes) ||
1578 !mcheck(r, &p, m)) {
1579 struct magic *m_cont;
1580
1581 /*
1582 * main entry didn't match, flush its continuations
1583 */
1584 if (!m->next || (m->next->cont_level == 0)) {
1585 continue;
1586 }

Callers 1

softmagicFunction · 0.70

Calls 5

ap_get_module_configFunction · 0.85
mgetFunction · 0.85
mcheckFunction · 0.85
mprintFunction · 0.85
magic_rsl_putcharFunction · 0.85

Tested by

no test coverage detected