cvs: php4 /ext/fdf fdf.c /main SAPI.c SAPI.h
| From: | Hartmut Holzgraefe | Date: | Fri, 13 Oct 2000 12:13:35 +0000 |
| Subject: | cvs: php4 /ext/fdf fdf.c /main SAPI.c SAPI.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2043@lists.php.net to get a copy of this message | ||
hholzgra Fri Oct 13 05:13:35 2000 EDT
Modified files:
/php4/ext/fdf fdf.c
/php4/main SAPI.c SAPI.h
Log:
post handler registration done right
(never use emalloc in an extension MINIT function)
Index: php4/ext/fdf/fdf.c
diff -u php4/ext/fdf/fdf.c:1.32 php4/ext/fdf/fdf.c:1.33
--- php4/ext/fdf/fdf.c:1.32 Wed Oct 11 15:44:15 2000
+++ php4/ext/fdf/fdf.c Fri Oct 13 05:13:34 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fdf.c,v 1.32 2000/10/11 22:44:15 hholzgra Exp $ */
+/* $Id: fdf.c,v 1.33 2000/10/13 12:13:34 hholzgra Exp $ */
/* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from
http://beta1.adobe.com/ada/acrosdk/forms.html.
*/
@@ -112,33 +112,7 @@
};
-SAPI_API int sapi_add_post_entry(char *content_type, void (*post_reader)(SLS_D),
- void (*post_handler)(char *content_type_dup, void *arg SLS_DC)) {
- sapi_post_entry *post_entry = (sapi_post_entry *)emalloc(sizeof(sapi_post_entry));
- if(!post_entry) return 0;
-
- post_entry->content_type = estrdup(content_type);
- if(post_entry->content_type == NULL) return 0;
- post_entry->content_type_len = strlen(content_type);
- post_entry->post_reader = post_reader;
- post_entry->post_handler = post_handler;
-
- return sapi_register_post_entry(post_entry);
-}
-
-SAPI_API void sapi_remove_post_entry(char *content_type) {
- sapi_post_entry *post_entry = (sapi_post_entry *)emalloc(sizeof(sapi_post_entry));
- if(!post_entry) return;
-
- post_entry->content_type = estrdup(content_type);
- if(post_entry->content_type == NULL) return;
-
- sapi_unregister_post_entry(post_entry);
-
- efree(post_entry);
-}
-
PHP_MINIT_FUNCTION(fdf)
{
FDFErc err;
@@ -198,7 +172,7 @@
FDFErc err;
/* remove handler for Acrobat FDF form post requests */
- sapi_remove_post_entry("application/vnd.fdf");
+ sapi_remove_post_entry("application/vnd.fdf");
#ifdef PHP_WIN32
return SUCCESS;
Index: php4/main/SAPI.c
diff -u php4/main/SAPI.c:1.93 php4/main/SAPI.c:1.94
--- php4/main/SAPI.c:1.93 Wed Oct 11 15:44:15 2000
+++ php4/main/SAPI.c Fri Oct 13 05:13:35 2000
@@ -532,6 +532,50 @@
zend_hash_del(&known_post_content_types, post_entry->content_type,
post_entry->content_type_len+1);
}
+SAPI_API int sapi_add_post_entry(char *content_type
+ , void (*post_reader)(SLS_D)
+ , void (*post_handler)(char *content_type_dup
+ , void *arg SLS_DC)) {
+
+ sapi_post_entry *post_entry = (sapi_post_entry *)malloc(sizeof(sapi_post_entry));
+ if(!post_entry) return 0;
+
+ post_entry->content_type = strdup(content_type);
+ if(post_entry->content_type == NULL) return 0;
+ post_entry->content_type_len = strlen(content_type);
+ post_entry->post_reader = post_reader;
+ post_entry->post_handler = post_handler;
+
+ return zend_hash_add(&known_post_content_types
+ , post_entry->content_type
+ , post_entry->content_type_len+1
+ , (void *) post_entry
+ , sizeof(sapi_post_entry)
+ , NULL
+ );
+}
+
+SAPI_API void sapi_remove_post_entry(char *content_type) {
+ sapi_post_entry *post_entry;
+
+ zend_hash_find(&known_post_content_types
+ ,content_type
+ ,strlen(content_type)+1
+ ,(void **)&post_entry
+ );
+
+ if(post_entry != NULL) {
+ zend_hash_del(&known_post_content_types
+ ,content_type
+ ,strlen(content_type)+1
+ );
+ free(post_entry->content_type);
+ free(post_entry);
+ } else {
+ php_error(E_WARNING,"unregister post handler failed in fdf");
+ }
+}
+
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D))
{
sapi_module.default_post_reader = default_post_reader;
Index: php4/main/SAPI.h
diff -u php4/main/SAPI.h:1.54 php4/main/SAPI.h:1.55
--- php4/main/SAPI.h:1.54 Wed Oct 11 15:44:15 2000
+++ php4/main/SAPI.h Fri Oct 13 05:13:35 2000
@@ -137,6 +137,10 @@
SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
+SAPI_API int sapi_add_post_entry(char *content_type
+ , void (*post_reader)(SLS_D)
+ , void (*post_handler)(char *content_type_dup, void *arg SLS_DC));
+SAPI_API void sapi_remove_post_entry(char *content_type);
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D));