Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

actions.c File Reference

Declares functions to work with actions files Functions declared include: FIXME. More...


Data Structures

struct  action_name
 A structure holding information about a single built-in action string. More...


Defines

#define AV_NONE   0
#define AV_ADD_STRING   1
#define AV_REM_STRING   2
#define AV_ADD_MULTI   3
#define AV_REM_MULTI   4
#define DEFINE_ACTION_MULTI(name, index)
#define DEFINE_ACTION_STRING(name, flag, index)
#define DEFINE_ACTION_BOOL(name, flag)
#define DEFINE_ACTION_ALIAS   1
#define MODE_START_OF_FILE   1
#define MODE_SETTINGS   2
#define MODE_DESCRIPTION   3
#define MODE_ALIAS   4
#define MODE_ACTIONS   5
#define DEFINE_ACTION_BOOL(__name, __bit)
#define DEFINE_ACTION_STRING(__name, __bit, __index)
#define DEFINE_ACTION_MULTI(__name, __index)
#define DEFINE_ACTION_ALIAS   0
#define DEFINE_ACTION_BOOL(__name, __bit)
#define DEFINE_ACTION_STRING(__name, __bit, __index)
#define DEFINE_ACTION_MULTI(__name, __index)
#define DEFINE_ACTION_ALIAS   0
#define DEFINE_ACTION_BOOL(__name, __bit)
#define DEFINE_ACTION_STRING(__name, __bit, __index)
#define DEFINE_ACTION_MULTI(__name, __index)
#define DEFINE_ACTION_ALIAS   0

Functions

int load_one_actions_file (struct client_state *csp, int fileid)
jb_err merge_actions (struct action_spec *dest, const struct action_spec *src)
jb_err copy_action (struct action_spec *dest, const struct action_spec *src)
void free_action (struct action_spec *src)
jb_err get_action_token (char **line, char **name, char **value)
jb_err get_actions (char *line, struct action_alias *alias_list, struct action_spec *cur_action)
void init_current_action (struct current_action_spec *dest)
void init_action (struct action_spec *dest)
jb_err merge_current_action (struct current_action_spec *dest, const struct action_spec *src)
void free_current_action (struct current_action_spec *src)
void unload_actions_file (void *file_data)
void free_alias_list (struct action_alias *alias_list)
int load_actions_file (struct client_state *csp)
char * actions_to_text (struct action_spec *action)
 DEFINE_CGI_PARAM_NO_RADIO ("hide-user-agent", ACTION_HIDE_USER_AGENT, ACTION_STRING_USER_AGENT,"Privoxy/3.0(Anonymous)") return result
char * actions_to_html (struct client_state *csp, struct action_spec *action)
char * current_action_to_html (struct client_state *csp, struct current_action_spec *action)

Variables

const char actions_rcs [] = "$Id: actions.c,v 2.1 2002/06/04 17:55:23 jongfoster Exp $"
const char actions_h_rcs [] = ACTIONS_H_VERSION
const struct action_name action_names []
file_listcurrent_actions_file [MAX_ACTION_FILES]
return result


Detailed Description

Declares functions to work with actions files Functions declared include: FIXME.

Log:
actions.c,v
Revision 2.1 2002/06/04 17:55:23 jongfoster Adding comments

Revision 2.0 2002/06/04 14:34:21 jongfoster Moving source files to src/

Revision 1.33 2002/05/26 12:14:19 roro Change unsigned to unsigned long in actions_name struct. This closes SourceForge Bug #539284.

Revision 1.32 2002/05/12 21:36:29 jongfoster Correcting function comments

Revision 1.31 2002/05/06 07:56:50 oes Made actions_to_html independent of FEATURE_CGI_EDIT_ACTIONS

Revision 1.30 2002/04/30 11:14:52 oes Made csp the first parameter in *action_to_html

Revision 1.29 2002/04/26 19:30:54 jongfoster

Revision 1.28 2002/04/26 12:53:15 oes Revision 1.27 2002/04/24 02:10:31 oes Revision 1.26 2002/03/26 22:29:54 swa we have a new homepage!

Revision 1.25 2002/03/24 13:25:43 swa name change related issues

Revision 1.24 2002/03/16 23:54:06 jongfoster Adding graceful termination feature, to help look for memory leaks. If you enable this (which, by design, has to be done by hand editing config.h) and then go to http://i.j.b/die, then the program will exit cleanly after the *next* request. It should free all the memory that was used.

Revision 1.23 2002/03/07 03:46:16 oes Fixed compiler warnings

