-const char actions_rcs[] = "$Id: actions.c,v 1.15 2001/10/14 21:58:22 jongfoster Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: actions.c,v $
+ * 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:
* - Exported get_actions()
#define AV_REM_MULTI 4 /* -multiopt{string} -multiopt{*} */
/*
- * We need a structure to hold the name, flag changes,
+ * We need a structure to hold the name, flag changes,
* type, and string index.
*/
struct action_name
* Returns : JB_ERR_OK or JB_ERR_MEMORY
*
*********************************************************************/
-jb_err merge_actions (struct action_spec *dest,
+jb_err merge_actions (struct action_spec *dest,
const struct action_spec *src)
{
int i;
* Returns : N/A
*
*********************************************************************/
-jb_err copy_action (struct action_spec *dest,
+jb_err copy_action (struct action_spec *dest,
const struct action_spec *src)
{
int i;
- jb_err err;
+ jb_err err = JB_ERR_OK;
memset(dest, '\0', sizeof(*dest));
return err;
}
}
+ return err;
}
* we found an action.
* 2 : name = [out] Start of action name, null
* terminated. NULL on EOL
- * 3 : value = [out] Start of action value, null
+ * 3 : value = [out] Start of action value, null
* terminated. NULL if none or EOL.
*
* Returns : JB_ERR_OK => Ok
*name = str;
/* parse option */
- while (((ch = *str) != '\0') &&
+ while (((ch = *str) != '\0') &&
(ch != ' ') && (ch != '\t') && (ch != '{'))
{
if (ch == '}')
if (option)
{
/* handle option in 'option' */
-
+
/* Check for standard action name */
const struct action_name * action = action_names;
{
/* try user aliases. */
const struct action_alias * alias = alias_list;
-
+
while ( (alias != NULL) && (0 != strcmpic(alias->name, option)) )
{
alias = alias->next;
* 1 : dest = Current actions, to modify.
* 2 : src = Action to add.
*
- * Returns : N/A
+ * Returns 0 : no error
+ * !=0 : error
*
*********************************************************************/
-jb_err merge_current_action (struct current_action_spec *dest,
+jb_err merge_current_action (struct current_action_spec *dest,
const struct action_spec *src)
{
int i;
- jb_err err;
+ jb_err err = JB_ERR_OK;
dest->flags &= src->mask;
dest->flags |= src->add;
}
}
}
+ return err;
}
{
struct action_alias * next = alias_list->next;
alias_list->next = NULL;
- freez((char *)alias_list->name);
+ freez(alias_list->name);
free_action(alias_list->action);
free(alias_list);
alias_list = next;
{
/* too short */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* too short */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: {{ }}",
csp->config->actions_file);
return 1; /* never get here */
* appear once.
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ 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);
}
/* {{description}} is a singleton and only {{settings}} may proceed it
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ 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);
}
* completely rewriting the file becomes non-trivial)
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ 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);
}
{
/* invalid {{something}} block */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: {{%s}}",
csp->config->actions_file, start);
return 1; /* never get here */
if (cur_action == NULL)
{
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': out of memory",
csp->config->actions_file);
return 1; /* never get here */
{
/* No closing } */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* error */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
if ((start == NULL) || (start == buf))
{
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
}
if (*start == '\0')
{
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* error */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s = %s",
csp->config->actions_file, buf, start);
return 1; /* never get here */
}
-
+
/* add to list */
new_alias->next = alias_list;
alias_list = new_alias;
if (create_url_spec(perm->url, buf))
{
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': cannot create URL pattern from: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* oops - please have a {} line as 1st line in file. */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': first line is invalid: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* How did we get here? This is impossible! */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': INTERNAL ERROR - mode = %d",
csp->config->actions_file, mode);
return 1; /* never get here */
}
fclose(fp);
-
+
free_action(cur_action);
free_alias_list(alias_list);