Fixed gcc43 conversion warnings.
[privoxy.git] / cgiedit.c
index 49e6cf9..5058dd7 100644 (file)
--- a/cgiedit.c
+++ b/cgiedit.c
@@ -1,7 +1,7 @@
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.41.2.12 2006/01/30 15:16:25 david__schmidt Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.46 2006/12/27 18:44:52 fabiankeil Exp $";
 /*********************************************************************
  *
- * File        :  $Source: /cvsroot/ijbswa/current/Attic/cgiedit.c,v $
+ * File        :  $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
  *
  * Purpose     :  CGI-based actionsfile editor.
  *
@@ -42,6 +42,22 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.41.2.12 2006/01/30 15:16:25 david
  *
  * Revisions   :
  *    $Log: cgiedit.c,v $
+ *    Revision 1.46  2006/12/27 18:44:52  fabiankeil
+ *    Stop shadowing string.h's index().
+ *
+ *    Revision 1.45  2006/12/21 12:57:48  fabiankeil
+ *    Add config option "split-large-forms"
+ *    to work around the browser bug reported
+ *    in BR #1570678.
+ *
+ *    Revision 1.44  2006/12/09 13:49:16  fabiankeil
+ *    Fix configure option --disable-toggle.
+ *    Thanks to Peter Thoenen for reporting this.
+ *
+ *    Revision 1.43  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.41.2.12  2006/01/30 15:16:25  david__schmidt
  *    Remove a little residual debugging info
  *
@@ -329,8 +345,10 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.41.2.12 2006/01/30 15:16:25 david
 #include "miscutil.h"
 #include "errlog.h"
 #include "loaders.h"
-#include "loadcfg.h"
+#ifdef FEATURE_TOGGLE
 /* loadcfg.h is for global_toggle_state only */
+#include "loadcfg.h"
+#endif /* def FEATURE_TOGGLE */
 #include "urlmatch.h"
 
 const char cgiedit_h_rcs[] = CGIEDIT_H_VERSION;
