Don't provide get_header() with the whole client state
authorFabian Keil <fk@fabiankeil.de>
Sat, 10 May 2008 13:23:38 +0000 (13:23 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sat, 10 May 2008 13:23:38 +0000 (13:23 +0000)
structure when it only needs access to csp->iob.

jcc.c
parsers.c
parsers.h

diff --git a/jcc.c b/jcc.c
index b2a2881..06ce04a 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.176 2008/05/10 11:37:57 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.177 2008/05/10 11:51:12 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.176 2008/05/10 11:37:57 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: jcc.c,v $
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.177  2008/05/10 11:51:12  fabiankeil
+ *    Make the "read the rest of the headers" loop a bit more readable.
+ *
  *    Revision 1.176  2008/05/10 11:37:57  fabiankeil
  *    - Instead of logging when the IIS5 hack is enabled, log when it fails.
  *    - Remove useless comment.
  *    Revision 1.176  2008/05/10 11:37:57  fabiankeil
  *    - Instead of logging when the IIS5 hack is enabled, log when it fails.
  *    - Remove useless comment.
@@ -1477,7 +1480,7 @@ static jb_err get_server_headers(struct client_state *csp)
    int continue_hack_in_da_house = 0;
    char * header;
 
    int continue_hack_in_da_house = 0;
    char * header;
 
-   while (((header = get_header(csp)) != NULL) || continue_hack_in_da_house)
+   while (((header = get_header(csp->iob)) != NULL) || continue_hack_in_da_house)
    {
       if (header == NULL)
       {
    {
       if (header == NULL)
       {
@@ -1985,7 +1988,7 @@ static void chat(struct client_state *csp)
          return;
       }
 
          return;
       }
 
-      req = get_header(csp);
+      req = get_header(csp->iob);
 
    } while ((NULL != req) && ('\0' == *req));
 
 
    } while ((NULL != req) && ('\0' == *req));
 
@@ -2073,7 +2076,7 @@ static void chat(struct client_state *csp)
    init_list(headers);
    for (;;)
    {
    init_list(headers);
    for (;;)
    {
-      p = get_header(csp);
+      p = get_header(csp->iob);
 
       if (p == NULL)
       {
 
       if (p == NULL)
       {
index 6c952c9..77568b8 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.125 2008/04/17 14:40:49 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.126 2008/05/03 16:40:45 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -44,6 +44,12 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.125 2008/04/17 14:40:49 fabiankei
  *
  * Revisions   :
  *    $Log: parsers.c,v $
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.126  2008/05/03 16:40:45  fabiankeil
+ *    Change content_filters_enabled()'s parameter from
+ *    csp->action to action so it can be also used in the
+ *    CGI code. Don't bother checking if there are filters
+ *    loaded, as that's somewhat besides the point.
+ *
  *    Revision 1.125  2008/04/17 14:40:49  fabiankeil
  *    Provide get_http_time() with the buffer size so it doesn't
  *    have to blindly assume that the buffer is big enough.
  *    Revision 1.125  2008/04/17 14:40:49  fabiankeil
  *    Provide get_http_time() with the buffer size so it doesn't
  *    have to blindly assume that the buffer is big enough.
@@ -1433,7 +1439,7 @@ jb_err decompress_iob(struct client_state *csp)
  * Description :  This (odd) routine will parse the csp->iob
  *
  * Parameters  :
  * Description :  This (odd) routine will parse the csp->iob
  *
  * Parameters  :
- *          1  :  csp = Current client state (buffers, headers, etc...)
+ *          1  :  iob = The I/O buffer to parse, usually csp->iob.
  *
  * Returns     :  Any one of the following:
  *
  *
  * Returns     :  Any one of the following:
  *
@@ -1443,11 +1449,9 @@ jb_err decompress_iob(struct client_state *csp)
  *          a complete header line.
  *
  *********************************************************************/
  *          a complete header line.
  *
  *********************************************************************/
-char *get_header(struct client_state *csp)
+char *get_header(struct iob *iob)
 {
 {
-   struct iob *iob;
    char *p, *q, *ret;
    char *p, *q, *ret;
-   iob = csp->iob;
 
    if ((iob->cur == NULL)
       || ((p = strchr(iob->cur, '\n')) == NULL))
 
    if ((iob->cur == NULL)
       || ((p = strchr(iob->cur, '\n')) == NULL))
index 161a9d6..ac3d339 100644 (file)
--- a/parsers.h
+++ b/parsers.h
@@ -1,6 +1,6 @@
 #ifndef PARSERS_H_INCLUDED
 #define PARSERS_H_INCLUDED
 #ifndef PARSERS_H_INCLUDED
 #define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.41 2008/04/16 16:38:21 fabiankeil Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.42 2008/04/17 14:40:49 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.h,v $
  *
  * Revisions   :
  *    $Log: parsers.h,v $
  *
  * Revisions   :
  *    $Log: parsers.h,v $
+ *    Revision 1.42  2008/04/17 14:40:49  fabiankeil
+ *    Provide get_http_time() with the buffer size so it doesn't
+ *    have to blindly assume that the buffer is big enough.
+ *
  *    Revision 1.41  2008/04/16 16:38:21  fabiankeil
  *    Don't pass the whole csp structure to flush_socket()
  *    when it only needs a file descriptor and a buffer.
  *    Revision 1.41  2008/04/16 16:38:21  fabiankeil
  *    Don't pass the whole csp structure to flush_socket()
  *    when it only needs a file descriptor and a buffer.
@@ -268,7 +272,7 @@ extern const add_header_func_ptr add_server_headers[];
 extern int flush_socket(jb_socket fd, struct iob *iob);
 extern jb_err add_to_iob(struct client_state *csp, char *buf, int n);
 extern jb_err decompress_iob(struct client_state *csp);
 extern int flush_socket(jb_socket fd, struct iob *iob);
 extern jb_err add_to_iob(struct client_state *csp, char *buf, int n);
 extern jb_err decompress_iob(struct client_state *csp);
-extern char *get_header(struct client_state *csp);
+extern char *get_header(struct iob *iob);
 extern char *get_header_value(const struct list *header_list, const char *header_name);
 extern jb_err sed(const struct parsers pats[], const add_header_func_ptr more_headers[], struct client_state *csp);
 extern void get_http_time(int time_offset, char *buf, size_t buffer_size);
 extern char *get_header_value(const struct list *header_list, const char *header_name);
 extern jb_err sed(const struct parsers pats[], const add_header_func_ptr more_headers[], struct client_state *csp);
 extern void get_http_time(int time_offset, char *buf, size_t buffer_size);