* -----------------
*
* $Log$
+* Revision 1.2 1999/05/11 00:01:42 zeev
+* * Get Apache to work. POST doesn't work yet.
+* * There are now -I directives for the absolute path of php4, php4/libzend and the builddir for
+* the Apache module, so we can #include any php/Zend header.
+* * Rename config.h to php_config.h
+*
* Revision 1.1 1999/04/21 23:11:20 ssb
* moved apache, com and hyperwave into ext/
*
#include "php_config.h"
#endif
-#if HYPERWAVE
-
#include <stdio.h>
#include <malloc.h>
#include <signal.h>
-#include "debug.h"
-#include "DList.h"
+#include "dlist.h"
+
+#define PUBLIC
+#define PRIVATE static
PUBLIC void *dlst_newnode(int size)
/****************************************************************************
*
****************************************************************************/
{
- DLST_BUCKET *node;
+ PHP_DLST_BUCKET *node;
- if ( !(node = (DLST_BUCKET*)malloc(size + sizeof(DLST_BUCKET))) ) {
+ if ( !(node = (PHP_DLST_BUCKET*)malloc(size + sizeof(PHP_DLST_BUCKET))) ) {
fprintf(stderr,"Not enough memory to allocate list node.\n");
/* raise(SIGABRT);*/
return NULL;
}
- return DLST_USERSPACE(node); /* Return pointer to user space */
+ return PHP_DLST_USERSPACE(node); /* Return pointer to user space */
}
PUBLIC void dlst_freenode(void *node)
*
****************************************************************************/
{
- free(DLST_HEADER(node));
+ free(PHP_DLST_HEADER(node));
}
PUBLIC DLIST *dlst_init(void)
*
****************************************************************************/
{
- DLST_BUCKET *n,*p;
+ PHP_DLST_BUCKET *n,*p;
n = l->head->next;
while (n != l->z) { /* Free all nodes in list */
p = n;
n = n->next;
- (*freeNode)(DLST_USERSPACE(p));
+ (*freeNode)(PHP_DLST_USERSPACE(p));
}
free(l); /* Free the list itself */
}
*
* Description: Inserts a new node into the list after the node 'after'. To
* insert a new node at the beginning of the list, user the
-* macro DLST_HEAD in place of 'after'. ie:
+* macro PHP_DLST_HEAD in place of 'after'. ie:
*
-* dlst_insertafter(mylist,node,DLST_HEAD(mylist));
+* dlst_insertafter(mylist,node,PHP_DLST_HEAD(mylist));
*
****************************************************************************/
{
- DLST_BUCKET *n = DLST_HEADER(node),*a = DLST_HEADER(after);
+ PHP_DLST_BUCKET *n = PHP_DLST_HEADER(node),*a = PHP_DLST_HEADER(after);
n->next = a->next;
a->next = n;
*
****************************************************************************/
{
- DLST_BUCKET *n = DLST_HEADER(node);
+ PHP_DLST_BUCKET *n = PHP_DLST_HEADER(node);
- node = DLST_USERSPACE(n->next);
+ node = PHP_DLST_USERSPACE(n->next);
n->next->next->prev = n;
n->next = n->next->next;
l->count--;
*
****************************************************************************/
{
- DLST_BUCKET *n;
+ PHP_DLST_BUCKET *n;
n = l->head->next;
- return (n == l->z ? NULL : DLST_USERSPACE(n));
+ return (n == l->z ? NULL : PHP_DLST_USERSPACE(n));
}
PUBLIC void *dlst_last(DLIST *l)
*
****************************************************************************/
{
- DLST_BUCKET *n;
+ PHP_DLST_BUCKET *n;
n = l->z->prev;
- return (n == l->head ? NULL : DLST_USERSPACE(n));
+ return (n == l->head ? NULL : PHP_DLST_USERSPACE(n));
}
PUBLIC void *dlst_next(void *prev)
*
****************************************************************************/
{
- DLST_BUCKET *n = DLST_HEADER(prev);
+ PHP_DLST_BUCKET *n = PHP_DLST_HEADER(prev);
n = n->next;
- return (n == n->next ? NULL : DLST_USERSPACE(n));
+ return (n == n->next ? NULL : PHP_DLST_USERSPACE(n));
}
PUBLIC void *dlst_prev(void *next)
*
****************************************************************************/
{
- DLST_BUCKET *n = DLST_HEADER(next);
+ PHP_DLST_BUCKET *n = PHP_DLST_HEADER(next);
n = n->prev;
- return (n == n->prev ? NULL : DLST_USERSPACE(n));
+ return (n == n->prev ? NULL : PHP_DLST_USERSPACE(n));
}
/* Static globals required by merge() */
-static DLST_BUCKET *z;
+static PHP_DLST_BUCKET *z;
static int (*cmp)(void*,void*);
-PRIVATE DLST_BUCKET *merge(DLST_BUCKET *a,DLST_BUCKET *b,DLST_BUCKET **end)
+PRIVATE PHP_DLST_BUCKET *merge(PHP_DLST_BUCKET *a,PHP_DLST_BUCKET *b,PHP_DLST_BUCKET **end)
/****************************************************************************
*
* Function: merge
*
****************************************************************************/
{
- DLST_BUCKET *c;
+ PHP_DLST_BUCKET *c;
/* Go through the lists, merging them together in sorted order */
c = z;
while (a != z && b != z) {
- if ((*cmp)(DLST_USERSPACE(a),DLST_USERSPACE(b)) <= 0) {
+ if ((*cmp)(PHP_DLST_USERSPACE(a),PHP_DLST_USERSPACE(b)) <= 0) {
c->next = a; c = a; a = a->next;
}
else {
****************************************************************************/
{
int i,N;
- DLST_BUCKET *a,*b; /* Pointers to sublists to merge */
- DLST_BUCKET *c; /* Pointer to end of sorted sublists */
- DLST_BUCKET *head; /* Pointer to dummy head node for list */
- DLST_BUCKET *todo; /* Pointer to sublists yet to be sorted */
- DLST_BUCKET *t; /* Temporary */
+ PHP_DLST_BUCKET *a,*b; /* Pointers to sublists to merge */
+ PHP_DLST_BUCKET *c; /* Pointer to end of sorted sublists */
+ PHP_DLST_BUCKET *head; /* Pointer to dummy head node for list */
+ PHP_DLST_BUCKET *todo; /* Pointer to sublists yet to be sorted */
+ PHP_DLST_BUCKET *t; /* Temporary */
/* Set up globals required by merge() and pointer to head */
}
}
-#endif
* -----------------
*
* $Log$
+* Revision 1.1 1999/04/21 23:11:20 ssb
+* moved apache, com and hyperwave into ext/
+*
* Revision 1.1.1.1 1999/04/07 21:03:20 zeev
* PHP 4.0
*
/*---------------------- Macros and type definitions ----------------------*/
-typedef struct DLST_BUCKET {
- struct DLST_BUCKET *next;
- struct DLST_BUCKET *prev;
- } DLST_BUCKET;
+typedef struct PHP_DLST_BUCKET {
+ struct PHP_DLST_BUCKET *next;
+ struct PHP_DLST_BUCKET *prev;
+ } PHP_DLST_BUCKET;
+
+/* necessary for AIX 4.2.x */
+
+#ifdef hz
+#undef hz
+#endif
typedef struct {
int count; /* Number of elements currently in list */
- DLST_BUCKET *head; /* Pointer to head element of list */
- DLST_BUCKET *z; /* Pointer to last node of list */
- DLST_BUCKET hz[2]; /* Space for head and z nodes */
+ PHP_DLST_BUCKET *head; /* Pointer to head element of list */
+ PHP_DLST_BUCKET *z; /* Pointer to last node of list */
+ PHP_DLST_BUCKET hz[2]; /* Space for head and z nodes */
} DLIST;
/* Return a pointer to the user space given the address of the header of
* a node.
*/
-#define DLST_USERSPACE(h) ((void*)((DLST_BUCKET*)(h) + 1))
+#define PHP_DLST_USERSPACE(h) ((void*)((PHP_DLST_BUCKET*)(h) + 1))
/* Return a pointer to the header of a node, given the address of the
* user space.
*/
-#define DLST_HEADER(n) ((DLST_BUCKET*)(n) - 1)
+#define PHP_DLST_HEADER(n) ((PHP_DLST_BUCKET*)(n) - 1)
/* Return a pointer to the user space of the list's head node. This user
* space does not actually exist, but it is useful to be able to address
* it to enable insertion at the start of the list.
*/
-#define DLST_HEAD(l) DLST_USERSPACE((l)->head)
+#define PHP_DLST_HEAD(l) PHP_DLST_USERSPACE((l)->head)
/* Return a pointer to the user space of the last node in list. */
-#define DLST_TAIL(l) DLST_USERSPACE((l)->z->prev)
+#define PHP_DLST_TAIL(l) PHP_DLST_USERSPACE((l)->z->prev)
/* Determine if a list is empty
*/
-#define DLST_EMPTY(l) ((l)->count == 0)
+#define PHP_DLST_EMPTY(l) ((l)->count == 0)
/*-------------------------- Function Prototypes --------------------------*/