Turn http_response.reason into an enum and rename it to http_response.crunch_reason.
authorFabian Keil <fk@fabiankeil.de>
Mon, 24 May 2010 11:38:22 +0000 (11:38 +0000)
committerFabian Keil <fk@fabiankeil.de>
Mon, 24 May 2010 11:38:22 +0000 (11:38 +0000)
cgi.c
filters.c
jcc.c
project.h

diff --git a/cgi.c b/cgi.c
index 758bb24..a51eced 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.127 2010/04/12 16:48:45 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.128 2010/04/21 20:48:06 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -553,7 +553,7 @@ static struct http_response *dispatch_known_cgi(struct client_state * csp,
          if (!err)
          {
             /* It worked */
-            rsp->reason = RSP_REASON_CGI_CALL;
+            rsp->crunch_reason = CGI_CALL;
             return finish_http_response(csp, rsp);
          }
          else
@@ -876,7 +876,7 @@ struct http_response *error_response(struct client_state *csp,
    if (!strcmp(templatename, "no-such-domain"))
    {
       rsp->status = strdup("404 No such domain");
-      rsp->reason = RSP_REASON_NO_SUCH_DOMAIN;
+      rsp->crunch_reason = NO_SUCH_DOMAIN;
    }
    else if (!strcmp(templatename, "forwarding-failed"))
    {
@@ -938,22 +938,22 @@ struct http_response *error_response(struct client_state *csp,
       }
 
       rsp->status = strdup("503 Forwarding failure");
-      rsp->reason = RSP_REASON_FORWARDING_FAILED;
+      rsp->crunch_reason = FORWARDING_FAILED;
    }
    else if (!strcmp(templatename, "connect-failed"))
    {
       rsp->status = strdup("503 Connect failed");
-      rsp->reason = RSP_REASON_CONNECT_FAILED;
+      rsp->crunch_reason = CONNECT_FAILED;
    }
    else if (!strcmp(templatename, "connection-timeout"))
    {
       rsp->status = strdup("504 Connection timeout");
-      rsp->reason = RSP_REASON_CONNECTION_TIMEOUT;
+      rsp->crunch_reason = CONNECTION_TIMEOUT;
    }
    else if (!strcmp(templatename, "no-server-data"))
    {
       rsp->status = strdup("502 No data received from server or forwarder");
-      rsp->reason = RSP_REASON_NO_SERVER_DATA;
+      rsp->crunch_reason = NO_SERVER_DATA;
    }
 
    if (rsp->status == NULL)
@@ -1053,7 +1053,7 @@ void cgi_init_error_messages(void)
       strlen(cgi_error_memory_response->head);
    cgi_error_memory_response->content_length =
       strlen(cgi_error_memory_response->body);
-   cgi_error_memory_response->reason = RSP_REASON_OUT_OF_MEMORY;
+   cgi_error_memory_response->crunch_reason = OUT_OF_MEMORY;
 }
 
 
@@ -1224,7 +1224,7 @@ jb_err cgi_error_unknown(const struct client_state *csp,
    rsp->content_length = 0;
    rsp->head_length = 0;
    rsp->is_static = 0;
-   rsp->reason = RSP_REASON_INTERNAL_ERROR;
+   rsp->crunch_reason = INTERNAL_ERROR;
 
    snprintf(errnumbuf, sizeof(errnumbuf), "%d", error_to_report);
 
index f3b31bb..ed5a373 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.128 2010/04/03 13:23:28 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.129 2010/05/01 18:20:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -795,7 +795,7 @@ struct http_response *block_url(struct client_state *csp)
          return cgi_error_memory();
       }
    }
-   rsp->reason = RSP_REASON_BLOCKED;
+   rsp->crunch_reason = BLOCKED;
 
    return finish_http_response(csp, rsp);
 
@@ -955,7 +955,7 @@ struct http_response *trust_url(struct client_state *csp)
       free_http_response(rsp);
       return cgi_error_memory();
    }
-   rsp->reason = RSP_REASON_UNTRUSTED;
+   rsp->crunch_reason = UNTRUSTED;
 
    return finish_http_response(csp, rsp);
 }
@@ -1295,7 +1295,7 @@ struct http_response *redirect_url(struct client_state *csp)
             free_http_response(rsp);
             return cgi_error_memory();
          }
-         rsp->reason = RSP_REASON_REDIRECTED;
+         rsp->crunch_reason = REDIRECTED;
          freez(new_url);
 
          return finish_http_response(csp, rsp);
