Commit e777f069 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(assign_path): New define for assign_string.

(unassign_path): New define for unassign_string.
(parameters): Use assign_path and unassign_path for all path
	parameters, to make them easier to find.  Use default values
	from paths.h instead of hardcoding the defaults in the file.
	A lot of values have changed; see the summary in the NEWS
	file.
(CONFIG_FILE): Removed.  This is now a define in paths.h.
(compiled_config_file): New constant.
(get_default_config_file_name): Use compiled_config_file instead
	of CONFIG_FILE.
(free_default_config_file_name): Ditto.
parent 5e137656
/*
* $Id: server-config.c,v 0.95 2003/08/15 19:46:09 ceder Exp $
* $Id: server-config.c,v 0.96 2003/08/16 10:51:55 ceder Exp $
* Copyright (C) 1991-1999, 2001-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -27,8 +27,6 @@
*
* This is in a .c file to make it possible to change a value without having
* to recompile the entire server (or, in fact, anything!)
*
* Compile with -DDEFAULT_PREFIX='"/usr/lyskom"' or something similar.
*/
......@@ -68,6 +66,7 @@
#ifdef DEBUG_CALLS
# include "services.h"
#endif
#include "paths.h"
struct kom_par param;
......@@ -75,6 +74,11 @@ static Success log_param(const char *val, const struct parameter *par);
static Success jubel(const char *val, const struct parameter *par);
static Success ident_param(const char *val, const struct parameter *par);
/* Paths are a special kind of strings. For now, just use these
defines to make it easier to spot paths in the table below. */
#define assign_path assign_string
#define unassign_path unassign_string
/* See lyskomd.texi for more info about the parameters.
Please remember to update lyskomd.texi if you add more parameters!
Try to keep this list and the list in lyskomd.texi in the same order. */
......@@ -89,7 +93,7 @@ static const struct parameter parameters[] = {
assign_bool, NULL, 0, 1, "no", &param.force_iso_8859_1,
NULL},
{"Prefix",
assign_string, unassign_string, 0, 1, DEFAULT_PREFIX,
assign_path, unassign_path, 0, 1, DEFAULT_PREFIX,
&param.dbase_dir,
NULL},
{"Send async",
......@@ -125,7 +129,7 @@ static const struct parameter parameters[] = {
NULL},
#ifdef LOGACCESSES
{"Log accesses",
assign_string, unassign_string, 0, 1, NULL,
assign_path, unassign_path, 0, 1, NULL,
&param.logaccess_file,
NULL},
#endif
......@@ -133,90 +137,90 @@ static const struct parameter parameters[] = {
/* The database files. */
{"Data file",
assign_string, unassign_string, 0, 1, "db/lyskomd-data",
assign_path, unassign_path, 0, 1, DATA_FILE,
&param.datafile_name,
NULL},
{"Backup file",
assign_string, unassign_string, 0, 1, "db/lyskomd-backup",
assign_path, unassign_path, 0, 1, BACKUP_FILE,
&param.backupfile_name,
NULL},
{"Backup file 2",
assign_string, unassign_string, 0, 1, "db/lyskomd-backup-prev",
assign_path, unassign_path, 0, 1, PREV_BACKUP_FILE,
&param.backupfile_name_2,
NULL},
{"Lock file",
assign_string, unassign_string, 0, 1, "db/lyskomd-lock",
assign_path, unassign_path, 0, 1, LOCK_FILE,
&param.lockfile_name,
NULL},
{"Text file",
assign_string, unassign_string, 0, 1, "db/lyskomd-texts",
assign_path, unassign_path, 0, 1, TEXT_FILE,
&param.textfile_name,
NULL},
{"Number file",
assign_string, unassign_string, 0, 1, "db/number.txt",
assign_path, unassign_path, 0, 1, NUMBER_FILE,
&param.numberfile_name,
NULL},
{"Number temp file",
assign_string, unassign_string, 0, 1, "db/number.tmp",
assign_path, unassign_path, 0, 1, NUMBER_FILE_TMP,
&param.numberfile_tmp_name,
NULL},
{"Text backup file",
assign_string, unassign_string, 0, 1, "db/lyskomd-texts-backup",
assign_path, unassign_path, 0, 1, TEXT_BACKUP_FILE,
&param.textbackupfile_name,
NULL},
{"Backup export directory",
assign_string, unassign_string, 0, 1, "exportdb",
assign_path, unassign_path, 0, 1, EXPORT_DIR,
&param.backup_dir,
NULL},
/* Various log files */
{"Log file",
assign_string, unassign_string, 0, 1, "etc/server-log",
assign_path, unassign_path, 0, 1, LYSKOMD_LOG,
&param.logfile_name,
NULL},
{"Log statistics",
assign_string, unassign_string, 0, 1, "etc/lyskomd-log",
assign_path, unassign_path, 0, 1, LYSKOMD_STATS,
&param.statistic_name,
NULL},
{"Pid file",
assign_string, unassign_string, 0, 1, "etc/pid",
assign_path, unassign_path, 0, 1, LYSKOMD_PID,
&param.pid_name,
NULL},
{"Memory usage file",
assign_string, unassign_string, 0, 1, "etc/memory-usage",
assign_path, unassign_path, 0, 1, MEMORY_USAGE,
&param.memuse_name,
NULL},
/* Other files. */
{"Aux-item definition file",
assign_string, unassign_string, 0, 1, "etc/aux-items.conf",
assign_path, unassign_path, 0, 1, AUX_FILE,
&param.aux_def_file,
NULL},
{"Status file",
assign_string, unassign_string, 0, 1, "etc/status",
assign_path, unassign_path, 0, 1, STATUS_FILE,
&param.status_file,
NULL},
{"Connection status file",
assign_string, unassign_string, 0, 1, "etc/connections.txt",
assign_path, unassign_path, 0, 1, CONNECTIONS_FILE,
&param.connection_status_file,
NULL},
{"Connection status temp file",
assign_string, unassign_string, 0, 1, "etc/connections.tmp",
assign_path, unassign_path, 0, 1, CONNECTIONS_TMP,
&param.connection_status_file_tmp,
NULL},
/* Where to dump core. */
{"Core directory",
assign_string, unassign_string, 0, 1, "cores",
assign_path, unassign_path, 0, 1, CORE_DIR,
&param.core_dir,
NULL},
{"Nologin file",
assign_string, unassign_string, 0, 1, "/etc/nologin",
assign_path, unassign_path, 0, 1, "/etc/nologin",
&param.nologin_file,
NULL},
......@@ -517,11 +521,11 @@ static const struct parameter parameters[] = {
&param.downtime_mail_end,
NULL},
{"lyskomd path",
assign_string, unassign_string, 0, 1, "bin/lyskomd",
assign_path, unassign_path, 0, 1, LYSKOMD_PATH,
&param.lyskomd_path,
NULL},
{"savecore path",
assign_string, unassign_string, 0, 1, "bin/savecore",
assign_path, unassign_path, 0, 1, SAVECORE_PATH,
&param.savecore_path,
NULL},
......@@ -529,10 +533,9 @@ static const struct parameter parameters[] = {
{NULL, NULL, NULL, 0, 0, NULL, NULL, NULL}};
/* Where to save things. These are used by lyskomd and dbck. */
static const char *CONFIG_FILE = "etc/config";
/* Where to save things. */
static const char compiled_config_file[] = CONFIG_FILE;
static const char *default_config = NULL;
const char *
......@@ -540,13 +543,13 @@ get_default_config_file_name(void)
{
if (default_config == NULL)
{
if (CONFIG_FILE[0] == '/')
default_config = CONFIG_FILE;
if (compiled_config_file[0] == '/')
default_config = compiled_config_file;
else
{
char *cfg = smalloc(strlen(DEFAULT_PREFIX)
+ strlen(CONFIG_FILE) + 2);
sprintf(cfg, "%s/%s", DEFAULT_PREFIX, CONFIG_FILE);
+ strlen(compiled_config_file) + 2);
sprintf(cfg, "%s/%s", DEFAULT_PREFIX, compiled_config_file);
default_config = cfg;
}
}
......@@ -557,7 +560,7 @@ get_default_config_file_name(void)
void
free_default_config_file_name(void)
{
if (default_config != NULL && default_config != CONFIG_FILE)
if (default_config != NULL && default_config != compiled_config_file)
{
/* cast away const; this string was allocated by
get_default_config_file_name(). */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment