cvs: php4 /ext/hyperwave hg_comm.c hw.c php_hyperwave.h
| From: | Uwe Steinmann | Date: | Thu, 09 Nov 2000 13:36:53 +0000 |
| Subject: | cvs: php4 /ext/hyperwave hg_comm.c hw.c php_hyperwave.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2539@lists.php.net to get a copy of this message | ||
steinm Thu Nov 9 05:36:53 2000 EDT
Modified files:
/php4/ext/hyperwave hg_comm.c hw.c php_hyperwave.h
Log:
- Some more comments
- Initial support to just include anchors into documents
Index: php4/ext/hyperwave/hg_comm.c
diff -u php4/ext/hyperwave/hg_comm.c:1.32 php4/ext/hyperwave/hg_comm.c:1.33
--- php4/ext/hyperwave/hg_comm.c:1.32 Fri Oct 27 02:29:39 2000
+++ php4/ext/hyperwave/hg_comm.c Thu Nov 9 05:36:53 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.32 2000/10/27 09:29:39 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.33 2000/11/09 13:36:53 steinm Exp $ */
/* #define HW_DEBUG */
@@ -326,12 +326,17 @@
/***********************************************************************
* Function fnCreateAnchorList() *
+* Uses either docofanchorrec or reldestrec to create a list of anchors *
+* depending on anchormode *
* *
* Returns a list of Anchors converted from an object record *
* Parameter: int objectID: the object for which the list is created *
* char **anchors: object records of anchors *
-* char **dest: object records of destinations *
+* char **docofanchorrec: Name of destination absolut *
+* char **reldestrec: Name of destination relativ to current *
+* object *
* int ancount: number of anchors *
+* int anchormode: 0 = use absolut dest, else rel. dest *
* Return: List of Anchors, NULL if error *
***********************************************************************/
#ifdef newlist
@@ -2112,6 +2117,7 @@
DLIST *pAnchorList;
#endif
+ /* Get dest as relative and absolut path */
send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
@@ -3366,11 +3372,17 @@
/* Now get for each anchor the object record of its destination */
for(i=0; i<count; i++) {
/* if you retrieve the anchors you sometimes get more than actually accessible.
- This happens for the object 0x29a9c. */
+ */
if((NULL != anchorrec[i]) && (NULL != (str = fnAttributeValue(anchorrec[i],
"Dest")))) {
sscanf(str, "0x%x", &objectID);
efree(str);
+ /* Using send_docbyanchorobj() makes sense because the Destination can
+ be both, an anchor or a document. If it is a document you get the
+ objectrecord of that document. If it is an anchor the function
+ graps the document which belongs to the anchor
+ and you get also the objectrecord of that document.
+ */
if(0 > send_docbyanchorobj(sockfd, objectID, &objptr)) {
efree(destptr);
return -1;
@@ -3412,6 +3424,7 @@
sscanf(str, "0x%x", &destobjectID);
efree(str);
+ /* See note in send_getdestforanchorsobj() at same position in source code */
if(0 > send_docbyanchorobj(sockfd, destobjectID, &docofanchorptr)) {
efree(reldestptr);
return -1;
@@ -4964,8 +4977,8 @@
efree(retmsg);
/* passively open the data connection. The HG server is probably
- already waiting for us.
- */
+ already waiting for us.
+ */
len = sizeof(serv_addr);
if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
/* php_printf("client: can't open data connection to server\n"); */
@@ -5016,6 +5029,7 @@
DLIST *pAnchorList = NULL;
#endif
+ /* Get dest as relative and absolut path */
send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
Index: php4/ext/hyperwave/hw.c
diff -u php4/ext/hyperwave/hw.c:1.66 php4/ext/hyperwave/hw.c:1.67
--- php4/ext/hyperwave/hw.c:1.66 Fri Oct 27 02:29:39 2000
+++ php4/ext/hyperwave/hw.c Thu Nov 9 05:36:53 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.66 2000/10/27 09:29:39 steinm Exp $ */
+/* $Id: hw.c,v 1.67 2000/11/09 13:36:53 steinm Exp $ */
#include <stdlib.h>
#include <errno.h>
@@ -108,6 +108,7 @@
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 @@
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)
{
@@ -3827,6 +3850,50 @@
RETURN_FALSE;
}
+ RETURN_STRING(anchorstr, 0);
+}
+/* }}} */
+
+/* {{{ 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);
}
/* }}} */
Index: php4/ext/hyperwave/php_hyperwave.h
diff -u php4/ext/hyperwave/php_hyperwave.h:1.10 php4/ext/hyperwave/php_hyperwave.h:1.11
--- php4/ext/hyperwave/php_hyperwave.h:1.10 Fri Oct 27 02:29:39 2000
+++ php4/ext/hyperwave/php_hyperwave.h Thu Nov 9 05:36:53 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_hyperwave.h,v 1.10 2000/10/27 09:29:39 steinm Exp $ */
+/* $Id: php_hyperwave.h,v 1.11 2000/11/09 13:36:53 steinm Exp $ */
#ifndef PHP_HYPERWAVE_H
#define PHP_HYPERWAVE_H
@@ -142,6 +142,7 @@
PHP_FUNCTION(hw_array2objrec);
PHP_FUNCTION(hw_connection_info);
PHP_FUNCTION(hw_getsrcbydestobj);
+PHP_FUNCTION(hw_insertanchors);
PHP_FUNCTION(hw_getrellink);
PHP_FUNCTION(hw_dummy);
PHP_FUNCTION(hw_who);