Add list_contains_item().
[privoxy.git] / cgisimple.c
index 64fd90d..3e32295 100644 (file)
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.50 2007/01/23 15:51:17 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.54 2007/04/09 18:11:35 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -36,6 +36,22 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.50 2007/01/23 15:51:17 fabian
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
+ *    Revision 1.54  2007/04/09 18:11:35  fabiankeil
+ *    Don't mistake VC++'s _snprintf() for a snprintf() replacement.
+ *
+ *    Revision 1.53  2007/04/08 13:21:04  fabiankeil
+ *    Reference action files in CGI URLs by id instead
+ *    of using the first part of the file name.
+ *    Fixes BR 1694250 and BR 1590556.
+ *
+ *    Revision 1.52  2007/02/13 15:10:26  fabiankeil
+ *    Apparently fopen()ing in "binary" mode doesn't require
+ *    #ifdefs, it's already done without them in cgiedit.c.
+ *
+ *    Revision 1.51  2007/02/10 16:55:22  fabiankeil
+ *    - Show forwarding settings on the show-url-info page
+ *    - Fix some HTML syntax errors.
+ *
  *    Revision 1.50  2007/01/23 15:51:17  fabiankeil
  *    Add favicon delivery functions.
  *
@@ -296,10 +312,6 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.50 2007/01/23 15:51:17 fabian
 #include <unistd.h>
 #endif /* def HAVE_ACCESS */
 
-#ifdef _WIN32
-#define snprintf _snprintf
-#endif /* def _WIN32 */
-
 #include "project.h"
 #include "cgi.h"
 #include "cgisimple.h"
@@ -905,15 +917,7 @@ jb_err cgi_send_user_manual(struct client_state *csp,
    }
 
    /* Open user-manual file */
-#ifdef WIN32
-   /*
-    * XXX: Do we support other operating systems that
-    * require special treatment to fopen in binary mode?
-    */
    if (NULL == (fp = fopen(full_path, "rb")))
-#else
-   if (NULL == (fp = fopen(full_path, "r")))
-#endif /* def WIN32 */
    {
       log_error(LOG_LEVEL_ERROR, "Cannot open user-manual file %s: %E", full_path);
       err = cgi_error_no_template(csp, rsp, full_path);
@@ -937,7 +941,7 @@ jb_err cgi_send_user_manual(struct client_state *csp,
    if (!fread(rsp->body, length, 1, fp))
    {
       /*
-       * This happens if we didn't fopen in binary mode.
+       * May happen if the file size changes between fseek() and fread().
        * If it does, we just log it and serve what we got.
        */
       log_error(LOG_LEVEL_ERROR, "Couldn't completely read user-manual file %s.", full_path);
@@ -1204,7 +1208,8 @@ jb_err cgi_show_status(struct client_state *csp,
       {
          if (!err) err = string_append(&s, "<tr><td>");
          if (!err) err = string_join(&s, html_encode(csp->actions_list[i]->filename));
-         snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&amp;index=%d\">View</a>", i);
+         snprintf(buf, sizeof(buf),
+            "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&amp;index=%d\">View</a>", i);
          if (!err) err = string_append(&s, buf);
 
 #ifdef FEATURE_CGI_EDIT_ACTIONS
@@ -1214,8 +1219,7 @@ jb_err cgi_show_status(struct client_state *csp,
             if (access(csp->config->actions_file[i], W_OK) == 0)
             {
 #endif /* def HAVE_ACCESS */
-               snprintf(buf, 100, "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%s\">Edit</a>",
-                  csp->config->actions_file_short[i]);
+               snprintf(buf, sizeof(buf), "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%d\">Edit</a>", i);
                if (!err) err = string_append(&s, buf);
 #ifdef HAVE_ACCESS
             }
@@ -1510,9 +1514,9 @@ jb_err cgi_show_url_info(struct client_state *csp,
                string_append(&matches, buf);
                string_append(&matches, "View</a>");
 #ifdef FEATURE_CGI_EDIT_ACTIONS
-               string_append(&matches, " <a class=\"cmd\" href=\"/edit-actions-list?f=");
-               string_join  (&matches, html_encode(csp->config->actions_file_short[i]));
-               string_append(&matches, "\">Edit</a>");
+               snprintf(buf, sizeof(buf), " <a class=\"cmd\" href=\"/edit-actions-list?f=%d\">", i);
+               string_append(&matches, buf);
+               string_append(&matches, "Edit</a>");
 #endif
                string_append(&matches, "</th></tr>\n");