Accept a socket-timeout value of 0 seconds.
[privoxy.git] / cgi.c
diff --git a/cgi.c b/cgi.c
index f04cf15..c0f1270 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.143 2011/08/17 10:26:47 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.149 2012/03/09 16:24:36 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -8,9 +8,6 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.143 2011/08/17 10:26:47 fabiankeil Exp $"
  *                This only contains the framework functions, the
  *                actual handler functions are declared elsewhere.
  *
- *                Functions declared include:
- *
- *
  * Copyright   :  Written by and Copyright (C) 2001-2004, 2006-2008
  *                the SourceForge Privoxy team. http://www.privoxy.org/
  *
@@ -317,15 +314,15 @@ struct http_response *dispatch_cgi(struct client_state *csp)
    /* Either the host matches CGI_SITE_1_HOST ..*/
    if (   ( (0 == strcmpic(host, CGI_SITE_1_HOST))
          || (0 == strcmpic(host, CGI_SITE_1_HOST ".")))
-       && (path[0] == '/') )
+       && (path[0] == '/'))
    {
       /* ..then the path will all be for us.  Remove leading '/' */
       path++;
    }
    /* Or it's the host part CGI_SITE_2_HOST, and the path CGI_SITE_2_PATH */
-   else if ( ( (0 == strcmpic(host, CGI_SITE_2_HOST ))
-            || (0 == strcmpic(host, CGI_SITE_2_HOST ".")) )
-          && (0 == strncmpic(path, CGI_SITE_2_PATH, strlen(CGI_SITE_2_PATH))) )
+   else if ((  (0 == strcmpic(host, CGI_SITE_2_HOST))
+            || (0 == strcmpic(host, CGI_SITE_2_HOST ".")))
+          && (0 == strncmpic(path, CGI_SITE_2_PATH, strlen(CGI_SITE_2_PATH))))
    {
       /* take everything following CGI_SITE_2_PATH */
       path += strlen(CGI_SITE_2_PATH);
@@ -726,8 +723,8 @@ jb_err get_string_param(const struct map *parameters,
    s = param;
    while ((ch = *s++) != '\0')
    {
-      if ( ((unsigned char)ch < (unsigned char)' ')
-        || (ch == '}') )
+      if (((unsigned char)ch < (unsigned char)' ')
+        || (ch == '}'))
       {
          /* Probable hack attempt, or user accidentally used '}'. */
          return JB_ERR_CGI_PARAMS;
@@ -1395,12 +1392,6 @@ char *add_help_link(const char *item,
  *********************************************************************/
 void get_http_time(int time_offset, char *buf, size_t buffer_size)
 {
-   static const char day_names[7][4] =
-      { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-   static const char month_names[12][4] =
-      { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-
    struct tm *t;
    time_t current_time;
 #if defined(HAVE_GMTIME_R)
@@ -1425,17 +1416,7 @@ void get_http_time(int time_offset, char *buf, size_t buffer_size)
    t = gmtime(&current_time);
 #endif
 
-   /* Format: "Sun, 06 Nov 1994 08:49:37 GMT" */
-   snprintf(buf, buffer_size,
-      "%s, %02d %s %4d %02d:%02d:%02d GMT",
-      day_names[t->tm_wday],
-      t->tm_mday,
-      month_names[t->tm_mon],
-      t->tm_year + 1900,
-      t->tm_hour,
-      t->tm_min,
-      t->tm_sec
-      );
+   strftime(buf, buffer_size, "%a, %d %b %Y %H:%M:%S GMT", t);
 
 }
 
@@ -2161,7 +2142,7 @@ struct map *default_exports(const struct client_state *csp, const char *caller)
    if (!err) err = map(exports, "time",          1, html_encode(buf), 0);
    if (!err) err = map(exports, "my-ip-address", 1, html_encode(ip_address ? ip_address : "unknown"), 0);
    freez(ip_address);
-   if (!err) err = map(exports, "my-port",       1, html_encode(port ? port : "unkown"), 0);
+   if (!err) err = map(exports, "my-port",       1, html_encode(port ? port : "unknown"), 0);
    freez(port);
    if (!err) err = map(exports, "my-hostname",   1, html_encode(hostname ? hostname : "unknown"), 0);
    freez(hostname);
@@ -2187,7 +2168,7 @@ struct map *default_exports(const struct client_state *csp, const char *caller)
    if (!err) err = map_block_killer(exports, "can-toggle");
 #endif
 
-   if(!strcmp(CODE_STATUS, "stable"))
+   if (!strcmp(CODE_STATUS, "stable"))
    {
       if (!err) err = map_block_killer(exports, "unstable");
    }