Revision 1.22 2002/01/21 00:27:02 jongfoster Allowing free_action(NULL). Moving the functions that include actionlist.h to the end of the file, because the Visual C++ 97 debugger gets extremely confused if you try to debug any code that comes after them in the file.

Revision 1.21 2002/01/17 20:54:44 jongfoster Renaming free_url to free_url_spec, since it frees a struct url_spec.

Revision 1.20 2001/11/22 21:56:49 jongfoster Making action_spec->flags into an unsigned long rather than just an unsigned int. Fixing a bug in the display of -add-header and -wafer

Revision 1.19 2001/11/13 00:14:07 jongfoster Fixing stupid bug now I've figured out what || means. (It always returns 0 or 1, not one of it's paramaters.)

Revision 1.18 2001/11/07 00:06:06 steudten Add line number in error output for lineparsing for actionsfile.

Revision 1.17 2001/10/25 03:40:47 david__schmidt Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple threads to call select() simultaneously. So, it's time to do a real, live, native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__ (native). Both versions will work, but using __OS2__ offers multi-threading.

Revision 1.16 2001/10/23 21:30:30 jongfoster Adding error-checking to selected functions.

Revision 1.15 2001/10/14 21:58:22 jongfoster Adding support for the CGI-based editor:

Revision 1.14 2001/09/22 16:36:59 jongfoster Removing unused parameter fs from read_config_line()

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().

Revision 1.10 2001/09/10 10:14:34 oes Removing unused variable

Revision 1.9 2001/07/30 22:08:36 jongfoster Tidying up defines:

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.


Define Documentation

#define AV_ADD_MULTI   3
 

Action type: +multi-action{string}.

#define AV_ADD_STRING   1
 

Action type: +string-action{string}.

#define AV_NONE   0
 

Action type: +bool-action or -bool-action.

#define AV_REM_MULTI   4
 

Action type: -multi-action{string} or -multi-action.

#define AV_REM_STRING   2
 

Action type: -string-action.

#define DEFINE_ACTION_BOOL __name,
__bit   
 

Value:

if (flags & __bit)                      \
   {                                       \
      string_append(&result, "\n<br>+");   \
      string_join(&result, add_help_link(__name, csp->config)); \
   }                                       \
   else                                    \
   {                                       \
      string_append(&result, "\n<br>-");   \
      string_join(&result, add_help_link(__name, csp->config)); \
   }

#define DEFINE_ACTION_BOOL __name,
__bit   
 

Value:

if (!(mask & __bit))                         \
   {                                            \
      string_append(&result, "\n<br>-");        \
      string_join(&result, add_help_link(__name, csp->config)); \
   }                                            \
   else if (add & __bit)                        \
   {                                            \
      string_append(&result, "\n<br>+");        \
      string_join(&result, add_help_link(__name, csp->config)); \
   }

#define DEFINE_ACTION_BOOL __name,
__bit   
 

Value:

if (!(mask & __bit))                            \
   {                                               \
      string_append(&result, " -" __name " \\\n"); \
   }                                               \
   else if (add & __bit)                           \
   {                                               \
      string_append(&result, " +" __name " \\\n"); \
   }

#define DEFINE_ACTION_BOOL name,
flag   
 

Value:

{ "+" name, ACTION_MASK_ALL, flag }, \
   { "-" name, ~flag, 0 },

#define DEFINE_ACTION_MULTI __name,
__index   
 

Value:

lst = action->multi[__index]->first;                \
   if (lst == NULL)                                    \
   {                                                   \
      string_append(&result, "\n<br>-");              \
      string_join(&result, add_help_link(__name, csp->config)); \
   }                                                   \
   else                                                \
   {                                                   \
      while (lst)                                      \
      {                                                \
         string_append(&result, "\n<br>+");            \
         string_join(&result, add_help_link(__name, csp->config)); \
         string_append(&result, "{");                  \
         string_join(&result, html_encode(lst->str));  \
         string_append(&result, "}");                  \
         lst = lst->next;                              \
      }                                                \
   }

#define DEFINE_ACTION_MULTI __name,
__index   
 

Value:

