X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=actions.c;h=f08104bcad12f1d10904156d027178cfac379888;hb=e5a56f639fb0aa0b008761349df73854fd0b8437;hp=0bc413ad066ad3ff365dcb4b352ceeba1fb5e279;hpb=2afa3221231342abdf0298bf1c463042843e05ab;p=privoxy.git
diff --git a/actions.c b/actions.c
index 0bc413ad..f08104bc 100644
--- a/actions.c
+++ b/actions.c
@@ -1,4 +1,4 @@
-const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.13 2001/09/16 15:47:37 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
@@ -33,6 +33,15 @@ const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster
*
* Revisions :
* $Log: actions.c,v $
+ * Revision 1.13 2001/09/16 15:47:37 jongfoster
+ * First version of CGI-based edit interface. This is very much a
+ * work-in-progress, and you can't actually use it to edit anything
+ * yet. You must #define FEATURE_CGI_EDIT_ACTIONS for these changes
+ * to have any effect.
+ *
+ * Revision 1.12 2001/09/16 13:21:27 jongfoster
+ * Changes to use new list functions.
+ *
* Revision 1.11 2001/09/14 00:17:32 jongfoster
* Tidying up memory allocation. New function init_action().
*
@@ -87,6 +96,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster
#include "miscutil.h"
#include "errlog.h"
#include "loaders.h"
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+#include "encode.h"
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
const char actions_h_rcs[] = ACTIONS_H_VERSION;
@@ -655,6 +667,106 @@ char * actions_to_text(struct action_spec *action)
}
+#ifdef FEATURE_CGI_EDIT_ACTIONS
+/*********************************************************************
+ *
+ * Function : actions_to_html
+ *
+ * Description : Converts a actionsfile entry from numeric form
+ * ("mask" and "add") to a
-seperated HTML string.
+ *
+ * Parameters :
+ * 1 : mask = As from struct url_actions
+ * 2 : add = As from struct url_actions
+ *
+ * Returns : A string. Caller must free it.
+ *
+ *********************************************************************/
+char * actions_to_html(struct action_spec *action)
+{
+ unsigned mask = action->mask;
+ unsigned add = action->add;
+ char * result = strdup("");
+ char * enc_str;
+ struct list_entry * lst;
+
+ /* sanity - prevents "-feature +feature" */
+ mask |= add;
+
+
+#define DEFINE_ACTION_BOOL(__name, __bit) \
+ if (!(mask & __bit)) \
+ { \
+ result = strsav(result, "\n
-" __name); \
+ } \
+ else if (add & __bit) \
+ { \
+ result = strsav(result, "\n
+" __name); \
+ }
+
+#define DEFINE_ACTION_STRING(__name, __bit, __index) \
+ if (!(mask & __bit)) \
+ { \
+ result = strsav(result, "\n
-" __name); \
+ } \
+ else if (add & __bit) \
+ { \
+ result = strsav(result, "\n
+" __name "{"); \
+ enc_str = html_encode(action->string[__index]);\
+ result = strsav(result, enc_str); \
+ freez(enc_str); \
+ result = strsav(result, "}"); \
+ }
+
+#define DEFINE_ACTION_MULTI(__name, __index) \
+ if (action->multi_remove_all[__index]) \
+ { \
+ result = strsav(result, "\n
-" __name "{*}"); \
+ } \
+ else \
+ { \
+ lst = action->multi_remove[__index]->first; \
+ while (lst) \
+ { \
+ result = strsav(result, "\n
-" __name "{");\
+ enc_str = html_encode(lst->str); \
+ result = strsav(result, enc_str); \
+ freez(enc_str); \
+ result = strsav(result, "}"); \
+ lst = lst->next; \
+ } \
+ } \
+ lst = action->multi_add[__index]->first; \
+ while (lst) \
+ { \
+ result = strsav(result, "\n
+" __name "{"); \
+ result = strsav(result, lst->str); \
+ result = strsav(result, "}"); \
+ lst = lst->next; \
+ }
+
+#define DEFINE_ACTION_ALIAS 0 /* No aliases for output */
+
+#include "actionlist.h"
+
+#undef DEFINE_ACTION_MULTI
+#undef DEFINE_ACTION_STRING
+#undef DEFINE_ACTION_BOOL
+#undef DEFINE_ACTION_ALIAS
+
+ /* trim leading
*/
+ if (result && *result)
+ {
+ char * s = result;
+ result = strdup(result + 5);
+ free(s);
+ }
+
+ return result;
+}
+#endif /* def FEATURE_CGI_EDIT_ACTIONS */
+
+
/*********************************************************************
*
* Function : current_actions_to_text
@@ -941,7 +1053,7 @@ int load_actions_file(struct client_state *csp)
return 1; /* never get here */
}
- while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
+ while (read_config_line(buf, sizeof(buf), fp) != NULL)
{
if (*buf == '{')
{