@@ -2290,7 +2290,7 @@ struct http_response *direct_response(struct client_state *csp)
                }
 
                rsp->is_static = 1;
-               rsp->reason = RSP_REASON_UNSUPPORTED;
+               rsp->crunch_reason = UNSUPPORTED;
 
                return(finish_http_response(csp, rsp));
             }
diff --git a/jcc.c b/jcc.c
index d52c68d..404258e 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.316 2010/04/23 11:53:48 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.317 2010/05/01 18:19:56 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -625,39 +625,39 @@ static const char *crunch_reason(const struct http_response *rsp)
       return "Internal error while searching for crunch reason";
    }
 
-   switch (rsp->reason)
+   switch (rsp->crunch_reason)
    {
-      case RSP_REASON_UNSUPPORTED:
+      case UNSUPPORTED:
          reason = "Unsupported HTTP feature";
          break;
-      case RSP_REASON_BLOCKED:
+      case BLOCKED:
          reason = "Blocked";
          break;
-      case RSP_REASON_UNTRUSTED:
+      case UNTRUSTED:
          reason = "Untrusted";
          break;
-      case RSP_REASON_REDIRECTED:
+      case REDIRECTED:
          reason = "Redirected";
          break;
-      case RSP_REASON_CGI_CALL:
+      case CGI_CALL:
          reason = "CGI Call";
          break;
-      case RSP_REASON_NO_SUCH_DOMAIN:
+      case NO_SUCH_DOMAIN:
          reason = "DNS failure";
          break;
-      case RSP_REASON_FORWARDING_FAILED:
+      case FORWARDING_FAILED:
          reason = "Forwarding failed";
          break;
-      case RSP_REASON_CONNECT_FAILED:
+      case CONNECT_FAILED:
          reason = "Connection failure";
          break;
-      case RSP_REASON_OUT_OF_MEMORY:
+      case OUT_OF_MEMORY:
          reason = "Out of memory (may mask other reasons)";
          break;
-      case RSP_REASON_CONNECTION_TIMEOUT:
+      case CONNECTION_TIMEOUT:
          reason = "Connection timeout";
          break;
-      case RSP_REASON_NO_SERVER_DATA:
+      case NO_SERVER_DATA:
          reason = "No server data received";
          break;
       default:
@@ -698,7 +698,7 @@ static void send_crunch_response(const struct client_state *csp, struct http_res
           * Not supposed to happen. If it does
           * anyway, treat it as an unknown error.
           */
-         cgi_error_unknown(csp, rsp, RSP_REASON_INTERNAL_ERROR);
+         cgi_error_unknown(csp, rsp, INTERNAL_ERROR);
          /* return code doesn't matter */
       }
 
index ab4e677..0cf9880 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.154 2010/01/10 13:53:48 ler762 Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.155 2010/04/12 16:51:31 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -308,18 +308,21 @@ struct http_request
  * the requested resource. Mostly ordered the way they are checked
  * for in chat().
  */
-#define RSP_REASON_UNSUPPORTED        1
-#define RSP_REASON_BLOCKED            2
-#define RSP_REASON_UNTRUSTED          3
-#define RSP_REASON_REDIRECTED         4
-#define RSP_REASON_CGI_CALL           5
-#define RSP_REASON_NO_SUCH_DOMAIN     6
-#define RSP_REASON_FORWARDING_FAILED  7
-#define RSP_REASON_CONNECT_FAILED     8
-#define RSP_REASON_OUT_OF_MEMORY      9
-#define RSP_REASON_INTERNAL_ERROR     10
-#define RSP_REASON_CONNECTION_TIMEOUT 11
-#define RSP_REASON_NO_SERVER_DATA     12
+enum crunch_reason
+{
+   UNSUPPORTED,
+   BLOCKED,
+   UNTRUSTED,
+   REDIRECTED,
+   CGI_CALL,
+   NO_SUCH_DOMAIN,
+   FORWARDING_FAILED,
+   CONNECT_FAILED,
+   OUT_OF_MEMORY,
+   INTERNAL_ERROR,
+   CONNECTION_TIMEOUT,
+   NO_SERVER_DATA
+};
 
 /**
  * Response generated by CGI, blocker, or error handler
@@ -334,7 +337,7 @@ struct http_response
   size_t content_length;  /**< Length of body, REQUIRED if binary body. */
   int    is_static;       /**< Nonzero if the content will never change and
                                should be cached by the browser (e.g. images). */
-  int reason;             /**< Why the response was generated in the first place. */
+  enum crunch_reason crunch_reason; /**< Why the response was generated in the first place. */
 };
 
 /**