if (action->multi_remove_all[__index])             \
   {                                                  \
      string_append(&result, "\n<br>-");              \
      string_join(&result, add_help_link(__name, csp->config)); \
   }                                                  \
   else                                               \
   {                                                  \
      lst = action->multi_remove[__index]->first;     \
      while (lst)                                     \
      {                                               \
         string_append(&result, "\n<br>-");           \
         string_join(&result, add_help_link(__name, csp->config)); \
         string_append(&result, "{");                 \
         string_join(&result, html_encode(lst->str)); \
         string_append(&result, "}");                 \
         lst = lst->next;                             \
      }                                               \
   }                                                  \
   lst = action->multi_add[__index]->first;           \
   while (lst)                                        \
   {                                                  \
      string_append(&result, "\n<br>+");              \
      string_join(&result, add_help_link(__name, csp->config)); \
      string_append(&result, "{");                    \
      string_join(&result, html_encode(lst->str));    \
      string_append(&result, "}");                    \
      lst = lst->next;                                \
   }

#define DEFINE_ACTION_MULTI __name,
__index   
 

Value:

if (action->multi_remove_all[__index])            \
   {                                                 \
      string_append(&result, " -" __name " \\\n");   \
   }                                                 \
   else                                              \
   {                                                 \
      lst = action->multi_remove[__index]->first;    \
      while (lst)                                    \
      {                                              \
         string_append(&result, " -" __name "{");    \
         string_append(&result, lst->str);           \
         string_append(&result, "} \\\n");           \
         lst = lst->next;                            \
      }                                              \
   }                                                 \
   lst = action->multi_add[__index]->first;          \
   while (lst)                                       \
   {                                                 \
      string_append(&result, " +" __name "{");       \
      string_append(&result, lst->str);              \
      string_append(&result, "} \\\n");              \
      lst = lst->next;                               \
   }

#define DEFINE_ACTION_MULTI name,
index   
 

Value:

{ "+" name, ACTION_MASK_ALL, 0, AV_ADD_MULTI, index }, \
   { "-" name, ACTION_MASK_ALL, 0, AV_REM_MULTI, index },

#define DEFINE_ACTION_STRING __name,
__bit,
__index   
 

Value:

if (flags & __bit)                                  \
   {                                                   \
      string_append(&result, "\n<br>+");               \
      string_join(&result, add_help_link(__name, csp->config)); \
      string_append(&result, "{");                     \
      string_join(&result, html_encode(action->string[__index])); \
      string_append(&result, "}");                     \
   }                                                   \
   else                                                \
   {                                                   \
      string_append(&result, "\n<br>-");               \
      string_join(&result, add_help_link(__name, csp->config)); \
   }

#define DEFINE_ACTION_STRING __name,
__bit,
__index   
 

Value:

if (!(mask & __bit))                              \
   {                                                 \
      string_append(&result, "\n<br>-");             \
      string_join(&result, add_help_link(__name, csp->config)); \
   }                                                 \
   else if (add & __bit)                             \
   {                                                 \
      string_append(&result, "\n<br>+");             \
      string_join(&result, add_help_link(__name, csp->config)); \
      string_append(&result, "{");                   \
      string_join(&result, html_encode(action->string[__index])); \
      string_append(&result, "}");                   \
   }

#define DEFINE_ACTION_STRING __name,
__bit,
__index   
 

Value:

if (!(mask & __bit))                                \
   {                                                   \
      string_append(&result, " -" __name " \\\n");     \
   }                                                   \
   else if (add & __bit)                               \
   {                                                   \
      string_append(&result, " +" __name "{");         \
      string_append(&result, action->string[__index]); \
      string_append(&result, "} \\\n");                \
   }

#define DEFINE_ACTION_STRING name,
flag,
index   
 

Value:

{ "+" name, ACTION_MASK_ALL, flag, AV_ADD_STRING, index }, \
   { "-" name, ~flag, 0, AV_REM_STRING, index },

#define MODE_ACTIONS   5
 

load_one_actions_file() parser status: In "{+some-actions}" block.

#define MODE_ALIAS   4
 

load_one_actions_file() parser status: In "{{alias}}" block.

#define MODE_DESCRIPTION   3
 

load_one_actions_file() parser status: In "{{description}}" block.

#define MODE_SETTINGS   2
 

load_one_actions_file() parser status: In "{{settings}}" block.

#define MODE_START_OF_FILE   1
 

load_one_actions_file() parser status: At start of file.


Function Documentation

char* actions_to_html struct client_state   csp,
struct action_spec   action
 

Converts a actionsfile entry from numeric form ("mask" and "add") to a
-seperated HTML string in which each action is linked to its chapter in the user manual.

Parameters:
csp  Client state (for config)
action  Action spec to be converted
Returns:
A string. Caller must free it. NULL on out-of-memory error.

char* actions_to_text struct action_spec   action
 

Converts a actionsfile entry from the internal structurt into a text line.

The output is split into one line for each action with line continuation.

