Automated function-comment nitpicking.
[privoxy.git] / cgiedit.c
index 54c44ec..4e4927d 100644 (file)
--- a/cgiedit.c
+++ b/cgiedit.c
@@ -1,4 +1,4 @@
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.11 2002/01/23 01:03:31 jongfoster Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.14 2002/03/05 00:24:51 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
@@ -42,6 +42,15 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.11 2002/01/23 01:03:31 jongfoster
  *
  * Revisions   :
  *    $Log: cgiedit.c,v $
+ *    Revision 1.14  2002/03/05 00:24:51  jongfoster
+ *    Patch to always edit the current actions file.
+ *
+ *    Revision 1.13  2002/03/04 02:07:59  david__schmidt
+ *    Enable web editing of actions file on OS/2 (it had been broken all this time!)
+ *
+ *    Revision 1.12  2002/03/03 09:18:03  joergs
+ *    Made jumbjuster work on AmigaOS again.
+ *
  *    Revision 1.11  2002/01/23 01:03:31  jongfoster
  *    Fixing gcc [CygWin] compiler warnings
  *
@@ -336,9 +345,9 @@ static jb_err map_copy_parameter_url(struct map *out,
  *                encoding it.
  *
  * Parameters  :
- *           1 :  out = target map
- *           2 :  in = source map
- *           3 :  name = name of cgi parameter to copy
+ *           :  out = target map
+ *           :  in = source map
+ *           :  name = name of cgi parameter to copy
  *
  * Returns     :  JB_ERR_OK on success
  *                JB_ERR_MEMORY on out-of-memory
@@ -385,9 +394,9 @@ static jb_err map_copy_parameter_html(struct map *out,
  *                encoding it.
  *
  * Parameters  :
- *           1 :  out = target map
- *           2 :  in = source map
- *           3 :  name = name of cgi parameter to copy
+ *           :  out = target map
+ *           :  in = source map
+ *           :  name = name of cgi parameter to copy
  *
  * Returns     :  JB_ERR_OK on success
  *                JB_ERR_MEMORY on out-of-memory
@@ -433,9 +442,9 @@ static jb_err map_copy_parameter_url(struct map *out,
  *                edit-actions-url
  *
  * 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
  *           f : (filename) Identifies the file to edit
@@ -529,9 +538,9 @@ jb_err cgi_edit_actions_url_form(struct client_state *csp,
  *                edit-actions-url
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -587,9 +596,9 @@ jb_err cgi_edit_actions_add_url_form(struct client_state *csp,
  *                edit-actions-url
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -703,7 +712,7 @@ jb_err edit_write_file(struct editable_file * file)
    assert(file);
    assert(file->filename);
 
-#ifdef AMIGA
+#if defined(AMIGA) || defined(__OS2__)
    if (NULL == (fp = fopen(file->filename, "w")))
 #else
    if (NULL == (fp = fopen(file->filename, "wt")))
@@ -938,8 +947,8 @@ static void edit_free_file_lines(struct file_line * first_line)
  * Description :  Match an actions file {{header}} line
  *
  * Parameters  :
- *          1  :  line - String from file
- *          2  :  name - Header to match against
+ *          1  :  line = String from file
+ *          2  :  name = Header to match against
  *
  * Returns     :  0 iff they match.
  *
@@ -996,10 +1005,10 @@ static int match_actions_file_header_line(const char * line, const char * name)
  * Description :  Match an actions file {{header}} line
  *
  * Parameters  :
- *          1  :  line - String from file.  Must not start with
+ *          1  :  line = String from file.  Must not start with
  *                       whitespace (else infinite loop!)
- *          2  :  name - Destination for name
- *          2  :  name - Destination for value
+ *          2  :  name = Destination for name
+ *          2  :  name = Destination for value
  *
  * Returns     :  JB_ERR_OK     on success
  *                JB_ERR_MEMORY on out-of-memory
@@ -1534,7 +1543,7 @@ jb_err edit_read_file(struct client_state *csp,
       }
    }
 
-#ifdef AMIGA
+#if defined(AMIGA) || defined(__OS2__)
    if (NULL == (fp = fopen(filename,"r")))
 #else
    if (NULL == (fp = fopen(filename,"rt")))
@@ -1711,13 +1720,13 @@ jb_err edit_read_actions_file(struct client_state *csp,
  *                secure.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  parameters = map of cgi parameters
- *           3 :  param_name = The name of the parameter to read
- *           4 :  suffix = File extension, e.g. ".actions"
- *           5 :  pfilename = destination for full filename.  Caller
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  parameters = map of cgi parameters
+ *           :  param_name = The name of the parameter to read
+ *           :  suffix = File extension, e.g. ".actions"
+ *           :  pfilename = destination for full filename.  Caller
  *                free()s.  Set to NULL on error.
- *           6 :  pparam = destination for partial filename,
+ *           :  pparam = destination for partial filename,
  *                suitable for use in another URL.  Allocated as part
  *                of the map "parameters", so don't free it.
  *                Set to NULL if not specified.
@@ -1737,7 +1746,9 @@ static jb_err get_file_name_param(struct client_state *csp,
 {
    const char *param;
    const char *s;
+#if 0 /* Patch to make 3.0.0 work properly. */
    char *name;
+#endif /* 0 - Patch to make 3.0.0 work properly. */
    char *fullpath;
    char ch;
    int len;
@@ -1781,6 +1792,13 @@ static jb_err get_file_name_param(struct client_state *csp,
       }
    }
 
+   /*
+    * FIXME Following is a hack to make 3.0.0 work properly.
+    * Change "#if 0" --> "#if 1" below when we have modular action
+    * files.
+    *    -- Jon
+    */
+#if 0 /* Patch to make 3.0.0 work properly. */
    /* Append extension */
    name = malloc(len + strlen(suffix) + 1);
    if (name == NULL)
@@ -1793,6 +1811,16 @@ static jb_err get_file_name_param(struct client_state *csp,
    /* Prepend path */
    fullpath = make_path(csp->config->confdir, name);
    free(name);
+#else /* 1 - Patch to make 3.0.0 work properly. */
+   if ((csp->actions_list == NULL)
+    || (csp->actions_list->filename == NULL))
+   {
+      return JB_ERR_CGI_PARAMS;
+   }
+
+   fullpath = ( (csp->actions_list && csp->actions_list->filename)
+             ? strdup(csp->actions_list->filename) : NULL);
+#endif /* 1 - Patch to make 3.0.0 work properly. */
    if (fullpath == NULL)
    {
       return JB_ERR_MEMORY;
@@ -1813,10 +1841,10 @@ static jb_err get_file_name_param(struct client_state *csp,
  *                passed to a CGI function.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  parameters = map of cgi parameters
- *           3 :  name = Name of CGI parameter to read
- *           4 :  pvalue = destination for value.
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  parameters = map of cgi parameters
+ *           :  name = Name of CGI parameter to read
+ *           :  pvalue = destination for value.
  *                         Set to -1 on error.
  *
  * Returns     :  JB_ERR_OK         on success
@@ -1890,10 +1918,10 @@ static jb_err get_number_param(struct client_state *csp,
  *                spaces and validates it.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  parameters = map of cgi parameters
- *           3 :  name = Name of CGI parameter to read
- *           4 :  pvalue = destination for value.  Will be malloc()'d.
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  parameters = map of cgi parameters
+ *           :  name = Name of CGI parameter to read
+ *           :  pvalue = destination for value.  Will be malloc()'d.
  *                         Set to NULL on error.
  *
  * Returns     :  JB_ERR_OK         on success
@@ -2023,10 +2051,10 @@ static jb_err get_url_spec_param(struct client_state *csp,
  *                Where 'sel' is 'a', 'b', or 'c'.
  *
  * Parameters  :
- *           1 :  exports = Exports map to modify.
- *           2 :  optionname = name for map
- *           3 :  values = null-terminated list of values;
- *           4 :  value = Selected value.
+ *           :  exports = Exports map to modify.
+ *           :  optionname = name for map
+ *           :  values = null-terminated list of values;
+ *           :  value = Selected value.
  *
  * CGI Parameters : None
  *
@@ -2092,9 +2120,9 @@ static jb_err map_radio(struct map * exports,
  *                outside the CGI editor.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  filename = The file that was modified.
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  filename = The file that was modified.
  *
  * CGI Parameters : none
  *
@@ -2137,9 +2165,9 @@ jb_err cgi_error_modified(struct client_state *csp,
  *                be parsed by the CGI editor.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  file = The file that was modified.
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  file = The file that was modified.
  *
  * CGI Parameters : none
  *
@@ -2191,9 +2219,9 @@ jb_err cgi_error_parse(struct client_state *csp,
  *                opened by the CGI editor.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
- *           3 :  filename = The file that was modified.
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
+ *           :  filename = The file that was modified.
  *
  * CGI Parameters : none
  *
@@ -2236,8 +2264,8 @@ jb_err cgi_error_file(struct client_state *csp,
  *                (query string) for a CGI were wrong.
  *
  * Parameters  :
- *           1 :  csp = Current client state (buffers, headers, etc...)
- *           2 :  rsp = http_response data structure for output
+ *           :  csp = Current client state (buffers, headers, etc...)
+ *           :  rsp = http_response data structure for output
  *
  * CGI Parameters : none
  *
@@ -2270,9 +2298,9 @@ jb_err cgi_error_disabled(struct client_state *csp,
  *                actions file to edit.
  *
  * 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
  *
@@ -2316,9 +2344,9 @@ jb_err cgi_edit_actions(struct client_state *csp,
  *                FIXME: This function shouldn't FATAL ever.
  *                FIXME: This function doesn't check the retval of map()
  * 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 : filename
  *
@@ -2671,9 +2699,9 @@ jb_err cgi_edit_actions_list(struct client_state *csp,
  * Description :  CGI function that edits the Actions list.
  *
  * 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
  *
@@ -2760,9 +2788,9 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
  * Description :  CGI function that actually edits the Actions list.
  *
  * 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
  *
@@ -2903,9 +2931,9 @@ jb_err cgi_edit_actions_submit(struct client_state *csp,
  *                an actions file.
  *
  * 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 :
  *    filename : Identifies the file to edit
@@ -3025,9 +3053,9 @@ jb_err cgi_edit_actions_url(struct client_state *csp,
  *                an actions file.
  *
  * 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 :
  *    filename : Identifies the file to edit
@@ -3164,9 +3192,9 @@ jb_err cgi_edit_actions_add_url(struct client_state *csp,
  *                the actions file.
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -3281,9 +3309,9 @@ jb_err cgi_edit_actions_remove_url(struct client_state *csp,
  *                (else JB_ERR_CGI_PARAMS).
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -3412,9 +3440,9 @@ jb_err cgi_edit_actions_section_remove(struct client_state *csp,
  *                an actions file.
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -3589,9 +3617,9 @@ jb_err cgi_edit_actions_section_add(struct client_state *csp,
  *                specified.
  *
  * 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 :
  *           f : (filename) Identifies the file to edit
@@ -3785,9 +3813,9 @@ jb_err cgi_edit_actions_section_swap(struct client_state *csp,
  *                an actions file.
  *
  * 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 :
  *         set : If present, how to change toggle setting: