-const char actions_rcs[] = "$Id: actions.c,v ???? $";
+const char actions_rcs[] = "$Id: actions.c,v 1.9 2001/07/30 22:08:36 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
*
* Revisions :
* $Log: actions.c,v $
+ * Revision 1.9 2001/07/30 22:08:36 jongfoster
+ * Tidying up #defines:
+ * - All feature #defines are now of the form FEATURE_xxx
+ * - Permanently turned off WIN_GUI_EDIT
+ * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
+ *
+ * Revision 1.8 2001/06/29 13:19:52 oes
+ * Removed logentry from cancelled commit
+ *
+ * Revision 1.7 2001/06/09 10:55:28 jongfoster
+ * Changing BUFSIZ ==> BUFFER_SIZE
+ *
+ * Revision 1.6 2001/06/07 23:04:34 jongfoster
+ * Made get_actions() static.
+ *
+ * Revision 1.5 2001/06/03 19:11:48 oes
+ * adapted to new enlist_unique arg format
+ *
+ * Revision 1.4 2001/06/01 20:03:42 jongfoster
+ * Better memory management - current_action->strings[] now
+ * contains copies of the strings, not the original.
+ *
+ * Revision 1.3 2001/06/01 18:49:17 jongfoster
+ * Replaced "list_share" with "list" - the tiny memory gain was not
+ * worth the extra complexity.
+ *
+ * Revision 1.2 2001/05/31 21:40:00 jongfoster
+ * Removing some commented out, obsolete blocks of code.
+ *
+ * Revision 1.1 2001/05/31 21:16:46 jongfoster
+ * Moved functions to process the action list into this new file.
+ *
*
*********************************************************************/
\f
const char actions_h_rcs[] = ACTIONS_H_VERSION;
+
+/* Turn off everything except forwarding */
/* This structure is used to hold user-defined aliases */
struct action_alias
{
/*
* Must declare this in this file for the above structure.
- * FIXME: Make this static or put structure in header.
*/
-extern int get_actions (char *line, struct action_alias * alias_list,
+static int get_actions (char *line,
+ struct action_alias * alias_list,
struct action_spec *cur_action);
/*
#undef DEFINE_ACTION_BOOL
#undef DEFINE_ACTION_ALIAS
- /*
- { "+add-header", ACTION_MASK_ALL, 0, AV_ADD_MULTI, ACTION_MULTI_ADD_HEADER },
- { "+block", ACTION_MASK_ALL, ACTION_BLOCK },
- { "+fast-redirects", ACTION_MASK_ALL, ACTION_FAST_REDIRECTS },
- { "+filter", ACTION_MASK_ALL, ACTION_FILTER },
- { "+hide-forwarded", ACTION_MASK_ALL, ACTION_HIDE_FORWARDED },
- { "+hide-from", ACTION_MASK_ALL, ACTION_HIDE_FROM, AV_ADD_STRING, ACTION_STRING_FROM },
- { "+hide-referer", ACTION_MASK_ALL, ACTION_HIDE_REFERER, AV_ADD_STRING, ACTION_STRING_REFERER },
- { "+hide-referrer", ACTION_MASK_ALL, ACTION_HIDE_REFERER, AV_ADD_STRING, ACTION_STRING_REFERER },
- { "+hide-user-agent", ACTION_MASK_ALL, ACTION_HIDE_USER_AGENT, AV_ADD_STRING, ACTION_STRING_USER_AGENT },
- { "+image", ACTION_MASK_ALL, ACTION_IMAGE },
- { "+no-cookies-read", ACTION_MASK_ALL, ACTION_NO_COOKIE_READ },
- { "+no-cookies-set", ACTION_MASK_ALL, ACTION_NO_COOKIE_SET },
- { "+no-popup", ACTION_MASK_ALL, ACTION_NO_POPUPS },
- { "+no-popups", ACTION_MASK_ALL, ACTION_NO_POPUPS },
- { "+vanilla-wafer", ACTION_MASK_ALL, ACTION_VANILLA_WAFER },
- { "+wafer", ACTION_MASK_ALL, 0, AV_ADD_MULTI, ACTION_MULTI_WAFER },
- { "-add-header", ACTION_MASK_ALL, 0, AV_REM_MULTI, ACTION_MULTI_ADD_HEADER },
- { "-block", ~ACTION_BLOCK, 0 },
- { "-fast-redirects", ~ACTION_FAST_REDIRECTS, 0 },
- { "-filter", ~ACTION_FILTER, 0 },
- { "-hide-forwarded", ~ACTION_HIDE_FORWARDED, 0 },
- { "-hide-from", ~ACTION_HIDE_FROM, 0, AV_REM_STRING, ACTION_STRING_FROM },
- { "-hide-referer", ~ACTION_HIDE_REFERER, 0, AV_REM_STRING, ACTION_STRING_REFERER },
- { "-hide-referrer", ~ACTION_HIDE_REFERER, 0, AV_REM_STRING, ACTION_STRING_REFERER },
- { "-hide-user-agent", ~ACTION_HIDE_USER_AGENT, 0, AV_REM_STRING, ACTION_STRING_USER_AGENT },
- { "-image", ~ACTION_IMAGE, 0 },
- { "-no-cookies-read", ~ACTION_NO_COOKIE_READ, 0 },
- { "-no-cookies-set", ~ACTION_NO_COOKIE_SET, 0 },
- { "-no-popup", ~ACTION_NO_POPUPS, 0 },
- { "-no-popups", ~ACTION_NO_POPUPS, 0 },
- { "-vanilla-wafer", ~ACTION_VANILLA_WAFER, 0 },
- { "-wafer", ACTION_MASK_ALL, 0, AV_REM_MULTI, ACTION_MULTI_WAFER },
-*/
{ NULL, 0, 0 } /* End marker */
};
* nonzero => Error (line was trashed anyway)
*
*********************************************************************/
-int get_actions(char *line, struct action_alias * alias_list,
- struct action_spec *cur_action)
+static int get_actions(char *line,
+ struct action_alias * alias_list,
+ struct action_spec *cur_action)
{
memset(cur_action, '\0', sizeof(*cur_action));
cur_action->mask = ACTION_MASK_ALL;
}
list_remove_item(remove, value);
- enlist_unique(add, value);
+ enlist_unique(add, value, 0);
break;
}
case AV_REM_MULTI:
if ( !cur_action->multi_remove_all[action->index] )
{
/* there isn't a catch-all in the remove list already */
- enlist_unique(remove, value);
+ enlist_unique(remove, value, 0);
}
list_remove_item(add, value);
}
#undef DEFINE_ACTION_STRING
#undef DEFINE_ACTION_BOOL
#undef DEFINE_ACTION_ALIAS
-/*
- ACTION_MULTI_TO_TEXT ( "add-header", ACTION_MULTI_ADD_HEADER)
- ACTION_TO_TEXT (ACTION_BLOCK, "block");
- ACTION_TO_TEXT (ACTION_FAST_REDIRECTS, "fast-redirects");
- ACTION_TO_TEXT (ACTION_FILTER, "filter");
- ACTION_TO_TEXT (ACTION_HIDE_FORWARDED, "hide-forwarded");
- ACTION_STRING_TO_TEXT(ACTION_HIDE_FROM, "hide-from", ACTION_STRING_FROM);
- ACTION_STRING_TO_TEXT(ACTION_HIDE_REFERER, "hide-referer", ACTION_STRING_REFERER);
- ACTION_STRING_TO_TEXT(ACTION_HIDE_USER_AGENT, "hide-user-agent", ACTION_STRING_USER_AGENT);
- ACTION_TO_TEXT (ACTION_IMAGE, "image");
- ACTION_TO_TEXT (ACTION_NO_COOKIE_READ, "no-cookies-read");
- ACTION_TO_TEXT (ACTION_NO_COOKIE_SET, "no-cookies-set");
- ACTION_TO_TEXT (ACTION_NO_POPUPS, "no-popups");
- ACTION_TO_TEXT (ACTION_VANILLA_WAFER, "vanilla-wafer");
- ACTION_MULTI_TO_TEXT ( "wafer", ACTION_MULTI_WAFER);
-
-#undef ACTION_TO_TEXT
-#undef ACTION_STRING_TO_TEXT
-#undef ACTION_MULTI_TO_TEXT
-*/
+
return result;
}
{
unsigned flags = action->flags;
char * result = strdup("");
- struct list_share * lst;
+ struct list * lst;
#define DEFINE_ACTION_BOOL(__name, __bit) \
if (flags & __bit) \
#undef DEFINE_ACTION_STRING
#undef DEFINE_ACTION_BOOL
#undef DEFINE_ACTION_ALIAS
-/*
-
- ACTION_MULTI_TO_TEXT ( "add-header", ACTION_MULTI_ADD_HEADER)
- ACTION_TO_TEXT (ACTION_BLOCK, "block");
- ACTION_TO_TEXT (ACTION_FAST_REDIRECTS, "fast-redirects");
- ACTION_TO_TEXT (ACTION_FILTER, "filter");
- ACTION_TO_TEXT (ACTION_HIDE_FORWARDED, "hide-forwarded");
- ACTION_STRING_TO_TEXT(ACTION_HIDE_FROM, "hide-from", ACTION_STRING_FROM);
- ACTION_STRING_TO_TEXT(ACTION_HIDE_REFERER, "hide-referer", ACTION_STRING_REFERER);
- ACTION_STRING_TO_TEXT(ACTION_HIDE_USER_AGENT, "hide-user-agent", ACTION_STRING_USER_AGENT);
- ACTION_TO_TEXT (ACTION_IMAGE, "image");
- ACTION_TO_TEXT (ACTION_NO_COOKIE_READ, "no-cookies-read");
- ACTION_TO_TEXT (ACTION_NO_COOKIE_SET, "no-cookies-set");
- ACTION_TO_TEXT (ACTION_NO_POPUPS, "no-popups");
- ACTION_TO_TEXT (ACTION_VANILLA_WAFER, "vanilla-wafer");
- ACTION_MULTI_TO_TEXT ( "wafer", ACTION_MULTI_WAFER);
-
-#undef ACTION_TO_TEXT
-#undef ACTION_STRING_TO_TEXT
-#undef ACTION_MULTI_TO_TEXT
-*/
+
return result;
}
char * str = src->string[i];
if (str)
{
- dest->string[i] = str;
+ freez(dest->string[i]);
+ dest->string[i] = strdup(str);
}
}
if (src->multi_remove_all[i])
{
/* Remove everything from dest */
- destroy_list_share(dest->multi[i]);
- list_duplicate_share(dest->multi[i], src->multi_add[i]);
+ destroy_list(dest->multi[i]);
+ list_duplicate(dest->multi[i], src->multi_add[i]);
}
else
{
- list_remove_list_share(dest->multi[i], src->multi_remove[i]);
- list_append_list_unique_share(dest->multi[i], src->multi_add[i]);
+ list_remove_list(dest->multi[i], src->multi_remove[i]);
+ list_append_list_unique(dest->multi[i], src->multi_add[i]);
}
}
}
{
int i;
+ for (i = 0; i < ACTION_STRING_COUNT; i++)
+ {
+ freez(src->string[i]);
+ }
+
for (i = 0; i < ACTION_MULTI_COUNT; i++)
{
- destroy_list_share(src->multi[i]);
+ destroy_list(src->multi[i]);
}
memset(src, '\0', sizeof(*src));
struct url_actions *last_perm;
struct url_actions *perm;
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
struct file_list *fs;
#define MODE_START_OF_FILE 1
#define MODE_ACTIONS 2
{
/* It's an actions block */
- char actions_buf[BUFSIZ];
+ char actions_buf[BUFFER_SIZE];
char * end;
/* set mode */
else if (mode == MODE_ALIAS)
{
/* define an alias */
- char actions_buf[BUFSIZ];
+ char actions_buf[BUFFER_SIZE];
struct action_alias * new_alias;
- int more = 1;
char * start = strchr(buf, '=');
char * end = start;
alias_list = next;
}
-#ifndef SPLIT_PROXY_ARGS
- if (!suppress_blocklists)
- {
- fs->proxy_args = strsav(fs->proxy_args, "</pre>");
- }
-#endif /* ndef SPLIT_PROXY_ARGS */
-
/* the old one is now obsolete */
if (current_actions_file)
{