Add favicon delivery functions.
authorFabian Keil <fk@fabiankeil.de>
Tue, 23 Jan 2007 15:51:17 +0000 (15:51 +0000)
committerFabian Keil <fk@fabiankeil.de>
Tue, 23 Jan 2007 15:51:17 +0000 (15:51 +0000)
cgi.c
cgisimple.c
cgisimple.h

diff --git a/cgi.c b/cgi.c
index 50d0fb4..f2d2429 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.87 2007/01/22 15:34:13 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.88 2007/01/23 13:14:32 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -38,6 +38,12 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.87 2007/01/22 15:34:13 fabiankeil Exp $";
  *
  * Revisions   :
  *    $Log: cgi.c,v $
  *
  * Revisions   :
  *    $Log: cgi.c,v $
+ *    Revision 1.88  2007/01/23 13:14:32  fabiankeil
+ *    - Map variables that aren't guaranteed to be
+ *      pure ASCII html_encoded.
+ *    - Use CGI_PREFIX to generate URL for user manual
+ *      CGI page to make sure CGI_SITE_2_PATH is included.
+ *
  *    Revision 1.87  2007/01/22 15:34:13  fabiankeil
  *    - "Protect" against a rather lame JavaScript-based
  *      Privoxy detection "attack" and check the referrer
  *    Revision 1.87  2007/01/22 15:34:13  fabiankeil
  *    - "Protect" against a rather lame JavaScript-based
  *      Privoxy detection "attack" and check the referrer
@@ -680,6 +686,12 @@ static const struct cgi_dispatcher cgi_dispatchers[] = {
          cgi_edit_actions_section_swap, 
          NULL, FALSE /* Swap two sections in the actionsfile */ },
 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
          cgi_edit_actions_section_swap, 
          NULL, FALSE /* Swap two sections in the actionsfile */ },
 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
+   { "error-favicon.ico", 
+         cgi_send_error_favicon,  
+         NULL, TRUE /* Sends the favicon image for error pages. */ },
+   { "favicon.ico", 
+         cgi_send_default_favicon,  
+         NULL, TRUE /* Sends the default favicon image. */ },
    { "robots.txt", 
          cgi_robots_txt,  
          NULL, TRUE /* Sends a robots.txt file to tell robots to go away. */ }, 
    { "robots.txt", 
          cgi_robots_txt,  
          NULL, TRUE /* Sends a robots.txt file to tell robots to go away. */ }, 
index b82dbde..22f5dd8 100644 (file)
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.48 2007/01/20 15:31:31 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.49 2007/01/20 16:29:38 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -36,6 +36,10 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.48 2007/01/20 15:31:31 fabian
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
+ *    Revision 1.49  2007/01/20 16:29:38  fabiankeil
+ *    Suppress edit buttons for action files if Privoxy has
+ *    no write access. Suggested by Roland in PR 1564026.
+ *
  *    Revision 1.48  2007/01/20 15:31:31  fabiankeil
  *    Display warning if show-url-info CGI page
  *    is used while Privoxy is toggled off.
  *    Revision 1.48  2007/01/20 15:31:31  fabiankeil
  *    Display warning if show-url-info CGI page
  *    is used while Privoxy is toggled off.
@@ -313,6 +317,41 @@ const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
 static char *show_rcs(void);
 static jb_err show_defines(struct map *exports);
 
 static char *show_rcs(void);
 static jb_err show_defines(struct map *exports);
 
