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

Function mcheck

modules/metadata/mod_mime_magic.c:1822–1966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1820}
1821
1822static int mcheck(request_rec *r, union VALUETYPE *p, struct magic *m)
1823{
1824 register unsigned long l = m->value.l;
1825 register unsigned long v;
1826 int matched;
1827
1828 if ((m->value.s[0] == 'x') && (m->value.s[1] == '\0')) {
1829 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01539)
1830 MODNAME ": BOINK");
1831 return 1;
1832 }
1833
1834 switch (m->type) {
1835 case BYTE:
1836 v = p->b;
1837 break;
1838
1839 case SHORT:
1840 case BESHORT:
1841 case LESHORT:
1842 v = p->h;
1843 break;
1844
1845 case LONG:
1846 case BELONG:
1847 case LELONG:
1848 case DATE:
1849 case BEDATE:
1850 case LEDATE:
1851 v = p->l;
1852 break;
1853
1854 case STRING:
1855 l = 0;
1856 /*
1857 * What we want here is: v = strncmp(m->value.s, p->s, m->vallen);
1858 * but ignoring any nulls. bcmp doesn't give -/+/0 and isn't
1859 * universally available anyway.
1860 */
1861 v = 0;
1862 {
1863 register unsigned char *a = (unsigned char *) m->value.s;
1864 register unsigned char *b = (unsigned char *) p->s;
1865 register int len = m->vallen;
1866
1867 while (--len >= 0)
1868 if ((v = *b++ - *a++) != 0)
1869 break;
1870 }
1871 break;
1872 default:
1873 /* bogosity, pretend that it just wasn't a match */
1874 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01540)
1875 MODNAME ": invalid type %d in mcheck().", m->type);
1876 return 0;
1877 }
1878
1879 v = signextend(r->server, m, v) & m->mask;

Callers 1

matchFunction · 0.85

Calls 1

signextendFunction · 0.85

Tested by

no test coverage detected