You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dr...@hyperreal.org on 1999/10/08 13:29:55 UTC
cvs commit: apache-2.0/src/lib/apr/misc/beos misc.h start.c
dreid 99/10/08 04:29:55
Modified: src/lib/apr/misc/beos misc.h start.c
Log:
Continuing to bring the beos APR into line.
Revision Changes Path
1.3 +7 -0 apache-2.0/src/lib/apr/misc/beos/misc.h
Index: misc.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/beos/misc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- misc.h 1999/08/27 16:25:41 1.2
+++ misc.h 1999/10/08 11:29:54 1.3
@@ -60,6 +60,13 @@
#include "apr_file_io.h"
#include "apr_errno.h"
+typedef struct datastruct {
+ void *data;
+ char *key;
+ struct datastruct *next;
+ struct datastruct *prev;
+} datastruct;
+
struct context_t {
struct ap_pool_t *pool;
void *prog_data;
1.6 +41 -11 apache-2.0/src/lib/apr/misc/beos/start.c
Index: start.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/beos/start.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- start.c 1999/10/04 16:37:00 1.5
+++ start.c 1999/10/08 11:29:54 1.6
@@ -63,7 +63,7 @@
#include <errno.h>
#include <string.h>
-ap_status_t ap_create_context(ap_context_t **newcont, ap_context_t *cont, void *data)
+ap_status_t ap_create_context(struct context_t **newcont, struct context_t *cont)
{
ap_context_t *new;
ap_pool_t *pool;
@@ -87,12 +87,7 @@
}
new->pool = pool;
- if (data == NULL && cont) {
- new->prog_data = cont->prog_data;
- }
- else {
- new->prog_data = data;
- }
+ new->prog_data = NULL;
*newcont = new;
return APR_SUCCESS;
@@ -104,19 +99,54 @@
return APR_SUCCESS;
}
-ap_status_t ap_set_userdata(struct context_t *cont, void *data)
+ap_status_t ap_set_userdata(struct context_t *cont, void *data, char *key,
+ ap_status_t (*cleanup) (void *))
{
+ datastruct *dptr = NULL, *dptr2 = NULL;
if (cont) {
- cont->prog_data = data;
+ dptr = cont->prog_data;
+ while (dptr) {
+ if (!strcmp(dptr->key, key))
+ break;
+ dptr2 = dptr;
+ dptr = dptr->next;
+ }
+ if (dptr == NULL) {
+ dptr = ap_palloc(cont, sizeof(datastruct));
+ dptr->next = dptr->prev = NULL;
+ dptr->key = strdup(key);
+ if (dptr2) {
+ dptr2->next = dptr;
+ dptr->prev = dptr2;
+ }
+ else {
+ cont->prog_data = dptr;
+ }
+ }
+ dptr->data = data;
+ ap_register_cleanup(cont, dptr->data, cleanup, cleanup);
return APR_SUCCESS;
}
return APR_ENOCONT;
}
-ap_status_t ap_get_userdata(void **data, struct context_t *cont)
+ap_status_t ap_get_userdata(void **data, struct context_t *cont, char *key)
{
+ datastruct *dptr = NULL;
if (cont) {
- (*data) = cont->prog_data;
+ dptr = cont->prog_data;
+ while (dptr) {
+ if (!strcmp(dptr->key, key)) {
+ break;
+ }
+ dptr = dptr->next;
+ }
+ if (dptr) {
+ (*data) = dptr->data;
+ }
+ else {
+ (*data) = NULL;
+ }
return APR_SUCCESS;
}
return APR_ENOCONT;