Parameters:
action  The action to format.
Returns:
A string. Caller must free it. NULL on out-of-memory error.

jb_err copy_action struct action_spec   dest,
const struct action_spec   src
 

Copy an action_specs.

Similar to "dest = src".

Parameters:
dest  Destination of copy.
src  Source for copy.
Returns:
N/A

char* current_action_to_html struct client_state   csp,
struct current_action_spec   action
 

Converts a curren action spec to a
seperated HTML text in which each action is linked to its chapter in the user manual.

Parameters:
csp  Client state (for config)
action  Current action spec to be converted
Returns:
A string. Caller must free it. NULL on out-of-memory error.

void free_action struct action_spec   src
 

Destroy an action_spec.

Frees memory used by it, except for the memory used by the struct action_spec itself.

Parameters:
src  Source to free.
Returns:
N/A

void free_alias_list struct action_alias   alias_list
 

Free memory used by a list of aliases.

Parameters:
alias_list  Linked list to free.
Returns:
N/A

void free_current_action struct current_action_spec   src
 

Free memory used by a current_action_spec.

Does not free the current_action_spec itself.

Parameters:
src  Source to free.
Returns:
N/A

jb_err get_action_token char **    line,
char **    name,
char **    value
 

Parses a line for the first action.

Modifies it's input array, doesn't allocate memory. e.g. given: *line=" +abc{def} -ghi "

Returns *line=" -ghi " *name="+abc" *value="def"

Parameters:
line  [in] The line containing the action. [out] Start of next action on line, or NULL if we reached the end of line before we found an action.
name  [out] Start of action name, null terminated. NULL on EOL
value  [out] Start of action value, null terminated. NULL if none or EOL.
Returns:
JB_ERR_OK => Ok JB_ERR_PARSE => Mismatched {} (line was trashed anyway)

jb_err get_actions char *    line,
struct action_alias   alias_list,
struct action_spec   cur_action
 

Parses a list of actions.

Parameters:
line  The string containing the actions. Will be written to by this function.
alias_list  Custom alias list, or NULL for none.
cur_action  Where to store the action. Caller allocates memory.
Returns:
JB_ERR_OK => Ok JB_ERR_PARSE => Parse error (line was trashed anyway) nonzero => Out of memory (line was trashed anyway)

void init_action struct action_spec   dest
 

Zero out an action.

Parameters:
dest  An uninitialized action_spec.
Returns:
N/A

void init_current_action struct current_action_spec   dest
 

Zero out an action.

Parameters:
dest  An uninitialized current_action_spec.
Returns:
N/A

int load_actions_file struct client_state   csp
 

Read and parse all the action files and add to files list.

Parameters:
csp  Current client state (buffers, headers, etc...)
Returns:
0 => Ok, everything else is an error.

int load_one_actions_file struct client_state   csp,
int    fileid
[static]
 

Read and parse a action file and add to files list.

Parameters:
csp  Current client state (buffers, headers, etc...)
fileid  File index to load.
Returns:
0 => Ok, everything else is an error.

jb_err merge_actions struct action_spec   dest,
const struct action_spec   src
 

Merge two actions together.

Similar to "dest += src".

Parameters:
dest  Actions to modify.
src  Action to add.
Returns:
JB_ERR_OK or JB_ERR_MEMORY

jb_err merge_current_action struct current_action_spec   dest,
const struct action_spec   src
 

Merge two actions together.

Similar to "dest += src". Differences between this and merge_actions() is that this one doesn't allocate memory for strings (so "src" better be in memory for at least as long as "dest" is, and you'd better free "dest" using "free_current_action"). Also, there is no mask or remove lists in dest. (If we're applying it to a URL, we don't need them)

Parameters:
dest  Current actions, to modify.
src  Action to add. Returns 0 : no error !=0 : error, probably JB_ERR_MEMORY.

void unload_actions_file void *    file_data
 

Unloads an actions module.

Parameters:
file_data  the data structure associated with the actions file.
Returns:
N/A


Variable Documentation

const struct action_name action_names[] [static]
 

The array of all built-in action strings.

const char actions_h_rcs[] = ACTIONS_H_VERSION
 

Version information about actions.h.

const char actions_rcs[] = "$Id: actions.c,v 2.1 2002/06/04 17:55:23 jongfoster Exp $"
 

Version information about actions.c.

struct file_list* current_actions_file[MAX_ACTION_FILES] [static]
 

Initial value:

 {
   NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL
}
The currently loaded actions files.


Generated on Tue Jun 4 18:54:48 2002 for Privoxy 3.1.1 by doxygen1.2.15