httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@lnd.com>
Subject util_script headers from strings?
Date Thu, 27 Jul 2000 17:21:20 GMT
Does anyone have a conceptual problem with my adding this code
to the util_script.c source?  Resolves an issue that ISAPI
(and perhaps others) pass strings to the webserver, rather than
a buff or file, for header parsing.

Is there code in Apache that would simplify this implementation?

Index: include/util_script.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/util_script.h,v
retrieving revision 1.8
diff -u -r1.8 util_script.h
--- include/util_script.h	2000/04/14 15:58:17	1.8
+++ include/util_script.h	2000/07/27 17:20:12
@@ -81,6 +81,10 @@
 API_EXPORT(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
 				       int (*getsfunc) (char *, int, void *),
 				       void *getsfunc_data);
+API_EXPORT_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, 
+                                                      char *buffer, 
+                                                      const char **data,
+                                                      ...);
 API_EXPORT(void) ap_send_size(ap_ssize_t size, request_rec *r);
 
 #ifdef __cplusplus
Index: main/util_script.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/util_script.c,v
retrieving revision 1.37
diff -u -r1.37 util_script.c
--- main/util_script.c	2000/07/21 19:50:47	1.37
+++ main/util_script.c	2000/07/27 17:20:13
@@ -606,6 +606,59 @@
     return ap_scan_script_header_err_core(r, buffer, getsfunc_BUFF, fb);
 }
 
+/*  If noone else sees a purpose to this code, it can move to mod_isapi 
+ *
+ *  ap_scan_script_header_err_strs can returns the pointer in data 
+ *  to the first unparsed/non-header char in the headers list.  It's
+ *  up to the function to figure out which arg that is pointing in.
+ */
+
+struct vastrs {
+    va_list args;
+    const char *curpos;
+};
+
+static int getsfunc_STRING(char *w, int len, void *pvastrs)
+{
+    struct vastrs *strs = (struct vastrs*) pvastrs;
+    char *p;
+    int t;
+    
+    if (!strs->curpos || !*strs->curpos) 
+        return 0;
+    p = strchr(strs->curpos, '\n');
+    if (p)
+        ++p;
+    else
+        p = strchr(strs->curpos, '\0');
+    t = p - strs->curpos;
+    if (t > len)
+        t = len;
+    strncpy (w, strs->curpos, t);
+    if (!strs->curpos[t])
+        strs->curpos = va_arg(strs->args, const char *);
+    else
+        strs->curpos += t;
+    return t;    
+}
+
+API_EXPORT_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, 
+                                                      char *buffer, 
+                                                      const char **data,
+                                                      ...)
+{
+    struct vastrs strs;
+    int res;
+
+    va_start(strs.args, buffer);
+    strs.curpos = va_arg(strs.args, char*);
+    res = ap_scan_script_header_err_core(r, buffer, getsfunc_STRING, (void *) &strs);
+    if (data)
+        *data = strs.curpos;
+    va_end(strs.args);
+    return res;
+}
+
 
 API_EXPORT(void) ap_send_size(ap_ssize_t size, request_rec *r)
 {


Mime
View raw message