1999-04-21 23:11:20 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-12-11 15:32:16 +00:00
| PHP Version 4 |
1999-04-21 23:11:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-12-11 15:32:16 +00:00
| Copyright ( c ) 1997 - 2002 The PHP Group |
1999-04-21 23:11:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2000-05-18 15:34:45 +00:00
| This source file is subject to version 2.02 of the PHP license , |
1999-07-16 13:13:16 +00:00
| that is bundled with this package in the file LICENSE , and is |
| available at through the world - wide - web at |
2000-05-18 15:34:45 +00:00
| http : //www.php.net/license/2_02.txt. |
1999-07-16 13:13:16 +00:00
| 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 . |
1999-04-21 23:11:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2002-02-28 08:29:35 +00:00
| Author : Uwe Steinmann < Uwe . Steinmann @ fernuni - hagen . de > |
1999-04-21 23:11:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
/* $Id$ */
# include <stdlib.h>
1999-09-01 06:15:46 +00:00
# include <errno.h>
1999-04-21 23:11:20 +00:00
2001-05-24 10:07:29 +00:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
1999-04-21 23:11:20 +00:00
# include "php.h"
1999-08-05 16:25:10 +00:00
# include "php_globals.h"
1999-12-04 19:19:57 +00:00
# include "ext/standard/php_standard.h"
1999-04-22 00:25:57 +00:00
# include "ext/standard/head.h"
1999-08-05 16:25:10 +00:00
# include "ext/standard/info.h"
2001-02-23 22:07:16 +00:00
# include "fopen_wrappers.h"
1999-08-05 16:25:10 +00:00
# include "SAPI.h"
1999-04-21 23:11:20 +00:00
2000-06-15 23:45:05 +00:00
# ifdef PHP_WIN32
1999-08-05 16:25:10 +00:00
# include <winsock.h>
# endif
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
# if HYPERWAVE
1999-04-21 23:11:20 +00:00
1999-08-06 10:42:00 +00:00
# include "php_ini.h"
1999-12-04 19:19:57 +00:00
# include "php_hyperwave.h"
1999-04-21 23:11:20 +00:00
2001-02-20 20:45:55 +00:00
static int le_socketp , le_psocketp , le_document ;
2000-06-16 18:24:02 +00:00
/*hw_module php_hw_module;*/
1999-04-21 23:11:20 +00:00
1999-09-08 12:29:13 +00:00
# define HW_ATTR_NONE 1
# define HW_ATTR_LANG 2
# define HW_ATTR_NR 3
1999-04-21 23:11:20 +00:00
function_entry hw_functions [ ] = {
1999-07-27 19:44:46 +00:00
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 )
1999-08-05 16:25:10 +00:00
PHP_FE ( hw_modifyobject , NULL )
1999-07-27 19:44:46 +00:00
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 )
2000-10-27 09:29:40 +00:00
PHP_FE ( hw_getobjectbyftquery , NULL )
PHP_FE ( hw_getobjectbyftqueryobj , NULL )
PHP_FE ( hw_getobjectbyftquerycoll , NULL )
PHP_FE ( hw_getobjectbyftquerycollobj , NULL )
1999-07-27 19:44:46 +00:00
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 )
2000-12-04 16:34:06 +00:00
PHP_FE ( hw_new_document_from_file , NULL )
1999-07-27 19:44:46 +00:00
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 )
1999-08-05 16:25:10 +00:00
PHP_FE ( hw_document_setcontent , NULL )
1999-07-27 19:44:46 +00:00
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 )
2000-11-09 13:36:54 +00:00
PHP_FE ( hw_insertanchors , NULL )
1999-07-27 19:44:46 +00:00
PHP_FE ( hw_getrellink , NULL )
PHP_FE ( hw_who , NULL )
PHP_FE ( hw_stat , NULL )
1999-10-21 15:15:27 +00:00
PHP_FE ( hw_mapid , NULL )
1999-07-27 19:44:46 +00:00
PHP_FE ( hw_dummy , NULL )
1999-04-21 23:11:20 +00:00
{ NULL , NULL , NULL }
} ;
1999-12-17 20:55:31 +00:00
zend_module_entry hw_module_entry = {
2001-10-11 23:33:59 +00:00
STANDARD_MODULE_HEADER ,
" hyperwave " , hw_functions , PHP_MINIT ( hw ) , PHP_MSHUTDOWN ( hw ) , NULL , NULL , PHP_MINFO ( hw ) , NO_VERSION_YET , STANDARD_MODULE_PROPERTIES
1999-04-21 23:11:20 +00:00
} ;
2000-06-30 09:46:39 +00:00
/*
1999-08-06 10:42:00 +00:00
# ifdef ZTS
int hw_globals_id ;
# else
PHP_HW_API php_hw_globals hw_globals ;
# endif
2000-06-30 09:46:39 +00:00
*/
ZEND_DECLARE_MODULE_GLOBALS ( hw )
1999-08-06 10:42:00 +00:00
2000-05-23 09:33:51 +00:00
# ifdef COMPILE_DL_HYPERWAVE
2000-05-02 00:30:36 +00:00
ZEND_GET_MODULE ( hw )
1999-08-06 10:42:00 +00:00
# endif
1999-04-21 23:11:20 +00:00
void print_msg ( hg_msg * msg , char * str , int txt ) ;
2001-07-31 05:44:11 +00:00
void _close_hw_link ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-04-21 23:11:20 +00:00
{
2000-10-20 18:25:16 +00:00
hw_connection * conn = ( hw_connection * ) rsrc - > ptr ;
2001-04-30 12:53:58 +00:00
1999-04-21 23:11:20 +00:00
if ( conn - > hostname )
free ( conn - > hostname ) ;
if ( conn - > username )
free ( conn - > username ) ;
close ( conn - > socket ) ;
free ( conn ) ;
1999-08-06 10:42:00 +00:00
HwSG ( num_links ) - - ;
1999-04-21 23:11:20 +00:00
}
2001-07-31 05:44:11 +00:00
void _close_hw_plink ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-04-21 23:11:20 +00:00
{
2000-10-20 18:25:16 +00:00
hw_connection * conn = ( hw_connection * ) rsrc - > ptr ;
2001-04-30 12:53:58 +00:00
1999-04-21 23:11:20 +00:00
if ( conn - > hostname )
free ( conn - > hostname ) ;
if ( conn - > username )
free ( conn - > username ) ;
close ( conn - > socket ) ;
free ( conn ) ;
1999-08-06 10:42:00 +00:00
HwSG ( num_links ) - - ;
HwSG ( num_persistent ) - - ;
1999-04-21 23:11:20 +00:00
}
2001-07-31 05:44:11 +00:00
void _free_hw_document ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
1999-04-21 23:11:20 +00:00
{
2000-10-20 18:25:16 +00:00
hw_document * doc = ( hw_document * ) rsrc - > ptr ;
1999-04-21 23:11:20 +00:00
if ( doc - > data )
free ( doc - > data ) ;
if ( doc - > attributes )
free ( doc - > attributes ) ;
if ( doc - > bodytag )
free ( doc - > bodytag ) ;
free ( doc ) ;
}
2000-06-30 09:46:39 +00:00
static void php_hw_init_globals ( zend_hw_globals * hw_globals )
1999-08-06 10:42:00 +00:00
{
2000-06-30 09:46:39 +00:00
hw_globals - > num_persistent = 0 ;
1999-08-06 10:42:00 +00:00
}
2001-07-28 11:36:37 +00:00
static PHP_INI_MH ( OnHyperwavePort )
{
1999-08-06 10:42:00 +00:00
if ( new_value = = NULL ) {
HwSG ( default_port ) = HG_SERVER_PORT ;
} else {
HwSG ( default_port ) = atoi ( new_value ) ;
}
return SUCCESS ;
}
PHP_INI_BEGIN ( )
2000-06-30 09:46:39 +00:00
STD_PHP_INI_ENTRY ( " hyerwave.allow_persistent " , " 0 " , PHP_INI_SYSTEM , OnUpdateInt , allow_persistent , zend_hw_globals , hw_globals )
1999-08-06 10:42:00 +00:00
PHP_INI_ENTRY ( " hyperwave.default_port " , " 418 " , PHP_INI_ALL , OnHyperwavePort )
PHP_INI_END ( )
2001-07-30 01:56:43 +00:00
PHP_MINIT_FUNCTION ( hw )
{
2000-06-30 09:46:39 +00:00
ZEND_INIT_MODULE_GLOBALS ( hw , php_hw_init_globals , NULL ) ;
1999-08-06 10:42:00 +00:00
REGISTER_INI_ENTRIES ( ) ;
2001-02-20 20:45:55 +00:00
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 ) ;
2001-09-25 21:58:48 +00:00
Z_TYPE ( hw_module_entry ) = type ;
1999-08-06 10:42:00 +00:00
2000-03-10 11:36:27 +00:00
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 ) ;
1999-08-06 10:42:00 +00:00
return SUCCESS ;
}
PHP_MSHUTDOWN_FUNCTION ( hw )
{
UNREGISTER_INI_ENTRIES ( ) ;
return SUCCESS ;
}
2001-06-06 13:06:12 +00:00
/* {{{ make_return_objrec
* creates an array in return value and frees all memory
1999-04-21 23:11:20 +00:00
* 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 )
{
1999-08-06 10:42:00 +00:00
zval * stat_arr ;
1999-04-21 23:11:20 +00:00
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 < count ; i + + )
efree ( objrecs [ i ] ) ;
efree ( objrecs ) ;
return - 1 ;
}
hidden = collhead = fullcollhead = total = 0 ;
2001-03-14 06:33:46 +00:00
collheadnr = fullcollheadnr = - 1 ;
1999-04-21 23:11:20 +00:00
for ( i = 0 ; i < count ; i + + ) {
/* Fill the array with entries. No need to free objrecs[i], since
* it is not duplicated in add_next_index_string ( ) .
*/
if ( NULL ! = objrecs [ i ] ) {
if ( 0 = = fnAttributeCompare ( objrecs [ i ] , " PresentationHints " , " Hidden " ) )
hidden + + ;
if ( 0 = = fnAttributeCompare ( objrecs [ i ] , " PresentationHints " , " CollectionHead " ) ) {
collhead + + ;
collheadnr = total ;
}
if ( 0 = = fnAttributeCompare ( objrecs [ i ] , " PresentationHints " , " FullCollectionHead " ) ) {
fullcollhead + + ;
fullcollheadnr = total ;
}
total + + ;
add_next_index_string ( * return_value , objrecs [ i ] , 0 ) ;
}
}
efree ( objrecs ) ;
/* Array for statistics */
1999-08-19 15:03:15 +00:00
MAKE_STD_ZVAL ( stat_arr ) ;
1999-08-06 10:42:00 +00:00
if ( array_init ( stat_arr ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
return - 1 ;
}
1999-08-06 10:42:00 +00:00
add_assoc_long ( stat_arr , " Hidden " , hidden ) ;
add_assoc_long ( stat_arr , " CollectionHead " , collhead ) ;
add_assoc_long ( stat_arr , " FullCollectionHead " , fullcollhead ) ;
add_assoc_long ( stat_arr , " Total " , total ) ;
add_assoc_long ( stat_arr , " CollectionHeadNr " , collheadnr ) ;
add_assoc_long ( stat_arr , " FullCollectionHeadNr " , fullcollheadnr ) ;
1999-04-21 23:11:20 +00:00
/* Add the stat array */
2001-09-25 21:58:48 +00:00
zend_hash_next_index_insert ( Z_ARRVAL_PP ( return_value ) , & stat_arr , sizeof ( zval ) , NULL ) ;
1999-04-21 23:11:20 +00:00
return 0 ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
2001-06-06 13:06:12 +00:00
/* {{{ make2_return_array_from_objrec
1999-04-21 23:11:20 +00:00
* * creates an array return value from object record
*/
1999-09-08 12:29:13 +00:00
int make2_return_array_from_objrec ( pval * * return_value , char * objrec , zval * sarr ) {
1999-09-03 10:21:55 +00:00
char * attrname , * str , * temp , language [ 3 ] ;
zval * spec_arr ;
1999-11-26 16:51:57 +00:00
char * strtok_buf = NULL ;
1999-09-03 10:21:55 +00:00
/* Create an array with an entry containing specs for each attribute
1999-09-08 12:29:13 +00:00
and fill in the specs for Title , Description , Keyword , Group .
If an array is passed as the last argument use it instead .
1999-09-03 10:21:55 +00:00
*/
1999-09-08 12:29:13 +00:00
if ( NULL ! = sarr ) {
spec_arr = sarr ;
} else {
MAKE_STD_ZVAL ( spec_arr ) ;
array_init ( spec_arr ) ;
add_assoc_long ( spec_arr , " Title " , HW_ATTR_LANG ) ;
add_assoc_long ( spec_arr , " Description " , HW_ATTR_LANG ) ;
add_assoc_long ( spec_arr , " Keyword " , HW_ATTR_LANG ) ;
add_assoc_long ( spec_arr , " Group " , HW_ATTR_NONE ) ;
2000-03-08 17:51:58 +00:00
add_assoc_long ( spec_arr , " HtmlAttr " , HW_ATTR_NONE ) ;
2000-04-04 13:35:07 +00:00
add_assoc_long ( spec_arr , " Parent " , HW_ATTR_NONE ) ;
2002-09-30 09:27:56 +00:00
add_assoc_long ( spec_arr , " SQLStmt " , HW_ATTR_NR ) ;
1999-09-03 10:21:55 +00:00
}
if ( array_init ( * return_value ) = = FAILURE ) {
2001-09-25 21:58:48 +00:00
Z_TYPE_PP ( return_value ) = IS_STRING ;
Z_STRVAL_PP ( return_value ) = empty_string ;
Z_STRLEN_PP ( return_value ) = 0 ;
1999-09-03 10:21:55 +00:00
return - 1 ;
}
/* Loop through the attributes of object record and check
if the attribute has a specification . If it has the value
is added to array in spec record . If not it is added straight
to the return_value array .
*/
temp = estrdup ( objrec ) ;
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( temp , " \n " , & strtok_buf ) ;
1999-09-03 10:21:55 +00:00
while ( attrname ! = NULL ) {
zval * data , * * dataptr ;
1999-09-08 12:29:13 +00:00
long spec ;
1999-09-03 10:21:55 +00:00
str = attrname ;
/* Check if a specification is available.
If it isn ' t available then insert the attribute as
a string into the return array
*/
while ( ( * str ! = ' = ' ) & & ( * str ! = ' \0 ' ) )
str + + ;
* str = ' \0 ' ;
str + + ;
2001-09-25 21:58:48 +00:00
if ( zend_hash_find ( Z_ARRVAL_P ( spec_arr ) , attrname , strlen ( attrname ) + 1 , ( void * * ) & dataptr ) = = FAILURE ) {
1999-09-03 10:21:55 +00:00
add_assoc_string ( * return_value , attrname , str , 1 ) ;
} else {
1999-09-08 12:29:13 +00:00
zval * newarr ;
1999-09-03 10:21:55 +00:00
data = * dataptr ;
2001-09-25 21:58:48 +00:00
spec = Z_LVAL_P ( data ) ;
1999-09-08 12:29:13 +00:00
2001-09-25 21:58:48 +00:00
if ( zend_hash_find ( Z_ARRVAL_PP ( return_value ) , attrname , strlen ( attrname ) + 1 , ( void * * ) & dataptr ) = = FAILURE ) {
1999-09-08 12:29:13 +00:00
MAKE_STD_ZVAL ( newarr ) ;
array_init ( newarr ) ;
2001-09-25 21:58:48 +00:00
zend_hash_add ( Z_ARRVAL_PP ( return_value ) , attrname , strlen ( attrname ) + 1 , & newarr , sizeof ( zval * ) , NULL ) ;
1999-09-08 12:29:13 +00:00
} else {
newarr = * dataptr ;
1999-09-03 10:21:55 +00:00
}
1999-09-08 12:29:13 +00:00
switch ( spec ) {
case HW_ATTR_LANG :
1999-09-03 10:21:55 +00:00
if ( str [ 2 ] = = ' : ' ) {
str [ 2 ] = ' \0 ' ;
strcpy ( language , str ) ;
str + = 3 ;
} else
strcpy ( language , " xx " ) ;
1999-09-08 12:29:13 +00:00
add_assoc_string ( newarr , language , str , 1 ) ;
1999-09-03 10:21:55 +00:00
break ;
1999-09-08 12:29:13 +00:00
case HW_ATTR_NR :
if ( str [ 1 ] = = ' : ' ) {
str [ 1 ] = ' \0 ' ;
strcpy ( language , str ) ;
str + = 2 ;
} else
strcpy ( language , " x " ) ;
add_assoc_string ( newarr , language , str , 1 ) ;
break ;
case HW_ATTR_NONE :
add_next_index_string ( newarr , str , 1 ) ;
1999-09-03 10:21:55 +00:00
break ;
}
}
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( NULL , " \n " , & strtok_buf ) ;
1999-09-03 10:21:55 +00:00
}
1999-10-06 05:31:24 +00:00
if ( NULL = = sarr ) {
2000-06-16 18:24:02 +00:00
/*
spec_arr - > refcount - - ;
2001-09-25 21:58:48 +00:00
zend_hash_destroy ( Z_ARRVAL_P ( spec_arr ) ) ;
efree ( Z_ARRVAL_P ( spec_arr ) ) ;
2000-06-16 18:24:02 +00:00
*/
1999-10-19 13:54:45 +00:00
zval_dtor ( spec_arr ) ;
1999-10-06 05:31:24 +00:00
efree ( spec_arr ) ;
}
1999-09-03 10:21:55 +00:00
efree ( temp ) ;
return ( 0 ) ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-09-03 10:21:55 +00:00
2001-06-06 13:06:12 +00:00
/* {{{ make_return_array_from_objrec
*/
1999-04-21 23:11:20 +00:00
int make_return_array_from_objrec ( pval * * return_value , char * objrec ) {
char * attrname , * str , * temp , language [ 3 ] , * title ;
1999-09-01 06:15:46 +00:00
int iTitle , iDesc , iKeyword , iGroup ;
1999-08-05 17:39:35 +00:00
zval * title_arr ;
zval * desc_arr ;
zval * keyword_arr ;
1999-09-01 06:15:46 +00:00
zval * group_arr ;
1999-04-21 23:11:20 +00:00
int hasTitle = 0 ;
int hasDescription = 0 ;
1999-08-05 16:25:10 +00:00
int hasKeyword = 0 ;
1999-09-01 06:15:46 +00:00
int hasGroup = 0 ;
1999-11-26 16:51:57 +00:00
char * strtok_buf ;
1999-04-21 23:11:20 +00:00
1999-08-19 15:03:15 +00:00
MAKE_STD_ZVAL ( title_arr ) ;
MAKE_STD_ZVAL ( desc_arr ) ;
MAKE_STD_ZVAL ( keyword_arr ) ;
1999-09-01 06:15:46 +00:00
MAKE_STD_ZVAL ( group_arr ) ;
1999-08-05 17:39:35 +00:00
1999-04-21 23:11:20 +00:00
if ( array_init ( * return_value ) = = FAILURE ) {
2001-09-25 21:58:48 +00:00
Z_TYPE_PP ( return_value ) = IS_STRING ;
Z_STRVAL_PP ( return_value ) = empty_string ;
Z_STRLEN_PP ( return_value ) = 0 ;
1999-04-21 23:11:20 +00:00
return - 1 ;
}
1999-08-05 16:25:10 +00:00
/* Fill Array of titles, descriptions and keywords */
1999-04-21 23:11:20 +00:00
temp = estrdup ( objrec ) ;
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( temp , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
while ( attrname ! = NULL ) {
str = attrname ;
iTitle = 0 ;
iDesc = 0 ;
1999-08-05 16:25:10 +00:00
iKeyword = 0 ;
1999-09-01 06:15:46 +00:00
iGroup = 0 ;
1999-04-21 23:11:20 +00:00
if ( 0 = = strncmp ( attrname , " Title= " , 6 ) ) {
1999-08-05 17:39:35 +00:00
if ( ( hasTitle = = 0 ) & & ( array_init ( title_arr ) = = FAILURE ) ) {
1999-08-05 16:25:10 +00:00
return - 1 ;
}
hasTitle = 1 ;
1999-04-21 23:11:20 +00:00
str + = 6 ;
iTitle = 1 ;
} else if ( 0 = = strncmp ( attrname , " Description= " , 12 ) ) {
1999-08-05 17:39:35 +00:00
if ( ( hasDescription = = 0 ) & & ( array_init ( desc_arr ) = = FAILURE ) ) {
1999-08-05 16:25:10 +00:00
return - 1 ;
}
hasDescription = 1 ;
1999-04-21 23:11:20 +00:00
str + = 12 ;
iDesc = 1 ;
1999-08-05 16:25:10 +00:00
} else if ( 0 = = strncmp ( attrname , " Keyword= " , 8 ) ) {
1999-08-05 17:39:35 +00:00
if ( ( hasKeyword = = 0 ) & & ( array_init ( keyword_arr ) = = FAILURE ) ) {
1999-08-05 16:25:10 +00:00
return - 1 ;
}
hasKeyword = 1 ;
str + = 8 ;
iKeyword = 1 ;
1999-09-01 06:15:46 +00:00
} else if ( 0 = = strncmp ( attrname , " Group= " , 6 ) ) {
if ( ( hasGroup = = 0 ) & & ( array_init ( group_arr ) = = FAILURE ) ) {
return - 1 ;
}
hasGroup = 1 ;
str + = 6 ;
iGroup = 1 ;
1999-08-05 16:25:10 +00:00
}
if ( iTitle | | iDesc | | iKeyword ) { /* Poor error check if end of string */
1999-04-21 23:11:20 +00:00
if ( str [ 2 ] = = ' : ' ) {
str [ 2 ] = ' \0 ' ;
strcpy ( language , str ) ;
str + = 3 ;
} else
strcpy ( language , " xx " ) ;
title = str ;
1999-08-05 16:25:10 +00:00
if ( iTitle )
1999-08-05 17:39:35 +00:00
add_assoc_string ( title_arr , language , title , 1 ) ;
1999-08-05 16:25:10 +00:00
else if ( iDesc )
1999-08-05 17:39:35 +00:00
add_assoc_string ( desc_arr , language , title , 1 ) ;
1999-08-05 16:25:10 +00:00
else if ( iKeyword )
1999-08-05 17:39:35 +00:00
add_assoc_string ( keyword_arr , language , title , 1 ) ;
1999-09-01 06:15:46 +00:00
} else if ( iGroup ) {
if ( iGroup )
add_next_index_string ( group_arr , str , 1 ) ;
1999-04-21 23:11:20 +00:00
}
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( NULL , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
}
efree ( temp ) ;
/* Add the title array, if we have one */
if ( hasTitle ) {
2001-09-25 21:58:48 +00:00
zend_hash_update ( Z_ARRVAL_PP ( return_value ) , " Title " , 6 , & title_arr , sizeof ( zval * ) , NULL ) ;
1999-04-21 23:11:20 +00:00
1999-08-19 15:03:15 +00:00
} else {
efree ( title_arr ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-19 15:03:15 +00:00
1999-04-21 23:11:20 +00:00
if ( hasDescription ) {
/* Add the description array, if we have one */
2001-09-25 21:58:48 +00:00
zend_hash_update ( Z_ARRVAL_PP ( return_value ) , " Description " , 12 , & desc_arr , sizeof ( zval * ) , NULL ) ;
1999-04-21 23:11:20 +00:00
1999-08-19 15:03:15 +00:00
} else {
efree ( desc_arr ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
if ( hasKeyword ) {
/* Add the keyword array, if we have one */
2001-09-25 21:58:48 +00:00
zend_hash_update ( Z_ARRVAL_PP ( return_value ) , " Keyword " , 8 , & keyword_arr , sizeof ( zval * ) , NULL ) ;
1999-08-05 16:25:10 +00:00
1999-08-19 15:03:15 +00:00
} else {
efree ( keyword_arr ) ;
1999-08-05 16:25:10 +00:00
}
1999-09-01 06:15:46 +00:00
if ( hasGroup ) {
/* Add the Group array, if we have one */
2001-09-25 21:58:48 +00:00
zend_hash_update ( Z_ARRVAL_PP ( return_value ) , " Group " , 6 , & group_arr , sizeof ( zval * ) , NULL ) ;
1999-09-01 06:15:46 +00:00
} else {
efree ( group_arr ) ;
}
1999-04-21 23:11:20 +00:00
/* All other attributes. Make a another copy first */
temp = estrdup ( objrec ) ;
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( temp , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
while ( attrname ! = NULL ) {
str = attrname ;
1999-08-05 16:25:10 +00:00
/* We don't want to insert titles, descr., keywords a second time */
1999-04-21 23:11:20 +00:00
if ( ( 0 ! = strncmp ( attrname , " Title= " , 6 ) ) & &
1999-08-05 16:25:10 +00:00
( 0 ! = strncmp ( attrname , " Description= " , 12 ) ) & &
1999-09-01 06:15:46 +00:00
( 0 ! = strncmp ( attrname , " Group= " , 6 ) ) & &
1999-08-05 16:25:10 +00:00
( 0 ! = strncmp ( attrname , " Keyword= " , 8 ) ) ) {
1999-04-21 23:11:20 +00:00
while ( ( * str ! = ' = ' ) & & ( * str ! = ' \0 ' ) )
str + + ;
* str = ' \0 ' ;
str + + ;
add_assoc_string ( * return_value , attrname , str , 1 ) ;
}
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( NULL , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
}
efree ( temp ) ;
return ( 0 ) ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
# define BUFFERLEN 1024
2001-06-06 13:06:12 +00:00
/* {{{ make_objrec_from_array
*/
2002-09-30 09:27:56 +00:00
static char * make_objrec_from_array ( HashTable * lht , char delim ) {
1999-04-21 23:11:20 +00:00
int i , count , keytype ;
2002-09-30 09:27:56 +00:00
ulong idx ;
uint length ;
1999-08-05 16:25:10 +00:00
char * key , str [ BUFFERLEN ] , * objrec = NULL ;
1999-08-17 09:59:19 +00:00
zval * keydata , * * keydataptr ;
1999-04-21 23:11:20 +00:00
if ( NULL = = lht )
return NULL ;
1999-08-02 19:17:14 +00:00
if ( 0 = = ( count = zend_hash_num_elements ( lht ) ) )
1999-04-21 23:11:20 +00:00
return NULL ;
2002-09-30 09:27:56 +00:00
if ( delim = = 0 )
delim = ' = ' ;
1999-08-02 19:17:14 +00:00
zend_hash_internal_pointer_reset ( lht ) ;
1999-04-21 23:11:20 +00:00
objrec = malloc ( 1 ) ;
* objrec = ' \0 ' ;
for ( i = 0 ; i < count ; i + + ) {
2002-09-30 09:27:56 +00:00
keytype = zend_hash_get_current_key_ex ( lht , & key , & length , & idx , 0 , NULL ) ;
2000-06-16 18:24:02 +00:00
/* if(HASH_KEY_IS_STRING == keytype) { */
1999-08-17 09:59:19 +00:00
zend_hash_get_current_data ( lht , ( void * * ) & keydataptr ) ;
keydata = * keydataptr ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( keydata ) ) {
1999-04-21 23:11:20 +00:00
case IS_STRING :
1999-09-01 06:15:46 +00:00
if ( HASH_KEY_IS_STRING = = keytype )
2002-09-30 09:27:56 +00:00
snprintf ( str , BUFFERLEN , " %s%c%s \n " , key , delim , Z_STRVAL_P ( keydata ) ) ;
else if ( HASH_KEY_IS_LONG = = keytype )
snprintf ( str , BUFFERLEN , " %ld%c%s \n " , idx , delim , Z_STRVAL_P ( keydata ) ) ;
1999-09-01 06:15:46 +00:00
else
2001-09-25 21:58:48 +00:00
snprintf ( str , BUFFERLEN , " %s \n " , Z_STRVAL_P ( keydata ) ) ;
1999-04-21 23:11:20 +00:00
break ;
case IS_LONG :
1999-09-01 06:15:46 +00:00
if ( HASH_KEY_IS_STRING = = keytype )
2002-09-30 09:27:56 +00:00
snprintf ( str , BUFFERLEN , " %s%c0x%lX \n " , key , delim , Z_LVAL_P ( keydata ) ) ;
else if ( HASH_KEY_IS_LONG = = keytype )
snprintf ( str , BUFFERLEN , " %ld%c%s \n " , idx , delim , Z_STRVAL_P ( keydata ) ) ;
1999-09-01 06:15:46 +00:00
else
2001-09-25 21:58:48 +00:00
snprintf ( str , BUFFERLEN , " 0x%lX \n " , Z_LVAL_P ( keydata ) ) ;
1999-08-05 16:25:10 +00:00
break ;
case IS_ARRAY : {
int i , len , keylen , count ;
char * strarr , * ptr , * ptr1 ;
2001-09-25 21:58:48 +00:00
count = zend_hash_num_elements ( Z_ARRVAL_P ( keydata ) ) ;
1999-08-05 16:25:10 +00:00
if ( count > 0 ) {
2002-09-30 09:27:56 +00:00
strarr = make_objrec_from_array ( Z_ARRVAL_P ( keydata ) , ' : ' ) ;
1999-08-05 16:25:10 +00:00
len = strlen ( strarr ) - 1 ;
keylen = strlen ( key ) ;
if ( NULL = = ( ptr = malloc ( len + 1 + count * ( keylen + 1 ) ) ) ) {
free ( objrec ) ;
return ( NULL ) ;
}
ptr1 = ptr ;
* ptr1 = ' \0 ' ;
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
for ( i = 0 ; i < len ; i + + ) {
* ptr1 + + = strarr [ i ] ;
if ( strarr [ i ] = = ' \n ' ) {
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
2002-09-30 09:27:56 +00:00
} /* else if(strarr[i] == '=')
ptr1 [ - 1 ] = ' : ' ; */
1999-08-05 16:25:10 +00:00
}
* ptr1 + + = ' \n ' ;
* ptr1 = ' \0 ' ;
1999-09-15 05:42:36 +00:00
strlcpy ( str , ptr , sizeof ( str ) ) ;
1999-08-05 16:25:10 +00:00
}
1999-04-21 23:11:20 +00:00
break ;
1999-08-05 16:25:10 +00:00
}
1999-04-21 23:11:20 +00:00
}
objrec = realloc ( objrec , strlen ( objrec ) + strlen ( str ) + 1 ) ;
strcat ( objrec , str ) ;
2000-06-16 18:24:02 +00:00
/* } */
1999-08-02 19:17:14 +00:00
zend_hash_move_forward ( lht ) ;
1999-04-21 23:11:20 +00:00
}
return objrec ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-08-05 16:25:10 +00:00
# undef BUFFERLEN
1999-04-21 23:11:20 +00:00
2001-06-06 13:06:12 +00:00
/* {{{ make_ints_from_array
*/
1999-04-21 23:11:20 +00:00
static int * make_ints_from_array ( HashTable * lht ) {
int i , count ;
1999-08-17 09:59:19 +00:00
int * objids = NULL ;
zval * * keydata ;
1999-04-21 23:11:20 +00:00
if ( NULL = = lht )
return NULL ;
1999-08-02 19:17:14 +00:00
if ( 0 = = ( count = zend_hash_num_elements ( lht ) ) )
1999-04-21 23:11:20 +00:00
return NULL ;
1999-08-02 19:17:14 +00:00
zend_hash_internal_pointer_reset ( lht ) ;
1999-08-17 09:59:19 +00:00
if ( NULL = = ( objids = emalloc ( count * sizeof ( int ) ) ) )
1999-04-21 23:11:20 +00:00
return NULL ;
for ( i = 0 ; i < count ; i + + ) {
1999-08-02 19:17:14 +00:00
zend_hash_get_current_data ( lht , ( void * * ) & keydata ) ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_PP ( keydata ) ) {
1999-04-21 23:11:20 +00:00
case IS_LONG :
2001-09-25 21:58:48 +00:00
objids [ i ] = Z_LVAL_PP ( keydata ) ;
1999-04-21 23:11:20 +00:00
break ;
default :
1999-08-17 09:59:19 +00:00
objids [ i ] = 0 ;
1999-04-21 23:11:20 +00:00
}
1999-08-02 19:17:14 +00:00
zend_hash_move_forward ( lht ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-17 09:59:19 +00:00
return objids ;
1999-04-21 23:11:20 +00:00
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
2001-06-06 13:06:12 +00:00
/* {{{ make_strs_from_array
*/
2000-11-09 13:36:54 +00:00
static char * * make_strs_from_array ( HashTable * arrht ) {
char * * carr = NULL ;
2000-12-12 12:28:26 +00:00
char * * ptr ;
2000-11-09 13:36:54 +00:00
zval * data , * * dataptr ;
zend_hash_internal_pointer_reset ( arrht ) ;
if ( NULL = = ( carr = emalloc ( zend_hash_num_elements ( arrht ) * sizeof ( char * ) ) ) )
2000-12-12 12:28:26 +00:00
return ( NULL ) ;
ptr = carr ;
2000-11-09 13:36:54 +00:00
/* Iterate through hash */
while ( zend_hash_get_current_data ( arrht , ( void * * ) & dataptr ) = = SUCCESS ) {
data = * dataptr ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( data ) ) {
2000-11-09 13:36:54 +00:00
case IS_STRING :
2001-09-25 21:58:48 +00:00
* ptr = estrdup ( Z_STRVAL_P ( data ) ) ;
2000-12-13 17:27:13 +00:00
/*fprintf(stderr, "carr[] = %s\n", *ptr); */
2000-11-09 13:36:54 +00:00
break ;
2000-12-13 17:27:13 +00:00
default :
* ptr = NULL ;
2000-11-09 13:36:54 +00:00
}
2000-12-13 17:27:13 +00:00
ptr + + ;
2000-11-09 13:36:54 +00:00
zend_hash_move_forward ( arrht ) ;
}
return ( carr ) ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
2000-11-09 13:36:54 +00:00
1999-08-05 16:25:10 +00:00
# define BUFFERLEN 30
2001-06-06 13:06:12 +00:00
/* {{{ php_hw_do_connect
*/
1999-12-17 21:50:07 +00:00
static void php_hw_do_connect ( INTERNAL_FUNCTION_PARAMETERS , int persistent )
1999-04-21 23:11:20 +00:00
{
2000-06-30 09:46:39 +00:00
zval * * argv [ 4 ] ;
1999-04-21 23:11:20 +00:00
int argc ;
int sockfd ;
int port = 0 ;
char * host = NULL ;
char * userdata = NULL ;
char * server_string = NULL ;
char * username = NULL ;
char * password = NULL ;
char * hashed_details ;
char * str = NULL ;
1999-08-05 16:25:10 +00:00
char buffer [ BUFFERLEN ] ;
1999-04-21 23:11:20 +00:00
int hashed_details_length ;
hw_connection * ptr ;
int do_swap ;
int version = 0 ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
switch ( argc ) {
case 2 :
case 4 :
2000-06-30 09:46:39 +00:00
if ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
break ;
default :
WRONG_PARAM_COUNT ;
}
/* Host: */
2000-06-30 09:46:39 +00:00
convert_to_string_ex ( argv [ 0 ] ) ;
2001-09-25 22:49:04 +00:00
host = ( char * ) estrndup ( Z_STRVAL_PP ( argv [ 0 ] ) , Z_STRLEN_PP ( argv [ 0 ] ) ) ;
1999-04-21 23:11:20 +00:00
/* Port: */
2000-06-30 09:46:39 +00:00
convert_to_long_ex ( argv [ 1 ] ) ;
2001-09-25 22:49:04 +00:00
port = Z_LVAL_PP ( argv [ 1 ] ) ;
1999-04-21 23:11:20 +00:00
/* Username and Password */
if ( argc > 2 ) {
/* Username */
2000-06-30 09:46:39 +00:00
convert_to_string_ex ( argv [ 2 ] ) ;
2001-09-25 22:49:04 +00:00
username = ( char * ) estrndup ( Z_STRVAL_PP ( argv [ 2 ] ) , Z_STRLEN_PP ( argv [ 2 ] ) ) ;
1999-04-21 23:11:20 +00:00
/* Password */
2000-06-30 09:46:39 +00:00
convert_to_string_ex ( argv [ 3 ] ) ;
2001-09-25 22:49:04 +00:00
password = ( char * ) estrndup ( Z_STRVAL_PP ( argv [ 3 ] ) , Z_STRLEN_PP ( argv [ 3 ] ) ) ;
1999-04-21 23:11:20 +00:00
}
/* Create identifier string for connection */
1999-08-05 16:25:10 +00:00
snprintf ( buffer , BUFFERLEN , " %d " , port ) ;
1999-04-21 23:11:20 +00:00
hashed_details_length = strlen ( host ) + strlen ( buffer ) + 8 ;
if ( NULL = = ( hashed_details = ( char * ) emalloc ( hashed_details_length + 1 ) ) ) {
if ( host ) efree ( host ) ;
if ( password ) efree ( password ) ;
if ( username ) efree ( username ) ;
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not get memory for connection details " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
1999-08-05 16:25:10 +00:00
sprintf ( hashed_details , " hw_%s_%d " , host , port ) ;
1999-04-21 23:11:20 +00:00
if ( persistent ) {
list_entry * le ;
/* try to find if we already have this link in our persistent list */
2000-02-08 09:47:55 +00:00
if ( zend_hash_find ( & EG ( persistent_list ) , hashed_details , hashed_details_length + 1 , ( void * * ) & le ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
list_entry new_le ;
1999-08-06 10:42:00 +00:00
if ( HwSG ( max_links ) ! = - 1 & & HwSG ( num_links ) > = HwSG ( max_links ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Too many open links (%d) " , get_active_function_name ( TSRMLS_C ) , HwSG ( num_links ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
1999-08-06 10:42:00 +00:00
if ( HwSG ( max_persistent ! = - 1 ) & & HwSG ( num_persistent ) > = HwSG ( max_persistent ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Too many open persistent links (%d) " , get_active_function_name ( TSRMLS_C ) , HwSG ( num_persistent ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( ( sockfd = open_hg_connection ( host , port ) ) < 0 ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not open connection to %s, Port: %d (retval=%d, errno=%d) " , get_active_function_name ( TSRMLS_C ) , host , port , sockfd , errno ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( NULL = = ( ptr = malloc ( sizeof ( hw_connection ) ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not get memory for connection structure " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( 0 ! = ( ptr - > lasterror = initialize_hg_connection ( sockfd , & do_swap , & version , & userdata , & server_string , username , password ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not initalize hyperwave connection " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
if ( userdata ) efree ( userdata ) ;
if ( server_string ) free ( server_string ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
ptr - > version = version ;
ptr - > server_string = server_string ;
ptr - > socket = sockfd ;
ptr - > swap_on = do_swap ;
ptr - > linkroot = 0 ;
ptr - > hostname = strdup ( host ) ;
ptr - > username = strdup ( " anonymous " ) ;
new_le . ptr = ( void * ) ptr ;
2001-09-25 21:58:48 +00:00
Z_TYPE ( new_le ) = le_psocketp ;
1999-04-21 23:11:20 +00:00
2001-08-11 16:39:07 +00:00
if ( zend_hash_update ( & EG ( persistent_list ) , hashed_details , hashed_details_length + 1 , ( void * ) & new_le , sizeof ( list_entry ) , NULL ) = = FAILURE ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not hash table with connection details " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
if ( server_string ) free ( server_string ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
1999-08-06 10:42:00 +00:00
HwSG ( num_links ) + + ;
HwSG ( num_persistent ) + + ;
1999-04-21 23:11:20 +00:00
} else {
1999-08-02 19:17:14 +00:00
/*php_printf("Found already open connection\n"); */
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( le ) ! = le_psocketp ) {
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
ptr = le - > ptr ;
}
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( ptr , le_psocketp ) ;
Z_TYPE_P ( return_value ) = IS_RESOURCE ;
1999-04-21 23:11:20 +00:00
} else {
2001-08-11 16:39:07 +00:00
list_entry * index_ptr , new_index_ptr ;
1999-04-21 23:11:20 +00:00
/* first we check the hash for the hashed_details key. if it exists,
* it should point us to the right offset where the actual hyperwave link sits .
* if it doesn ' t , open a new hyperwave link , add it to the resource list ,
* and add a pointer to it with hashed_details as the key .
*/
2001-08-11 16:39:07 +00:00
if ( zend_hash_find ( & EG ( regular_list ) , hashed_details , hashed_details_length + 1 , ( void * * ) & index_ptr ) = = SUCCESS ) {
int type , link ;
1999-04-21 23:11:20 +00:00
void * ptr ;
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( index_ptr ) ! = le_index_ptr ) {
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
link = ( int ) index_ptr - > ptr ;
2001-08-11 16:39:07 +00:00
ptr = ( hw_connection * ) zend_list_find ( link , & type ) ; /* check if the link is still there */
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = HwSG ( default_link ) = link ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
efree ( hashed_details ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
if ( host ) efree ( host ) ;
return ;
} else {
2001-08-11 16:39:07 +00:00
zend_hash_del ( & EG ( regular_list ) , hashed_details , hashed_details_length + 1 ) ;
1999-04-21 23:11:20 +00:00
}
}
if ( ( sockfd = open_hg_connection ( host , port ) ) < 0 ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not open connection to %s, Port: %d (retval=%d " , get_active_function_name ( TSRMLS_C ) , host , port , sockfd ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( NULL = = ( ptr = malloc ( sizeof ( hw_connection ) ) ) ) {
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( 0 ! = ( ptr - > lasterror = initialize_hg_connection ( sockfd , & do_swap , & version , & userdata , & server_string , username , password ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not initalize hyperwave connection " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
if ( userdata ) efree ( userdata ) ;
if ( server_string ) free ( server_string ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
if ( username ) efree ( username ) ;
if ( password ) efree ( password ) ;
ptr - > version = version ;
ptr - > server_string = server_string ;
ptr - > socket = sockfd ;
ptr - > swap_on = do_swap ;
ptr - > linkroot = 0 ;
ptr - > hostname = strdup ( host ) ;
ptr - > username = strdup ( " anonymous " ) ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( ptr , le_socketp ) ;
Z_TYPE_P ( return_value ) = IS_RESOURCE ;
1999-04-21 23:11:20 +00:00
2001-09-25 21:58:48 +00:00
new_index_ptr . ptr = ( void * ) Z_LVAL_P ( return_value ) ;
Z_TYPE ( new_index_ptr ) = le_index_ptr ;
2001-08-11 16:39:07 +00:00
if ( zend_hash_update ( & EG ( regular_list ) , hashed_details , hashed_details_length + 1 , ( void * ) & new_index_ptr , sizeof ( list_entry ) , NULL ) = = FAILURE ) {
2002-06-28 10:52:11 +00:00
php_error ( E_ERROR , " %s(): Could not update connection details in hash table " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
if ( host ) efree ( host ) ;
efree ( hashed_details ) ;
RETURN_FALSE ;
}
}
efree ( hashed_details ) ;
if ( host ) efree ( host ) ;
2001-09-25 21:58:48 +00:00
HwSG ( default_link ) = Z_LVAL_P ( return_value ) ;
1999-04-21 23:11:20 +00:00
/* At this point we have a working connection. If userdata was given
we are also indentified .
If there is no userdata because hw_connect was called without username
and password , we don ' t evaluate userdata .
*/
if ( NULL = = userdata )
return ;
if ( ptr - > username ) free ( ptr - > username ) ;
str = userdata ;
while ( ( * str ! = 0 ) & & ( * str ! = ' ' ) )
str + + ;
if ( * str ! = ' \0 ' )
ptr - > username = strdup ( + + str ) ;
else
ptr - > username = NULL ;
efree ( userdata ) ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-08-05 16:25:10 +00:00
# undef BUFFERLEN
1999-04-21 23:11:20 +00:00
/* Start of user level functions */
/* ***************************** */
/* {{{ proto int hw_connect(string host, int port [string username [, string password]])
Connect to the Hyperwave server */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_connect )
1999-04-21 23:11:20 +00:00
{
2001-08-11 16:39:07 +00:00
php_hw_do_connect ( INTERNAL_FUNCTION_PARAM_PASSTHRU , 0 ) ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
2000-06-18 16:31:52 +00:00
/* {{{ proto int hw_pconnect(string host, int port [, string username [, string password]])
1999-04-21 23:11:20 +00:00
Connect to the Hyperwave server persistent */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_pconnect )
1999-04-21 23:11:20 +00:00
{
2001-08-11 16:39:07 +00:00
php_hw_do_connect ( INTERNAL_FUNCTION_PARAM_PASSTHRU , 1 ) ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
/* {{{ proto void hw_close(int link)
Close connection to Hyperwave server */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_close )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
1999-12-17 19:51:39 +00:00
zend_list_delete ( id ) ;
1999-04-21 23:11:20 +00:00
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto void hw_info(int link)
Outputs info string */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_info )
1999-04-21 23:11:20 +00:00
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int id , type ;
hw_connection * ptr ;
char * str ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( NULL ! = ( str = get_hw_info ( ptr ) ) ) {
/*
1999-08-02 19:17:14 +00:00
php_printf ( " %s \n " , str ) ;
1999-04-21 23:11:20 +00:00
efree ( str ) ;
*/
2001-09-25 21:58:48 +00:00
Z_STRLEN_P ( return_value ) = strlen ( str ) ;
Z_STRVAL_P ( return_value ) = str ;
Z_TYPE_P ( return_value ) = IS_STRING ;
1999-04-21 23:11:20 +00:00
return ;
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto int hw_error(int link)
Returns last error number */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_error )
1999-04-21 23:11:20 +00:00
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
RETURN_LONG ( ptr - > lasterror ) ;
}
/* }}} */
/* {{{ proto string hw_errormsg(int link)
Returns last error message */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_errormsg )
1999-04-21 23:11:20 +00:00
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int id , type ;
hw_connection * ptr ;
char errstr [ 100 ] ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-05-18 08:07:09 +00:00
switch ( ptr - > lasterror ) {
1999-04-21 23:11:20 +00:00
case 0 :
sprintf ( errstr , " No error " ) ;
break ;
case NOACCESS :
2001-05-18 08:07:09 +00:00
sprintf ( errstr , " Access denied " ) ;
1999-04-21 23:11:20 +00:00
break ;
case NODOCS :
sprintf ( errstr , " No documents " ) ;
break ;
case NONAME :
sprintf ( errstr , " No collection name " ) ;
break ;
case NODOC :
sprintf ( errstr , " Object is not a document " ) ;
break ;
case NOOBJ :
sprintf ( errstr , " No object received " ) ;
break ;
case NOCOLLS :
sprintf ( errstr , " No collections received " ) ;
break ;
case DBSTUBNG :
sprintf ( errstr , " Connection to low-level database failed " ) ;
break ;
case NOTFOUND :
sprintf ( errstr , " Object not found " ) ;
break ;
case EXIST :
sprintf ( errstr , " Collection already exists " ) ;
break ;
case FATHERDEL :
sprintf ( errstr , " parent collection disappeared " ) ;
break ;
case FATHNOCOLL :
sprintf ( errstr , " parent collection not a collection " ) ;
break ;
case NOTEMPTY :
sprintf ( errstr , " Collection not empty " ) ;
break ;
case DESTNOCOLL :
sprintf ( errstr , " Destination not a collection " ) ;
break ;
case SRCEQDEST :
sprintf ( errstr , " Source equals destination " ) ;
break ;
case REQPEND :
sprintf ( errstr , " Request pending " ) ;
break ;
case TIMEOUT :
sprintf ( errstr , " Timeout " ) ;
break ;
case NAMENOTUNIQUE :
sprintf ( errstr , " Name not unique " ) ;
break ;
case WRITESTOPPED :
sprintf ( errstr , " Database now read-only; try again later " ) ;
break ;
case LOCKED :
sprintf ( errstr , " Object locked; try again later " ) ;
break ;
1999-08-05 16:25:10 +00:00
case CHANGEBASEFLD :
sprintf ( errstr , " Change of base-attribute " ) ;
break ;
2001-05-18 08:07:09 +00:00
case NOTREMOVED :
sprintf ( errstr , " Attribute not removed " ) ;
break ;
1999-08-05 16:25:10 +00:00
case FLDEXISTS :
sprintf ( errstr , " Attribute exists " ) ;
break ;
2001-05-18 08:07:09 +00:00
case CMDSYNTAX :
sprintf ( errstr , " Syntax error in command " ) ;
break ;
1999-08-05 16:25:10 +00:00
case NOLANGUAGE :
sprintf ( errstr , " No or unknown language specified " ) ;
break ;
2001-05-18 08:07:09 +00:00
case WRGTYPE :
sprintf ( errstr , " Wrong type in object " ) ;
break ;
case WRGVERSION :
sprintf ( errstr , " Client version too old " ) ;
break ;
case CONNECTION :
sprintf ( errstr , " No connection to other server " ) ;
break ;
case SYNC :
sprintf ( errstr , " Synchronization error " ) ;
break ;
case NOPATH :
sprintf ( errstr , " No path entry " ) ;
break ;
case WRGPATH :
sprintf ( errstr , " Wrong path entry " ) ;
break ;
case PASSWD :
sprintf ( errstr , " Wrong password (server-to-server server authentication) " ) ;
break ;
case LC_NO_MORE_USERS :
sprintf ( errstr , " No more users for license " ) ;
break ;
case LC_NO_MORE_DOCS :
sprintf ( errstr , " No more documents for this session and license " ) ;
break ;
case RSERV_NRESP :
sprintf ( errstr , " Remote server not responding " ) ;
break ;
case Q_OVERFLOW :
sprintf ( errstr , " Query overflow " ) ;
break ;
case USR_BREAK :
sprintf ( errstr , " Break by user " ) ;
break ;
case N_IMPL :
sprintf ( errstr , " Not implemented " ) ;
break ;
case WRG_VALUE :
sprintf ( errstr , " Wrong value " ) ;
break ;
case INSUFF_FUNDS :
sprintf ( errstr , " Insufficient funds " ) ;
break ;
case REORG :
sprintf ( errstr , " Reorganization in progress " ) ;
break ;
case USER_LIMIT :
sprintf ( errstr , " Limit of simultaneous users reached " ) ;
break ;
case FTCONNECT :
sprintf ( errstr , " No connection to fulltext server " ) ;
break ;
case FTTIMEOUT :
sprintf ( errstr , " Connection timed out " ) ;
break ;
case FTINDEX :
sprintf ( errstr , " Something wrong with fulltext index " ) ;
break ;
case FTSYNTAX :
sprintf ( errstr , " Query syntax error " ) ;
break ;
case REQUESTPENDING :
sprintf ( errstr , " Request pending " ) ;
break ;
case NOCONNECTION :
sprintf ( errstr , " No connection to document server " ) ;
break ;
case WRONGVERSION :
sprintf ( errstr , " Wrong protocol version " ) ;
break ;
case NOTINITIALIZED :
sprintf ( errstr , " Not initialized " ) ;
break ;
case BADREQUEST :
sprintf ( errstr , " Bad request " ) ;
break ;
case BADLRN :
sprintf ( errstr , " Bad document number " ) ;
break ;
case OPENSTORE_WRITE :
sprintf ( errstr , " Cannot write to local store " ) ;
break ;
case OPENSTORE_READ :
sprintf ( errstr , " Cannot read from local store " ) ;
break ;
case READSTORE :
sprintf ( errstr , " Store read error " ) ;
break ;
case WRITESTORE :
sprintf ( errstr , " Write error " ) ;
break ;
case CLOSESTORE :
sprintf ( errstr , " Close error " ) ;
break ;
case BADPATH :
sprintf ( errstr , " Bad path " ) ;
break ;
case NOPATHDC :
sprintf ( errstr , " No path " ) ;
break ;
case OPENFILE :
sprintf ( errstr , " Cannot open file " ) ;
break ;
case READFILE :
sprintf ( errstr , " Cannot read from file // same " ) ;
break ;
case WRITEFILE :
sprintf ( errstr , " Cannot write to file " ) ;
break ;
case CONNECTCLIENT :
sprintf ( errstr , " Could not connect to client " ) ;
break ;
case ACCEPT :
sprintf ( errstr , " Could not accept connection " ) ;
break ;
case READSOCKET :
sprintf ( errstr , " Could not read from socket " ) ;
break ;
case WRITESOCKET :
sprintf ( errstr , " Could not write to socket " ) ;
break ;
case TOOMUCHDATA :
sprintf ( errstr , " Received too much data " ) ;
break ;
case TOOFEWDATA :
sprintf ( errstr , " Received too few data // ... " ) ;
break ;
case NOTIMPLEMENTED :
sprintf ( errstr , " Not implemented " ) ;
break ;
case USERBREAK :
sprintf ( errstr , " User break " ) ;
break ;
case INTERNAL :
sprintf ( errstr , " Internal error " ) ;
break ;
case INVALIDOBJECT :
sprintf ( errstr , " Invalid object " ) ;
break ;
case JOBTIMEOUT :
sprintf ( errstr , " Job timed out " ) ;
break ;
case OPENPORT :
sprintf ( errstr , " Cannot open port // ... for several resons " ) ;
break ;
case NODATA :
sprintf ( errstr , " Received no data " ) ;
break ;
case NOPORT :
sprintf ( errstr , " No port to handle this request " ) ;
break ;
case NOTCACHED :
sprintf ( errstr , " Document not cached " ) ;
break ;
case BADCACHETYPE :
sprintf ( errstr , " Bad cache type " ) ;
break ;
case OPENCACHE_WRITE :
sprintf ( errstr , " Cannot write to cache " ) ;
break ;
case OPENCACHE_READ :
sprintf ( errstr , " Cannot read from cache // same " ) ;
break ;
case NOSOURCE :
sprintf ( errstr , " Do not know what to read " ) ;
break ;
case CLOSECACHE :
sprintf ( errstr , " Could not insert into cache " ) ;
break ;
case CONNECTREMOTE :
sprintf ( errstr , " Could not connect to remote server " ) ;
break ;
case LOCKREFUSED :
sprintf ( errstr , " Lock refused // could not lock the stores " ) ;
break ;
1999-04-21 23:11:20 +00:00
default :
sprintf ( errstr , " Unknown error: %d " , ptr - > lasterror ) ;
}
RETURN_STRING ( errstr , 1 ) ;
}
/* }}} */
1999-08-05 16:25:10 +00:00
/* {{{ proto int hw_root(void)
1999-04-21 23:11:20 +00:00
Returns object id of root collection */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_root )
1999-04-21 23:11:20 +00:00
{
2001-08-13 07:55:39 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 0 ) {
WRONG_PARAM_COUNT ;
}
2001-08-13 06:43:47 +00:00
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = 0 ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
2001-06-06 13:06:12 +00:00
/* {{{ php_hw_command
*/
1999-12-17 21:50:07 +00:00
char * php_hw_command ( INTERNAL_FUNCTION_PARAMETERS , int comm ) {
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int link , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
return NULL ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
return NULL ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
if ( 0 ! = ( ptr - > lasterror = send_command ( ptr - > socket , comm , & object ) ) )
return NULL ;
return object ;
}
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto string hw_stat(int link)
Returns status string */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_stat )
{
1999-04-21 23:11:20 +00:00
char * object ;
1999-12-17 21:50:07 +00:00
object = php_hw_command ( INTERNAL_FUNCTION_PARAM_PASSTHRU , STAT_COMMAND ) ;
1999-04-21 23:11:20 +00:00
if ( object = = NULL )
RETURN_FALSE ;
2001-09-25 21:58:48 +00:00
Z_STRVAL_P ( return_value ) = object ;
Z_STRLEN_P ( return_value ) = strlen ( object ) ;
Z_TYPE_P ( return_value ) = IS_STRING ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
/* {{{ proto array hw_who(int link)
Returns names and info of users loged in */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_who )
{
1999-08-06 10:42:00 +00:00
zval * user_arr ;
1999-04-21 23:11:20 +00:00
char * object , * ptr , * temp , * attrname ;
int i ;
1999-11-26 16:51:57 +00:00
char * strtok_buf ;
1999-04-21 23:11:20 +00:00
1999-12-17 21:50:07 +00:00
object = php_hw_command ( INTERNAL_FUNCTION_PARAM_PASSTHRU , WHO_COMMAND ) ;
1999-04-21 23:11:20 +00:00
if ( object = = NULL )
RETURN_FALSE ;
ptr = object ;
1999-08-05 16:25:10 +00:00
php_printf ( " %s \n " , ptr ) ;
/* Skip first two lines, they just contain:
Users in Database
*/
1999-04-21 23:11:20 +00:00
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' \n ' ) )
ptr + + ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' \n ' ) )
ptr + + ;
if ( * ptr = = ' \0 ' ) {
efree ( object ) ;
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( object ) ;
RETURN_FALSE ;
}
temp = estrdup ( ptr ) ;
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( temp , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
i = 0 ;
while ( attrname ! = NULL ) {
char * name ;
1999-12-26 21:21:33 +00:00
ALLOC_ZVAL ( user_arr ) ;
1999-08-06 10:42:00 +00:00
if ( array_init ( user_arr ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
efree ( object ) ;
RETURN_FALSE ;
}
ptr = attrname ;
1999-08-05 16:25:10 +00:00
if ( * ptr + + = = ' * ' )
1999-08-06 10:42:00 +00:00
add_assoc_long ( user_arr , " self " , 1 ) ;
1999-04-21 23:11:20 +00:00
else
1999-08-06 10:42:00 +00:00
add_assoc_long ( user_arr , " self " , 0 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " id " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " name " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr = = ' ' ) )
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " system " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr = = ' ' ) )
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " onSinceDate " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr = = ' ' ) )
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " onSinceTime " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
ptr + + ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr = = ' ' ) )
ptr + + ;
name = ptr ;
while ( ( * ptr ! = ' \0 ' ) & & ( * ptr ! = ' ' ) )
ptr + + ;
* ptr = ' \0 ' ;
1999-08-06 10:42:00 +00:00
add_assoc_string ( user_arr , " TotalTime " , name , 1 ) ;
1999-04-21 23:11:20 +00:00
/* Add the user array */
2001-09-25 21:58:48 +00:00
zend_hash_index_update ( Z_ARRVAL_P ( return_value ) , i + + , & user_arr , sizeof ( pval ) , NULL ) ;
1999-04-21 23:11:20 +00:00
2000-05-04 10:38:17 +00:00
attrname = php_strtok_r ( NULL , " \n " , & strtok_buf ) ;
1999-04-21 23:11:20 +00:00
}
efree ( temp ) ;
efree ( object ) ;
}
/* }}} */
1999-08-05 16:25:10 +00:00
/* {{{ proto string hw_dummy(int link, int id, int msgid)
2000-02-22 15:48:43 +00:00
Hyperwave dummy function */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_dummy )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-04-21 23:11:20 +00:00
int link , id , type , msgid ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
msgid = Z_LVAL_PP ( arg3 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
if ( 0 ! = ( ptr - > lasterror = send_dummy ( ptr - > socket , id , msgid , & object ) ) )
RETURN_FALSE ;
1999-08-02 19:17:14 +00:00
php_printf ( " %s " , object ) ;
2001-09-25 21:58:48 +00:00
Z_STRVAL_P ( return_value ) = object ;
Z_STRLEN_P ( return_value ) = strlen ( object ) ;
Z_TYPE_P ( return_value ) = IS_STRING ;
1999-04-21 23:11:20 +00:00
}
}
1999-08-05 16:25:10 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
2001-03-14 06:33:46 +00:00
/* {{{ proto string hw_getobject(int link, int objid [, string query])
2000-12-04 16:34:06 +00:00
Returns object record */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobject )
{
1999-12-15 19:10:54 +00:00
pval * * argv [ 3 ] ;
1999-08-05 16:25:10 +00:00
int argc , link , id , type , multi ;
2000-04-04 13:35:07 +00:00
char * query ;
1999-04-21 23:11:20 +00:00
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-08-05 16:25:10 +00:00
if ( argc < 2 | | argc > 3 )
WRONG_PARAM_COUNT ;
1999-12-18 22:40:35 +00:00
if ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE )
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
1999-08-05 16:25:10 +00:00
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( argv [ 0 ] ) ;
2001-09-25 22:49:04 +00:00
if ( Z_TYPE_PP ( argv [ 1 ] ) = = IS_ARRAY ) {
1999-08-05 16:25:10 +00:00
multi = 1 ;
1999-12-15 19:10:54 +00:00
convert_to_array_ex ( argv [ 1 ] ) ;
1999-08-05 16:25:10 +00:00
} else {
multi = 0 ;
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( argv [ 1 ] ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
if ( argc = = 3 ) {
1999-12-15 19:10:54 +00:00
convert_to_string_ex ( argv [ 2 ] ) ;
2001-09-25 22:49:04 +00:00
query = Z_STRVAL_PP ( argv [ 2 ] ) ;
2000-04-04 13:35:07 +00:00
} else
query = NULL ;
1999-08-05 16:25:10 +00:00
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( argv [ 0 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
1999-08-05 16:25:10 +00:00
if ( multi ) {
char * * objects = NULL ;
int count , * ids , i ;
HashTable * lht ;
1999-08-17 09:59:19 +00:00
zval * * keydata ;
1999-08-05 16:25:10 +00:00
2001-09-25 22:49:04 +00:00
lht = Z_ARRVAL_PP ( argv [ 1 ] ) ;
2001-03-14 06:33:46 +00:00
if ( 0 = = ( count = zend_hash_num_elements ( lht ) ) ) {
1999-08-05 16:25:10 +00:00
RETURN_FALSE ;
2001-03-14 06:33:46 +00:00
}
1999-08-05 16:25:10 +00:00
ids = emalloc ( count * sizeof ( hw_objectID ) ) ;
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
zend_hash_internal_pointer_reset ( lht ) ;
for ( i = 0 ; i < count ; i + + ) {
zend_hash_get_current_data ( lht , ( void * * ) & keydata ) ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_PP ( keydata ) ) {
1999-08-05 16:25:10 +00:00
case IS_LONG :
2001-09-25 21:58:48 +00:00
ids [ i ] = Z_LVAL_PP ( keydata ) ;
1999-08-05 16:25:10 +00:00
break ;
default :
2001-09-25 21:58:48 +00:00
ids [ i ] = Z_LVAL_PP ( keydata ) ;
1999-08-05 16:25:10 +00:00
}
zend_hash_move_forward ( lht ) ;
}
2000-04-04 13:35:07 +00:00
if ( 0 ! = ( ptr - > lasterror = send_objectbyidquery ( ptr - > socket , ids , & count , query , & objects ) ) ) {
1999-08-05 16:25:10 +00:00
efree ( ids ) ;
RETURN_FALSE ;
}
efree ( ids ) ;
if ( array_init ( return_value ) = = FAILURE ) {
efree ( objects ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + ) {
add_index_string ( return_value , i , objects [ i ] , 0 ) ;
}
efree ( objects ) ;
} else {
char * object = NULL ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_PP ( argv [ 1 ] ) ;
1999-08-05 16:25:10 +00:00
if ( 0 ! = ( ptr - > lasterror = send_getobject ( ptr - > socket , id , & object ) ) )
RETURN_FALSE ;
RETURN_STRING ( object , 0 ) ;
1999-04-21 23:11:20 +00:00
}
}
/* }}} */
/* {{{ proto int hw_insertobject(int link, string objrec, string parms)
Inserts an object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_insertobject )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 , * arg3 ;
int link , type ;
char * objrec , * parms ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_string ( arg2 ) ;
convert_to_string ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
objrec = Z_STRVAL_P ( arg2 ) ;
parms = Z_STRVAL_P ( arg3 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int objid ;
if ( 0 ! = ( ptr - > lasterror = send_insertobject ( ptr - > socket , objrec , parms , & objid ) ) )
RETURN_FALSE ;
RETURN_LONG ( objid ) ;
}
}
/* }}} */
/* {{{ proto string hw_getandlock(int link, int objid)
Returns object record and locks object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getandlock )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
if ( 0 ! = ( ptr - > lasterror = send_getandlock ( ptr - > socket , id , & object ) ) )
RETURN_FALSE ;
RETURN_STRING ( object , 0 ) ;
}
}
/* }}} */
/* {{{ proto void hw_unlock(int link, int objid)
Unlocks object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_unlock )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_unlock ( ptr - > socket , id ) ) )
RETURN_FALSE ;
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto void hw_deleteobject(int link, int objid)
Deletes object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_deleteobject )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_deleteobject ( ptr - > socket , id ) ) )
RETURN_FALSE ;
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto void hw_changeobject(int link, int objid, array attributes)
1999-08-05 16:25:10 +00:00
Changes attributes of an object ( obsolete ) */
# define BUFFERLEN 200
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_changeobject )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 , * arg3 ;
int link , id , type , i ;
hw_connection * ptr ;
1999-08-05 16:25:10 +00:00
char * modification , * oldobjrec , buf [ BUFFERLEN ] ;
1999-04-21 23:11:20 +00:00
HashTable * newobjarr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ; /* Connection */
convert_to_long ( arg2 ) ; /* object ID */
convert_to_array ( arg3 ) ; /* Array with new attributes */
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
newobjarr = Z_ARRVAL_P ( arg3 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* get the old object record */
1999-08-05 16:25:10 +00:00
if ( 0 ! = ( ptr - > lasterror = send_getandlock ( ptr - > socket , id , & oldobjrec ) ) )
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
1999-08-02 19:17:14 +00:00
zend_hash_internal_pointer_reset ( newobjarr ) ;
1999-04-21 23:11:20 +00:00
modification = strdup ( " " ) ;
1999-08-02 19:17:14 +00:00
for ( i = 0 ; i < zend_hash_num_elements ( newobjarr ) ; i + + ) {
1999-08-05 16:25:10 +00:00
char * key , * str , * str1 , newattribute [ BUFFERLEN ] ;
1999-08-17 09:59:19 +00:00
pval * data , * * dataptr ;
1999-04-21 23:11:20 +00:00
int j , noinsert = 1 ;
ulong ind ;
2000-12-22 12:57:09 +00:00
zend_hash_get_current_key ( newobjarr , & key , & ind , 0 ) ;
1999-08-17 09:59:19 +00:00
zend_hash_get_current_data ( newobjarr , ( void * ) & dataptr ) ;
data = * dataptr ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( data ) ) {
1999-04-21 23:11:20 +00:00
case IS_STRING :
2001-09-25 21:58:48 +00:00
if ( strlen ( Z_STRVAL_P ( data ) ) = = 0 )
1999-08-05 16:25:10 +00:00
snprintf ( newattribute , BUFFERLEN , " rem %s " , key ) ;
1999-04-21 23:11:20 +00:00
else
2001-09-25 21:58:48 +00:00
snprintf ( newattribute , BUFFERLEN , " add %s=%s " , key , Z_STRVAL_P ( data ) ) ;
1999-08-05 16:25:10 +00:00
noinsert = 0 ;
1999-04-21 23:11:20 +00:00
break ;
default :
1999-08-05 16:25:10 +00:00
newattribute [ 0 ] = ' \0 ' ;
1999-04-21 23:11:20 +00:00
}
if ( ! noinsert ) {
modification = fnInsStr ( modification , 0 , " \\ " ) ;
modification = fnInsStr ( modification , 0 , newattribute ) ;
1999-08-05 16:25:10 +00:00
/* modification = fnInsStr(modification, 0, "add "); */
1999-04-21 23:11:20 +00:00
/* Retrieve the old attribute from object record */
if ( NULL ! = ( str = strstr ( oldobjrec , key ) ) ) {
str1 = str ;
j = 0 ;
1999-08-05 16:25:10 +00:00
while ( ( str1 ! = NULL ) & & ( * str1 ! = ' \n ' ) & & ( j < BUFFERLEN - 1 ) ) {
1999-04-21 23:11:20 +00:00
buf [ j + + ] = * str1 + + ;
}
buf [ j ] = ' \0 ' ;
modification = fnInsStr ( modification , 0 , " \\ " ) ;
modification = fnInsStr ( modification , 0 , buf ) ;
modification = fnInsStr ( modification , 0 , " rem " ) ;
}
}
1999-08-02 19:17:14 +00:00
zend_hash_move_forward ( newobjarr ) ;
1999-04-21 23:11:20 +00:00
}
efree ( oldobjrec ) ;
set_swap ( ptr - > swap_on ) ;
modification [ strlen ( modification ) - 1 ] = ' \0 ' ;
1999-08-05 16:25:10 +00:00
if ( 0 ! = ( ptr - > lasterror = send_changeobject ( ptr - > socket , id , modification ) ) ) {
free ( modification ) ;
send_unlock ( ptr - > socket , id ) ;
RETURN_FALSE ;
}
free ( modification ) ;
if ( 0 ! = ( ptr - > lasterror = send_unlock ( ptr - > socket , id ) ) ) {
RETURN_FALSE ;
}
RETURN_TRUE ;
}
# undef BUFFERLEN
/* }}} */
2000-06-12 13:33:49 +00:00
/* {{{ proto void hw_modifyobject(int link, int objid, array remattributes, array addattributes [, int mode])
1999-08-05 16:25:10 +00:00
Modifies attributes of an object */
# define BUFFERLEN 200
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_modifyobject )
{
2000-06-30 09:46:39 +00:00
zval * * argv [ 5 ] ;
1999-08-05 16:25:10 +00:00
int argc ;
int link , id , type , i , mode ;
hw_connection * ptr ;
char * modification ;
HashTable * remobjarr , * addobjarr ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-08-05 16:25:10 +00:00
if ( ( argc > 5 ) | | ( argc < 4 ) )
WRONG_PARAM_COUNT ;
2000-06-30 09:46:39 +00:00
if ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE )
1999-08-05 16:25:10 +00:00
if ( argc < 4 ) {
WRONG_PARAM_COUNT ;
}
2000-06-30 09:46:39 +00:00
convert_to_long_ex ( argv [ 0 ] ) ; /* Connection */
convert_to_long_ex ( argv [ 1 ] ) ; /* object ID */
convert_to_array_ex ( argv [ 2 ] ) ; /* Array with attributes to remove */
convert_to_array_ex ( argv [ 3 ] ) ; /* Array with attributes to add */
1999-08-05 16:25:10 +00:00
if ( argc = = 5 ) {
2000-06-30 09:46:39 +00:00
convert_to_long_ex ( argv [ 4 ] ) ;
2001-09-25 22:49:04 +00:00
mode = Z_LVAL_PP ( argv [ 4 ] ) ;
1999-08-05 16:25:10 +00:00
} else
mode = 0 ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( argv [ 0 ] ) ;
id = Z_LVAL_PP ( argv [ 1 ] ) ;
remobjarr = Z_ARRVAL_PP ( argv [ 2 ] ) ;
addobjarr = Z_ARRVAL_PP ( argv [ 3 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
modification = strdup ( " " ) ;
if ( addobjarr ! = NULL ) {
zend_hash_internal_pointer_reset ( addobjarr ) ;
for ( i = 0 ; i < zend_hash_num_elements ( addobjarr ) ; i + + ) {
char * key , addattribute [ BUFFERLEN ] ;
1999-08-17 09:59:19 +00:00
zval * data , * * dataptr ;
1999-08-05 16:25:10 +00:00
int noinsert = 1 ;
ulong ind ;
2000-12-22 12:57:09 +00:00
zend_hash_get_current_key ( addobjarr , & key , & ind , 0 ) ;
1999-08-17 09:59:19 +00:00
zend_hash_get_current_data ( addobjarr , ( void * ) & dataptr ) ;
data = * dataptr ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( data ) ) {
1999-08-05 16:25:10 +00:00
case IS_STRING :
2001-09-25 21:58:48 +00:00
if ( strlen ( Z_STRVAL_P ( data ) ) > 0 ) {
snprintf ( addattribute , BUFFERLEN , " add %s=%s " , key , Z_STRVAL_P ( data ) ) ;
1999-08-05 16:25:10 +00:00
/* fprintf(stderr, "add: %s\n", addattribute); */
noinsert = 0 ;
}
break ;
case IS_ARRAY : {
int i , len , keylen , count ;
char * strarr , * ptr , * ptr1 ;
2001-09-25 21:58:48 +00:00
count = zend_hash_num_elements ( Z_ARRVAL_P ( data ) ) ;
1999-08-05 16:25:10 +00:00
if ( count > 0 ) {
2002-09-30 09:27:56 +00:00
strarr = make_objrec_from_array ( Z_ARRVAL_P ( data ) , ' : ' ) ;
1999-08-05 16:25:10 +00:00
len = strlen ( strarr ) - 1 ;
keylen = strlen ( key ) ;
if ( NULL = = ( ptr = malloc ( len + 1 + count * ( keylen + 1 + 4 ) ) ) ) {
if ( modification )
free ( modification ) ;
RETURN_FALSE ;
}
ptr1 = ptr ;
* ptr1 = ' \0 ' ;
strcpy ( ptr1 , " add " ) ;
ptr1 + = 4 ;
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
for ( i = 0 ; i < len ; i + + ) {
* ptr1 + + = strarr [ i ] ;
if ( strarr [ i ] = = ' \n ' ) {
ptr1 [ - 1 ] = ' \\ ' ;
strcpy ( ptr1 , " add " ) ;
ptr1 + = 4 ;
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
2002-09-30 09:27:56 +00:00
} /* else if(strarr[i] == '=')
ptr1 [ - 1 ] = ' : ' ; */
1999-08-05 16:25:10 +00:00
}
* ptr1 = ' \0 ' ;
1999-09-15 05:42:36 +00:00
strlcpy ( addattribute , ptr , sizeof ( addattribute ) ) ;
1999-08-05 16:25:10 +00:00
noinsert = 0 ;
}
break ;
}
}
if ( ! noinsert ) {
modification = fnInsStr ( modification , 0 , " \\ " ) ;
modification = fnInsStr ( modification , 0 , addattribute ) ;
}
zend_hash_move_forward ( addobjarr ) ;
}
}
if ( remobjarr ! = NULL ) {
int nr ;
zend_hash_internal_pointer_reset ( remobjarr ) ;
nr = zend_hash_num_elements ( remobjarr ) ;
for ( i = 0 ; i < nr ; i + + ) {
char * key , remattribute [ BUFFERLEN ] ;
1999-08-17 09:59:19 +00:00
zval * data , * * dataptr ;
1999-08-05 16:25:10 +00:00
int noinsert = 1 ;
ulong ind ;
2000-12-22 12:57:09 +00:00
zend_hash_get_current_key ( remobjarr , & key , & ind , 0 ) ;
1999-08-17 09:59:19 +00:00
zend_hash_get_current_data ( remobjarr , ( void * ) & dataptr ) ;
data = * dataptr ;
2001-09-25 21:58:48 +00:00
switch ( Z_TYPE_P ( data ) ) {
1999-08-05 16:25:10 +00:00
case IS_STRING :
2001-09-25 21:58:48 +00:00
if ( strlen ( Z_STRVAL_P ( data ) ) > 0 ) {
snprintf ( remattribute , BUFFERLEN , " rem %s=%s " , key , Z_STRVAL_P ( data ) ) ;
1999-08-05 16:25:10 +00:00
noinsert = 0 ;
} else {
snprintf ( remattribute , BUFFERLEN , " rem %s " , key ) ;
noinsert = 0 ;
}
break ;
case IS_ARRAY : {
int i , len , keylen , count ;
char * strarr , * ptr , * ptr1 ;
2001-09-25 21:58:48 +00:00
count = zend_hash_num_elements ( Z_ARRVAL_P ( data ) ) ;
1999-08-05 16:25:10 +00:00
if ( count > 0 ) {
2002-09-30 09:27:56 +00:00
strarr = make_objrec_from_array ( Z_ARRVAL_P ( data ) , ' : ' ) ;
1999-08-05 16:25:10 +00:00
len = strlen ( strarr ) - 1 ;
keylen = strlen ( key ) ;
if ( NULL = = ( ptr = malloc ( len + 1 + count * ( keylen + 1 + 4 ) ) ) ) {
if ( modification )
free ( modification ) ;
RETURN_FALSE ;
}
ptr1 = ptr ;
* ptr1 = ' \0 ' ;
strcpy ( ptr1 , " rem " ) ;
ptr1 + = 4 ;
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
for ( i = 0 ; i < len ; i + + ) {
* ptr1 + + = strarr [ i ] ;
if ( strarr [ i ] = = ' \n ' ) {
ptr1 [ - 1 ] = ' \\ ' ;
strcpy ( ptr1 , " rem " ) ;
ptr1 + = 4 ;
strcpy ( ptr1 , key ) ;
ptr1 + = keylen ;
* ptr1 + + = ' = ' ;
2002-09-30 09:27:56 +00:00
} /* else if(strarr[i] == '=')
ptr1 [ - 1 ] = ' : ' ; */
1999-08-05 16:25:10 +00:00
}
* ptr1 + + = ' \n ' ;
* ptr1 = ' \0 ' ;
1999-09-15 05:42:36 +00:00
strlcpy ( remattribute , ptr , sizeof ( remattribute ) ) ;
1999-08-05 16:25:10 +00:00
noinsert = 0 ;
}
break ;
}
}
if ( ! noinsert ) {
modification = fnInsStr ( modification , 0 , " \\ " ) ;
modification = fnInsStr ( modification , 0 , remattribute ) ;
}
zend_hash_move_forward ( remobjarr ) ;
}
}
set_swap ( ptr - > swap_on ) ;
modification [ strlen ( modification ) - 1 ] = ' \0 ' ;
if ( strlen ( modification ) = = 0 ) {
ptr - > lasterror = 0 ;
free ( modification ) ;
RETURN_TRUE ;
}
1999-09-01 06:15:46 +00:00
/* fprintf(stderr, "modifyobject: %s\n", modification); */
1999-08-05 16:25:10 +00:00
switch ( mode ) {
case 0 :
if ( 0 = = ( ptr - > lasterror = send_lock ( ptr - > socket , id ) ) ) {
if ( 0 = = ( ptr - > lasterror = send_changeobject ( ptr - > socket , id , modification ) ) ) {
if ( 0 ! = ( ptr - > lasterror = send_unlock ( ptr - > socket , id ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Aiii, Changeobject failed and couldn't unlock object (id = 0x%X) " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-08-05 16:25:10 +00:00
free ( modification ) ;
RETURN_FALSE ;
}
free ( modification ) ;
RETURN_FALSE ;
} else {
send_unlock ( ptr - > socket , id ) ;
free ( modification ) ;
RETURN_FALSE ;
}
} else {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Could not lock object (id = 0x%X) " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-08-05 16:25:10 +00:00
free ( modification ) ;
RETURN_FALSE ;
}
break ;
case 1 :
/* WARNING: send_groupchangobject() only works right, if each attribute
can be modified . Doing a changeobject recursively often tries to
modify objects which cannot be modified e . g . because an attribute cannot
be removed . In such a case no further modification on that object is done .
Doing a ' rem Rights \ add Rights = R : a ' will fail completely if the attribute
Rights is not there already . The object locking is done in send_groupchangeobject ( ) ;
*/
if ( 0 ! = ( ptr - > lasterror = send_groupchangeobject ( ptr - > socket , id , modification ) ) ) {
free ( modification ) ;
RETURN_FALSE ;
}
break ;
default :
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Mode must be 0 or 1 (recursive) " , get_active_function_name ( TSRMLS_C ) ) ;
1999-08-05 16:25:10 +00:00
}
1999-04-21 23:11:20 +00:00
free ( modification ) ;
RETURN_TRUE ;
}
1999-08-05 16:25:10 +00:00
# undef BUFFERLEN
1999-04-21 23:11:20 +00:00
/* }}} */
2001-06-06 13:06:12 +00:00
/* {{{ php_hw_mvcp
*/
1999-12-17 21:50:07 +00:00
void php_hw_mvcp ( INTERNAL_FUNCTION_PARAMETERS , int mvcp ) {
1999-08-19 15:03:15 +00:00
pval * arg1 , * arg2 , * arg3 , * arg4 ;
int link , type , dest = 0 , from = 0 , count ;
1999-04-21 23:11:20 +00:00
HashTable * src_arr ;
hw_connection * ptr ;
int collIDcount , docIDcount , i , * docIDs , * collIDs ;
switch ( mvcp ) {
case MOVE : /* Move also has fromID */
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | getParameters ( ht , 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE )
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
break ;
case COPY :
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE )
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
break ;
}
convert_to_long ( arg1 ) ;
convert_to_array ( arg2 ) ;
convert_to_long ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
src_arr = Z_ARRVAL_P ( arg2 ) ;
1999-04-21 23:11:20 +00:00
switch ( mvcp ) {
case MOVE : /* Move also has fromID, which is arg3 --> arg4 becomes destID */
convert_to_long ( arg4 ) ;
2001-09-25 22:49:04 +00:00
from = Z_LVAL_P ( arg3 ) ;
dest = Z_LVAL_P ( arg4 ) ;
1999-04-21 23:11:20 +00:00
break ;
case COPY : /* No fromID for Copy needed --> arg3 is destID */
2001-09-25 22:49:04 +00:00
dest = Z_LVAL_P ( arg3 ) ;
1999-04-21 23:11:20 +00:00
from = 0 ;
break ;
}
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
1999-08-19 15:03:15 +00:00
count = zend_hash_num_elements ( src_arr ) ;
if ( NULL = = ( collIDs = emalloc ( count * sizeof ( int ) ) ) ) {
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
1999-08-19 15:03:15 +00:00
if ( NULL = = ( docIDs = emalloc ( count * sizeof ( int ) ) ) ) {
1999-04-21 23:11:20 +00:00
efree ( collIDs ) ;
RETURN_FALSE ;
}
collIDcount = docIDcount = 0 ;
1999-08-19 15:03:15 +00:00
zend_hash_internal_pointer_reset ( src_arr ) ;
for ( i = 0 ; i < count ; i + + ) {
1999-04-21 23:11:20 +00:00
char * objrec ;
1999-08-19 15:03:15 +00:00
zval * keydata , * * keydataptr ;
zend_hash_get_current_data ( src_arr , ( void * * ) & keydataptr ) ;
keydata = * keydataptr ;
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( keydata ) = = IS_LONG ) {
if ( 0 ! = ( ptr - > lasterror = send_getobject ( ptr - > socket , Z_LVAL_P ( keydata ) , & objrec ) ) ) {
1999-04-21 23:11:20 +00:00
efree ( collIDs ) ;
efree ( docIDs ) ;
RETURN_FALSE ;
}
if ( 0 = = fnAttributeCompare ( objrec , " DocumentType " , " collection " ) )
2001-09-25 21:58:48 +00:00
collIDs [ collIDcount + + ] = Z_LVAL_P ( keydata ) ;
1999-04-21 23:11:20 +00:00
else
2001-09-25 21:58:48 +00:00
docIDs [ docIDcount + + ] = Z_LVAL_P ( keydata ) ;
1999-04-21 23:11:20 +00:00
efree ( objrec ) ;
}
1999-08-19 15:03:15 +00:00
zend_hash_move_forward ( src_arr ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-19 15:03:15 +00:00
1999-04-21 23:11:20 +00:00
if ( 0 ! = ( ptr - > lasterror = send_mvcpdocscoll ( ptr - > socket , docIDs , docIDcount , from , dest , mvcp ) ) ) {
efree ( collIDs ) ;
efree ( docIDs ) ;
RETURN_FALSE ;
}
if ( 0 ! = ( ptr - > lasterror = send_mvcpcollscoll ( ptr - > socket , collIDs , collIDcount , from , dest , mvcp ) ) ) {
efree ( collIDs ) ;
efree ( docIDs ) ;
RETURN_FALSE ;
}
efree ( collIDs ) ;
efree ( docIDs ) ;
RETURN_LONG ( docIDcount + collIDcount ) ;
}
2001-06-06 13:06:12 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto void hw_mv(int link, array objrec, int from, int dest)
Moves object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_mv )
{
1999-12-17 21:50:07 +00:00
php_hw_mvcp ( INTERNAL_FUNCTION_PARAM_PASSTHRU , MOVE ) ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
/* {{{ proto void hw_cp(int link, array objrec, int dest)
Copies object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_cp )
{
1999-12-17 21:50:07 +00:00
php_hw_mvcp ( INTERNAL_FUNCTION_PARAM_PASSTHRU , COPY ) ;
1999-04-21 23:11:20 +00:00
}
/* }}} */
2000-06-12 13:33:49 +00:00
/* {{{ proto hwdoc hw_gettext(int link, int objid [, int rootid])
1999-04-21 23:11:20 +00:00
Returns text document . Links are relative to rootid if given */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_gettext )
{
1999-04-21 23:11:20 +00:00
pval * argv [ 3 ] ;
int argc , link , id , type , mode ;
int rootid = 0 ;
1999-08-05 16:25:10 +00:00
char * urlprefix ;
1999-04-21 23:11:20 +00:00
hw_document * doc ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
if ( ( argc > 3 ) | | ( argc < 2 ) )
WRONG_PARAM_COUNT ;
if ( getParametersArray ( ht , argc , argv ) = = FAILURE )
RETURN_FALSE ;
convert_to_long ( argv [ 0 ] ) ;
convert_to_long ( argv [ 1 ] ) ;
1999-08-05 16:25:10 +00:00
mode = 0 ;
urlprefix = NULL ;
1999-04-21 23:11:20 +00:00
if ( argc = = 3 ) {
2001-09-25 22:49:04 +00:00
switch ( Z_TYPE_P ( argv [ 2 ] ) ) {
1999-08-05 16:25:10 +00:00
case IS_LONG :
convert_to_long ( argv [ 2 ] ) ;
2001-09-25 22:49:04 +00:00
rootid = Z_LVAL_P ( argv [ 2 ] ) ;
1999-08-05 16:25:10 +00:00
mode = 1 ;
break ;
case IS_STRING :
convert_to_string ( argv [ 2 ] ) ;
2001-09-25 22:49:04 +00:00
urlprefix = Z_STRVAL_P ( argv [ 2 ] ) ;
1999-08-05 16:25:10 +00:00
break ;
}
}
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( argv [ 0 ] ) ;
id = Z_LVAL_P ( argv [ 1 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
char * bodytag = NULL ;
int count ;
/* !!!! memory for object and attributes is allocated with malloc !!!! */
1999-08-05 16:25:10 +00:00
if ( 0 ! = ( ptr - > lasterror = send_gettext ( ptr - > socket , id , mode , rootid , & attributes , & bodytag , & object , & count , urlprefix ) ) )
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = bodytag ;
doc - > size = count ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
}
/* }}} */
/* {{{ proto void hw_edittext(int link, hwdoc doc)
Modifies text document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_edittext )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
1999-08-05 16:25:10 +00:00
int link , doc , type ;
1999-04-21 23:11:20 +00:00
hw_connection * ptr ;
hw_document * docptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
1999-04-21 23:11:20 +00:00
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find socket identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-09-25 22:49:04 +00:00
doc = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
docptr = zend_list_find ( doc , & type ) ;
1999-04-21 23:11:20 +00:00
2001-02-20 20:45:55 +00:00
if ( ! docptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find document identifier %d " , get_active_function_name ( TSRMLS_C ) , doc ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
if ( 0 ! = ( ptr - > lasterror = send_edittext ( ptr - > socket , docptr - > attributes , docptr - > data ) ) ) {
RETURN_FALSE ;
}
}
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto hwdoc hw_getcgi(int link, int objid)
2000-06-12 13:33:49 +00:00
Returns the output of a CGI script */
1999-08-05 16:25:10 +00:00
# define BUFFERLEN 1000
/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getcgi )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_document * doc ;
hw_connection * ptr ;
1999-08-05 16:25:10 +00:00
char cgi_env_str [ BUFFERLEN ] ;
1999-04-21 23:11:20 +00:00
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
int count ;
/* Here is another undocument function of Hyperwave.
If you call a cgi script with getcgi - message , you will
have to provide the complete cgi enviroment , since it is
only known to the webserver ( or wavemaster ) . This is done
by extending the object record with the following incomplete
string . It should contain any enviroment variable a cgi script
requires .
*/
2000-06-15 23:45:05 +00:00
# ifdef PHP_WIN32
1999-08-05 16:25:10 +00:00
snprintf ( cgi_env_str , BUFFERLEN , " CGI_REQUEST_METHOD=%s \n CGI_PATH_INFO=%s \n CGI_QUERY_STRING=%s " ,
1999-04-21 23:11:20 +00:00
getenv ( " REQUEST_METHOD " ) ,
getenv ( " PATH_INFO " ) ,
getenv ( " QUERY_STRING " ) ) ;
# else
1999-08-05 16:25:10 +00:00
snprintf ( cgi_env_str , BUFFERLEN , " CGI_REQUEST_METHOD=%s \n CGI_PATH_INFO=%s \n CGI_QUERY_STRING=%s " ,
1999-05-09 08:48:05 +00:00
SG ( request_info ) . request_method ,
1999-05-02 19:54:02 +00:00
SG ( request_info ) . request_uri ,
1999-05-02 18:07:41 +00:00
SG ( request_info ) . query_string ) ;
1999-04-21 23:11:20 +00:00
# endif
/* !!!! memory for object and attributes is allocated with malloc !!!! */
if ( 0 ! = ( ptr - > lasterror = send_getcgi ( ptr - > socket , id , cgi_env_str , & attributes , & object , & count ) ) )
RETURN_FALSE ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = NULL ;
doc - > size = count ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
}
1999-08-05 16:25:10 +00:00
# undef BUFFERLEN
1999-04-21 23:11:20 +00:00
/* }}} */
1999-08-05 16:25:10 +00:00
/* {{{ proto int hw_getremote(int link, int objid)
Returns the content of a remote document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getremote )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_document * doc ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
int count ;
/* !!!! memory for object and attributes is allocated with malloc !!!! */
if ( 0 ! = ( ptr - > lasterror = send_getremote ( ptr - > socket , id , & attributes , & object , & count ) ) )
RETURN_FALSE ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = NULL ;
doc - > size = count ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
}
/* }}} */
1999-08-05 16:25:10 +00:00
/* {{{ proto [array|int] hw_getremotechildren(int link, string objrec)
Returns the remote document or an array of object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getremotechildren )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , type , i ;
hw_connection * ptr ;
char * objrec ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_string ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
objrec = Z_STRVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int count , * offsets ;
char * remainder , * ptr1 ;
if ( 0 ! = ( ptr - > lasterror = send_getremotechildren ( ptr - > socket , objrec , & remainder , & offsets , & count ) ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
/*
for ( i = 0 ; i < count ; i + + )
php_printf ( " offset[%d] = %d-- \n " , i , offsets [ i ] ) ;
php_printf ( " count = %d, remainder = <HR>%s---<HR> " , count , remainder ) ;
*/
/* The remainder depends on the number of returned objects and
whether the MimeType of the object to retrieve is set . If
the MimeType is set the result will start with the
HTTP header ' Content - type : mimetype ' , otherwise it will be
a list of object records and therefore starts with
' ObjectID = 0 ' . In the first case the offset and count are somewhat
strange . Quite often count had a value of 6 which appears to be
meaningless , but if you sum up the offsets you get the length
of the remainder which is the lenght of the document .
The document must have been chopped up into 6 pieces , each ending
with ' ServerId = 0 xYYYYYYYY ' .
In the second case the offset contains the lenght of
each object record ; count contains the number of object records .
Even if a remote object has children
( several sql statements ) but the MimeType is set , it will
return a document in the format of MimeType . On the other
hand a remote object does not have any children but just
returns a docuement will not be shown unless the MimeType
is set . It returns the pure object record of the object without
the SQLStatement attribute . Quite senseless .
Though , this behavior depends on how the hgi gateway in Hyperwave
is implemented .
*/
1999-04-21 23:11:20 +00:00
if ( strncmp ( remainder , " ObjectID=0 " , 10 ) ) {
hw_document * doc ;
1999-08-05 16:25:10 +00:00
char * ptr ;
int i , j , len ;
/* For some reason there is always the string
' SeverId = 0 xYYYYYYYY ' at the end , so we cut it off .
The document may as well be divided into several pieces
and each of them has the ServerId at the end .
The following will put the pieces back together and
strip the ServerId . count contains the number of pieces .
*/
for ( i = 0 , len = 0 ; i < count ; i + + )
len + = offsets [ i ] - 18 ;
2001-08-11 16:39:07 +00:00
/*fprintf(stderr, "len = %d\n", len); */
1999-04-21 23:11:20 +00:00
doc = malloc ( sizeof ( hw_document ) ) ;
1999-08-05 16:25:10 +00:00
doc - > data = malloc ( len + 1 ) ;
ptr = doc - > data ;
for ( i = 0 , j = 0 ; i < count ; i + + ) {
memcpy ( ( char * ) ptr , ( char * ) & remainder [ j ] , offsets [ i ] - 18 ) ;
2001-08-11 16:39:07 +00:00
/*fprintf(stderr, "rem = %s\n", &remainder[j]); */
1999-08-05 16:25:10 +00:00
j + = offsets [ i ] ;
ptr + = offsets [ i ] - 18 ;
}
* ptr = ' \0 ' ;
1999-04-21 23:11:20 +00:00
doc - > attributes = strdup ( objrec ) ;
doc - > bodytag = NULL ;
1999-08-05 16:25:10 +00:00
doc - > size = strlen ( doc - > data ) ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
} else {
if ( array_init ( return_value ) = = FAILURE ) {
efree ( offsets ) ;
RETURN_FALSE ;
}
ptr1 = remainder ;
for ( i = 0 ; i < count ; i + + ) {
* ( ptr1 + offsets [ i ] - 1 ) = ' \0 ' ;
add_index_string ( return_value , i , ptr1 , 1 ) ;
ptr1 + = offsets [ i ] ;
}
}
efree ( offsets ) ;
efree ( remainder ) ;
}
}
/* }}} */
/* {{{ proto void hw_setlinkroot(int link, int rootid)
Set the id to which links are calculated */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_setlinkroot )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , type , rootid ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
rootid = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
ptr - > linkroot = rootid ;
RETURN_LONG ( rootid ) ;
}
/* }}} */
2001-01-26 21:22:33 +00:00
/* {{{ proto hwdoc hw_pipedocument(int link, int objid [, array urlprefixes])
Returns document with links inserted . Optionally a array with five urlprefixes may be passed , which will be inserted for the different types of anchors . This should be a named array with the following keys : HW_DEFAULT_LINK , HW_IMAGE_LINK , HW_BACKGROUND_LINK , HW_INTAG_LINK , and HW_APPLET_LINK */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_pipedocument )
{
2000-11-23 14:44:10 +00:00
pval * arg1 , * arg2 , * arg3 ;
int i , link , id , type , argc , mode ;
int rootid = 0 ;
HashTable * prefixarray ;
char * * urlprefix ;
hw_connection * ptr ;
hw_document * doc ;
# if APACHE
server_rec * serv = ( ( request_rec * ) SG ( server_context ) ) - > server ;
# endif
argc = ZEND_NUM_ARGS ( ) ;
switch ( argc )
{
case 2 :
if ( getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE )
2000-12-12 12:28:26 +00:00
WRONG_PARAM_COUNT ;
2000-11-23 14:44:10 +00:00
break ;
case 3 :
if ( getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE )
2000-12-12 12:28:26 +00:00
WRONG_PARAM_COUNT ;
2000-11-23 14:44:10 +00:00
break ;
default :
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
2000-11-23 14:44:10 +00:00
RETURN_FALSE ;
}
/* check for the array with urlprefixes */
if ( argc = = 3 ) {
convert_to_array ( arg3 ) ;
2001-09-25 22:49:04 +00:00
prefixarray = Z_ARRVAL_P ( arg3 ) ;
2000-11-23 14:44:10 +00:00
if ( ( prefixarray = = NULL ) | | ( zend_hash_num_elements ( prefixarray ) ! = 5 ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): You must provide 5 urlprefixes (you have provided %d) " , get_active_function_name ( TSRMLS_C ) , zend_hash_num_elements ( prefixarray ) ) ;
2000-11-23 14:44:10 +00:00
RETURN_FALSE ;
}
urlprefix = emalloc ( 5 * sizeof ( char * ) ) ;
zend_hash_internal_pointer_reset ( prefixarray ) ;
for ( i = 0 ; i < 5 ; i + + ) {
char * key ;
zval * data , * * dataptr ;
ulong ind ;
2000-12-22 12:57:09 +00:00
zend_hash_get_current_key ( prefixarray , & key , & ind , 0 ) ;
2000-11-23 14:44:10 +00:00
zend_hash_get_current_data ( prefixarray , ( void * ) & dataptr ) ;
data = * dataptr ;
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( data ) ! = IS_STRING ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): %s must be a String " , get_active_function_name ( TSRMLS_C ) , key ) ;
2000-11-23 14:44:10 +00:00
RETURN_FALSE ;
} else if ( strcmp ( key , " HW_DEFAULT_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_DEFAULT_LINK ] = Z_STRVAL_P ( data ) ;
2000-11-23 14:44:10 +00:00
} else if ( strcmp ( key , " HW_IMAGE_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_IMAGE_LINK ] = Z_STRVAL_P ( data ) ;
2000-11-23 14:44:10 +00:00
} else if ( strcmp ( key , " HW_BACKGROUND_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_BACKGROUND_LINK ] = Z_STRVAL_P ( data ) ;
2000-11-23 14:44:10 +00:00
} else if ( strcmp ( key , " HW_INTAG_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_INTAG_LINK ] = Z_STRVAL_P ( data ) ;
2000-11-23 14:44:10 +00:00
} else if ( strcmp ( key , " HW_APPLET_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_APPLET_LINK ] = Z_STRVAL_P ( data ) ;
2000-11-23 14:44:10 +00:00
} else {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): %s is not a valid urlprefix " , get_active_function_name ( TSRMLS_C ) , key ) ;
2000-11-23 14:44:10 +00:00
RETURN_FALSE ;
}
zend_hash_move_forward ( prefixarray ) ;
}
} else {
urlprefix = NULL ;
}
mode = 0 ;
if ( ptr - > linkroot > 0 )
mode = 1 ;
rootid = ptr - > linkroot ;
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
char * bodytag = NULL ;
int count ;
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
if ( 0 ! = ( ptr - > lasterror = send_pipedocument ( ptr - > socket ,
# if APACHE
serv - > server_hostname ,
# else
getenv ( " HOSTNAME " ) ,
# endif
id , mode , rootid , & attributes , & bodytag , & object , & count , urlprefix ) ) )
RETURN_FALSE ;
if ( urlprefix ) efree ( urlprefix ) ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = bodytag ;
doc - > size = count ;
/* fprintf(stderr, "size = %d\n", count); */
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
2000-11-23 14:44:10 +00:00
}
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto hwdoc hw_pipedocument(int link, int objid)
Returns document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_oldpipedocument )
{
1999-04-21 23:11:20 +00:00
pval * argv [ 3 ] ;
int link , id , type , argc , mode ;
int rootid = 0 ;
hw_connection * ptr ;
hw_document * doc ;
# if APACHE
1999-08-05 16:25:10 +00:00
server_rec * serv = ( ( request_rec * ) SG ( server_context ) ) - > server ;
1999-04-21 23:11:20 +00:00
# endif
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
if ( ( argc > 2 ) | | ( argc < 2 ) )
WRONG_PARAM_COUNT ;
if ( getParametersArray ( ht , argc , argv ) = = FAILURE )
RETURN_FALSE ;
convert_to_long ( argv [ 0 ] ) ;
convert_to_long ( argv [ 1 ] ) ;
/* if(argc == 3) {
convert_to_long ( argv [ 2 ] ) ;
2001-09-25 22:49:04 +00:00
rootid = Z_LVAL_P ( argv [ 2 ] ) ;
1999-04-21 23:11:20 +00:00
if ( rootid ! = 0 )
mode = 1 ;
}
2001-09-25 22:49:04 +00:00
*/ link = Z_LVAL_P ( argv [ 0 ] ) ;
id = Z_LVAL_P ( argv [ 1 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
mode = 0 ;
if ( ptr - > linkroot > 0 )
mode = 1 ;
rootid = ptr - > linkroot ;
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
char * bodytag = NULL ;
int count ;
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
if ( 0 ! = ( ptr - > lasterror = send_pipedocument ( ptr - > socket ,
# if APACHE
serv - > server_hostname ,
# else
1999-08-05 16:25:10 +00:00
getenv ( " HOSTNAME " ) ,
1999-04-21 23:11:20 +00:00
# endif
1999-08-05 16:25:10 +00:00
id , mode , rootid , & attributes , & bodytag , & object , & count , NULL ) ) )
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = bodytag ;
doc - > size = count ;
1999-08-05 16:25:10 +00:00
/* fprintf(stderr, "size = %d\n", count); */
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto hwdoc hw_pipecgi(int link, int objid)
2000-06-12 13:33:49 +00:00
Returns output of CGI script */
1999-08-05 16:25:10 +00:00
# define BUFFERLEN 1000
/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_pipecgi )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
hw_connection * ptr ;
hw_document * doc ;
char cgi_env_str [ 1000 ] ;
# if APACHE
1999-08-05 16:25:10 +00:00
server_rec * serv = ( ( request_rec * ) SG ( server_context ) ) - > server ;
1999-04-21 23:11:20 +00:00
# endif
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
char * attributes = NULL ;
int count ;
2000-06-15 23:45:05 +00:00
# ifdef PHP_WIN32
1999-08-05 16:25:10 +00:00
snprintf ( cgi_env_str , BUFFERLEN , " CGI_REQUEST_METHOD=%s \n CGI_PATH_INFO=%s \n CGI_QUERY_STRING=%s " ,
1999-04-21 23:11:20 +00:00
getenv ( " REQUEST_METHOD " ) ,
getenv ( " PATH_INFO " ) ,
getenv ( " QUERY_STRING " ) ) ;
# else
1999-08-05 16:25:10 +00:00
snprintf ( cgi_env_str , BUFFERLEN , " CGI_REQUEST_METHOD=%s \n CGI_PATH_INFO=%s \n CGI_QUERY_STRING=%s " ,
1999-05-09 08:48:05 +00:00
SG ( request_info ) . request_method ,
1999-05-02 19:54:02 +00:00
SG ( request_info ) . request_uri ,
1999-05-02 18:07:41 +00:00
SG ( request_info ) . query_string ) ;
1999-04-21 23:11:20 +00:00
# endif
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
if ( 0 ! = ( ptr - > lasterror = send_pipecgi ( ptr - > socket ,
# if APACHE
serv - > server_hostname ,
# else
1999-08-05 16:25:10 +00:00
getenv ( " HOSTNAME " ) ,
1999-04-21 23:11:20 +00:00
# endif
id , cgi_env_str , & attributes , & object , & count ) ) )
RETURN_FALSE ;
doc = malloc ( sizeof ( hw_document ) ) ;
doc - > data = object ;
doc - > attributes = attributes ;
doc - > bodytag = NULL ;
doc - > size = count ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
}
# undef BUFFERLEN
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto void hw_insertdocument(int link, int parentid, hwdoc doc)
Insert new document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_insertdocument )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 , * arg3 ;
int link , id , doc , type ;
hw_connection * ptr ;
hw_document * docptr ;
1999-08-05 16:25:10 +00:00
hw_objectID objid ;
1999-04-21 23:11:20 +00:00
# if APACHE
1999-08-05 16:25:10 +00:00
server_rec * serv = ( ( request_rec * ) SG ( server_context ) ) - > server ;
1999-04-21 23:11:20 +00:00
# endif
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
convert_to_long ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find connection identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-09-25 22:49:04 +00:00
doc = Z_LVAL_P ( arg3 ) ;
2001-08-11 16:39:07 +00:00
docptr = zend_list_find ( doc , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! docptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find document identifier %d " , get_active_function_name ( TSRMLS_C ) , doc ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
if ( 0 ! = ( ptr - > lasterror = send_putdocument ( ptr - > socket ,
# if APACHE
serv - > server_hostname ,
# else
1999-08-05 16:25:10 +00:00
getenv ( " HOSTNAME " ) ,
1999-04-21 23:11:20 +00:00
# endif
1999-08-05 16:25:10 +00:00
id , docptr - > attributes , docptr - > data , docptr - > size , & objid ) ) ) {
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
}
1999-08-05 16:25:10 +00:00
RETURN_LONG ( objid ) ;
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto hwdoc hw_new_document(string objrec, string data, int size)
2000-12-04 16:34:06 +00:00
Create a new document */
2001-07-31 07:09:49 +00:00
PHP_FUNCTION ( hw_new_document )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 , * arg3 ;
1999-08-05 16:25:10 +00:00
char * ptr ;
1999-04-21 23:11:20 +00:00
hw_document * doc ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | getParameters ( ht , 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_string ( arg1 ) ;
convert_to_string ( arg2 ) ;
convert_to_long ( arg3 ) ;
doc = malloc ( sizeof ( hw_document ) ) ;
1999-08-05 16:25:10 +00:00
if ( NULL = = doc )
RETURN_FALSE ;
2001-09-25 22:49:04 +00:00
doc - > data = malloc ( Z_LVAL_P ( arg3 ) + 1 ) ;
1999-08-05 16:25:10 +00:00
if ( NULL = = doc - > data ) {
free ( doc ) ;
RETURN_FALSE ;
}
2001-09-25 22:49:04 +00:00
memcpy ( doc - > data , Z_STRVAL_P ( arg2 ) , Z_LVAL_P ( arg3 ) ) ;
1999-08-05 16:25:10 +00:00
ptr = doc - > data ;
2001-09-26 09:00:30 +00:00
ptr [ Z_LVAL_P ( arg3 ) ] = ' \0 ' ;
2001-09-25 22:49:04 +00:00
doc - > attributes = strdup ( Z_STRVAL_P ( arg1 ) ) ;
1999-04-21 23:11:20 +00:00
doc - > bodytag = NULL ;
2001-09-25 22:49:04 +00:00
doc - > size = Z_LVAL_P ( arg3 ) ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
2000-12-04 16:34:06 +00:00
/* {{{ proto hwdoc hw_new_document_from_file(string objrec, string filename)
Create a new document from a file */
2001-07-31 07:09:49 +00:00
PHP_FUNCTION ( hw_new_document_from_file )
{
2000-12-04 16:34:06 +00:00
pval * * arg1 , * * arg2 ;
char * ptr ;
2002-03-16 01:28:57 +00:00
php_stream * stream ;
2000-12-04 16:34:06 +00:00
int use_include_path = 0 ;
hw_document * doc ;
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_string_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
2002-03-15 21:03:08 +00:00
stream = php_stream_open_wrapper ( Z_STRVAL_PP ( arg2 ) , " r " , use_include_path | ENFORCE_SAFE_MODE | REPORT_ERRORS ,
NULL TSRMLS_CC ) ;
if ( stream = = NULL ) {
2000-12-04 16:34:06 +00:00
RETURN_FALSE ;
}
doc = malloc ( sizeof ( hw_document ) ) ;
if ( NULL = = doc )
RETURN_FALSE ;
2002-03-16 13:48:57 +00:00
doc - > size = php_stream_copy_to_mem ( stream , & doc - > data , PHP_STREAM_COPY_ALL , 1 ) ;
2000-12-04 16:34:06 +00:00
2002-03-15 21:03:08 +00:00
php_stream_close ( stream ) ;
2002-07-03 06:10:29 +00:00
/* I'm not sure if it is necessary to add a '\0'. It depends on whether
* PHP - Strings has to be null terminated . doc - > size doesn ' t count the
* ' \0 ' .
*/
doc - > data = realloc ( doc - > data , doc - > size + 1 ) ;
2000-12-04 16:34:06 +00:00
ptr = doc - > data ;
2002-07-03 06:10:29 +00:00
ptr [ doc - > size ] = ' \0 ' ;
2001-09-25 22:49:04 +00:00
doc - > attributes = strdup ( Z_STRVAL_PP ( arg1 ) ) ;
2000-12-04 16:34:06 +00:00
doc - > bodytag = NULL ;
2001-09-25 21:58:48 +00:00
Z_LVAL_P ( return_value ) = zend_list_insert ( doc , le_document ) ;
Z_TYPE_P ( return_value ) = IS_LONG ;
2000-12-04 16:34:06 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto void hw_free_document(hwdoc doc)
Frees memory of document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_free_document )
{
1999-04-21 23:11:20 +00:00
pval * arg1 ;
int id , type ;
hw_document * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | getParameters ( ht , 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
1999-12-17 19:51:39 +00:00
zend_list_delete ( id ) ;
1999-04-21 23:11:20 +00:00
RETURN_TRUE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
/* {{{ proto void hw_outputdocument(hwdoc doc)
An alias for hw_output_document */
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto void hw_output_document(hwdoc doc)
Prints document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_output_document )
{
1999-04-21 23:11:20 +00:00
pval * arg1 ;
1999-08-05 16:25:10 +00:00
int id , type ;
1999-04-21 23:11:20 +00:00
hw_document * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | getParameters ( ht , 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-08-05 16:22:50 +00:00
php_write ( ptr - > data , ptr - > size TSRMLS_CC ) ;
1999-04-21 23:11:20 +00:00
RETURN_TRUE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
/* {{{ proto string hw_documentbodytag(hwdoc doc [, string prefix])
An alias for hw_document_bodytag */
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto string hw_document_bodytag(hwdoc doc [, string prefix])
2000-12-04 16:34:06 +00:00
Return bodytag prefixed by prefix */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_document_bodytag )
{
1999-04-21 23:11:20 +00:00
pval * argv [ 2 ] ;
int id , type , argc ;
hw_document * ptr ;
char * temp , * str = NULL ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
if ( ( argc > 2 ) | | ( argc < 1 ) )
WRONG_PARAM_COUNT ;
if ( getParametersArray ( ht , argc , argv ) = = FAILURE )
RETURN_FALSE ;
convert_to_long ( argv [ 0 ] ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( argv [ 0 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( argc = = 2 ) {
convert_to_string ( argv [ 1 ] ) ;
2001-09-25 22:49:04 +00:00
str = Z_STRVAL_P ( argv [ 1 ] ) ;
1999-04-21 23:11:20 +00:00
}
if ( str ! = NULL ) {
2001-09-25 22:49:04 +00:00
temp = emalloc ( Z_STRLEN_P ( argv [ 1 ] ) + strlen ( ptr - > bodytag ) + 2 ) ;
1999-04-21 23:11:20 +00:00
strcpy ( temp , ptr - > bodytag ) ;
strcpy ( temp + strlen ( ptr - > bodytag ) - 1 , str ) ;
2001-09-25 22:49:04 +00:00
strcpy ( temp + strlen ( ptr - > bodytag ) - 1 + Z_STRLEN_P ( argv [ 1 ] ) , " > \n " ) ;
1999-04-21 23:11:20 +00:00
RETURN_STRING ( temp , 0 ) ;
} else {
2001-10-24 09:06:33 +00:00
/* fprintf(stderr, "hw_document_bodytag: %s (%s)\n", ptr->bodytag, ptr->attributes); */
2000-12-13 17:27:13 +00:00
if ( ptr - > bodytag ) {
RETURN_STRING ( ptr - > bodytag , 1 ) ;
} else {
RETURN_EMPTY_STRING ( ) ;
}
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto string hw_document_content(hwdoc doc)
Returns content of document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_document_content )
{
1999-04-21 23:11:20 +00:00
pval * argv [ 1 ] ;
int id , type , argc ;
hw_document * ptr ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
if ( argc ! = 1 )
WRONG_PARAM_COUNT ;
if ( getParametersArray ( ht , argc , argv ) = = FAILURE )
RETURN_FALSE ;
convert_to_long ( argv [ 0 ] ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( argv [ 0 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2000-12-04 16:34:06 +00:00
RETURN_STRINGL ( ptr - > data , ptr - > size , 1 ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
/* {{{ proto int hw_document_setcontent(hwdoc doc, string content)
Sets / replaces content of document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_document_setcontent )
{
1999-08-05 16:25:10 +00:00
pval * argv [ 2 ] ;
int id , type , argc ;
hw_document * ptr ;
char * str ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-08-05 16:25:10 +00:00
if ( argc ! = 2 )
WRONG_PARAM_COUNT ;
if ( getParametersArray ( ht , argc , argv ) = = FAILURE )
RETURN_FALSE ;
convert_to_long ( argv [ 0 ] ) ;
convert_to_string ( argv [ 1 ] ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( argv [ 0 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-08-05 16:25:10 +00:00
RETURN_FALSE ;
}
str = ptr - > data ;
2001-09-25 22:49:04 +00:00
if ( NULL ! = ( ptr - > data = strdup ( Z_STRVAL_P ( argv [ 1 ] ) ) ) ) {
1999-08-05 16:25:10 +00:00
ptr - > size = strlen ( ptr - > data ) ;
free ( str ) ;
RETURN_TRUE ;
} else {
ptr - > data = str ;
RETURN_FALSE ;
}
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto int hw_documentsize(hwdoc doc)
An alias for hw_document_size */
/* }}} */
/* {{{ proto int hw_document_size(hwdoc doc)
1999-04-21 23:11:20 +00:00
Returns size of document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_document_size )
{
1999-04-21 23:11:20 +00:00
pval * arg1 ;
int id , type ;
hw_document * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | getParameters ( ht , 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
RETURN_LONG ( ptr - > size ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto string hw_documentattributes(hwdoc doc)
An alias for hw_document_attributes */
/* }}} */
/* {{{ proto string hw_document_attributes(hwdoc doc)
1999-04-21 23:11:20 +00:00
Returns object record of document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_document_attributes )
{
1999-04-21 23:11:20 +00:00
pval * arg1 ;
int id , type ;
hw_document * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | getParameters ( ht , 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
2001-09-25 22:49:04 +00:00
id = Z_LVAL_P ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( id , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
RETURN_STRING ( ptr - > attributes , 1 ) ;
/* make_return_array_from_objrec(&return_value, ptr->attributes); */
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getparentsobj(int link, int objid)
Returns array of parent object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getparentsobj )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getparentsobj ( ptr - > socket , id , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getparents(int link, int objid)
Returns array of parent object ids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getparents )
{
1999-04-21 23:11:20 +00:00
pval * arg1 , * arg2 ;
int link , id , type ;
int count ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | getParameters ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
convert_to_long ( arg1 ) ;
convert_to_long ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_P ( arg1 ) ;
id = Z_LVAL_P ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int * childIDs = NULL ;
int i ;
if ( 0 ! = ( ptr - > lasterror = send_getparents ( ptr - > socket , id , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + ) {
add_index_long ( return_value , i , childIDs [ i ] ) ;
}
efree ( childIDs ) ;
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_children(int link, int objid)
Returns array of children object ids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_children )
{
2000-06-30 09:46:39 +00:00
zval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int * childIDs = NULL ;
int i ;
if ( 0 ! = ( ptr - > lasterror = send_children ( ptr - > socket , id , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + ) {
add_index_long ( return_value , i , childIDs [ i ] ) ;
}
efree ( childIDs ) ;
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto array hw_childrenobj(int link, int objid)
1999-04-21 23:11:20 +00:00
Returns array of children object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_childrenobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_childrenobj ( ptr - > socket , id , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto array hw_getchildcoll(int link, int objid)
1999-04-21 23:11:20 +00:00
Returns array of child collection object ids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getchildcoll )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int * childIDs = NULL ;
int i ;
if ( 0 ! = ( ptr - > lasterror = send_getchildcoll ( ptr - > socket , id , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + ) {
add_index_long ( return_value , i , childIDs [ i ] ) ;
}
efree ( childIDs ) ;
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-08-05 16:25:10 +00:00
/* {{{ proto array hw_getchildcollobj(int link, int objid)
1999-04-21 23:11:20 +00:00
Returns array of child collection object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getchildcollobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getchildcollobj ( ptr - > socket , id , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto int hw_docbyanchor(int link, int anchorid)
Returns objid of document belonging to anchorid */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_docbyanchor )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( ht , 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
int objectID ;
if ( 0 ! = ( ptr - > lasterror = send_docbyanchor ( ptr - > socket , id , & objectID ) ) )
RETURN_FALSE ;
RETURN_LONG ( objectID ) ;
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_docbyanchorobj(int link, int anchorid)
Returns object record of document belonging to anchorid */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_docbyanchorobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * object = NULL ;
if ( 0 ! = ( ptr - > lasterror = send_docbyanchorobj ( ptr - > socket , id , & object ) ) )
RETURN_FALSE ;
RETURN_STRING ( object , 0 ) ;
/*
make_return_array_from_objrec ( & return_value , object ) ;
efree ( object ) ;
*/
}
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getobjectbyquery(int link, string query, int maxhits)
Search for query and return maxhits objids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyquery )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-04-21 23:11:20 +00:00
int link , type , maxhits ;
char * query ;
int count , i ;
int * childIDs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
query = Z_STRVAL_PP ( arg2 ) ;
maxhits = Z_LVAL_PP ( arg3 ) ;
1999-04-21 23:11:20 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyquery ( ptr - > socket , query , maxhits , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , childIDs [ i ] ) ;
efree ( childIDs ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getobjectbyqueryobj(int link, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for query and return maxhits object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyqueryobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-04-21 23:11:20 +00:00
int link , type , maxhits ;
char * query ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
query = Z_STRVAL_PP ( arg2 ) ;
maxhits = Z_LVAL_PP ( arg3 ) ;
1999-04-21 23:11:20 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyqueryobj ( ptr - > socket , query , maxhits , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getobjectbyquerycoll(int link, int collid, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for query in collection and return maxhits objids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyquerycoll )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-21 23:11:20 +00:00
int link , id , type , maxhits ;
char * query ;
int count , i ;
hw_connection * ptr ;
int * childIDs = NULL ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
query = Z_STRVAL_PP ( arg3 ) ;
maxhits = Z_LVAL_PP ( arg4 ) ;
1999-04-21 23:11:20 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyquerycoll ( ptr - > socket , id , query , maxhits , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , childIDs [ i ] ) ;
efree ( childIDs ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getobjectbyquerycollobj(int link, int collid, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for query in collection and return maxhits object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyquerycollobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-21 23:11:20 +00:00
int link , id , type , maxhits ;
char * query ;
int count ;
hw_connection * ptr ;
char * * childObjRecs = NULL ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
query = Z_STRVAL_PP ( arg3 ) ;
maxhits = Z_LVAL_PP ( arg4 ) ;
1999-04-21 23:11:20 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyquerycollobj ( ptr - > socket , id , query , maxhits , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
2000-10-27 09:29:40 +00:00
/* {{{ proto array hw_getobjectbyftquery(int link, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for query as fulltext and return maxhits objids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyftquery )
{
2000-10-27 09:29:40 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
int link , type , maxhits ;
char * query ;
int count , i ;
int * childIDs = NULL ;
float * weights ;
hw_connection * ptr ;
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_long_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
query = Z_STRVAL_PP ( arg2 ) ;
maxhits = Z_LVAL_PP ( arg3 ) ;
2000-10-27 09:29:40 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyftquery ( ptr - > socket , query , maxhits , & childIDs , & weights , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , childIDs [ i ] ) ;
efree ( childIDs ) ;
}
/* }}} */
/* {{{ proto array hw_getobjectbyftqueryobj(int link, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for query as fulltext and return maxhits object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyftqueryobj )
{
2000-10-27 09:29:40 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
int link , type , maxhits ;
char * query ;
int count ;
char * * childObjRecs = NULL ;
float * weights ;
hw_connection * ptr ;
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_long_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
query = Z_STRVAL_PP ( arg2 ) ;
maxhits = Z_LVAL_PP ( arg3 ) ;
2000-10-27 09:29:40 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyftqueryobj ( ptr - > socket , query , maxhits , & childObjRecs , & weights , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto array hw_getobjectbyftquerycoll(int link, int collid, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for fulltext query in collection and return maxhits objids */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyftquerycoll )
{
2000-10-27 09:29:40 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
int link , id , type , maxhits ;
char * query ;
int count , i ;
hw_connection * ptr ;
int * childIDs = NULL ;
float * weights ;
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
query = Z_STRVAL_PP ( arg3 ) ;
maxhits = Z_LVAL_PP ( arg4 ) ;
2000-10-27 09:29:40 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyftquerycoll ( ptr - > socket , id , query , maxhits , & childIDs , & weights , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , childIDs [ i ] ) ;
efree ( childIDs ) ;
}
/* }}} */
/* {{{ proto array hw_getobjectbyftquerycollobj(int link, int collid, string query, int maxhits)
2000-12-04 16:34:06 +00:00
Search for fulltext query in collection and return maxhits object records */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getobjectbyftquerycollobj )
{
2000-10-27 09:29:40 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
int link , id , type , maxhits ;
char * query ;
int count ;
hw_connection * ptr ;
char * * childObjRecs = NULL ;
float * weights ;
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
WRONG_PARAM_COUNT ;
}
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
query = Z_STRVAL_PP ( arg3 ) ;
maxhits = Z_LVAL_PP ( arg4 ) ;
2000-10-27 09:29:40 +00:00
if ( maxhits < 0 ) maxhits = 0x7FFFFFFF ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getobjbyftquerycollobj ( ptr - > socket , id , query , maxhits , & childObjRecs , & weights , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
2000-10-27 09:29:40 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getchilddoccoll(int link, int objid)
Returns all children ids which are documents */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getchilddoccoll )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count , i ;
int * childIDs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getchilddoccoll ( ptr - > socket , id , & childIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( childIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , childIDs [ i ] ) ;
efree ( childIDs ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getchilddoccollobj(int link, int objid)
Returns all children object records which are documents */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getchilddoccollobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getchilddoccollobj ( ptr - > socket , id , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getanchors(int link, int objid)
2000-12-04 16:34:06 +00:00
Return all anchors of object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getanchors )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count , i ;
int * anchorIDs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getanchors ( ptr - > socket , id , & anchorIDs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
if ( array_init ( return_value ) = = FAILURE ) {
efree ( anchorIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < count ; i + + )
add_index_long ( return_value , i , anchorIDs [ i ] ) ;
efree ( anchorIDs ) ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto array hw_getanchorsobj(int link, int objid)
2000-12-04 16:34:06 +00:00
Return all object records of anchors of object */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getanchorsobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , id , type ;
int count ;
char * * anchorObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = ( hw_connection * ) zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , id ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getanchorsobj ( ptr - > socket , id , & anchorObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , anchorObjRecs , count ) )
RETURN_FALSE ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto string hw_getusername(int link)
Returns the current user name */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getusername )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
int link , type ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-09-25 21:58:48 +00:00
Z_STRVAL_P ( return_value ) = estrdup ( ptr - > username ) ;
Z_STRLEN_P ( return_value ) = strlen ( ptr - > username ) ;
Z_TYPE_P ( return_value ) = IS_STRING ;
1999-08-05 16:25:10 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto void hw_identify(int link, string username, string password)
Identifies at Hyperwave server */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_identify )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-04-21 23:11:20 +00:00
int link , type ;
char * name , * passwd , * userdata ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_string_ex ( arg2 ) ;
convert_to_string_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
name = Z_STRVAL_PP ( arg2 ) ;
passwd = Z_STRVAL_PP ( arg3 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
{
char * str ;
if ( 0 ! = ( ptr - > lasterror = send_identify ( ptr - > socket , name , passwd , & userdata ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d \n " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
if ( ptr - > username ) free ( ptr - > username ) ;
ptr - > username = NULL ;
RETURN_FALSE ;
}
2001-09-25 21:58:48 +00:00
Z_STRVAL_P ( return_value ) = userdata ;
Z_STRLEN_P ( return_value ) = strlen ( userdata ) ;
Z_TYPE_P ( return_value ) = IS_STRING ;
1999-04-21 23:11:20 +00:00
if ( ptr - > username ) free ( ptr - > username ) ;
str = userdata ;
while ( ( * str ! = 0 ) & & ( * str ! = ' ' ) )
str + + ;
if ( * str ! = ' \0 ' )
ptr - > username = strdup ( + + str ) ;
else
ptr - > username = NULL ;
}
}
/* }}} */
2000-12-04 16:34:06 +00:00
/* {{{ proto array hw_objrec2array(string objrec, [array format])
2000-06-12 13:33:49 +00:00
Returns object array of object record */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_objrec2array )
{
1999-12-15 19:10:54 +00:00
zval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
2000-06-05 19:47:54 +00:00
switch ( ZEND_NUM_ARGS ( ) ) {
1999-09-08 12:29:13 +00:00
case 1 :
1999-12-18 22:40:35 +00:00
if ( zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE )
1999-09-08 12:29:13 +00:00
WRONG_PARAM_COUNT ;
1999-12-15 19:10:54 +00:00
convert_to_string_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
make2_return_array_from_objrec ( & return_value , Z_STRVAL_PP ( arg1 ) , NULL ) ;
1999-09-08 12:29:13 +00:00
break ;
case 2 :
1999-12-18 22:40:35 +00:00
if ( zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE )
1999-09-08 12:29:13 +00:00
WRONG_PARAM_COUNT ;
1999-12-15 19:10:54 +00:00
convert_to_array_ex ( arg2 ) ;
convert_to_string_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
make2_return_array_from_objrec ( & return_value , Z_STRVAL_PP ( arg1 ) , * arg2 ) ;
1999-09-08 12:29:13 +00:00
break ;
default :
WRONG_PARAM_COUNT ;
1999-04-21 23:11:20 +00:00
}
}
/* }}} */
/* {{{ proto string hw_array2objrec(array objarr)
Returns object record of object array */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_array2objrec )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
char * objrec , * retobj ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_array_ex ( arg1 ) ;
2002-09-30 09:27:56 +00:00
objrec = make_objrec_from_array ( Z_ARRVAL_PP ( arg1 ) , ' = ' ) ;
1999-04-21 23:11:20 +00:00
if ( objrec ) {
retobj = estrdup ( objrec ) ;
free ( objrec ) ;
RETURN_STRING ( retobj , 0 ) ;
} else
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto array hw_incollections(int link, array objids, array collids, int para)
Returns object ids which are in collections */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_incollections )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-21 23:11:20 +00:00
int type , link , i ;
hw_connection * ptr ;
int cobjids , ccollids , * objectIDs , * collIDs , cretids , * retIDs , retcoll ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_array_ex ( arg2 ) ;
convert_to_array_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
retcoll = Z_LVAL_PP ( arg4 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-09-25 22:49:04 +00:00
cobjids = zend_hash_num_elements ( Z_ARRVAL_PP ( arg2 ) ) ;
if ( NULL = = ( objectIDs = make_ints_from_array ( Z_ARRVAL_PP ( arg2 ) ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Could not create Int Array from Array " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2001-09-25 22:49:04 +00:00
ccollids = zend_hash_num_elements ( Z_ARRVAL_PP ( arg3 ) ) ;
if ( NULL = = ( collIDs = make_ints_from_array ( Z_ARRVAL_PP ( arg3 ) ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Could not create Int Array from Array " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
efree ( objectIDs ) ;
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_incollections ( ptr - > socket , retcoll ,
cobjids , objectIDs ,
ccollids , collIDs ,
& cretids , & retIDs ) ) ) {
if ( objectIDs ) efree ( objectIDs ) ;
if ( collIDs ) efree ( collIDs ) ;
RETURN_FALSE ;
}
if ( objectIDs ) efree ( objectIDs ) ;
if ( collIDs ) efree ( collIDs ) ;
if ( array_init ( return_value ) = = FAILURE ) {
efree ( retIDs ) ;
RETURN_FALSE ;
}
for ( i = 0 ; i < cretids ; i + + )
add_index_long ( return_value , i , retIDs [ i ] ) ;
efree ( retIDs ) ;
}
/* }}} */
/* {{{ proto void hw_inscoll(int link, int parentid, array objarr)
Inserts collection */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_inscoll )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-04-21 23:11:20 +00:00
char * objrec ;
int id , newid , type , link ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_array_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
2002-09-30 09:27:56 +00:00
if ( NULL = = ( objrec = make_objrec_from_array ( Z_ARRVAL_PP ( arg3 ) , ' = ' ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Could not create Object Record from Array " , get_active_function_name ( TSRMLS_C ) ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_inscoll ( ptr - > socket , id , objrec , & newid ) ) ) {
if ( objrec ) free ( objrec ) ;
RETURN_FALSE ;
}
if ( objrec ) free ( objrec ) ;
RETURN_LONG ( newid ) ;
}
/* }}} */
1999-08-05 16:25:10 +00:00
/* {{{ proto void hw_insdoc(int link, int parentid, string objrec [, string text])
1999-04-21 23:11:20 +00:00
Inserts document */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_insdoc )
{
2000-06-30 09:46:39 +00:00
zval * * argv [ 4 ] ;
1999-04-21 23:11:20 +00:00
char * objrec , * text ;
int id , newid , type , link , argc ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
argc = ZEND_NUM_ARGS ( ) ;
1999-04-21 23:11:20 +00:00
if ( ( argc < 3 ) | | ( argc > 4 ) )
WRONG_PARAM_COUNT ;
1999-12-18 22:40:35 +00:00
if ( zend_get_parameters_array_ex ( argc , argv ) = = FAILURE )
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( argv [ 0 ] ) ;
convert_to_long_ex ( argv [ 1 ] ) ;
convert_to_string_ex ( argv [ 2 ] ) ;
1999-04-21 23:11:20 +00:00
if ( argc = = 4 ) {
1999-12-15 19:10:54 +00:00
convert_to_string_ex ( argv [ 3 ] ) ;
2001-09-25 22:49:04 +00:00
text = Z_STRVAL_PP ( argv [ 3 ] ) ;
1999-04-21 23:11:20 +00:00
} else {
text = NULL ;
}
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( argv [ 0 ] ) ;
id = Z_LVAL_PP ( argv [ 1 ] ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
2001-09-25 22:49:04 +00:00
objrec = Z_STRVAL_PP ( argv [ 2 ] ) ;
1999-04-21 23:11:20 +00:00
if ( 0 ! = ( ptr - > lasterror = send_insdoc ( ptr - > socket , id , objrec , text , & newid ) ) ) {
RETURN_FALSE ;
}
RETURN_LONG ( newid ) ;
}
/* }}} */
/* {{{ proto int hw_getsrcbydestobj(int link, int destid)
Returns object id of source docuent by destination anchor */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getsrcbydestobj )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 ;
1999-04-21 23:11:20 +00:00
int link , type , id ;
int count ;
char * * childObjRecs = NULL ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 2 | | zend_get_parameters_ex ( 2 , & arg1 , & arg2 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
id = Z_LVAL_PP ( arg2 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_getsrcbydest ( ptr - > socket , id , & childObjRecs , & count ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
/* create return value and free all memory */
if ( 0 > make_return_objrec ( & return_value , childObjRecs , count ) )
RETURN_FALSE ;
}
/* }}} */
1999-10-21 15:15:27 +00:00
/* {{{ proto int hw_mapid(int link, int serverid, int destid)
2000-06-12 13:33:49 +00:00
Returns virtual object id of document on remote Hyperwave server */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_mapid )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 ;
1999-10-21 15:15:27 +00:00
int link , type , servid , id , virtid ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 3 | | zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE ) {
1999-10-21 15:15:27 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
servid = Z_LVAL_PP ( arg2 ) ;
id = Z_LVAL_PP ( arg3 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-10-21 15:15:27 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = send_mapid ( ptr - > socket , servid , id , & virtid ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-10-21 15:15:27 +00:00
RETURN_FALSE ;
}
RETURN_LONG ( virtid ) ;
}
/* }}} */
1999-04-21 23:11:20 +00:00
/* {{{ proto string hw_getrellink(int link, int rootid, int sourceid, int destid)
2000-12-04 16:34:06 +00:00
Get link from source to dest relative to rootid */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_getrellink )
{
1999-12-15 19:10:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
1999-04-21 23:11:20 +00:00
int link , type ;
int rootid , destid , sourceid ;
char * anchorstr ;
hw_connection * ptr ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 4 | | zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_long_ex ( arg2 ) ;
convert_to_long_ex ( arg3 ) ;
convert_to_long_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
rootid = Z_LVAL_PP ( arg2 ) ;
sourceid = Z_LVAL_PP ( arg3 ) ;
destid = Z_LVAL_PP ( arg4 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
set_swap ( ptr - > swap_on ) ;
if ( 0 ! = ( ptr - > lasterror = getrellink ( ptr - > socket , rootid , sourceid , destid , & anchorstr ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d " , get_active_function_name ( TSRMLS_C ) , ptr - > lasterror ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
RETURN_STRING ( anchorstr , 0 ) ;
}
/* }}} */
2000-12-12 12:28:26 +00:00
/* {{{ proto string hw_insertanchors(int hwdoc, array anchorecs, array dest [, array urlprefixes])
2000-11-09 13:36:54 +00:00
Inserts only anchors into text */
2001-08-05 01:43:02 +00:00
PHP_FUNCTION ( hw_insertanchors )
{
2000-11-09 13:36:54 +00:00
pval * * arg1 , * * arg2 , * * arg3 , * * arg4 ;
hw_document * hwdoc ;
2000-12-12 12:28:26 +00:00
int type , docid , error , argc , count ;
2000-11-09 13:36:54 +00:00
char * * anchorrecs ;
char * * dest ;
2000-12-12 12:28:26 +00:00
char * * urlprefix ;
char * bodytag = NULL ;
2000-11-09 13:36:54 +00:00
HashTable * arrht ;
2000-12-12 12:28:26 +00:00
HashTable * prefixarray ;
2000-11-09 13:36:54 +00:00
2000-12-12 12:28:26 +00:00
argc = ZEND_NUM_ARGS ( ) ;
switch ( argc )
{
case 3 :
if ( zend_get_parameters_ex ( 3 , & arg1 , & arg2 , & arg3 ) = = FAILURE )
WRONG_PARAM_COUNT ;
break ;
case 4 :
if ( zend_get_parameters_ex ( 4 , & arg1 , & arg2 , & arg3 , & arg4 ) = = FAILURE )
WRONG_PARAM_COUNT ;
break ;
default :
2000-11-09 13:36:54 +00:00
WRONG_PARAM_COUNT ;
}
2000-12-12 12:28:26 +00:00
2000-11-09 13:36:54 +00:00
convert_to_long_ex ( arg1 ) ;
convert_to_array_ex ( arg2 ) ;
convert_to_array_ex ( arg3 ) ;
2001-09-25 22:49:04 +00:00
docid = Z_LVAL_PP ( arg1 ) ;
2000-11-09 13:36:54 +00:00
hwdoc = zend_list_find ( docid , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! hwdoc | | ( type ! = le_document ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , docid ) ;
2000-11-09 13:36:54 +00:00
RETURN_FALSE ;
}
2000-12-12 12:28:26 +00:00
/* check for the array with urlprefixes */
if ( argc = = 4 ) {
int i ;
convert_to_array_ex ( arg4 ) ;
2001-09-25 22:49:04 +00:00
prefixarray = Z_ARRVAL_PP ( arg4 ) ;
2000-12-12 12:28:26 +00:00
if ( ( prefixarray = = NULL ) | | ( zend_hash_num_elements ( prefixarray ) ! = 5 ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): You must provide 5 urlprefixes (you have provided %d) " , get_active_function_name ( TSRMLS_C ) , zend_hash_num_elements ( prefixarray ) ) ;
2000-12-12 12:28:26 +00:00
RETURN_FALSE ;
}
urlprefix = emalloc ( 5 * sizeof ( char * ) ) ;
zend_hash_internal_pointer_reset ( prefixarray ) ;
for ( i = 0 ; i < 5 ; i + + ) {
char * key ;
zval * data , * * dataptr ;
ulong ind ;
2000-12-22 12:57:09 +00:00
zend_hash_get_current_key ( prefixarray , & key , & ind , 0 ) ;
2000-12-12 12:28:26 +00:00
zend_hash_get_current_data ( prefixarray , ( void * ) & dataptr ) ;
data = * dataptr ;
2001-09-25 21:58:48 +00:00
if ( Z_TYPE_P ( data ) ! = IS_STRING ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): %s must be a String " , get_active_function_name ( TSRMLS_C ) , key ) ;
2000-12-12 12:28:26 +00:00
RETURN_FALSE ;
} else if ( strcmp ( key , " HW_DEFAULT_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_DEFAULT_LINK ] = Z_STRVAL_P ( data ) ;
2000-12-12 12:28:26 +00:00
} else if ( strcmp ( key , " HW_IMAGE_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_IMAGE_LINK ] = Z_STRVAL_P ( data ) ;
2000-12-12 12:28:26 +00:00
} else if ( strcmp ( key , " HW_BACKGROUND_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_BACKGROUND_LINK ] = Z_STRVAL_P ( data ) ;
2000-12-12 12:28:26 +00:00
} else if ( strcmp ( key , " HW_INTAG_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_INTAG_LINK ] = Z_STRVAL_P ( data ) ;
2000-12-12 12:28:26 +00:00
} else if ( strcmp ( key , " HW_APPLET_LINK " ) = = 0 ) {
2001-09-25 21:58:48 +00:00
urlprefix [ HW_APPLET_LINK ] = Z_STRVAL_P ( data ) ;
2000-12-12 12:28:26 +00:00
} else {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): %s is not a valid urlprefix " , get_active_function_name ( TSRMLS_C ) , key ) ;
2000-12-12 12:28:26 +00:00
RETURN_FALSE ;
}
zend_hash_move_forward ( prefixarray ) ;
}
} else {
urlprefix = NULL ;
}
2001-09-25 22:49:04 +00:00
if ( zend_hash_num_elements ( Z_ARRVAL_PP ( arg2 ) ) ! = zend_hash_num_elements ( Z_ARRVAL_PP ( arg3 ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unequal number of elements in arrays " , get_active_function_name ( TSRMLS_C ) ) ;
2000-11-09 13:36:54 +00:00
RETURN_FALSE ;
}
/* Turn PHP-Array of strings into C-Array of strings */
2001-09-25 22:49:04 +00:00
arrht = Z_ARRVAL_PP ( arg2 ) ;
2000-11-09 13:36:54 +00:00
anchorrecs = make_strs_from_array ( arrht ) ;
2001-09-25 22:49:04 +00:00
arrht = Z_ARRVAL_PP ( arg3 ) ;
2000-11-09 13:36:54 +00:00
dest = make_strs_from_array ( arrht ) ;
2000-12-12 12:28:26 +00:00
if ( 0 ! = ( error = send_insertanchors ( & ( hwdoc - > data ) , & count , anchorrecs , dest , zend_hash_num_elements ( arrht ) , urlprefix , & bodytag ) ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Command returned %d " , get_active_function_name ( TSRMLS_C ) , error ) ;
2000-11-09 13:36:54 +00:00
RETURN_FALSE ;
}
2000-12-13 17:27:13 +00:00
/*fprintf(stderr, "in hw_insertanchors: %s\n", hwdoc->attributes); */
2000-12-12 12:28:26 +00:00
hwdoc - > size = count ;
2000-12-13 17:27:13 +00:00
if ( hwdoc - > bodytag ) free ( hwdoc - > bodytag ) ;
hwdoc - > bodytag = bodytag ;
2000-12-12 12:28:26 +00:00
RETURN_TRUE ;
2000-11-09 13:36:54 +00:00
}
/* }}} */
1999-04-21 23:11:20 +00:00
1999-07-27 19:44:46 +00:00
PHP_MINFO_FUNCTION ( hw )
1999-04-21 23:11:20 +00:00
{
2000-04-06 16:57:33 +00:00
php_info_print_table_start ( ) ;
php_info_print_table_row ( 2 , " Hyperwave Support " , " enabled " ) ;
php_info_print_table_row ( 2 , " HG-CSP Version " , " 7.17 " ) ;
php_info_print_table_end ( ) ;
1999-08-06 10:42:00 +00:00
DISPLAY_INI_ENTRIES ( ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
/* {{{ proto void hw_connection_info(int link)
Prints information about the connection to Hyperwave server */
1999-05-21 10:06:25 +00:00
PHP_FUNCTION ( hw_connection_info )
1999-04-21 23:11:20 +00:00
{
1999-12-15 19:10:54 +00:00
pval * * arg1 ;
1999-04-21 23:11:20 +00:00
hw_connection * ptr ;
int link , type ;
2000-06-05 19:47:54 +00:00
if ( ZEND_NUM_ARGS ( ) ! = 1 | | zend_get_parameters_ex ( 1 , & arg1 ) = = FAILURE ) {
1999-04-21 23:11:20 +00:00
WRONG_PARAM_COUNT ;
}
1999-12-15 19:10:54 +00:00
convert_to_long_ex ( arg1 ) ;
2001-09-25 22:49:04 +00:00
link = Z_LVAL_PP ( arg1 ) ;
2001-08-11 16:39:07 +00:00
ptr = zend_list_find ( link , & type ) ;
2001-02-20 20:45:55 +00:00
if ( ! ptr | | ( type ! = le_socketp & & type ! = le_psocketp ) ) {
2002-06-28 10:52:11 +00:00
php_error ( E_WARNING , " %s(): Unable to find file identifier %d " , get_active_function_name ( TSRMLS_C ) , link ) ;
1999-04-21 23:11:20 +00:00
RETURN_FALSE ;
}
1999-08-02 19:17:14 +00:00
php_printf ( " Hyperwave Info: \n host=%s, \n server string=%s \n version=%d \n swap=%d \n " , ptr - > hostname , ptr - > server_string , ptr - > version , ptr - > swap_on ) ;
1999-04-21 23:11:20 +00:00
}
1999-08-05 16:25:10 +00:00
/* }}} */
1999-04-21 23:11:20 +00:00
void print_msg ( hg_msg * msg , char * str , int txt )
{
char * ptr ;
int i ;
fprintf ( stdout , " \n print_msg: >>%s<< \n " , str ) ;
fprintf ( stdout , " print_msg: length = %d \n " , msg - > length ) ;
fprintf ( stdout , " print_msg: msgid = %d \n " , msg - > version_msgid ) ;
fprintf ( stdout , " print_msg: msg_type = %d \n " , msg - > msg_type ) ;
if ( msg - > length > HEADER_LENGTH ) {
ptr = msg - > buf ;
for ( i = 0 ; i < msg - > length - HEADER_LENGTH ; i + + ) {
if ( * ptr = = ' \n ' )
fprintf ( stdout , " %c " , * ptr + + ) ;
else if ( iscntrl ( * ptr ) )
{ fprintf ( stdout , " . " ) ; ptr + + ; }
else
fprintf ( stdout , " %c " , * ptr + + ) ;
}
}
fprintf ( stdout , " \n \n " ) ;
}
# endif
/*
* Local variables :
* tab - width : 4
1999-08-05 16:25:10 +00:00
* c - basic - offset : 4
1999-04-21 23:11:20 +00:00
* End :
2001-09-09 13:29:31 +00:00
* vim600 : sw = 4 ts = 4 fdm = marker
* vim < 600 : sw = 4 ts = 4
1999-04-21 23:11:20 +00:00
*/