diff options
author | Hartmut Holzgraefe <hholzgra@php.net> | 2000-10-13 12:13:35 +0000 |
---|---|---|
committer | Hartmut Holzgraefe <hholzgra@php.net> | 2000-10-13 12:13:35 +0000 |
commit | 545ae277bc213a849cc729c84f2881a19b2d2a07 (patch) | |
tree | 2bbcc9596bef62959131f17f152482d882f9914b /main | |
parent | 6d5f1d97f8409ea471ad46b2bd17da7de124b8fa (diff) | |
download | php-git-545ae277bc213a849cc729c84f2881a19b2d2a07.tar.gz |
post handler registration done right
(never use emalloc in an extension MINIT function)
Diffstat (limited to 'main')
-rw-r--r-- | main/SAPI.c | 44 | ||||
-rw-r--r-- | main/SAPI.h | 4 |
2 files changed, 48 insertions, 0 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index a45e5d31fd..c2c532f83f 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -532,6 +532,50 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry) 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; diff --git a/main/SAPI.h b/main/SAPI.h index cb8c7df683..918912b717 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -137,6 +137,10 @@ SAPI_API void sapi_handle_post(void *arg SLS_DC); 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)); |