of the core configuration.
- debug level is switched to the new config variable type. From now,
it is changeble runtime.
#include "tcp_options.h"
#include "config.h"
+#include "cfg_core.h"
#ifdef CORE_TLS
#include "tls/tls_config.h"
#endif
}
;
assign_stm:
- DEBUG_V EQUAL NUMBER { debug=$3; }
+ DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
| DEBUG_V EQUAL error { yyerror("number expected"); }
| FORK EQUAL NUMBER { dont_fork= ! $3; }
| FORK EQUAL error { yyerror("boolean value expected"); }
--- /dev/null
+/*
+ * $Id$
+ *
+ * Copyright (C) 2007 iptelorg GmbH
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser 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 your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ * info@iptel.org
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * History
+ * -------
+ * 2007-12-03 Initial version (Miklos)
+ */
+
+#include "dprint.h"
+#include "cfg/cfg.h"
+#include "cfg_core.h"
+
+struct cfg_group_core default_core_cfg = {
+ L_DEFAULT /* print only msg. < L_WARN */
+};
+
+void *core_cfg = &default_core_cfg;
+
+cfg_def_t core_cfg_def[] = {
+ {"debug", CFG_VAR_INT, 0, 0, 0, 0, "debug level"},
+ {0, 0, 0, 0, 0, 0}
+};
--- /dev/null
+/*
+ * $Id$
+ *
+ * Copyright (C) 2007 iptelorg GmbH
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser 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 your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ * info@iptel.org
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * HOWTO:
+ * If you need a new configuration variable within the core, put it into
+ * struct cfg_goup_core, and define it in cfg_core.c:core_cfg_def array.
+ * The default value of the variable must be inserted into
+ * cfg_core.c:default_core_cfg
+ * Include this header file in your source code, and retrieve the
+ * value with cfg_get(core, core_cfg, variable_name).
+ *
+ * History
+ * -------
+ * 2007-12-03 Initial version (Miklos)
+ */
+
+#ifndef _CFG_CORE_H
+#define _CFG_CORE_H
+
+#include "cfg/cfg.h"
+
+extern void *core_cfg;
+
+struct cfg_group_core {
+ int debug;
+};
+
+extern struct cfg_group_core default_core_cfg;
+extern cfg_def_t core_cfg_def[];
+
+#endif /* _CFG_CORE_H */
#define dprint_h
#include <syslog.h>
+#include "cfg_core.h"
#define L_ALERT -3
/* vars:*/
-extern int debug;
extern int log_stderr;
extern int log_facility;
extern volatile int dprint_crit; /* protection against "simultaneous"
#ifdef __SUNPRO_C
#define DPrint( ...) \
do{ \
- if ((debug>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
+ if ((cfg_get(core, core_cfg, debug)>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
DPRINT_CRIT_ENTER; \
if (log_stderr){ \
dprint (__VA_ARGS__); \
#else
#define DPrint(fmt,args...) \
do{ \
- if ((debug>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
+ if ((cfg_get(core, core_cfg, debug)>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
DPRINT_CRIT_ENTER; \
if (log_stderr){ \
dprint (fmt, ## args); \
#ifdef __SUNPRO_C
#define LOG(lev, ...) \
do { \
- if ((debug>=(lev)) && DPRINT_NON_CRIT){ \
+ if ((cfg_get(core, core_cfg, debug)>=(lev)) && DPRINT_NON_CRIT){ \
DPRINT_CRIT_ENTER; \
if (log_stderr) dprint (__VA_ARGS__); \
else { \
#else
#define LOG(lev, fmt, args...) \
do { \
- if ((debug>=(lev)) && DPRINT_NON_CRIT){ \
+ if ((cfg_get(core, core_cfg, debug)>=(lev)) && DPRINT_NON_CRIT){ \
DPRINT_CRIT_ENTER; \
if (log_stderr) dprint (fmt, ## args); \
else { \
#include "rand/fastrand.h" /* seed */
#include "stats.h"
+#include "cfg/cfg.h"
#include "cfg/cfg_struct.h"
+#include "cfg_core.h"
#ifdef DEBUG_DMALLOC
#include <dmalloc.h>
int process_no = 0; /* index of process in the pt */
int sig_flag = 0; /* last signal received */
-int debug = L_DEFAULT; /* print only msg. < L_WARN */
int dont_fork = 0;
int dont_daemonize = 0;
int log_stderr = 0;
break;
case 'd':
debug_flag = 1;
- debug++;
+ default_core_cfg.debug++;
break;
case 'V':
printf("version: %s\n", version);
init_named_flags();
yyin=cfg_stream;
- debug_save = debug;
+ debug_save = default_core_cfg.debug;
if ((yyparse()!=0)||(cfg_errors)){
fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);
goto error;
if (cfg_warnings){
fprintf(stderr, "%d config warnings\n", cfg_warnings);
}
- if (debug_flag) debug = debug_save;
+ if (debug_flag) default_core_cfg.debug = debug_save;
print_rls();
/* options with higher priority than cfg file */
LOG(L_CRIT, "could not initialize configuration framework\n");
goto error;
}
+ /* declare the core cfg before the module configs */
+ if (cfg_declare("core", core_cfg_def, &default_core_cfg, cfg_size(core),
+ &core_cfg)
+ ) {
+ LOG(L_CRIT, "could not declare the core configuration\n");
+ goto error;
+ }
if (init_modules() != 0) {
fprintf(stderr, "ERROR: error while initializing modules\n");