mod_mime_magic.c revision adb8ad10ffc20ed06ec6cfab6cd7933ab429ea7d
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg/* ====================================================================
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * The Apache Software License, Version 1.1
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * reserved.
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * Redistribution and use in source and binary forms, with or without
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * modification, are permitted provided that the following conditions
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * 1. Redistributions of source code must retain the above copyright
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * notice, this list of conditions and the following disclaimer.
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * 2. Redistributions in binary form must reproduce the above copyright
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * notice, this list of conditions and the following disclaimer in
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * the documentation and/or other materials provided with the
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * distribution.
7190e58eec40192c9719d2f2593471eda14e7e7cfuankg * 3. The end-user documentation included with the redistribution,
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * if any, must include the following acknowledgment:
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * "This product includes software developed by the
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * Apache Software Foundation (http://www.apache.org/)."
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * Alternately, this acknowledgment may appear in the software itself,
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * if and wherever such third-party acknowledgments normally appear.
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * 4. The names "Apache" and "Apache Software Foundation" must
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * not be used to endorse or promote products derived from this
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * software without prior written permission. For written
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * permission, please contact apache@apache.org.
95ca7cc2aa11b41497ffab3a1003bc09d24b6bc1fuankg * 5. Products derived from this software may not be called "Apache",
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * nor may "Apache" appear in their name, without prior written
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * permission of the Apache Software Foundation.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ce22ce4743d79a889dca64df4459c598e2c188c7fuankg * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * SUCH DAMAGE.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * ====================================================================
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * This software consists of voluntary contributions made by many
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * individuals on behalf of the Apache Software Foundation. For more
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * information on the Apache Software Foundation, please see
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Portions of this software are based upon public domain software
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * originally written at the National Center for Supercomputing Applications,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * University of Illinois, Urbana-Champaign.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * mod_mime_magic: MIME type lookup via file magic numbers
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Copyright (c) 1996-1997 Cisco Systems, Inc.
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes * This software was submitted by Cisco Systems to the Apache Software Foundation in July
8d6e239d0e0aa0593fd93b4fef193d8c51b61b3cfuankg * 1997. Future revisions and derivatives of this source code must
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * acknowledge Cisco Systems as the original contributor of this module.
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * All other licensing and usage conditions are those of the Apache Software Foundation.
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * Some of this code is derived from the free version of the file command
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * originally posted to comp.sources.unix. Copyright info for that program
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * is included below as required.
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * ---------------------------------------------------------------------------
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.
8d6e239d0e0aa0593fd93b4fef193d8c51b61b3cfuankg * This software is not subject to any license of the American Telephone and
8d6e239d0e0aa0593fd93b4fef193d8c51b61b3cfuankg * Telegraph Company or of the Regents of the University of California.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Permission is granted to anyone to use this software for any purpose on any
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * computer system, and to alter it and redistribute it freely, subject to
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * the following restrictions:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * 1. The author is not responsible for the consequences of use of this
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * software, no matter how awful, even if they arise from flaws in it.
8492a2583e10c69f40de92f9d5da884b64d9f379fuankg * 2. The origin of this software must not be misrepresented, either by
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * explicit claim or by omission. Since few users ever read sources, credits
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * must appear in the documentation.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * 3. Altered versions must be plainly marked as such, and must not be
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * misrepresented as being the original software. Since few users ever read
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * sources, credits must appear in the documentation.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * 4. This notice may not be removed or altered.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * -------------------------------------------------------------------------
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * For compliance with Mr Darwin's terms: this has been very significantly
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * modified from the free "file" command.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - all-in-one file for compilation convenience when moving from one
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * version of Apache to the next.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - Memory allocation is done through the Apache API's apr_pool_t structure.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - All functions have had necessary Apache API request or server
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * structures passed to them where necessary to call other Apache API
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * routines. (i.e. usually for logging, files, or memory allocation in
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * itself or a called function.)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - struct magic has been converted from an array to a single-ended linked
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * list because it only grows one record at a time, it's only accessed
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * sequentially, and the Apache API has no equivalent of realloc().
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - Functions have been changed to get their parameters from the server
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * configuration instead of globals. (It should be reentrant now but has
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * not been tested in a threaded environment.)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - Places where it used to print results to stdout now saves them in a
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * list where they're used to set the MIME type in the Apache request
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - Command-line flags have been removed since they will never be used here.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Ian Kluft <ikluft@cisco.com>
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Engineering Information Framework
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Central Engineering
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Cisco Systems, Inc.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * San Jose, CA, USA
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Initial installation July/August 1996
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Misc bug fixes May 1997
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Submission to Apache Software Foundation July 1997
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes/* ### this isn't set by configure? does anybody set this? */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * data structures and related constants
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#define MIME_BINARY_UNKNOWN "application/octet-stream"
41022996c916eb4ab2ec3204eb491b64779eb100bnicholes/* HOWMANY must be at least 4096 to make gzip -dcq work */
41022996c916eb4ab2ec3204eb491b64779eb100bnicholes/* SMALL_HOWMANY limits how much work we do to figure out text files */
41022996c916eb4ab2ec3204eb491b64779eb100bnicholes#define MAXDESC 50 /* max leng of text description */
036436f4f4cdcd76186c0058891216545967043bbnicholes#define MAXstring 64 /* max leng of "string" types */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned char reln; /* relation (0=eq, '>'=gt, etc) */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned char b;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned short h;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned long l;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned long mask; /* mask before comparison with value */
ce22ce4743d79a889dca64df4459c598e2c188c7fuankg /* NOTE: this string is suspected of overrunning - find it! */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * data structures for tar file recognition
b387b9d37fc71c534f4718777454a8f5a1169017fuankg * --------------------------------------------------------------------------
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Header file for public domain tar (tape archive) program.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * @(#)tar.h 1.20 86/10/29 Public Domain. Created 25 August 1985 by John
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Gilmore, ihnp4!hoptoad!gnu.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Header block on tape.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * I'm going to use traditional DP naming conventions here. A "block" is a big
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * chunk of stuff that we do I/O on. A "record" is a piece of info that we
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * care about. Typically many "record"s fit into a "block".
56ab8639aed4d3b2f031d9c1160c5f40af01bdebjerenkrantz/* The magic field is filled with this if uname and gname are valid. */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * file-function prototypes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int ascmagic(request_rec *, unsigned char *, apr_size_t);
f7d723f1ad88ed006c6caf4c2c6604b7c59dd172bnicholesstatic int softmagic(request_rec *, unsigned char *, apr_size_t);
4f935de4900dc064a1e145be5e48f6af77ac24fcbnicholesstatic void tryit(request_rec *, unsigned char *, apr_size_t, int);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int zmagic(request_rec *, unsigned char *, apr_size_t);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int getvalue(server_rec *, struct magic *, char **);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int hextoint(int);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic char *getstr(server_rec *, char *, char *, int, int *);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int parse(server_rec *, apr_pool_t *p, char *, int);
e961abd49ab1b184b356f63591d37083a5651451bnicholesstatic int match(request_rec *, unsigned char *, apr_size_t);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int mget(request_rec *, union VALUETYPE *, unsigned char *,
5f2aaa2483c4526d7930df4a0e5844c1b7b6c9c0fuankgstatic int mcheck(request_rec *, union VALUETYPE *, struct magic *);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic void mprint(request_rec *, union VALUETYPE *, struct magic *);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unsigned char **, apr_size_t);
440cda576ca9ff6476e4a04bdb253c5023da15eejerenkrantzstatic long from_oct(int, char *);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int fsmagic(request_rec *r, const char *fn);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * includes for ASCII substring recognition formerly "names.h" in file
6f2fa094a76c27135a9825ca9492f9db0a1a3bc9bnicholes * Original notes: names and types used by ascmagic in file(1). These tokens are
a400161a259d6d9fd47a47fd9a4bb413fd85e3bcsf * here because they can appear anywhere in the first HOWMANY bytes, while
a400161a259d6d9fd47a47fd9a4bb413fd85e3bcsf * tokens in /etc/magic must appear at fixed offsets into the file. Don't
a400161a259d6d9fd47a47fd9a4bb413fd85e3bcsf * make HOWMANY too high unless you have a very fast CPU.
91f672664302529bb620e3265cccd861661d258cbnicholes/* these types are used to index the apr_table_t 'types': keep em in sync! */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes/* HTML inserted in first because this is a web server module now */
ce22ce4743d79a889dca64df4459c598e2c188c7fuankgstatic char *types[] =
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "application/binary", /* "can't happen error on names.h/types", */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic struct names {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* These must be sorted by eye for optimal hit rate */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* Add to this list only after substantial meditation */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }, /* must precede "The", "the", etc. */
8d6e239d0e0aa0593fd93b4fef193d8c51b61b3cfuankg * Too many files of text have these words in them. Find another way to
25b3aa26ee94824bb1e9ff2631aa1588b37e5f72fuankg * recognize Fortrash.
00d1c0c914426a97022d8205a875c48b211001c2fuankg#endif /* NOTDEF */
398f7be4e4ef696ddf6803a26e9c2c0589f090d2fuankg#define NNAMES ((sizeof(names)/sizeof(struct names)) - 1)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Result String List (RSL)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * The file(1) command prints its output. Instead, we store the various
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * "printed" strings in a list (allocating memory as we go) and concatenate
0662ed52e814f8f08ef0e09956413a792584eddffuankg * them at the end when we finally know how much space they'll need.
25b3aa26ee94824bb1e9ff2631aa1588b37e5f72fuankgtypedef struct magic_rsl_s {
} magic_rsl;
return new;
if (!conf) {
return NULL;
{NULL}
sizeof(magic_req_rec));
return req_dat;
if (!req_dat) {
str[0] = c;
res_pos = 0;
cur_pos++) {
#if MIME_MAGIC_DEBUG
return result;
} rsl_states;
return DECLINED;
return DECLINED;
state++;
return DECLINED;
type_len++;
state++;
state++;
type_len++;
state++;
encoding_len++;
return DECLINED;
return DECLINED;
char *tmp;
char *tmp;
if (!r->content_type ||
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
int result;
case DONE:
return OK;
case OK:
return result;
return DECLINED;
return HTTP_INTERNAL_SERVER_ERROR;
if (nbytes == 0)
return OK;
int errs = 0;
int lineno;
#if MIME_MAGIC_DEBUG
int rule = 0;
int ws_offset;
if (line[0]) {
ws_offset = 0;
ws_offset++;
#if MIME_MAGIC_DEBUG
rule++;
++errs;
(void) apr_file_close(f);
#if MIME_MAGIC_DEBUG
conf,
#if MIME_MAGIC_DEBUG
prevm = 0;
prevm = m;
switch (m->type) {
case BYTE:
case SHORT:
case BESHORT:
case LESHORT:
case DATE:
case BEDATE:
case LEDATE:
case LONG:
case BELONG:
case LELONG:
case STRING:
struct magic *m;
m->flag = 0;
m->cont_level = 0;
m->cont_level++;
if (apr_isdigit((unsigned char) *l)) {
while (apr_isdigit((unsigned char) *l))
l += NBYTE;
l += NSHORT;
l += NLONG;
l += NSTRING;
l += NDATE;
l += NBESHORT;
l += NBELONG;
l += NBEDATE;
l += NLESHORT;
l += NLELONG;
l += NLEDATE;
m->mask = ~0L;
m->reln = *l;
m->reln = *l;
m->reln = *l;
m->nospflag = 0;
#if MIME_MAGIC_DEBUG
int slen;
register int val;
if (apr_isspace((unsigned char) c))
if (p >= pmax) {
goto out;
*p++ = (char) val;
val = c;
c = hextoint(*s++);
c = hextoint(*s++);
*p++ = (char) val;
out:
static int hextoint(int c)
if (apr_isdigit((unsigned char) c))
case APR_DIR:
return DONE;
case APR_CHR:
return DONE;
case APR_BLK:
return DONE;
case APR_PIPE:
return DONE;
case APR_LNK:
return HTTP_INTERNAL_SERVER_ERROR;
case APR_SOCK:
return DONE;
case APR_REG:
return HTTP_INTERNAL_SERVER_ERROR;
return DONE;
return OK;
* apprentice.c). Passed the name and FILE * of one file to be typed.
#if MIME_MAGIC_DEBUG
int rule_counter = 0;
int cont_level = 0;
int need_separator = 0;
union VALUETYPE p;
struct magic *m;
#if MIME_MAGIC_DEBUG
conf,
#if MIME_MAGIC_DEBUG
#if MIME_MAGIC_DEBUG
rule_counter++;
!mcheck(r, &p, m)) {
#if MIME_MAGIC_DEBUG
rule_counter++;
m = m_cont;
#if MIME_MAGIC_DEBUG
mprint(r, &p, m);
if (m->desc[0])
cont_level++;
m = m->next;
while (m && (m->cont_level != 0)) {
#if MIME_MAGIC_DEBUG
mcheck(r, &p, m)) {
if (need_separator
&& (m->nospflag == 0)
need_separator = 0;
mprint(r, &p, m);
if (m->desc[0])
cont_level++;
m = m->next;
#if MIME_MAGIC_DEBUG
#if MIME_MAGIC_DEBUG
switch (m->type) {
case BYTE:
case SHORT:
case BESHORT:
case LESHORT:
case LONG:
case BELONG:
case LELONG:
case STRING:
case DATE:
case BEDATE:
case LEDATE:
m->type);
char *rt;
switch (m->type) {
case BYTE:
case SHORT:
case LONG:
case DATE:
case STRING:
case BESHORT:
case BELONG:
case BEDATE:
case LESHORT:
case LELONG:
case LEDATE:
if (!mconvert(r, p, m))
case BYTE:
case SHORT:
case LONG:
if (!mconvert(r, p, m))
register unsigned long l = m->value.l;
int matched;
switch (m->type) {
case BYTE:
case SHORT:
case BESHORT:
case LESHORT:
case LONG:
case BELONG:
case LELONG:
case DATE:
case BEDATE:
case LEDATE:
case STRING:
* What we want here is: v = strncmp(m->value.s, p->s, m->vallen);
register unsigned char *a = (unsigned char *) m->value.s;
while (--len >= 0)
switch (m->reln) {
#if MIME_MAGIC_DEBUG
matched = v != l;
#if MIME_MAGIC_DEBUG
matched = v == l;
#if MIME_MAGIC_DEBUG
matched = v > l;
#if MIME_MAGIC_DEBUG
matched = (long) v > (long) l;
#if MIME_MAGIC_DEBUG
matched = v < l;
#if MIME_MAGIC_DEBUG
matched = (long) v < (long) l;
#if MIME_MAGIC_DEBUG
matched = (v & l) == l;
#if MIME_MAGIC_DEBUG
matched = (v & l) != l;
#if MIME_MAGIC_DEBUG
matched = 0;
m->reln);
return matched;
int has_escapes = 0;
char *token;
register struct names *p;
int small_nbytes;
/* look for tokens from names.h - this is expensive!, so we'll limit
if (has_escapes)
if (has_escapes) {
char *magic;
int maglen;
int silent;
} compr[] = {
unsigned char *newbuf;
int newsize;
for (i = 0; i < ncompr; i++) {
if (i == ncompr)
struct uncompress_parms {
request_rec *r;
int method;
const char *const *env;
return (rc);
parm.r = r;
* @(#)list.c 1.18 9/23/86 Public Domain - gnu $Id: mod_mime_magic.c,v 1.7
sum = 0;
for (i = sizeof(union record); --i >= 0;) {
register long value;
where++;
if (--digs <= 0)
value = 0;
--digs;
return value;
char *sub_filename;
#if MIME_MAGIC_DEBUG
suffix_pos--;
result = 0;
#if MIME_MAGIC_DEBUG
#if MIME_MAGIC_DEBUG
r->content_encoding =
r->content_language =
return result;
int result;
server_rec *s;
#if MIME_MAGIC_DEBUG
#if MIME_MAGIC_DEBUG
prevm = 0;
prevm = m;
int result;
return DECLINED;
if (r->content_type) {
return DECLINED;
return DECLINED;
if (!magic_set_config(r)) {
return HTTP_INTERNAL_SERVER_ERROR;
return result;
return magic_rsl_to_request(r);