cvs: /php4/ext/hyperwave hg_comm.c
| From: | Uwe Steinmann | Date: | Tue, 07 Mar 2000 13:16:30 +0000 |
| Subject: | cvs: /php4/ext/hyperwave hg_comm.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11671@lists.php.net to get a copy of this message | ||
steinm Tue Mar 7 05:16:30 2000 EDT
Modified files:
/php4/ext/hyperwave hg_comm.c
Log:
- switch to zend's double link list finished
Index: php4/ext/hyperwave/hg_comm.c
diff -u php4/ext/hyperwave/hg_comm.c:1.22 php4/ext/hyperwave/hg_comm.c:1.23
--- php4/ext/hyperwave/hg_comm.c:1.22 Fri Mar 3 04:37:09 2000
+++ php4/ext/hyperwave/hg_comm.c Tue Mar 7 05:16:00 2000
@@ -16,11 +16,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.22 2000/03/03 12:37:09 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.23 2000/03/07 13:16:00 steinm Exp $ */
/* #define HW_DEBUG */
-//#define newlist
+#define newlist
#include <stdlib.h>
#include "php.h"
@@ -143,7 +143,7 @@
int start, int end)
#endif
{
- ANCHOR *cur_ptr;
+ ANCHOR *cur_ptr, **ptr;
#ifdef newlist
if(NULL == (cur_ptr = (ANCHOR *) emalloc(sizeof(ANCHOR))))
@@ -169,7 +169,8 @@
cur_ptr->fragment = NULL;
#ifdef newlist
- zend_llist_prepend_element(pAnchorList, cur_ptr);
+ zend_llist_prepend_element(pAnchorList, &cur_ptr);
+ ptr = (ANCHOR **) zend_llist_get_first(pAnchorList);
#else
dlst_insertafter(pAnchorList, cur_ptr, PHP_DLST_HEAD(pAnchorList));
#endif
@@ -191,8 +192,9 @@
#endif
{
#ifdef newlist
- ANCHOR *ptr;
- ptr = (ANCHOR *) ptr1;
+ ANCHOR **ptr2, *ptr;
+ ptr2 = (ANCHOR **) ptr1;
+ ptr = *ptr2;
#endif
if(ptr->destdocname) efree(ptr->destdocname);
@@ -225,28 +227,30 @@
void fnListAnchor(DLIST *pAnchorList)
#endif
{
- ANCHOR *cur_ptr;
#ifdef newlist
- cur_ptr = (ANCHOR *) zend_llist_get_last(pAnchorList);
+ ANCHOR *cur_ptr, **ptr;
+ ptr = (ANCHOR **) zend_llist_get_last(pAnchorList);
+ if(ptr)
+ cur_ptr = *ptr;
+ while(ptr) {
#else
+ ANCHOR *cur_ptr;
cur_ptr = (ANCHOR *) dlst_last(pAnchorList);
-#endif
while(cur_ptr) {
+#endif
- fprintf(stderr, "%d, %d, %s, %s, %s %s\n", cur_ptr->start,
+ fprintf(stderr, "0x%X->0x%X ", ptr, cur_ptr);
+ fprintf(stderr, "%d, %d, %s, %s, %s, %s %s\n", cur_ptr->start,
cur_ptr->end,
+ cur_ptr->tanchor == 1 ? "src" :
"dest",
cur_ptr->destdocname,
cur_ptr->nameanchor,
cur_ptr->link,
cur_ptr->tagattr);
-// if(ptr->htmlattr) efree(ptr->htmlattr);
-// if(ptr->codebase) efree(ptr->codebase);
-// if(ptr->code) efree(ptr->code);
-// if(ptr->keyword) efree(ptr->keyword);
-// if(ptr->fragment) efree(ptr->fragment);
-
#ifdef newlist
- cur_ptr = (ANCHOR *) zend_llist_get_prev(pAnchorList);
+ ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList);
+ if(ptr)
+ cur_ptr = *ptr;
#else
cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
#endif
@@ -261,8 +265,21 @@
* ANCHOR a2: Second Anchor *
* Return: As strcmp *
***********************************************************************/
+#ifdef newlist
+int fnCmpAnchors(const void *e1, const void *e2)
+{
+ ANCHOR *a1, **aa1, *a2, **aa2;
+ zend_llist_element **ee1, **ee2;
+ ee1 = e1;
+ ee2 = e2;
+ aa1 = (ANCHOR **) (*ee1)->data;
+ aa2 = (ANCHOR **) (*ee2)->data;
+ a1 = *aa1;
+ a2 = *aa2;
+#else
int fnCmpAnchors(ANCHOR *a1, ANCHOR *a2)
{
+#endif
if(a1->start < a2->start)
return -1;
if(a1->start == a2->start) {
@@ -542,7 +559,7 @@
#else
char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char *urlprefix) {
#endif
- ANCHOR *cur_ptr;
+ ANCHOR *cur_ptr, **ptr;
char bgstr[BUFFERLEN], istr[BUFFERLEN];
char *scriptname;
char *newtext;
@@ -578,13 +595,16 @@
bgstr[0] = '\0';
#ifdef newlist
zend_llist_sort(pAnchorList, fnCmpAnchors);
- cur_ptr = (ANCHOR *) zend_llist_get_last(pAnchorList);
+ ptr = (ANCHOR **) zend_llist_get_last(pAnchorList);
+ if(ptr)
+ cur_ptr = *ptr;
+ while(NULL != ptr) {
#else
dlst_mergesort(pAnchorList, fnCmpAnchors);
cur_ptr = (ANCHOR *) dlst_last(pAnchorList);
+ while(NULL != cur_ptr) {
#endif
- while(NULL != cur_ptr) {
istr[0] = '\0';
if(cur_ptr->tanchor == 1) { /* Src Anchor */
if(laststart >= cur_ptr->end)
@@ -673,9 +693,11 @@
laststart = cur_ptr->start;
}
#ifdef newlist
- cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
+ ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList);
+ if(ptr)
+ cur_ptr = *ptr;
#else
- cur_ptr = (ANCHOR *) zend_llist_get_prev(pAnchorList);
+ cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
#endif
}
snprintf(istr, BUFFERLEN, "<BODY %s>", bgstr);
@@ -1995,7 +2017,7 @@
send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
-//fnListAnchor(pAnchorList);
+
/* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
if(anchors) efree(anchors);
if(destrec) efree(destrec);