httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@hyperreal.org
Subject cvs commit: apache-2.0/src/lib/apr/misc/win32 start.c misc.h
Date Wed, 22 Sep 1999 13:29:29 GMT
stoddard    99/09/22 06:29:29

  Modified:    src/lib/apr/misc/win32 start.c misc.h
  Log:
  More syncing with the unix tree. There really should be a 'common' tree
  to put much of this stuff.
  
  Revision  Changes    Path
  1.5       +49 -19    apache-2.0/src/lib/apr/misc/win32/start.c
  
  Index: start.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/win32/start.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- start.c	1999/09/22 13:13:40	1.4
  +++ start.c	1999/09/22 13:29:27	1.5
  @@ -78,29 +78,24 @@
       ap_pool_t *pool;
   
       if (cont) {
  -        ap_context_t = ap_make_sub_pool(cont->pool);
  +        pool = ap_make_sub_pool(cont->pool);
       }
       else {
  -        ap_context_t = ap_init_alloc();;
  +        pool = ap_init_alloc();;
       }
           
  -    if (ap_context_t == NULL) {
  +    if (pool == NULL) {
           return APR_ENOPOOL;
       }
       
  -	if (cont) {
  -		new = (ap_context_t *)ap_palloc(cont, sizeof(ap_context_t));
  -	}
  -	else {
  -		new = (ap_context_t *)malloc(sizeof(ap_context_t));
  -	}
  -    new->pool = pool;
  -    if (data == NULL && cont) {
  -        new->prog_data = cont->prog_data;
  +    if (cont) {
  +        new = (ap_context_t *)ap_palloc(cont, sizeof(ap_context_t));
       }
       else {
  -        new->prog_data = data;
  +        new = (ap_context_t *)malloc(sizeof(ap_context_t));
       }
  +    new->pool = pool;
  +    new->prog_data = NULL;
   
       iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte);
       err = WSAStartup((WORD) iVersionRequested, &wsaData);
  @@ -109,8 +104,8 @@
       }
       if (LOBYTE(wsaData.wVersion) != WSAHighByte ||
           HIBYTE(wsaData.wVersion) != WSALowByte) {
  -	    WSACleanup();
  -	    return APR_EEXIST;
  +        WSACleanup();
  +        return APR_EEXIST;
       }
   
       ap_register_cleanup(new, NULL, clean_cont, NULL);
  @@ -151,19 +146,54 @@
   	return APR_EEXIST;
   }
   
  -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(struct context_t *cont, void **data)
  +ap_status_t ap_get_userdata(struct context_t *cont, char *key, void **data)
   {
  +    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;
  
  
  
  1.3       +7 -0      apache-2.0/src/lib/apr/misc/win32/misc.h
  
  Index: misc.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/win32/misc.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- misc.h	1999/08/27 16:26:01	1.2
  +++ misc.h	1999/09/22 13:29:28	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;
  
  
  

Mime
View raw message