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

Function zmagic

modules/metadata/mod_mime_magic.c:2081–2108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2079#define ncompr (sizeof(compr) / sizeof(compr[0]))
2080
2081static int zmagic(request_rec *r, unsigned char *buf, apr_size_t nbytes)
2082{
2083 unsigned char *newbuf;
2084 int newsize;
2085 int i;
2086
2087 for (i = 0; i < ncompr; i++) {
2088 if (nbytes < compr[i].maglen)
2089 continue;
2090 if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0)
2091 break;
2092 }
2093
2094 if (i == ncompr)
2095 return 0;
2096
2097 if ((newsize = uncompress(r, i, &newbuf, HOWMANY)) > 0) {
2098 /* set encoding type in the request record */
2099 r->content_encoding = compr[i].encoding;
2100
2101 newbuf[newsize-1] = '\0'; /* null-terminate uncompressed data */
2102 /* Try to detect the content type of the uncompressed data */
2103 if (tryit(r, newbuf, newsize, 0) != OK) {
2104 return 0;
2105 }
2106 }
2107 return 1;
2108}
2109
2110
2111struct uncompress_parms {

Callers 1

tryitFunction · 0.85

Calls 2

uncompressFunction · 0.85
tryitFunction · 0.85

Tested by

no test coverage detected