cvs: /php4/ext/domxml domxml.c /php4/ext/hyperwave hg_comm.c hw.c /php4/tests testhyperwave
| From: | Uwe Steinmann | Date: | Wed, 08 Mar 2000 17:52:28 +0000 |
| Subject: | cvs: /php4/ext/domxml domxml.c /php4/ext/hyperwave hg_comm.c hw.c /php4/tests testhyperwave | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11760@lists.php.net to get a copy of this message | ||
steinm Wed Mar 8 09:52:28 2000 EDT
Modified files:
/php4/ext/domxml domxml.c
/php4/ext/hyperwave hg_comm.c hw.c
/php4/tests testhyperwave
Log:
- several fixes and cleanups in hw module
Index: php4/ext/domxml/domxml.c
diff -u php4/ext/domxml/domxml.c:1.29 php4/ext/domxml/domxml.c:1.30
--- php4/ext/domxml/domxml.c:1.29 Mon Mar 6 10:41:06 2000
+++ php4/ext/domxml/domxml.c Wed Mar 8 09:51:57 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: domxml.c,v 1.29 2000/03/06 18:41:06 ssb Exp $ */
+/* $Id: domxml.c,v 1.30 2000/03/08 17:51:57 steinm Exp $ */
#include "php.h"
@@ -1201,7 +1201,7 @@
add_property_stringl(pattr, "content", (char *) attr->val->content,
strlen(attr->val->content), 1);
else {
if(0 == node_children(&children, attr->val))
- zend_hash_update(pattr->value.obj.properties, "content",
strlen("content")+1, (void *) &children, sizeof(zval *), NULL);
+ zend_hash_update(pattr->value.obj.properties, "content",
sizeof("content"), (void *) &children, sizeof(zval *), NULL);
}
zend_hash_next_index_insert((*attributes)->value.ht, &pattr, sizeof(zval *), NULL);
attr = attr->next;
@@ -1250,15 +1250,15 @@
/* Get the namespace of the current node and add it as a property */
if(!node_namespace(&namespace, last))
- zend_hash_update(child->value.obj.properties, "namespace",
strlen("namespace")+1, (void *) &namespace, sizeof(zval *), NULL);
+ zend_hash_update(child->value.obj.properties, "namespace",
sizeof("namespace"), (void *) &namespace, sizeof(zval *), NULL);
/* Get the attributes of the current node and add it as a property */
if(!node_attributes(&attributes, last))
- zend_hash_update(child->value.obj.properties, "attributes",
strlen("attributes")+1, (void *) &attributes, sizeof(zval *), NULL);
+ zend_hash_update(child->value.obj.properties, "attributes",
sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL);
/* Get recursively the children of the current node and add it as a property */
if(!node_children(&mchildren, last->childs))
- zend_hash_update(child->value.obj.properties, "children",
strlen("children")+1, (void *) &mchildren, sizeof(zval *), NULL);
+ zend_hash_update(child->value.obj.properties, "children",
sizeof("children"), (void *) &mchildren, sizeof(zval *), NULL);
last = last->next;
}
@@ -1305,7 +1305,7 @@
if(0 == node_children(&children, root)) {
int i, count;
HashTable *lht;
- zend_hash_update(return_value->value.obj.properties, "children",
strlen("children")+1, (void *) &children, sizeof(zval *), NULL);
+ zend_hash_update(return_value->value.obj.properties, "children",
sizeof("children"), (void *) &children, sizeof(zval *), NULL);
/* Find the child of xml type element */
lht = children->value.ht;
Index: php4/ext/hyperwave/hg_comm.c
diff -u php4/ext/hyperwave/hg_comm.c:1.24 php4/ext/hyperwave/hg_comm.c:1.25
--- php4/ext/hyperwave/hg_comm.c:1.24 Tue Mar 7 06:53:01 2000
+++ php4/ext/hyperwave/hg_comm.c Wed Mar 8 09:51:57 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.24 2000/03/07 14:53:01 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.25 2000/03/08 17:51:57 steinm Exp $ */
/* #define HW_DEBUG */
@@ -457,16 +457,37 @@
cur_ptr->fragment = estrdup(link);
}
- cur_ptr->htmlattr = NULL;
- if(NULL != (str = strstr(object, "HtmlAttr="))) {
+ {
+ char *htmlattr, *str2;
+ int offset;
+ str1 = object;
+ htmlattr = emalloc(strlen(object));
+ htmlattr[0] = '\0';
+ offset = 0;
+ while(NULL != (str = strstr(str1, "HtmlAttr="))) {
str += 9;
str1 = str;
while((*str1 != '\n') && (*str1 != '\0'))
str1++;
- cur_ptr->htmlattr = emalloc(str1 - str + 1);
- strncpy(cur_ptr->htmlattr, str, str1 - str);
- cur_ptr->htmlattr[str1 - str] = '\0';
+ if(NULL != (str2 = strchr(str, '='))) {
+ str2++;
+ strncpy(&htmlattr[offset], str, str2 - str);
+ offset = offset + (str2 - str);
+ htmlattr[offset++] = '"';
+ strncpy(&htmlattr[offset], str2, str1 - str2);
+ offset = offset + (str1 - str2);
+ htmlattr[offset++] = '"';
+ htmlattr[offset++] = ' ';
+ htmlattr[offset] = '\0';
+ }
+ }
+ if(offset){
+ /* remove last space */
+ htmlattr[offset-1] = '\0';
+ cur_ptr->htmlattr = estrdup(htmlattr);
}
+ efree(htmlattr);
+ }
if(NULL != (str = strstr(object, "LinkType="))) {
str += 9;
@@ -629,9 +650,14 @@
default:
newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
if(cur_ptr->fragment)
- snprintf(istr, BUFFERLEN, "<A HREF='%s#%s' %s>", cur_ptr->link,
cur_ptr->fragment, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
+ snprintf(istr, BUFFERLEN, "<A HREF='%s#%s'", cur_ptr->link,
cur_ptr->fragment);
else
- snprintf(istr, BUFFERLEN, "<A HREF='%s' %s>", cur_ptr->link,
cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
+ snprintf(istr, BUFFERLEN, "<A HREF='%s'", cur_ptr->link);
+ if(cur_ptr->htmlattr) {
+ strncat(istr, " ", BUFFERLEN - 1 - strlen(istr));
+ strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr));
+ }
+ strncat(istr, ">", BUFFERLEN - 1 - strlen(istr));
}
} else {
switch(cur_ptr->linktype) {
@@ -643,7 +669,6 @@
break;
case HW_INTAG_LINK:
if(cur_ptr->fragment)
-/* snprintf(istr, BUFFERLEN, " %s='%s/%s#%s'", cur_ptr->tagattr,
scriptname == NULL ? "." : scriptname, cur_ptr->destdocname, cur_ptr->fragment);*/
snprintf(istr, BUFFERLEN, " %s='#%s'", cur_ptr->tagattr,
cur_ptr->fragment);
else
snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname
== NULL ? "." : scriptname, cur_ptr->destdocname);
@@ -661,19 +686,19 @@
newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
if(cur_ptr->nameanchor)
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname ==
NULL ? "schade" : scriptname, cur_ptr->destdocname, cur_ptr->nameanchor,
cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
+ snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s'", scriptname == NULL ?
"schade" : scriptname, cur_ptr->destdocname, cur_ptr->nameanchor);
+ else if(cur_ptr->fragment)
+ snprintf(istr, BUFFERLEN, "<A HREF=\"%s/%s#%s\"", scriptname == NULL
? "" : scriptname, cur_ptr->destdocname, cur_ptr->fragment);
else
- if(cur_ptr->fragment)
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname ==
NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->fragment,
cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr);
- else
- snprintf(istr, BUFFERLEN, "<A HREF='%s/%s' %s>", scriptname ==
NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->htmlattr == NULL ?
"" : cur_ptr->htmlattr);
+ snprintf(istr, BUFFERLEN, "<A HREF='%s/%s'", scriptname == NULL ?
"" : scriptname, cur_ptr->destdocname);
+
+ if(cur_ptr->htmlattr) {
+ strncat(istr, " ", BUFFERLEN - 1 - strlen(istr));
+ strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr));
+ }
+ strncat(istr, ">", BUFFERLEN - 1 - strlen(istr));
}
}
- newtext = fnInsStr(newtext, cur_ptr->start, istr);
- /* In case there are several TAGS nested, we accumulate the offset
- You wonder what the 4 means? It's the length of </A> */
- offset += strlen(istr) + 4;
- laststart = cur_ptr->start;
} else {
if(laststart >= cur_ptr->end)
offset = 0;
@@ -686,12 +711,12 @@
snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->keyword);
else if(cur_ptr->nameanchor)
snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->nameanchor);
- newtext = fnInsStr(newtext, cur_ptr->start, istr);
- /* In case there are several TAGS nested, we accumulate the offset
- You wonder what the 4 means? It's the length of </A> */
- offset += strlen(istr) + 4;
- laststart = cur_ptr->start;
}
+ newtext = fnInsStr(newtext, cur_ptr->start, istr);
+ /* In case there are several TAGS nested, we accumulate the offset
+ You wonder what the 4 means? It's the length of </A> */
+ offset += strlen(istr) + 4;
+ laststart = cur_ptr->start;
#ifdef newlist
ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList);
if(ptr)
Index: php4/ext/hyperwave/hw.c
diff -u php4/ext/hyperwave/hw.c:1.45 php4/ext/hyperwave/hw.c:1.46
--- php4/ext/hyperwave/hw.c:1.45 Mon Mar 6 10:41:07 2000
+++ php4/ext/hyperwave/hw.c Wed Mar 8 09:51:57 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.45 2000/03/06 18:41:07 ssb Exp $ */
+/* $Id: hw.c,v 1.46 2000/03/08 17:51:57 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -299,6 +299,7 @@
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);
+ add_assoc_long(spec_arr, "HtmlAttr", HW_ATTR_NONE);
}
if (array_init(*return_value) == FAILURE) {
Index: php4/tests/testhyperwave
diff -u php4/tests/testhyperwave:1.2 php4/tests/testhyperwave:1.3
--- php4/tests/testhyperwave:1.2 Fri Mar 3 04:38:20 2000
+++ php4/tests/testhyperwave Wed Mar 8 09:51:57 2000
@@ -1,9 +1,9 @@
<?
- $id = 187852; // A plain/text document
+ $id = 188178; // A plain/text document
$collid = 169828; // A collection
$query = "Name=m*"; // Search query for test_9
$host = "gehtnix";
- $username = "steinm";
+ $username = "annonymous";
$password = "";
$connect = hw_connect($host, 418, $username, $password);
@@ -22,11 +22,13 @@
$test_7 = "no"; // Insert a new text document
$test_8 = "no"; // Remove the just inserted text document
$test_9 = "no"; // Searching for objects with Name $query
+ $test_10= "yes"; // Listing all anchors of a document
/* Lists an object array
*/
function list_attr($attributes) {
- global $imagepath;
+ var_dump($attributes);
+ return;
for($i=0; $i<count($attributes); $i++) {
$key = key($attributes);
switch($key) {
@@ -195,6 +197,16 @@
}
list_attr($objrecs[$c_objrecs]);
}
+
+ if($test_10 == "yes") {
+ $anchors = hw_getanchorsobj($connect, $id);
+ $countanchors = count($anchors) - 1;
+ echo "$countanchors Anchors of Object $id\n";
+ for($i=0; $i<$countanchors; $i++) {
+ $arr = hw_objrec2array($anchors[$i]);
+ list_attr($arr);
+ }
+ }
hw_close($connect);
?>