From: jongfoster Date: Sun, 16 Sep 2001 13:21:27 +0000 (+0000) Subject: Changes to use new list functions. X-Git-Tag: v_2_9_9~79 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=2afa3221231342abdf0298bf1c463042843e05ab Changes to use new list functions. --- diff --git a/actions.c b/actions.c index 909cd68c..0bc413ad 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.10 2001/09/10 10:14:34 oes Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.11 2001/09/14 00:17:32 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -33,6 +33,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.10 2001/09/10 10:14:34 oes Exp $" * * Revisions : * $Log: actions.c,v $ + * 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 * @@ -205,9 +208,9 @@ void merge_actions (struct action_spec *dest, if (src->multi_remove_all[i]) { /* Remove everything from dest */ - destroy_list(dest->multi_remove[i]); - destroy_list(dest->multi_add[i]); + list_remove_all(dest->multi_remove[i]); dest->multi_remove_all[i] = 1; + list_duplicate(dest->multi_add[i], src->multi_add[i]); } else if (dest->multi_remove_all[i]) @@ -518,8 +521,8 @@ static int get_actions(char *line, * * Remove *ALL*. */ - destroy_list(remove); - destroy_list(add); + list_remove_all(remove); + list_remove_all(add); cur_action->multi_remove_all[action->index] = 1; } else @@ -586,7 +589,7 @@ char * actions_to_text(struct action_spec *action) unsigned mask = action->mask; unsigned add = action->add; char * result = strdup(""); - struct list * lst; + struct list_entry * lst; /* sanity - prevents "-feature +feature" */ mask |= add; @@ -621,7 +624,7 @@ char * actions_to_text(struct action_spec *action) } \ else \ { \ - lst = action->multi_remove[__index]->next; \ + lst = action->multi_remove[__index]->first; \ while (lst) \ { \ result = strsav(result, " -" __name "{"); \ @@ -630,7 +633,7 @@ char * actions_to_text(struct action_spec *action) lst = lst->next; \ } \ } \ - lst = action->multi_add[__index]->next; \ + lst = action->multi_add[__index]->first; \ while (lst) \ { \ result = strsav(result, " +" __name "{"); \ @@ -668,7 +671,7 @@ char * current_action_to_text(struct current_action_spec *action) { unsigned flags = action->flags; char * result = strdup(""); - struct list * lst; + struct list_entry * lst; #define DEFINE_ACTION_BOOL(__name, __bit) \ if (flags & __bit) \ @@ -693,7 +696,7 @@ char * current_action_to_text(struct current_action_spec *action) } #define DEFINE_ACTION_MULTI(__name, __index) \ - lst = action->multi[__index]->next; \ + lst = action->multi[__index]->first; \ if (lst == NULL) \ { \ result = strsav(result, " -" __name); \ @@ -737,6 +740,7 @@ char * current_action_to_text(struct current_action_spec *action) void init_current_action (struct current_action_spec *dest) { memset(dest, '\0', sizeof(*dest)); + dest->flags = ACTION_MOST_COMPATIBLE; } @@ -802,8 +806,7 @@ void merge_current_action (struct current_action_spec *dest, { if (src->multi_remove_all[i]) { - /* Remove everything from dest */ - destroy_list(dest->multi[i]); + /* Remove everything from dest, then add src->multi_add */ list_duplicate(dest->multi[i], src->multi_add[i]); } else diff --git a/filters.c b/filters.c index b0dbd2db..aa798bcd 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.30 2001/09/16 11:00:10 jongfoster Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.31 2001/09/16 11:38:02 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,14 @@ const char filters_rcs[] = "$Id: filters.c,v 1.30 2001/09/16 11:00:10 jongfoster * * Revisions : * $Log: filters.c,v $ + * Revision 1.31 2001/09/16 11:38:02 jongfoster + * Splitting fill_template() into 2 functions: + * template_load() loads the file + * template_fill() performs the PCRS regexps. + * This is because the CGI edit interface has a "table row" + * template which is used many times in the page - this + * change means it's only loaded from disk once. + * * Revision 1.30 2001/09/16 11:00:10 jongfoster * New function alloc_http_response, for symmetry with free_http_response * @@ -637,11 +645,11 @@ struct http_response *trust_url(struct client_state *csp) /* * Export the trust info, if available */ - if (csp->config->trust_info->next) + if (csp->config->trust_info->first) { - struct list *l; + struct list_entry *l; - for (l = csp->config->trust_info->next; l ; l = l->next) + for (l = csp->config->trust_info->first; l ; l = l->next) { sprintf(buf, "
  • %s
    \n",l->str, l->str); p = strsav(p, buf); diff --git a/jcc.c b/jcc.c index b3509e46..8491c84a 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.37 2001/09/10 11:12:24 oes Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.38 2001/09/16 13:01:46 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.37 2001/09/10 11:12:24 oes Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.38 2001/09/16 13:01:46 jongfoster + * Removing redundant function call that zeroed zalloc()'d memory. + * * Revision 1.37 2001/09/10 11:12:24 oes * Deleted unused variable * @@ -581,7 +584,7 @@ static void chat(struct client_state *csp) * vanilla wafer, then send the vanilla wafer. */ if ((csp->config->jarfile != NULL) - && (csp->action->multi[ACTION_MULTI_WAFER]->next == NULL) + && list_is_empty(csp->action->multi[ACTION_MULTI_WAFER]) && ((csp->action->flags & ACTION_VANILLA_WAFER) != 0)) { enlist(csp->action->multi[ACTION_MULTI_WAFER], VANILLA_WAFER); @@ -622,7 +625,7 @@ static void chat(struct client_state *csp) /* We have a request. */ hdr = sed(client_patterns, add_client_headers, csp); - destroy_list(csp->headers); + list_remove_all(csp->headers); /* * Now, check to see if we need to intercept it, i.e. diff --git a/parsers.c b/parsers.c index f7496175..dfdde1f4 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.23 2001/09/12 18:08:19 steudten Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.24 2001/09/13 23:05:50 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -41,6 +41,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.23 2001/09/12 18:08:19 steudten E * * Revisions : * $Log: parsers.c,v $ + * Revision 1.24 2001/09/13 23:05:50 jongfoster + * Changing the string paramater to the header parsers a "const". + * * Revision 1.23 2001/09/12 18:08:19 steudten * * In parse_http_request() header rewriting miss the host value, so @@ -489,14 +492,14 @@ char *get_header(struct client_state *csp) *********************************************************************/ char *sed(const struct parsers pats[], void (* const more_headers[])(struct client_state *), struct client_state *csp) { - struct list *p; + struct list_entry *p; const struct parsers *v; char *hdr; void (* const *f)(); for (v = pats; v->str ; v++) { - for (p = csp->headers->next; p ; p = p->next) + for (p = csp->headers->first; p ; p = p->next) { /* Header crunch()ed in previous run? -> ignore */ if (p->str == NULL) continue; @@ -506,7 +509,7 @@ char *sed(const struct parsers pats[], void (* const more_headers[])(struct clie if (strncmpic(p->str, v->str, v->len) == 0) { hdr = v->parser(v, p->str, csp); - freez(p->str); + freez((char *)p->str); /* FIXME: Yuck! patching a list...*/ p->str = hdr; } } @@ -1150,11 +1153,11 @@ char *client_accept(const struct parsers *v, const char *s, struct client_state *********************************************************************/ void client_cookie_adder(struct client_state *csp) { - struct list *lst; + struct list_entry *lst; char *tmp = NULL; char *e; - for (lst = csp->cookie_list->next; lst ; lst = lst->next) + for (lst = csp->cookie_list->first; lst ; lst = lst->next) { if (tmp) { @@ -1163,7 +1166,7 @@ void client_cookie_adder(struct client_state *csp) tmp = strsav(tmp, lst->str); } - for (lst = csp->action->multi[ACTION_MULTI_WAFER]->next; lst ; lst = lst->next) + for (lst = csp->action->multi[ACTION_MULTI_WAFER]->first; lst ; lst = lst->next) { if (tmp) { @@ -1206,9 +1209,9 @@ void client_cookie_adder(struct client_state *csp) *********************************************************************/ void client_xtra_adder(struct client_state *csp) { - struct list *lst; + struct list_entry *lst; - for (lst = csp->action->multi[ACTION_MULTI_ADD_HEADER]->next; + for (lst = csp->action->multi[ACTION_MULTI_ADD_HEADER]->first; lst ; lst = lst->next) { log_error(LOG_LEVEL_HEADER, "addh: %s", lst->str);