cellog Sun Dec 23 21:12:41 2007 UTC
Added files:
/pecl/phar/testsfrontcontroller2.phpt frontcontroller3.phpt
Modified files:
/pecl/phar phar.c phar_internal.h phar_object.c
/pecl/phar/testsfrontcontroller1.phpt
Log:
complete re-factoring of front controller. Now it is done with
Phar-webPhar():
?php
Phar::webPhar();
__HALT_COMPILER();
With the above stub, the default front controller will kick in. An array of
mime type overrides, and another
array mapping phar file entry - redirected entry can be used to further
customize
[DOC]
http://cvs.php.net/viewvc.cgi/pecl/phar/phar.c?r1=1.234r2=1.235diff_format=u
Index: pecl/phar/phar.c
diff -u pecl/phar/phar.c:1.234 pecl/phar/phar.c:1.235
--- pecl/phar/phar.c:1.234 Sat Dec 22 07:46:52 2007
+++ pecl/phar/phar.cSun Dec 23 21:12:41 2007
@@ -17,7 +17,7 @@
+--+
*/
-/* $Id: phar.c,v 1.234 2007/12/22 07:46:52 cellog Exp $ */
+/* $Id: phar.c,v 1.235 2007/12/23 21:12:41 cellog Exp $ */
#define PHAR_MAIN
#include phar_internal.h
@@ -185,11 +185,6 @@
*/
static void phar_destroy_phar_data(phar_archive_data *data TSRMLS_DC) /* {{{ */
{
- if (!PHAR_G(request_ends)) {
- if (zend_hash_num_elements((PHAR_GLOBALS-phar_web_map))) {
- zend_hash_del((PHAR_GLOBALS-phar_web_map),
data-fname, data-fname_len);
- }
- }
if (data-alias data-alias != data-fname) {
efree(data-alias);
data-alias = NULL;
@@ -504,7 +499,7 @@
* appended, truncated, or read. For read, if the entry is marked unmodified,
it is
* assumed that the file pointer, if present, is opened for reading
*/
-static int phar_get_entry_data(phar_entry_data **ret, char *fname, int
fname_len, char *path, int path_len, char *mode, char **error TSRMLS_DC) /* {{{
*/
+int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len,
char *path, int path_len, char *mode, char **error TSRMLS_DC) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry;
@@ -1334,13 +1329,6 @@
mydata-sig_len = sig_len;
mydata-signature = signature;
phar_request_initialize(TSRMLS_C);
- if ((manifest_flags PHAR_HDR_WEB) != 0) {
- mydata-is_web = 1;
- if (!zend_hash_num_elements((PHAR_GLOBALS-phar_mimes))) {
- phar_init_mime_list(TSRMLS_C);
- }
- zend_hash_add((PHAR_GLOBALS-phar_web_map), mydata-fname,
fname_len, (void*)mydata, sizeof(void*), NULL);
- }
zend_hash_add((PHAR_GLOBALS-phar_fname_map), mydata-fname,
fname_len, (void*)mydata, sizeof(phar_archive_data*), NULL);
if (register_alias) {
mydata-is_explicit_alias = 1;
@@ -2780,13 +2768,8 @@
manifest_len = offset + archive-alias_len + sizeof(manifest) +
main_metadata_str.len;
phar_set_32(manifest, manifest_len);
phar_set_32(manifest+4, new_manifest_count);
- if (archive-is_web) {
- *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION_NOWEB)
8) 0xFF);
- *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION_NOWEB)
0xF0));
- } else {
- *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) 8)
0xFF);
- *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) 0xF0));
- }
+ *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) 8) 0xFF);
+ *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) 0xF0));
phar_set_32(manifest+10, global_flags);
phar_set_32(manifest+14, archive-alias_len);
@@ -3867,159 +3850,6 @@
}
/* }}} */
-static void phar_init_mime_list(TSRMLS_D)
-{
- phar_mime_type mime;
-#define PHAR_SET_MIME(mimetype, ret, ...) \
- mime.mime = mimetype; \
- mime.len = sizeof((mimetype))+1; \
- mime.type = ret; \
- { \
- char mimes[][5] = {__VA_ARGS__, \0}; \
- int i = 0; \
- for (; mimes[i][0]; i++) { \
- zend_hash_add((PHAR_GLOBALS-phar_mimes), mimes[i],
strlen(mimes[i]), (void *)mime, sizeof(phar_mime_type), NULL); \
- } \
- }
-
- PHAR_SET_MIME(text/html, PHAR_MIME_PHPS, phps)
- PHAR_SET_MIME(text/plain, PHAR_MIME_OTHER, c, cc, cpp, c++,
dtd, h, log, rng, txt, xsd)
- PHAR_SET_MIME(, PHAR_MIME_PHP, php, inc)
- PHAR_SET_MIME(video/avi, PHAR_MIME_OTHER, avi)
- PHAR_SET_MIME(image/bmp, PHAR_MIME_OTHER, bmp)
- PHAR_SET_MIME(text/css, PHAR_MIME_OTHER, css)
- PHAR_SET_MIME(image/gif, PHAR_MIME_OTHER, gif)
- PHAR_SET_MIME(text/html, PHAR_MIME_OTHER, htm, html, htmls)
- PHAR_SET_MIME(image/x-ico, PHAR_MIME_OTHER, ico)
- PHAR_SET_MIME(image/jpeg, PHAR_MIME_OTHER, jpe, jpg, jpeg)
- PHAR_SET_MIME(application/x-javascript,