@@ -980,7 +998,7 @@ jb_err edit_write_file(struct editable_file * file)
             {
                /* Must quote '#' characters */
                int numhash = 0;
-               int len;
+               size_t len;
                char * src;
                char * dest;
                char * str;
@@ -996,7 +1014,7 @@ jb_err edit_write_file(struct editable_file * file)
 
                /* Allocate new memory for string */
                len = strlen(cur_line->unprocessed);
-               if (NULL == (str = malloc((size_t) len + 1 + numhash)))
+               if (NULL == (str = malloc(len + 1 + (size_t)numhash)))
                {
                   /* Uh oh, just trashed file! */
                   fclose(fp);
@@ -1278,7 +1296,7 @@ static jb_err split_line_on_equals(const char * line, char ** pname, char ** pva
       name_end--;
    }
 
-   name_len = name_end - line + 1; /* Length excluding \0 */
+   name_len = (size_t)(name_end - line) + 1; /* Length excluding \0 */
    if (NULL == (*pname = (char *) malloc(name_len + 1)))
    {
       return JB_ERR_MEMORY;
@@ -1974,7 +1992,7 @@ static jb_err get_file_name_param(struct client_state *csp,
    char *name;
    char *fullpath;
    char ch;
-   int len;
+   size_t len;
 
    assert(csp);
    assert(parameters);
@@ -2231,7 +2249,7 @@ static jb_err map_radio(struct map * exports,
       }
    }
 
-   *p = value;
+   *p = (char)value;
    return map(exports, buf, 0, "checked", 1);
 }
 
@@ -3023,6 +3041,35 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
 
    if (!err) err = actions_to_radio(exports, cur_line->data.action);
 
+   /*
+    * XXX: Some browsers (at least IE6 and IE7) have an artifical URL
+    * length limitation and ignore clicks on the Submit buttons if
+    * the resulting GET URL would be longer than their limit.
+    *
+    * In Privoxy 3.0.5 beta the standard edit-actions-for-url template
+    * reached this limit and action editing stopped working in these
+    * browsers (BR #1570678).
+    *
+    * The config option split-large-forms works around this browser
+    * bug (HTTP has no URL lenght limitation) by deviding the action
+    * list form into multiple smaller ones. It means the URLs are shorter
+    * and work in broken browsers as well, but the user can no longer change
+    * all actions with one submit.
+    *
+    * A better solution would be to switch to POST requests,
+    * but this will do for now.
+    */
+   if(!err && (csp->config->feature_flags & RUNTIME_FEATURE_SPLIT_LARGE_FORMS))
+   {
+      /* Generate multiple smaller form by killing the big one. */
+      err = map_block_killer(exports, "one-form-only");
+   }
+   else
+   {
+      /* Default: Generate one large form by killing the smaller ones. */
+      err = map_block_killer(exports, "multiple-forms");
+   }
+
    for (i = 0; i < MAX_AF_FILES; i++)
    {
       if ((csp->rlist[i] != NULL) && (csp->rlist[i]->f != NULL))
@@ -3046,7 +3093,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
    {
       /* We have some entries in the filter list */
       char * result;
-      int index = 0;
+      int filter_identifier = 0;
       char * filter_template;
 
       err = template_load(csp, &filter_template, "edit-actions-for-url-filter", 0);
@@ -3104,7 +3151,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
                }
 
                /* Generate a unique serial number */
-               snprintf(number, sizeof(number), "%x", index++);
+               snprintf(number, sizeof(number), "%x", filter_identifier++);
                number[sizeof(number) - 1] = '\0';
 
                line_exports = new_map();
@@ -3193,7 +3240,7 @@ jb_err cgi_edit_actions_submit(struct client_state *csp,
    unsigned line_number;
    char target[1024];
    jb_err err;
-   int index;
+   int filter_identifier;
    const char * action_set_name;
    char ch;
    struct file_list * fl;
@@ -3237,9 +3284,9 @@ jb_err cgi_edit_actions_submit(struct client_state *csp,
    get_string_param(parameters, "p", &action_set_name);
    if (action_set_name != NULL)
    {
-      for (index = 0; index < MAX_AF_FILES; index++)
+      for (filter_identifier = 0; filter_identifier < MAX_AF_FILES; filter_identifier++)
       {
-         if (((fl = csp->actions_list[index]) != NULL) && ((b = fl->f) != NULL))
+         if (((fl = csp->actions_list[filter_identifier]) != NULL) && ((b = fl->f) != NULL))
          {
             for (b = b->next; NULL != b; b = b->next)
             {
@@ -3280,7 +3327,7 @@ jb_err cgi_edit_actions_submit(struct client_state *csp,
       cur_line->data.action->multi_remove_all[ACTION_MULTI_FILTER] = 0;
    }
 
-   for (index = 0; !err; index++)
+   for (filter_identifier = 0; !err; filter_identifier++)
    {
       char key_value[30];
       char key_name[30];
@@ -3288,9 +3335,9 @@ jb_err cgi_edit_actions_submit(struct client_state *csp,
       char value;
 
       /* Generate the keys */
-      snprintf(key_value, sizeof(key_value), "filter_r%x", index);
+      snprintf(key_value, sizeof(key_value), "filter_r%x", filter_identifier);
       key_value[sizeof(key_value) - 1] = '\0';
-      snprintf(key_name, sizeof(key_name), "filter_n%x", index);
+      snprintf(key_name, sizeof(key_name), "filter_n%x", filter_identifier);
       key_name[sizeof(key_name) - 1] = '\0';
 
       err = get_string_param(parameters, key_name, &name);
@@ -4228,7 +4275,7 @@ jb_err cgi_edit_actions_section_swap(struct client_state *csp,
    return cgi_redirect(rsp, target);
 }
 
-
+#ifdef FEATURE_TOGGLE
 /*********************************************************************
  *
  * Function    :  cgi_toggle
@@ -4296,7 +4343,7 @@ jb_err cgi_toggle(struct client_state *csp,
 
    return template_fill_for_cgi(csp, template_name, exports, rsp);
 }
-
+#endif /* def FEATURE_TOGGLE */
 
 /*********************************************************************
  *