-const char actions_rcs[] = "$Id: actions.c,v 1.25 2002/03/24 13:25:43 swa Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.26 2002/03/26 22:29:54 swa Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
*
* Revisions :
* $Log: actions.c,v $
+ * Revision 1.26 2002/03/26 22:29:54 swa
+ * we have a new homepage!
+ *
* Revision 1.25 2002/03/24 13:25:43 swa
* name change related issues
*
};
+static int load_one_actions_file(struct client_state *csp, int fileid);
+
+
/*********************************************************************
*
* Function : merge_actions
*
* Description : Copy an action_specs.
* Similar to "cur_action = new_action".
- * Note that dest better not contain valid data
- * - it's overwritten, not freed.
*
* Parameters :
* 1 : dest = Destination of copy.
int i;
jb_err err = JB_ERR_OK;
+ free_action(dest);
memset(dest, '\0', sizeof(*dest));
dest->mask = src->mask;
}
-static struct file_list *current_actions_file = NULL;
+static struct file_list *current_actions_file[MAX_ACTION_FILES] = {
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL
+};
#ifdef FEATURE_GRACEFUL_TERMINATION
*
* Function : load_actions_file
*
- * Description : Read and parse a action file and add to files
+ * Description : Read and parse all the action files and add to files
* list.
*
* Parameters :
*
*********************************************************************/
int load_actions_file(struct client_state *csp)
+{
+ int i;
+ int result;
+
+ for (i = 0; i < MAX_ACTION_FILES; i++)
+ {
+ if (csp->config->actions_file[i])
+ {
+ result = load_one_actions_file(csp, i);
+ if (result)
+ {
+ return result;
+ }
+ }
+ else if (current_actions_file[i])
+ {
+ current_actions_file[i]->unloader = unload_actions_file;
+ current_actions_file[i] = NULL;
+ }
+ }
+
+ return 0;
+}
+
+/*********************************************************************
+ *
+ * Function : load_one_actions_file
+ *
+ * Description : Read and parse a action file and add to files
+ * list.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : fileid = File index to load.
+ *
+ * Returns : 0 => Ok, everything else is an error.
+ *
+ *********************************************************************/
+static int load_one_actions_file(struct client_state *csp, int fileid)
{
/*
struct action_alias * alias_list = NULL;
unsigned long linenum = 0;
- if (!check_file_changed(current_actions_file, csp->config->actions_file, &fs))
+ if (!check_file_changed(current_actions_file[fileid], csp->config->actions_file[fileid], &fs))
{
/* No need to load */
- if (csp)
- {
- csp->actions_list = current_actions_file;
- }
+ csp->actions_list[fileid] = current_actions_file[fileid];
return 0;
}
if (!fs)
{
log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': error finding file: %E",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
if (last_perm == NULL)
{
log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': out of memory!",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
- if ((fp = fopen(csp->config->actions_file, "r")) == NULL)
+ if ((fp = fopen(csp->config->actions_file[fileid], "r")) == NULL)
{
log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': error opening file: %E",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line (%lu): %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line (%lu): {{ }}",
- csp->config->actions_file, linenum);
+ csp->config->actions_file[fileid], linenum);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"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);
+ csp->config->actions_file[fileid], linenum);
}
mode = MODE_SETTINGS;
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"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);
+ csp->config->actions_file[fileid], linenum);
}
mode = MODE_DESCRIPTION;
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"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);
+ csp->config->actions_file[fileid], linenum);
}
mode = MODE_ALIAS;
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line (%lu): {{%s}}",
- csp->config->actions_file, linenum, start);
+ csp->config->actions_file[fileid], linenum, start);
return 1; /* never get here */
}
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': out of memory",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
init_action(cur_action);
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line (%lu): %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
*end = '\0';
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line (%lu): %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
}
{
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line (%lu): %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': out of memory!",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
{
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line (%lu): %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line (%lu): %s = %s",
- csp->config->actions_file, linenum, buf, start);
+ csp->config->actions_file[fileid], linenum, buf, start);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': out of memory!",
- csp->config->actions_file);
+ csp->config->actions_file[fileid]);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': line %lu: cannot create URL pattern from: %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': first needed line (%lu) is invalid: %s",
- csp->config->actions_file, linenum, buf);
+ csp->config->actions_file[fileid], linenum, buf);
return 1; /* never get here */
}
else
fclose(fp);
log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': INTERNAL ERROR - mode = %d",
- csp->config->actions_file, mode);
+ csp->config->actions_file[fileid], mode);
return 1; /* never get here */
}
}
free_alias_list(alias_list);
/* the old one is now obsolete */
- if (current_actions_file)
+ if (current_actions_file[fileid])
{
- current_actions_file->unloader = unload_actions_file;
+ current_actions_file[fileid]->unloader = unload_actions_file;
}
fs->next = files->next;
files->next = fs;
- current_actions_file = fs;
+ current_actions_file[fileid] = fs;
- if (csp)
- {
- csp->actions_list = fs;
- }
+ csp->actions_list[fileid] = fs;
return(0);