X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=actions.c;h=4e74aaa0bb4c9c4aacd318b0d5f8c8b865963833;hp=fff75a6994ba5257e278c91884e7390b03208eb9;hb=9285f53c6431ca054e4a970d97ee22db090639ab;hpb=5f390b415777db21894f1b856ab3d21c9c24f7c6 diff --git a/actions.c b/actions.c index fff75a69..4e74aaa0 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.19 2001/11/13 00:14:07 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -33,6 +33,20 @@ const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster * * Revisions : * $Log: actions.c,v $ + * 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. * @@ -106,6 +120,7 @@ const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster #include #include #include +#include #include "project.h" #include "jcc.h" @@ -135,7 +150,7 @@ const char actions_h_rcs[] = ACTIONS_H_VERSION; #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{*} */ +#define AV_REM_MULTI 4 /* -multiopt{string} -multiopt */ /* * We need a structure to hold the name, flag changes, @@ -245,7 +260,7 @@ jb_err merge_actions (struct action_spec *dest, /* No "remove all"s to worry about. */ list_remove_list(dest->multi_add[i], src->multi_remove[i]); err = list_append_list_unique(dest->multi_remove[i], src->multi_remove[i]); - err = err || list_append_list_unique(dest->multi_add[i], src->multi_add[i]); + if (!err) err = list_append_list_unique(dest->multi_add[i], src->multi_add[i]); } if (err) @@ -302,8 +317,12 @@ jb_err copy_action (struct action_spec *dest, for (i = 0; i < ACTION_MULTI_COUNT; i++) { dest->multi_remove_all[i] = src->multi_remove_all[i]; - err = list_duplicate(dest->multi_remove[i], src->multi_remove[i]); - err = err || list_duplicate(dest->multi_add[i], src->multi_add[i]); + err = list_duplicate(dest->multi_remove[i], src->multi_remove[i]); + if (err) + { + return err; + } + err = list_duplicate(dest->multi_add[i], src->multi_add[i]); if (err) { return err; @@ -676,7 +695,7 @@ char * actions_to_text(struct action_spec *action) #define DEFINE_ACTION_MULTI(__name, __index) \ if (action->multi_remove_all[__index]) \ { \ - string_append(&result, " -" __name "{*}"); \ + string_append(&result, " -" __name); \ } \ else \ { \ @@ -775,7 +794,7 @@ char * actions_to_html(struct action_spec *action) #define DEFINE_ACTION_MULTI(__name, __index) \ if (action->multi_remove_all[__index]) \ { \ - string_append(&result, "\n
-" __name "{*}"); \ + string_append(&result, "\n
-" __name); \ } \ else \ { \ @@ -856,7 +875,7 @@ char * actions_to_html(struct action_spec *action) *********************************************************************/ char * current_action_to_text(struct current_action_spec *action) { - unsigned flags = action->flags; + unsigned long flags = action->flags; char * result = strdup(""); struct list_entry * lst; @@ -1145,6 +1164,7 @@ int load_actions_file(struct client_state *csp) struct action_spec * cur_action = NULL; int cur_action_used = 0; struct action_alias * alias_list = NULL; + unsigned long linenum = 0; if (!check_file_changed(current_actions_file, csp->config->actions_file, &fs)) { @@ -1177,7 +1197,7 @@ int load_actions_file(struct client_state *csp) return 1; /* never get here */ } - while (read_config_line(buf, sizeof(buf), fp) != NULL) + while (read_config_line(buf, sizeof(buf), fp, &linenum) != NULL) { if (*buf == '{') { @@ -1193,8 +1213,8 @@ int load_actions_file(struct client_state *csp) /* too short */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid line: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': invalid line (%lu): %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } @@ -1207,8 +1227,8 @@ int load_actions_file(struct client_state *csp) /* too short */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid line: {{ }}", - csp->config->actions_file); + "can't load actions file '%s': invalid line (%lu): {{ }}", + csp->config->actions_file, linenum); return 1; /* never get here */ } @@ -1239,8 +1259,8 @@ int load_actions_file(struct client_state *csp) */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': {{settings}} must only appear once, and it must be before anything else.", - csp->config->actions_file); + "can't load actions file '%s': line %lu: {{settings}} must only appear once, and it must be before anything else.", + csp->config->actions_file, linenum); } mode = MODE_SETTINGS; } @@ -1253,8 +1273,8 @@ int load_actions_file(struct client_state *csp) */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': {{description}} must only appear once, and only a {{settings}} block may be above it.", - csp->config->actions_file); + "can't load actions file '%s': line %lu: {{description}} must only appear once, and only a {{settings}} block may be above it.", + csp->config->actions_file, linenum); } mode = MODE_DESCRIPTION; } @@ -1275,8 +1295,8 @@ int load_actions_file(struct client_state *csp) */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': {{alias}} must only appear once, and it must be before all actions.", - csp->config->actions_file, start); + "can't load actions file '%s': line %lu: {{alias}} must only appear once, and it must be before all actions.", + csp->config->actions_file, linenum); } mode = MODE_ALIAS; } @@ -1285,8 +1305,8 @@ int load_actions_file(struct client_state *csp) /* invalid {{something}} block */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid line: {{%s}}", - csp->config->actions_file, start); + "can't load actions file '%s': invalid line (%lu): {{%s}}", + csp->config->actions_file, linenum, start); return 1; /* never get here */ } } @@ -1332,8 +1352,8 @@ int load_actions_file(struct client_state *csp) /* No closing } */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid line: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': invalid line (%lu): %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } *end = '\0'; @@ -1346,8 +1366,8 @@ int load_actions_file(struct client_state *csp) /* error */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid line: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': invalid line (%lu): %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } } @@ -1381,8 +1401,8 @@ int load_actions_file(struct client_state *csp) if ((start == NULL) || (start == buf)) { log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid alias line: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': invalid alias line (%lu): %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } @@ -1416,8 +1436,8 @@ int load_actions_file(struct client_state *csp) if (*start == '\0') { log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid alias line: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': invalid alias line (%lu): %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } @@ -1430,8 +1450,8 @@ int load_actions_file(struct client_state *csp) /* error */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': invalid alias line: %s = %s", - csp->config->actions_file, buf, start); + "can't load actions file '%s': invalid alias line (%lu): %s = %s", + csp->config->actions_file, linenum, buf, start); return 1; /* never get here */ } @@ -1461,8 +1481,8 @@ int load_actions_file(struct client_state *csp) { fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': cannot create URL pattern from: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': line %lu: cannot create URL pattern from: %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } @@ -1475,8 +1495,8 @@ int load_actions_file(struct client_state *csp) /* oops - please have a {} line as 1st line in file. */ fclose(fp); log_error(LOG_LEVEL_FATAL, - "can't load actions file '%s': first line is invalid: %s", - csp->config->actions_file, buf); + "can't load actions file '%s': first needed line (%lu) is invalid: %s", + csp->config->actions_file, linenum, buf); return 1; /* never get here */ } else