/* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Uwe Steinmann | +----------------------------------------------------------------------+ */ /* $Id$ */ #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_globals.h" #include "ext/standard/php_standard.h" #include "ext/standard/head.h" #include "ext/standard/info.h" #include "fopen_wrappers.h" #include "SAPI.h" #ifdef PHP_WIN32 #include #endif #if HYPERWAVE #include "php_ini.h" #include "php_hyperwave.h" static int le_socketp, le_psocketp, le_document; /*hw_module php_hw_module;*/ #define HW_ATTR_NONE 1 #define HW_ATTR_LANG 2 #define HW_ATTR_NR 3 function_entry hw_functions[] = { PHP_FE(hw_connect, NULL) PHP_FE(hw_pconnect, NULL) PHP_FE(hw_close, NULL) PHP_FE(hw_root, NULL) PHP_FE(hw_info, NULL) PHP_FE(hw_connection_info, NULL) PHP_FE(hw_error, NULL) PHP_FE(hw_errormsg, NULL) PHP_FE(hw_getparentsobj, NULL) PHP_FE(hw_getparents, NULL) PHP_FE(hw_children, NULL) PHP_FE(hw_childrenobj, NULL) PHP_FE(hw_getchildcoll, NULL) PHP_FE(hw_getchildcollobj, NULL) PHP_FE(hw_getobject, NULL) PHP_FE(hw_getandlock, NULL) PHP_FE(hw_unlock, NULL) PHP_FE(hw_gettext, NULL) PHP_FE(hw_edittext, NULL) PHP_FE(hw_getcgi, NULL) PHP_FE(hw_getremote, NULL) PHP_FE(hw_getremotechildren, NULL) PHP_FE(hw_pipedocument, NULL) PHP_FE(hw_pipecgi, NULL) PHP_FE(hw_insertdocument, NULL) PHP_FE(hw_mv, NULL) PHP_FE(hw_cp, NULL) PHP_FE(hw_deleteobject, NULL) PHP_FE(hw_changeobject, NULL) PHP_FE(hw_modifyobject, NULL) PHP_FE(hw_docbyanchor, NULL) PHP_FE(hw_docbyanchorobj, NULL) PHP_FE(hw_getobjectbyquery, NULL) PHP_FE(hw_getobjectbyqueryobj, NULL) PHP_FE(hw_getobjectbyquerycoll, NULL) PHP_FE(hw_getobjectbyquerycollobj, NULL) PHP_FE(hw_getobjectbyftquery, NULL) PHP_FE(hw_getobjectbyftqueryobj, NULL) PHP_FE(hw_getobjectbyftquerycoll, NULL) PHP_FE(hw_getobjectbyftquerycollobj, NULL) PHP_FE(hw_getchilddoccoll, NULL) PHP_FE(hw_getchilddoccollobj, NULL) PHP_FE(hw_getanchors, NULL) PHP_FE(hw_getanchorsobj, NULL) PHP_FE(hw_getusername, NULL) PHP_FE(hw_setlinkroot, NULL) PHP_FE(hw_identify, NULL) PHP_FE(hw_free_document, NULL) PHP_FE(hw_new_document, NULL) PHP_FE(hw_new_document_from_file, NULL) PHP_FE(hw_output_document, NULL) PHP_FE(hw_document_size, NULL) PHP_FE(hw_document_attributes, NULL) PHP_FE(hw_document_bodytag, NULL) PHP_FE(hw_document_content, NULL) PHP_FE(hw_document_setcontent, NULL) PHP_FE(hw_objrec2array, NULL) PHP_FE(hw_array2objrec, NULL) PHP_FE(hw_incollections, NULL) PHP_FE(hw_inscoll, NULL) PHP_FE(hw_insertobject, NULL) PHP_FE(hw_insdoc, NULL) PHP_FE(hw_getsrcbydestobj, NULL) PHP_FE(hw_insertanchors, NULL) PHP_FE(hw_getrellink, NULL) PHP_FE(hw_who, NULL) PHP_FE(hw_stat, NULL) PHP_FE(hw_mapid, NULL) PHP_FE(hw_dummy, NULL) {NULL, NULL, NULL} }; zend_module_entry hw_module_entry = { STANDARD_MODULE_HEADER, "hyperwave", hw_functions, PHP_MINIT(hw), PHP_MSHUTDOWN(hw), NULL, NULL, PHP_MINFO(hw), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; /* #ifdef ZTS int hw_globals_id; #else PHP_HW_API php_hw_globals hw_globals; #endif */ ZEND_DECLARE_MODULE_GLOBALS(hw) #ifdef COMPILE_DL_HYPERWAVE ZEND_GET_MODULE(hw) #endif void print_msg(hg_msg *msg, char *str, int txt); void _close_hw_link(zend_rsrc_list_entry *rsrc TSRMLS_DC) { hw_connection *conn = (hw_connection *)rsrc->ptr; if(conn->hostname) free(conn->hostname); if(conn->username) free(conn->username); close(conn->socket); free(conn); HwSG(num_links)--; } void _close_hw_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC) { hw_connection *conn = (hw_connection *)rsrc->ptr; if(conn->hostname) free(conn->hostname); if(conn->username) free(conn->username); close(conn->socket); free(conn); HwSG(num_links)--; HwSG(num_persistent)--; } void _free_hw_document(zend_rsrc_list_entry *rsrc TSRMLS_DC) { hw_document *doc = (hw_document *)rsrc->ptr; if(doc->data) free(doc->data); if(doc->attributes) free(doc->attributes); if(doc->bodytag) free(doc->bodytag); free(doc); } static void php_hw_init_globals(zend_hw_globals *hw_globals) { hw_globals->num_persistent = 0; } static PHP_INI_MH(OnHyperwavePort) { if (new_value==NULL) { HwSG(default_port) = HG_SERVER_PORT; } else { HwSG(default_port) = atoi(new_value); } return SUCCESS; } PHP_INI_BEGIN() STD_PHP_INI_ENTRY("hyerwave.allow_persistent", "0", PHP_INI_SYSTEM, OnUpdateInt, allow_persistent, zend_hw_globals, hw_globals) PHP_INI_ENTRY("hyperwave.default_port", "418", PHP_INI_ALL, OnHyperwavePort) PHP_INI_END() PHP_MINIT_FUNCTION(hw) { ZEND_INIT_MODULE_GLOBALS(hw, php_hw_init_globals, NULL); REGISTER_INI_ENTRIES(); le_socketp = zend_register_list_destructors_ex(_close_hw_link, NULL, "hyperwave link", module_number); le_psocketp = zend_register_list_destructors_ex(NULL, _close_hw_plink, "hyperwave link persistent", module_number); le_document = zend_register_list_destructors_ex(_free_hw_document, NULL, "hyperwave document", module_number); Z_TYPE(hw_module_entry) = type; REGISTER_LONG_CONSTANT("HW_ATTR_LANG", HW_ATTR_LANG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("HW_ATTR_NR", HW_ATTR_NR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("HW_ATTR_NONE", HW_ATTR_NONE, CONST_CS | CONST_PERSISTENT); return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(hw) { UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* {{{ make_return_objrec * creates an array in return value and frees all memory * Also adds as an assoc. array at the end of the return array with * statistics. */ int make_return_objrec(pval **return_value, char **objrecs, int count) { zval *stat_arr; int i; int hidden, collhead, fullcollhead, total; int collheadnr, fullcollheadnr; if (array_init(*return_value) == FAILURE) { /* Ups, failed! Let's at least free the memory */ for(i=0; i