-const char actions_rcs[] = "$Id: actions.c,v 1.92 2013/12/24 13:35:23 fabiankeil Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.95 2016/01/16 12:33:35 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
*
* Purpose : Declares functions to work with actions files
*
- * Copyright : Written by and Copyright (C) 2001-2011 the
+ * Copyright : Written by and Copyright (C) 2001-2016 the
* Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
return 1; /* never get here */
}
- fs->f = last_perm = (struct url_actions *)zalloc(sizeof(*last_perm));
- if (last_perm == NULL)
- {
- log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': out of memory!",
- csp->config->actions_file[fileid]);
- return 1; /* never get here */
- }
+ fs->f = last_perm = zalloc_or_die(sizeof(*last_perm));
if ((fp = fopen(csp->config->actions_file[fileid], "r")) == NULL)
{
cur_action = NULL;
}
cur_action_used = 0;
- cur_action = (struct action_spec *)zalloc(sizeof(*cur_action));
- if (cur_action == NULL)
- {
- fclose(fp);
- log_error(LOG_LEVEL_FATAL,
- "can't load actions file '%s': out of memory",
- csp->config->actions_file[fileid]);
- return 1; /* never get here */
- }
+ cur_action = zalloc_or_die(sizeof(*cur_action));
init_action(cur_action);
/*
*
* buf + 1 to skip the leading '{'
*/
- actions_buf = strdup_or_die(buf + 1);
+ actions_buf = end = strdup_or_die(buf + 1);
/* check we have a trailing } and then trim it */
- end = actions_buf + strlen(actions_buf) - 1;
+ if (strlen(actions_buf))
+ {
+ end += strlen(actions_buf) - 1;
+ }
if (*end != '}')
{
/* No closing } */
return 1; /* never get here */
}
- if ((new_alias = zalloc(sizeof(*new_alias))) == NULL)
- {
- fclose(fp);
- log_error(LOG_LEVEL_FATAL,
- "can't load actions file '%s': out of memory!",
- csp->config->actions_file[fileid]);
- return 1; /* never get here */
- }
+ new_alias = zalloc_or_die(sizeof(*new_alias));
/* Eat any the whitespace before the '=' */
end--;
/* it's an URL pattern */
/* allocate a new node */
- if ((perm = zalloc(sizeof(*perm))) == NULL)
- {
- fclose(fp);
- log_error(LOG_LEVEL_FATAL,
- "can't load actions file '%s': out of memory!",
- csp->config->actions_file[fileid]);
- return 1; /* never get here */
- }
+ perm = zalloc_or_die(sizeof(*perm));
perm->action = cur_action;
cur_action_used = 1;