cvs: php4 /ext/mime_magic mime_magic.c php_mime_magic.h
| From: | Hartmut Holzgraefe | Date: | Tue, 26 Mar 2002 19:57:33 +0000 |
| Subject: | cvs: php4 /ext/mime_magic mime_magic.c php_mime_magic.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10704@lists.php.net to get a copy of this message | ||
hholzgra Tue Mar 26 14:57:33 2002 EDT
Modified files:
/php4/ext/mime_magic mime_magic.c php_mime_magic.h
Log:
build conflicts fixed
Index: php4/ext/mime_magic/mime_magic.c
diff -u php4/ext/mime_magic/mime_magic.c:1.1 php4/ext/mime_magic/mime_magic.c:1.2
--- php4/ext/mime_magic/mime_magic.c:1.1 Sun Mar 24 18:00:47 2002
+++ php4/ext/mime_magic/mime_magic.c Tue Mar 26 14:57:32 2002
@@ -15,7 +15,7 @@
| Author: Hartmut Holzgraefe |
+----------------------------------------------------------------------+
- $Id: mime_magic.c,v 1.1 2002/03/24 23:00:47 hholzgra Exp $
+ $Id: mime_magic.c,v 1.2 2002/03/26 19:57:32 hholzgra Exp $
This module contains a lot of stuff taken from Apache mod_mime_magic,
so the lincense section is a little bit longer than usual:
@@ -301,9 +301,9 @@
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);
@@ -998,10 +998,10 @@
* 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 */
@@ -1013,7 +1013,7 @@
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;
}
/*
@@ -1022,7 +1022,7 @@
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)
@@ -1035,7 +1035,7 @@
(void) close(fd);
(void) magic_rsl_putchar('\n');
- return OK;
+ return MIME_MAGIC_OK;
}
static void tryit(unsigned char *buf, int nb, int checkzmagic)
@@ -1070,8 +1070,8 @@
/*
- * 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)
@@ -1083,14 +1083,14 @@
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:
/*
@@ -1098,7 +1098,7 @@
* 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
@@ -1107,7 +1107,7 @@
* 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:
@@ -1116,13 +1116,13 @@
*/
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:
@@ -1130,7 +1130,7 @@
default:
php_error(E_WARNING,
MODNAME ": invalid mode 0%o.", (unsigned int)finfo.st_mode);
- return ERROR;
+ return MIME_MAGIC_ERROR;
}
/*
@@ -1138,9 +1138,9 @@
*/
if (finfo.st_size == 0) {
magic_rsl_puts(MIME_TEXT_UNKNOWN);
- return DONE;
+ return MIME_MAGIC_DONE;
}
- return OK;
+ return MIME_MAGIC_OK;
}
/*
@@ -1979,7 +1979,7 @@
/* 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 */
@@ -1999,7 +1999,7 @@
}
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 */
@@ -2021,7 +2021,7 @@
/* abandon malfunctioning module */
php_error(E_WARNING,
MODNAME ": bad state %d (ws)", state);
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* NOTREACHED */
}
@@ -2065,7 +2065,7 @@
/* abandon malfunctioning module */
php_error(E_WARNING,
MODNAME ": bad state %d (ns)", state);
- return DECLINED;
+ return MIME_MAGIC_DECLINED;
}
/* NOTREACHED */
}
@@ -2077,7 +2077,7 @@
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 */
@@ -2103,11 +2103,11 @@
/* 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;
}
/*
Index: php4/ext/mime_magic/php_mime_magic.h
diff -u php4/ext/mime_magic/php_mime_magic.h:1.1 php4/ext/mime_magic/php_mime_magic.h:1.2
--- php4/ext/mime_magic/php_mime_magic.h:1.1 Sun Mar 24 18:00:47 2002
+++ php4/ext/mime_magic/php_mime_magic.h Tue Mar 26 14:57:32 2002
@@ -15,7 +15,7 @@
| Author: |
+----------------------------------------------------------------------+
- $Id: php_mime_magic.h,v 1.1 2002/03/24 23:00:47 hholzgra Exp $
+ $Id: php_mime_magic.h,v 1.2 2002/03/26 19:57:32 hholzgra Exp $
*/
#ifndef PHP_MIME_MAGIC_H
@@ -28,10 +28,10 @@
#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"
@@ -140,7 +140,6 @@
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);
@@ -156,10 +155,15 @@
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