+/*
+ * 16x16 ico blobs for favicon delivery functions.
+ */
+const char default_favicon_data[] =
+   "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
+   "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
+   "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
+   "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
+   "\000\000\377\377\377\000\377\000\052\000\017\360\000\000\077"
+   "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
+   "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
+   "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
+   "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
+   "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
+   "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
+   "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
+   "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
+   "\017\000\000";
+const char error_favicon_data[] =
+   "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
+   "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
+   "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
+   "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
+   "\000\000\377\377\377\000\000\000\377\000\017\360\000\000\077"
+   "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
+   "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
+   "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
+   "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
+   "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
+   "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
+   "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
+   "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
+   "\017\000\000";
+const size_t default_favicon_length  = sizeof(default_favicon_data) - 1;
+const size_t error_favicon_length  = sizeof(error_favicon_data) - 1;
 
 /*********************************************************************
  *
 
 /*********************************************************************
  *
@@ -675,6 +714,88 @@ jb_err cgi_transparent_image(struct client_state *csp,
 }
 
 
 }
 
 
+/*********************************************************************
+ *
+ * Function    :  cgi_send_default_favicon
+ *
+ * Description :  CGI function that sends the standard favicon.
+ *
+ * Parameters  :
+ *          1  :  csp = Current client state (buffers, headers, etc...)
+ *          2  :  rsp = http_response data structure for output
+ *          3  :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  JB_ERR_OK on success
+ *                JB_ERR_MEMORY on out-of-memory error.  
+ *
+ *********************************************************************/
+jb_err cgi_send_default_favicon(struct client_state *csp,
+                                struct http_response *rsp,
+                                const struct map *parameters)
+{
+   rsp->body = bindup(default_favicon_data, default_favicon_length);
+   rsp->content_length = default_favicon_length;
+
+   if (rsp->body == NULL)
+   {
+      return JB_ERR_MEMORY;
+   }
+
+   if (enlist(rsp->headers, "Content-Type: image/x-icon"))
+   {
+      return JB_ERR_MEMORY;
+   }
+
+   rsp->is_static = 1;
+
+   return JB_ERR_OK;
+
+}
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_send_error_favicon
+ *
+ * Description :  CGI function that sends the favicon for error pages.
+ *
+ * Parameters  :
+ *          1  :  csp = Current client state (buffers, headers, etc...)
+ *          2  :  rsp = http_response data structure for output
+ *          3  :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  JB_ERR_OK on success
+ *                JB_ERR_MEMORY on out-of-memory error.  
+ *
+ *********************************************************************/
+jb_err cgi_send_error_favicon(struct client_state *csp,
+                              struct http_response *rsp,
+                              const struct map *parameters)
+{
+   rsp->body = bindup(error_favicon_data, error_favicon_length);
+   rsp->content_length = error_favicon_length;
+
+   if (rsp->body == NULL)
+   {
+      return JB_ERR_MEMORY;
+   }
+
+   if (enlist(rsp->headers, "Content-Type: image/x-icon"))
+   {
+      return JB_ERR_MEMORY;
+   }
+
+   rsp->is_static = 1;
+
+   return JB_ERR_OK;
+
+}
+
+
 /*********************************************************************
  *
  * Function    :  cgi_send_stylesheet
 /*********************************************************************
  *
  * Function    :  cgi_send_stylesheet
index f0b5cd9..8778894 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef CGISIMPLE_H_INCLUDED
 #define CGISIMPLE_H_INCLUDED
 #ifndef CGISIMPLE_H_INCLUDED
 #define CGISIMPLE_H_INCLUDED
-#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.13 2006/07/18 14:48:45 david__schmidt Exp $"
+#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.14 2006/09/06 18:45:03 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.h,v $
@@ -11,7 +11,7 @@
  *                Functions declared include:
  * 
  *
  *                Functions declared include:
  * 
  *
- * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
+ * Copyright   :  Written by and Copyright (C) 2001-2007 the SourceForge
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
  *
  * Revisions   :
  *    $Log: cgisimple.h,v $
  *
  * Revisions   :
  *    $Log: cgisimple.h,v $
+ *    Revision 1.14  2006/09/06 18:45:03  fabiankeil
+ *    Incorporate modified version of Roland Rosenfeld's patch to
+ *    optionally access the user-manual via Privoxy. Closes patch 679075.
+ *
+ *    Formatting changed to Privoxy style, added call to
+ *    cgi_error_no_template if the requested file doesn't
+ *    exist and modified check whether or not Privoxy itself
+ *    should serve the manual. Should work cross-platform now.
+ *
  *    Revision 1.13  2006/07/18 14:48:45  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
  *    Revision 1.13  2006/07/18 14:48:45  david__schmidt
  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
  *    with what was really the latest development (the v_3_0_branch branch)
@@ -129,6 +138,12 @@ extern jb_err cgi_show_request (struct client_state *csp,
 extern jb_err cgi_transparent_image (struct client_state *csp,
                                      struct http_response *rsp,
                                      const struct map *parameters);
 extern jb_err cgi_transparent_image (struct client_state *csp,
                                      struct http_response *rsp,
                                      const struct map *parameters);
+extern jb_err cgi_send_error_favicon (struct client_state *csp,
+                                      struct http_response *rsp,
+                                      const struct map *parameters);
+extern jb_err cgi_send_default_favicon (struct client_state *csp,
+                                        struct http_response *rsp,
+                                        const struct map *parameters);
 extern jb_err cgi_send_stylesheet(struct client_state *csp,
                                   struct http_response *rsp,
                                   const struct map *parameters);
 extern jb_err cgi_send_stylesheet(struct client_state *csp,
                                   struct http_response *rsp,
                                   const struct map *parameters);