Automated function-comment nitpicking.
[privoxy.git] / cgisimple.c
index fe8c345..c3836db 100644 (file)
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.10 2002/01/17 21:10:37 jongfoster Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.14 2002/03/02 04:14:50 david__schmidt Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -36,6 +36,20 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.10 2002/01/17 21:10:37 jongfo
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
+ *    Revision 1.14  2002/03/02 04:14:50  david__schmidt
+ *    Clean up a little CRLF unpleasantness that suddenly appeared
+ *
+ *    Revision 1.13  2002/02/21 00:10:37  jongfoster
+ *    Adding send-banner?type=auto option
+ *
+ *    Revision 1.12  2002/01/23 01:03:32  jongfoster
+ *    Fixing gcc [CygWin] compiler warnings
+ *
+ *    Revision 1.11  2002/01/23 00:01:04  jongfoster
+ *    Adding cgi_transparent_gif() for http://i.j.b/t
+ *    Adding missing html_encode() to many CGI functions.
+ *    Adding urlmatch.[ch] to http://i.j.b/show-version
+ *
  *    Revision 1.10  2002/01/17 21:10:37  jongfoster
  *    Changes to cgi_show_url_info to use new matching code from urlmatch.c.
  *    Also fixing a problem in the same function with improperly quoted URLs
@@ -124,9 +138,9 @@ static jb_err show_defines(struct map *exports);
  *                Lists menu of available unhidden CGIs.
  *               
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : none
  *
@@ -191,9 +205,9 @@ jb_err cgi_default(struct client_state *csp,
  *                given.
  *               
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : none
  *
@@ -235,9 +249,9 @@ jb_err cgi_error_404(struct client_state *csp,
  *                made of it.
  *               
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : none
  *
@@ -298,13 +312,15 @@ jb_err cgi_show_request(struct client_state *csp,
  * Description :  CGI function that returns a banner. 
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters :
- *           type : Selects the type of banner between "trans" and "jb".
- *                  Defaults to "jb" if absent or != "trans".
+ *           type : Selects the type of banner between "trans", "logo",
+ *                  and "auto". Defaults to "logo" if absent or invalid.
+ *                  "auto" means to select as if we were image-blocking.
+ *                  (Only the first character really counts).
  *
  * Returns     :  JB_ERR_OK on success
  *                JB_ERR_MEMORY on out-of-memory error.  
@@ -314,7 +330,28 @@ jb_err cgi_send_banner(struct client_state *csp,
                        struct http_response *rsp,
                        const struct map *parameters)
 {
-   if (strcmp(lookup(parameters, "type"), "trans"))
+   char imagetype = lookup(parameters, "type")[0];
+
+   if (imagetype == 'a') /* auto */
+   {
+      /* Default to logo */
+      imagetype = 'l';
+#ifdef FEATURE_IMAGE_BLOCKING
+      if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
+      {
+         /* determine HOW images should be blocked */
+         const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
+
+         /* and handle accordingly: */
+         if ((p != NULL) && (0 == strcmpic(p, "blank")))
+         {
+            imagetype = 't';
+         }
+      }
+#endif /* def FEATURE_IMAGE_BLOCKING */
+   }
+      
+   if ((imagetype != 't') && (imagetype != 'b')) /* transparant/blank */
    {
       rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length);
       rsp->content_length = image_junkbuster_gif_length;
@@ -349,9 +386,9 @@ jb_err cgi_send_banner(struct client_state *csp,
  * Description :  CGI function that sends a 1x1 transparent GIF.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : None
  *
@@ -391,9 +428,9 @@ jb_err cgi_transparent_gif(struct client_state *csp,
  *                file versions of IJB.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : none
  *
@@ -434,9 +471,9 @@ jb_err cgi_show_version(struct client_state *csp,
  *                current status of IJB.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters :
  *        file :  Which file to show.  Only first letter is checked,
@@ -655,9 +692,9 @@ jb_err cgi_show_status(struct client_state *csp,
  *                matches starting from the defaults have lead to that.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters :
  *            url : The url whose actions are to be determined.
@@ -674,7 +711,6 @@ jb_err cgi_show_url_info(struct client_state *csp,
                          const struct map *parameters)
 {
    char *url_param;
-   char *host = NULL;
    struct map *exports;
 
    assert(csp);
@@ -915,9 +951,9 @@ jb_err cgi_show_url_info(struct client_state *csp,
  * Description :  CGI function to return "/robots.txt".
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  parameters = map of cgi parameters
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  parameters = map of cgi parameters
  *
  * CGI Parameters : None
  *
@@ -964,7 +1000,7 @@ jb_err cgi_robots_txt(struct client_state *csp,
  *                used when building
  *
  * Parameters  :
- *           1 :  exports = map to extend
+ *           :  exports = map to extend
  *
  * Returns     :  JB_ERR_OK on success
  *                JB_ERR_MEMORY on out-of-memory error.