Status: X-Status: X-Keywords: Return-Path: Delivered-To: apmail-httpd-apreq-cvs-archive@httpd.apache.org Received: (qmail 35412 invoked by uid 500); 26 Jun 2001 10:58:57 -0000 Mailing-List: contact apreq-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list apreq-cvs@httpd.apache.org Received: (qmail 35239 invoked by uid 1048); 26 Jun 2001 10:58:42 -0000 Date: 26 Jun 2001 10:58:42 -0000 Message-ID: <20010626105842.35238.qmail@apache.org> From: davidw@apache.org To: httpd-apreq-cvs@apache.org Subject: cvs commit: httpd-apreq/c apache_cookie.c apache_multipart_buffer.c apache_request.c apache_request.h davidw 01/06/26 03:58:41 Modified: c apache_cookie.c apache_multipart_buffer.c apache_request.c apache_request.h Log: Killed extra white space corresponding to s/[:space:]+$// Added a few macros for accessing struct components. Revision Changes Path 1.10 +10 -10 httpd-apreq/c/apache_cookie.c Index: apache_cookie.c =================================================================== RCS file: /home/cvs/httpd-apreq/c/apache_cookie.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- apache_cookie.c 2001/03/15 03:04:12 1.9 +++ apache_cookie.c 2001/06/26 10:58:20 1.10 @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -78,7 +78,7 @@ char *retval = NULL; int ix = key[0] == '-' ? 1 : 0; - switch (key[ix]) { + switch (key[ix]) { case 'n': cookie_get_set(c->name, val); break; @@ -96,14 +96,14 @@ break; case 's': if(val) { - c->secure = + c->secure = !strcaseEQ(val, "off") && !strcaseEQ(val, "0"); } retval = c->secure ? "on" : ""; break; default: - ap_log_rerror(APC_ERROR, + ap_log_rerror(APC_ERROR, "[libapreq] unknown cookie pair: `%s' => `%s'", key, val); }; @@ -114,7 +114,7 @@ { va_list args; ApacheRequest req; - ApacheCookie *c = + ApacheCookie *c = ap_pcalloc(r->pool, sizeof(ApacheCookie)); req.r = r; @@ -144,7 +144,7 @@ ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data) { const char *pair; - ApacheCookieJar *retval = + ApacheCookieJar *retval = ap_make_array(r->pool, 1, sizeof(ApacheCookie *)); if (!data) { @@ -192,7 +192,7 @@ cookie_push_arr(arr, ap_pstrcat(p, name, "=", val, NULL)); \ } -static char * escape_url(pool *p, char *val) +static char * escape_url(pool *p, char *val) { char *result = ap_os_escape_path(p, val?val:"", 1); char *end = result + strlen(result); @@ -248,15 +248,15 @@ cookie = ap_pstrcat(p, escape_url(p, c->name), "=", NULL); for (i=0; ivalues->nelts; i++) { - cookie = ap_pstrcat(p, cookie, - escape_url(p, ((char**)c->values->elts)[i]), + cookie = ap_pstrcat(p, cookie, + escape_url(p, ((char**)c->values->elts)[i]), (i < (c->values->nelts-1) ? "&" : NULL), NULL); } retval = cookie; for (i=0; inelts; i++) { - retval = ap_pstrcat(p, retval, "; ", + retval = ap_pstrcat(p, retval, "; ", ((char**)values->elts)[i], NULL); } 1.8 +9 -9 httpd-apreq/c/apache_multipart_buffer.c Index: apache_multipart_buffer.c =================================================================== RCS file: /home/cvs/httpd-apreq/c/apache_multipart_buffer.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- apache_multipart_buffer.c 2001/06/12 22:46:37 1.7 +++ apache_multipart_buffer.c 2001/06/26 10:58:24 1.8 @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -70,7 +70,7 @@ int needlen = strlen(needle); int len = haystacklen; char *ptr = haystack; - + /* iterate through first character matches */ while( (ptr = memchr(ptr, needle[0], len)) ) { /* calculate length after match */ @@ -100,10 +100,10 @@ if(self->bytes_in_buffer > 0 && self->buf_begin != self->buffer) memmove(self->buffer, self->buf_begin, self->bytes_in_buffer); self->buf_begin = self->buffer; - + /* calculate the free space in the buffer */ bytes_to_read = self->bufsize - self->bytes_in_buffer; - + /* read the required number of bytes */ if(bytes_to_read > 0) { char *buf = self->buffer + self->bytes_in_buffer; @@ -158,7 +158,7 @@ self->buf_begin = ptr; self->bytes_in_buffer = 0; } - + return line; } @@ -171,7 +171,7 @@ fill_buffer(self); ptr = next_line(self); } - + #ifdef DEBUG ap_log_rerror(MPB_ERROR, "get_line: '%s'", ptr); #endif @@ -183,7 +183,7 @@ int find_boundary(multipart_buffer *self, char *boundary) { char *line; - + /* loop thru lines */ while( (line = get_line(self)) ) { #ifdef DEBUG @@ -248,7 +248,7 @@ "multipart_buffer_headers: '%s' = '%s'", key, value); #endif - + ap_table_add(tab, key, value); } else { @@ -282,7 +282,7 @@ /* maximum number of bytes we are reading */ len = max < bytes-1 ? max : bytes-1; - + /* if we read any data... */ if(len > 0) { /* copy the data */ 1.14 +39 -38 httpd-apreq/c/apache_request.c Index: apache_request.c =================================================================== RCS file: /home/cvs/httpd-apreq/c/apache_request.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- apache_request.c 2001/06/12 22:46:38 1.13 +++ apache_request.c 2001/06/26 10:58:28 1.14 @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -84,7 +84,7 @@ return HTTP_REQUEST_ENTITY_TOO_LARGE; } - *rbuf = ap_pcalloc(r->pool, length + 1); + *rbuf = ap_pcalloc(r->pool, length + 1); ap_hard_timeout("[libapreq] util_read", r); @@ -112,7 +112,7 @@ char *tmp; if (r->path_info && *r->path_info) { - int path_info_start = ap_find_path_info(r->uri, r->path_info); + int path_info_start = ap_find_path_info(r->uri, r->path_info); tmp = ap_pstrndup(r->pool, r->uri, path_info_start); } else { @@ -133,18 +133,18 @@ return ap_table_get(req->parms, key); } -static int make_params(void *data, const char *key, const char *val) -{ - array_header *arr = (array_header *)data; - *(char **)ap_push_array(arr) = (char *)val; - return 1; -} +static int make_params(void *data, const char *key, const char *val) +{ + array_header *arr = (array_header *)data; + *(char **)ap_push_array(arr) = (char *)val; + return 1; +} array_header *ApacheRequest_params(ApacheRequest *req, const char *key) { array_header *values = ap_make_array(req->r->pool, 4, sizeof(char *)); ApacheRequest_parse(req); - ap_table_do(make_params, (void*)values, req->parms, key, NULL); + ap_table_do(make_params, (void*)values, req->parms, key, NULL); return values; } @@ -155,7 +155,7 @@ int i; for (i=0; inelts; i++) { - retval = ap_pstrcat(req->r->pool, + retval = ap_pstrcat(req->r->pool, retval ? retval : "", ((char **)values->elts)[i], (i == (values->nelts - 1)) ? NULL : ", ", @@ -249,7 +249,7 @@ static void split_to_parms(ApacheRequest *req, const char *data) { - request_rec *r = req->r; + request_rec *r = req->r; const char *val; while (*data && (val = my_urlword(r->pool, &data))) { @@ -274,22 +274,22 @@ split_to_parms(req, r->args); } - if (r->method_number == M_POST) { - const char *ct = ap_table_get(r->headers_in, "Content-type"); + if (r->method_number == M_POST) { + const char *ct = ap_table_get(r->headers_in, "Content-type"); if (ct && strncaseEQ(ct, DEFAULT_ENCTYPE, DEFAULT_ENCTYPE_LENGTH)) { - result = ApacheRequest_parse_urlencoded(req); + result = ApacheRequest_parse_urlencoded(req); } else if (ct && strncaseEQ(ct, MULTIPART_ENCTYPE, MULTIPART_ENCTYPE_LENGTH)) { - result = ApacheRequest_parse_multipart(req); + result = ApacheRequest_parse_multipart(req); } else { - ap_log_rerror(REQ_ERROR, - "[libapreq] unknown content-type: `%s'", ct); + ap_log_rerror(REQ_ERROR, + "[libapreq] unknown content-type: `%s'", ct); result = HTTP_INTERNAL_SERVER_ERROR; } - } + } else { - result = ApacheRequest_parse_urlencoded(req); + result = ApacheRequest_parse_urlencoded(req); } req->parsed = 1; @@ -299,10 +299,10 @@ int ApacheRequest_parse_urlencoded(ApacheRequest *req) { - request_rec *r = req->r; + request_rec *r = req->r; int rc = OK; - if (r->method_number == M_POST) { + if (r->method_number == M_POST) { const char *data = NULL, *type; type = ap_table_get(r->headers_in, "Content-Type"); @@ -327,7 +327,7 @@ if( ap_pfclose(req->r->pool, upload->fp) ) ap_log_rerror(REQ_ERROR, - "[libapreq] close error on '%s'", upload->tempname); + "[libapreq] close error on '%s'", upload->tempname); #ifndef DEBUG if( remove(upload->tempname) ) ap_log_rerror(REQ_ERROR, @@ -342,9 +342,10 @@ request_rec *r = req->r; FILE *fp; char prefix[] = "apreq"; - char *name; - int fd, tries = 100; - + char *name = NULL; + int fd = 0; + int tries = 100; + while (--tries > 0) { if ( (name = tempnam(req->temp_dir, prefix)) == NULL ) continue; @@ -354,16 +355,16 @@ else free(name); } - + if ( tries == 0 || (fp = ap_pfdopen(r->pool, fd, "w+" "b") ) == NULL ) { - ap_log_rerror(REQ_ERROR, "[libapreq] could not create/open temp file"); + ap_log_rerror(REQ_ERROR, "[libapreq] could not create/open temp file"); if ( fd >= 0 ) { remove(name); free(name); } return NULL; } upload->fp = fp; upload->tempname = name; - ap_register_cleanup(r->pool, (void *)upload, + ap_register_cleanup(r->pool, (void *)upload, remove_tmpfile, ap_null_cleanup); return fp; @@ -404,14 +405,14 @@ } (void)ap_getword(r->pool, &ct, '='); - boundary = ap_getword_conf(r->pool, &ct); + boundary = ap_getword_conf(r->pool, &ct); if (!(mbuff = multipart_buffer_new(boundary, length, r))) { return DECLINED; } while (!multipart_buffer_eof(mbuff)) { - table *header = multipart_buffer_headers(mbuff); + table *header = multipart_buffer_headers(mbuff); const char *cd, *param=NULL, *filename=NULL; char buff[FILLUNIT]; int blen, wlen; @@ -521,7 +522,7 @@ if (*time_str == '-') { is_neg = 1; ++time_str; - } + } else if (*time_str == '+') { ++time_str; } @@ -539,7 +540,7 @@ buf[ix] = '\0'; offset = atoi(buf); - return time(NULL) + + return time(NULL) + (expire_mult(*time_str) * (is_neg ? (0 - offset) : offset)); } @@ -559,13 +560,13 @@ return ap_pstrdup(p, time_str); } - tms = gmtime(&when); + tms = gmtime(&when); return ap_psprintf(p, - "%s, %.2d%c%s%c%.2d %.2d:%.2d:%.2d GMT", - ap_day_snames[tms->tm_wday], + "%s, %.2d%c%s%c%.2d %.2d:%.2d:%.2d GMT", + ap_day_snames[tms->tm_wday], tms->tm_mday, sep, ap_month_snames[tms->tm_mon], sep, - tms->tm_year + 1900, - tms->tm_hour, tms->tm_min, tms->tm_sec); + tms->tm_year + 1900, + tms->tm_hour, tms->tm_min, tms->tm_sec); } char *ApacheRequest_expires(ApacheRequest *req, char *time_str) 1.8 +6 -0 httpd-apreq/c/apache_request.h Index: apache_request.h =================================================================== RCS file: /home/cvs/httpd-apreq/c/apache_request.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- apache_request.h 2001/06/12 22:46:38 1.7 +++ apache_request.h 2001/06/26 10:58:29 1.8 @@ -105,11 +105,17 @@ #define ApacheRequest_upload(req) \ ((req->parsed || (ApacheRequest_parse(req) == OK)) ? req->upload : NULL) +#define ApacheUpload_FILE(upload) (upload->fp) + +#define ApacheUpload_size(upload) (upload->size) + #define ApacheUpload_info(upload, key) \ ap_table_get(upload->info, key) #define ApacheUpload_type(upload) \ ApacheUpload_info(upload, "Content-Type") + +#define ApacheRequest_set_post_max(req, max) (req->post_max = max) char *ApacheUtil_expires(pool *p, char *time_str, int type); #define EXPIRES_HTTP 1