X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=actions.c;h=866d6233ad36be2b84da54efb5f766719662811a;hb=74da8556618cbd7e499e46ecd598aec0ae9feba4;hp=b9c63af96f3b01c9fad08c60c9e231c4d91a0b7c;hpb=a51f4b51843337c9335f6976a1acde693089de18;p=privoxy.git diff --git a/actions.c b/actions.c index b9c63af9..866d6233 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.75 2011/12/31 14:49:58 fabiankeil Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.80 2012/03/09 17:56:21 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -69,11 +69,13 @@ const char actions_h_rcs[] = ACTIONS_H_VERSION; * an enumerated type (well, the preprocessor equivalent). Here are * the values: */ -#define AV_NONE 0 /* +opt -opt */ -#define AV_ADD_STRING 1 /* +stropt{string} */ -#define AV_REM_STRING 2 /* -stropt */ -#define AV_ADD_MULTI 3 /* +multiopt{string} +multiopt{string2} */ -#define AV_REM_MULTI 4 /* -multiopt{string} -multiopt */ +enum action_value_type { + AV_NONE = 0, /* +opt -opt */ + AV_ADD_STRING = 1, /* +stropt{string} */ + AV_REM_STRING = 2, /* -stropt */ + AV_ADD_MULTI = 3, /* +multiopt{string} +multiopt{string2} */ + AV_REM_MULTI = 4 /* -multiopt{string} -multiopt */ +}; /* * We need a structure to hold the name, flag changes, @@ -82,10 +84,10 @@ const char actions_h_rcs[] = ACTIONS_H_VERSION; struct action_name { const char * name; - unsigned long mask; /* a bit set to "0" = remove action */ - unsigned long add; /* a bit set to "1" = add action */ - int takes_value; /* an AV_... constant */ - int index; /* index into strings[] or multi[] */ + unsigned long mask; /* a bit set to "0" = remove action */ + unsigned long add; /* a bit set to "1" = add action */ + enum action_value_type value_type; /* an AV_... constant */ + int index; /* index into strings[] or multi[] */ }; /* @@ -499,7 +501,7 @@ jb_err get_actions(char *line, /* Check for standard action name */ const struct action_name * action = action_names; - while ( (action->name != NULL) && (0 != strcmpic(action->name, option)) ) + while ((action->name != NULL) && (0 != strcmpic(action->name, option))) { action++; } @@ -510,7 +512,7 @@ jb_err get_actions(char *line, cur_action->add &= action->mask; cur_action->add |= action->add; - switch (action->takes_value) + switch (action->value_type) { case AV_NONE: /* ignore any option. */ @@ -580,8 +582,8 @@ jb_err get_actions(char *line, struct list * remove_p = cur_action->multi_remove[action->index]; struct list * add_p = cur_action->multi_add[action->index]; - if ( (value == NULL) || (*value == '\0') - || ((*value == '*') && (value[1] == '\0')) ) + if ((value == NULL) || (*value == '\0') + || ((*value == '*') && (value[1] == '\0'))) { /* * no option, or option == "*". @@ -596,7 +598,7 @@ jb_err get_actions(char *line, { /* Valid option - remove only 1 option */ - if ( !cur_action->multi_remove_all[action->index] ) + if (!cur_action->multi_remove_all[action->index]) { /* there isn't a catch-all in the remove list already */ err = enlist_unique(remove_p, value, 0); @@ -620,7 +622,7 @@ jb_err get_actions(char *line, /* try user aliases. */ const struct action_alias * alias = alias_list; - while ( (alias != NULL) && (0 != strcmpic(alias->name, option)) ) + while ((alias != NULL) && (0 != strcmpic(alias->name, option))) { alias = alias->next; } @@ -1406,14 +1408,14 @@ static int load_one_actions_file(struct client_state *csp, int fileid) "While loading actions file '%s': invalid line (%lu): %s", csp->config->actions_file[fileid], linenum, buf); } - else if ( atoi(fields[0]) > VERSION_MAJOR - || (num_fields > 1 && atoi(fields[1]) > VERSION_MINOR) - || (num_fields > 2 && atoi(fields[2]) > VERSION_POINT)) + else if ( (atoi(fields[0]) > VERSION_MAJOR) + || ((num_fields > 1) && (atoi(fields[1]) > VERSION_MINOR)) + || ((num_fields > 2) && (atoi(fields[2]) > VERSION_POINT))) { fclose(fp); log_error(LOG_LEVEL_FATAL, "Actions file '%s', line %lu requires newer Privoxy version: %s", - csp->config->actions_file[fileid], linenum, buf ); + csp->config->actions_file[fileid], linenum, buf); return 1; /* never get here */ } free(version_string);