summaryrefslogtreecommitdiff
path: root/ext/hyperwave/hw.c
diff options
context:
space:
mode:
authorUwe Steinmann <steinm@php.net>2000-11-09 13:36:54 +0000
committerUwe Steinmann <steinm@php.net>2000-11-09 13:36:54 +0000
commiteaad937f84c8bacaa425a038b4b837686c47c1f5 (patch)
tree1edfc957305ac34ccfbb8060c6895a5fe03264cb /ext/hyperwave/hw.c
parentd82bade81cb5d8dfa85d95918fadfa31268d401e (diff)
downloadphp-git-eaad937f84c8bacaa425a038b4b837686c47c1f5.tar.gz
- Some more comments
- Initial support to just include anchors into documents
Diffstat (limited to 'ext/hyperwave/hw.c')
-rw-r--r--ext/hyperwave/hw.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
index d383d30629..0351c4d7ac 100644
--- a/ext/hyperwave/hw.c
+++ b/ext/hyperwave/hw.c
@@ -108,6 +108,7 @@ function_entry hw_functions[] = {
PHP_FE(hw_insertobject, NULL)
PHP_FE(hw_insdoc, NULL)
PHP_FE(hw_getsrcbydestobj, NULL)
+ PHP_FE(hw_insertanchors, NULL)
PHP_FE(hw_getrellink, NULL)
PHP_FE(hw_who, NULL)
PHP_FE(hw_stat, NULL)
@@ -633,6 +634,28 @@ static int * make_ints_from_array(HashTable *lht) {
return objids;
}
+static char **make_strs_from_array(HashTable *arrht) {
+ char **carr = NULL;
+ zval *data, **dataptr;
+
+ zend_hash_internal_pointer_reset(arrht);
+ if(NULL == (carr = emalloc(zend_hash_num_elements(arrht) * sizeof(char *))))
+ return(NULL);
+
+ /* Iterate through hash */
+ while(zend_hash_get_current_data(arrht, (void **) &dataptr) == SUCCESS) {
+ data = *dataptr;
+ switch(data->type) {
+ case IS_STRING:
+ *carr++ = estrdup(data->value.str.val);
+ break;
+ }
+
+ zend_hash_move_forward(arrht);
+ }
+ return(carr);
+}
+
#define BUFFERLEN 30
static void php_hw_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
@@ -3831,6 +3854,50 @@ PHP_FUNCTION(hw_getrellink) {
}
/* }}} */
+/* {{{ proto string hw_insertanchors(int hwdoc, array anchorecs, array dest)
+ Inserts only anchors into text */
+PHP_FUNCTION(hw_insertanchors) {
+ pval **arg1, **arg2, **arg3, **arg4;
+ hw_document *hwdoc;
+ int type, docid, error;
+ char *anchorstr;
+ char **anchorrecs;
+ char **dest;
+ HashTable *arrht;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(arg1);
+ convert_to_array_ex(arg2);
+ convert_to_array_ex(arg3);
+ docid=(*arg1)->value.lval;
+ hwdoc = zend_list_find(docid, &type);
+ if(!hwdoc || (type!=HwSG(le_document))) {
+ php_error(E_WARNING,"Unable to find file identifier %d",link);
+ RETURN_FALSE;
+ }
+
+ if(zend_hash_num_elements((*arg2)->value.ht) != zend_hash_num_elements((*arg3)->value.ht)) {
+ php_error(E_WARNING,"Unequal number of elments in arrays");
+ RETURN_FALSE;
+ }
+
+ /* Turn PHP-Array of strings into C-Array of strings */
+ arrht = (*arg2)->value.ht;
+ anchorrecs = make_strs_from_array(arrht);
+ arrht = (*arg3)->value.ht;
+ dest = make_strs_from_array(arrht);
+/*
+ if (0 != (error = insertanchors(hwdoc->data, anchorrecs, dest, zend_hash_num_elements(arrht)))) {
+ php_error(E_WARNING, "command (insertanchors) returned %d\n", error);
+ RETURN_FALSE;
+ }
+*/
+ RETURN_STRING(anchorstr, 0);
+}
+/* }}} */
+
PHP_MINFO_FUNCTION(hw)
{