/* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.0 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_0.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. | +----------------------------------------------------------------------+ | Authors: Uwe Steinmann | +----------------------------------------------------------------------+ */ /* $Id$ */ #if COMPILE_DL #include "dl/phpdl.h" #endif #include #include #include "php.h" #include "php_globals.h" #include "ext/standard/php_standard.h" #include "ext/standard/head.h" #include "ext/standard/info.h" #include "SAPI.h" #if WIN32|WINNT #include #else #include "build-defs.h" #endif #if HYPERWAVE #include "php_ini.h" #include "php_hyperwave.h" //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_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_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_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 = { "HyperWave", hw_functions, PHP_MINIT(hw), PHP_MSHUTDOWN(hw), NULL, NULL, PHP_MINFO(hw), 0, 0, 0, NULL }; #ifdef ZTS int hw_globals_id; #else PHP_HW_API php_hw_globals hw_globals; #endif #ifdef COMPILE_DL DLEXPORT zend_module_entry *get_module(void) { return &hw_module_entry; } #endif void print_msg(hg_msg *msg, char *str, int txt); #if COMPILE_DL DLEXPORT zend_module_entry *get_module(void) { return &hw_module_entry; } #endif void _close_hw_link(hw_connection *conn) { if(conn->hostname) free(conn->hostname); if(conn->username) free(conn->username); close(conn->socket); free(conn); HwSG(num_links)--; } void _close_hw_plink(hw_connection *conn) { 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(hw_document *doc) { if(doc->data) free(doc->data); if(doc->attributes) free(doc->attributes); if(doc->bodytag) free(doc->bodytag); free(doc); } #ifdef ZTS static void php_hw_init_globals(php_hw_globals *hw_globals) { HwSG(num_persistent) = 0; } #endif static PHP_INI_MH(OnHyperwavePort) { HwSLS_FETCH(); 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, php_hw_globals, hw_globals) PHP_INI_ENTRY("hyperwave.default_port", "418", PHP_INI_ALL, OnHyperwavePort) PHP_INI_END() PHP_MINIT_FUNCTION(hw) { #ifdef ZTS hw_globals_id = ts_allocate_id(sizeof(php_hw_globals), php_hw_init_globals, NULL); #else HwSG(num_persistent)=0; #endif REGISTER_INI_ENTRIES(); HwSG(le_socketp) = register_list_destructors(_close_hw_link,NULL); HwSG(le_psocketp) = register_list_destructors(NULL,_close_hw_plink); HwSG(le_document) = register_list_destructors(_free_hw_document,NULL); hw_module_entry.type = 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; } /* 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