magic_set_config();
- if(OK != magic_process(filename)) {
+ if(MIME_MAGIC_OK != magic_process(filename)) {
RETVAL_FALSE;
- } else if(OK != magic_rsl_get(&content_type, &content_encoding)) {
+ } else if(MIME_MAGIC_OK != magic_rsl_get(&content_type, &content_encoding)) {
RETVAL_FALSE;
} else {
RETVAL_STRING(content_type, 1);
* first try judging the file based on its filesystem status
*/
switch ((result = fsmagic(filename))) {
- case DONE:
+ case MIME_MAGIC_DONE:
magic_rsl_putchar('\n');
- return OK;
- case OK:
+ return MIME_MAGIC_OK;
+ case MIME_MAGIC_OK:
break;
default:
/* fatal error, bail out */
php_error(E_WARNING,
MODNAME ": can't read `%s'", filename);
/* let some other handler decide what the problem is */
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/*
if ((nbytes = read(fd, (char *) buf, sizeof(buf) - 1)) == -1) {
php_error(E_WARNING,
MODNAME ": read failed: %s", filename);
- return ERROR;
+ return MIME_MAGIC_ERROR;
}
if (nbytes == 0)
(void) close(fd);
(void) magic_rsl_putchar('\n');
- return OK;
+ return MIME_MAGIC_OK;
}
static void tryit(unsigned char *buf, int nb, int checkzmagic)
/*
- * return DONE to indicate it's been handled
- * return OK to indicate it's a regular file still needing handling
+ * return MIME_MAGIC_DONE to indicate it's been handled
+ * return MIME_MAGIC_OK to indicate it's a regular file still needing handling
* other returns indicate a failure of some sort
*/
static int fsmagic(const char *fn)
switch (finfo.st_mode & S_IFMT) {
case S_IFDIR:
magic_rsl_puts(DIR_MAGIC_TYPE);
- return DONE;
+ return MIME_MAGIC_DONE;
case S_IFCHR:
/*
* (void) magic_rsl_printf(r,"character special (%d/%d)",
* major(sb->st_rdev), minor(sb->st_rdev));
*/
(void) magic_rsl_puts(MIME_BINARY_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
#ifdef S_IFBLK
case S_IFBLK:
/*
* major(sb->st_rdev), minor(sb->st_rdev));
*/
(void) magic_rsl_puts(MIME_BINARY_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
/* TODO add code to handle V7 MUX and Blit MUX files */
#endif
#ifdef S_IFIFO
* magic_rsl_puts(r,"fifo (named pipe)");
*/
(void) magic_rsl_puts(MIME_BINARY_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
#endif
#ifdef S_IFLNK
case S_IFLNK:
*/
php_error(E_WARNING,
MODNAME ": broken symlink (%s)", fn);
- return ERROR;
+ return MIME_MAGIC_ERROR;
#endif
#ifdef S_IFSOCK
#ifndef __COHERENT__
case S_IFSOCK:
magic_rsl_puts(MIME_BINARY_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
#endif
#endif
case S_IFREG:
default:
php_error(E_WARNING,
MODNAME ": invalid mode 0%o.", (unsigned int)finfo.st_mode);
- return ERROR;
+ return MIME_MAGIC_ERROR;
}
/*
*/
if (finfo.st_size == 0) {
magic_rsl_puts(MIME_TEXT_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
}
- return OK;
+ return MIME_MAGIC_OK;
}
/*
/* check if we have a result */
if (!req_dat || !req_dat->head) {
/* empty - no match, we defer to other Apache modules */
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* start searching for the type and encoding */
}
else if (state == rsl_type) {
/* whitespace: type has no slash! */
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
else if (state == rsl_subtype) {
/* whitespace: end of MIME type */
/* abandon malfunctioning module */
php_error(E_WARNING,
MODNAME ": bad state %d (ws)", state);
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* NOTREACHED */
}
/* abandon malfunctioning module */
php_error(E_WARNING,
MODNAME ": bad state %d (ns)", state);
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* NOTREACHED */
}
if (state != rsl_subtype && state != rsl_separator &&
state != rsl_encoding) {
/* defer to other modules */
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* save the info in the request record */
/* detect memory allocation errors */
if (!content_type ||
(state == rsl_encoding && !*content_encoding)) {
- return ERROR;
+ return MIME_MAGIC_ERROR;
}
/* success! */
- return OK;
+ return MIME_MAGIC_OK;
}
/*
#define MAXMIMESTRING 256
-#define OK 0
-#define DECLINED -1
-#define DONE -2
-#define ERROR -3
+#define MIME_MAGIC_OK 0
+#define MIME_MAGIC_DECLINED -1
+#define MIME_MAGIC_DONE -2
+#define MIME_MAGIC_ERROR -3
#define DIR_MAGIC_TYPE "httpd/unix-directory"
static int is_tar(unsigned char *, int);
static int softmagic(unsigned char *, int);
static void tryit(unsigned char *, int, int);
-static int zmagic(unsigned char *, int);
static int getvalue(struct magic *, char **);
static int hextoint(int);
static int magic_rsl_get(char **, char **);
static int magic_process(char *);
-static int uncompress(int,
- unsigned char **, int);
static long from_oct(int, char *);
static int fsmagic(const char *fn);
+
+#if 0 /* TODO */
+static int zmagic(unsigned char *, int);
+static int uncompress(int, unsigned char **, int);
+static int uncompress_child(void *, child_info *);
+#endif
+
/*
* includes for ASCII substring recognition formerly "names.h" in file
* command