rbb 99/05/24 20:22:08
Modified: apr/misc/unix start.c apr/test testfile.c testthread.c include apr_general.h Log: Update misc library to always return a status code. Also updated some of the test files. Revision Changes Path 1.4 +35 -37 apache-apr/apr/misc/unix/start.c Index: start.c =================================================================== RCS file: /home/cvs/apache-apr/apr/misc/unix/start.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- start.c 1999/05/25 03:14:17 1.3 +++ start.c 1999/05/25 03:22:06 1.4 @@ -59,60 +59,58 @@ #include <errno.h> #include <string.h> -ap_context_t *ap_initialize(void *data) +ap_status_t ap_create_context(ap_context_t *cont, void *data, ap_context_t **newcont) { ap_context_t *new; ap_pool_t *pool; - pool = ap_init_alloc(); - + if (cont) { + pool = ap_make_sub_pool(cont->pool); + } + else { + pool = ap_init_alloc();; + } + if (pool == NULL) { - errno = APR_ENOPOOL; - return NULL; + return APR_ENOPOOL; } new = (ap_context_t *)ap_palloc(pool, sizeof(ap_context_t)); new->pool = pool; - new->prog_data = data; - new->signal_safe = 0; - new->cancel_safe = 0; - - return new; + if (data == NULL && cont) { + new->prog_data = cont->prog_data; + } + else { + new->prog_data = data; + } + if (cont) { + new->signal_safe = cont->signal_safe; + new->cancel_safe = cont->cancel_safe; + } + else { + new->signal_safe = 0; + new->cancel_safe = 0; + } + + *newcont = new; + return APR_SUCCESS; } ap_status_t ap_set_signal_safe(ap_context_t *cont, ap_int16_t safe) { - cont->signal_safe = safe; - return APR_SUCCESS; + if (cont) { + cont->signal_safe = safe; + return APR_SUCCESS; + } + return APR_ENOCONT; } ap_status_t ap_set_cancel_safe(ap_context_t *cont, ap_int16_t safe) { - cont->cancel_safe = safe; - return APR_SUCCESS; -} - -ap_context_t *ap_create_sub_context(ap_context_t *cont, void *data) -{ - ap_context_t *new; - ap_pool_t *pool; - - pool = ap_make_sub_pool(cont->pool); - if (pool == NULL) { - errno = APR_ENOPOOL; - return NULL; - } - new = (ap_context_t *)ap_palloc(pool, sizeof(ap_context_t)); - new->pool = pool; - if (data == NULL) { - cont->prog_data = cont->prog_data; + if (cont) { + cont->cancel_safe = safe; + return APR_SUCCESS; } - else { - cont->prog_data = data; - } - cont->signal_safe = cont->signal_safe; - cont->cancel_safe = cont->cancel_safe; - - return new; + return APR_ENOCONT; } ap_status_t ap_destroy_context(ap_context_t *cont) 1.21 +1 -1 apache-apr/apr/test/testfile.c Index: testfile.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testfile.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- testfile.c 1999/05/25 03:14:18 1.20 +++ testfile.c 1999/05/25 03:22:07 1.21 @@ -77,7 +77,7 @@ char *str; char *filename = "test.fil"; - if ((context = ap_initialize(NULL)) == NULL) { + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { fprintf(stderr, "Couldn't allocate context."); exit(-1); } 1.5 +1 -1 apache-apr/apr/test/testthread.c Index: testthread.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testthread.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- testthread.c 1999/05/25 03:14:18 1.4 +++ testthread.c 1999/05/25 03:22:07 1.5 @@ -116,7 +116,7 @@ ap_status_t st; fprintf(stdout, "Initializing the context......."); - if (ap_create_context(NULL, NULL,context) != APR_SUCCESS) { + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { fprintf(stderr, "could not initialize\n"); exit(-1); } 1.12 +1 -2 apache-apr/include/apr_general.h Index: apr_general.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_general.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- apr_general.h 1999/05/12 12:00:11 1.11 +++ apr_general.h 1999/05/25 03:22:08 1.12 @@ -88,10 +88,9 @@ } ap_context_t; /* Context functions */ -ap_context_t *ap_initialize(void *); +ap_status_t ap_create_context(ap_context_t *, void *, ap_context_t **); ap_status_t ap_set_signal_safe(ap_context_t *, ap_int16_t ); ap_status_t ap_set_cancel_safe(ap_context_t *, ap_int16_t); -ap_context_t *ap_create_sub_context(ap_context_t *, void *); ap_status_t ap_exit(ap_context_t *); #ifdef __cplusplus