summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorAndreas Eversberg2009-05-14 20:31:43 +0200
committerAndreas Eversberg2009-05-14 20:31:43 +0200
commit6db34c1dca5c3a2acd0af689319b583ff8271dbc (patch)
treecae92dc36046b477b9ecfa6122a7049b7c68ca01 /options.c
parentAdded GSM network support. (diff)
downloadlcr-6db34c1dca5c3a2acd0af689319b583ff8271dbc.tar.gz
lcr-6db34c1dca5c3a2acd0af689319b583ff8271dbc.tar.xz
lcr-6db34c1dca5c3a2acd0af689319b583ff8271dbc.zip
Restructured tones_dir, added tones_dir to interface.conf
Code cleanup.. modified: README modified: apppbx.cpp modified: default/interface.conf modified: default/options.conf modified: dss1.cpp modified: extension.c modified: gsm.cpp modified: interface.c modified: interface.h modified: mISDN.cpp modified: options.c modified: options.h modified: port.cpp
Diffstat (limited to 'options.c')
-rw-r--r--options.c131
1 files changed, 38 insertions, 93 deletions
diff --git a/options.c b/options.c
index b76059e..6f74533 100644
--- a/options.c
+++ b/options.c
@@ -27,7 +27,6 @@ struct options options = {
"tones_american", /* directory of tones */
"", /* directories of tones to fetch */
"", /* dummy caller id */
- 0, /* use tones by dsp.o */
0, /* by default use priority 0 */
"lcr@your.machine", /* source mail adress */
"/var/tmp", /* path of lock files */
@@ -53,22 +52,19 @@ int read_options(void)
SPRINT(filename, "%s/options.conf", CONFIG_DATA);
- if (!(fp=fopen(filename,"r")))
- {
+ if (!(fp=fopen(filename,"r"))) {
SPRINT(options_error, "Cannot open %s\n",filename);
return(0);
}
line=0;
- while((fgets(buffer,sizeof(buffer),fp)))
- {
+ while((fgets(buffer,sizeof(buffer),fp))) {
line++;
buffer[sizeof(buffer)-1]=0;
if (buffer[0]) buffer[strlen(buffer)-1]=0;
p=buffer;
- while(*p <= 32) /* skip spaces */
- {
+ while(*p <= 32) { /* skip spaces */
if (*p == 0)
break;
p++;
@@ -78,10 +74,8 @@ int read_options(void)
option[0]=0;
i=0; /* read option */
- while(*p > 32)
- {
- if (i+1 >= sizeof(option))
- {
+ while(*p > 32) {
+ if (i+1 >= sizeof(option)) {
SPRINT(options_error, "Error in %s (line %d): option too long.\n",filename,line);
goto error;
}
@@ -89,21 +83,17 @@ int read_options(void)
option[i++] = *p++;
}
- while(*p <= 32) /* skip spaces */
- {
+ while(*p <= 32) { /* skip spaces */
if (*p == 0)
break;
p++;
}
param[0]=0;
- if (*p!=0 && *p!='#') /* param */
- {
+ if (*p!=0 && *p!='#') { /* param */
i=0; /* read param */
- while(*p > 31)
- {
- if (i+1 >= sizeof(param))
- {
+ while(*p > 31) {
+ if (i+1 >= sizeof(param)) {
SPRINT(options_error, "Error in %s (line %d): param too long.\n",filename,line);
goto error;
}
@@ -115,45 +105,36 @@ int read_options(void)
/* at this point we have option and param */
/* check option */
- if (!strcmp(option,"nt_if") || !strcmp(option,"te_if"))
- {
+ if (!strcmp(option,"nt_if") || !strcmp(option,"te_if")) {
SPRINT(options_error, "Error in %s (line %d): obsolete option %s. Use multiple 'port' options to define ports to use.\n",filename,line,option);
goto error;
} else
- if (!strcmp(option,"debug"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"debug")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
goto error;
}
options.deb = strtol(param, NULL, 0);
} else
- if (!strcmp(option,"log"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"log")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
goto error;
}
SCPY(options.log, param);
} else
- if (!strcmp(option,"alaw"))
- {
+ if (!strcmp(option,"alaw")) {
options.law = 'a';
} else
- if (!strcmp(option,"ulaw"))
- {
+ if (!strcmp(option,"ulaw")) {
options.law = 'u';
} else
- if (!strcmp(option,"tones_dir"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"tones_dir")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
goto error;
}
@@ -162,10 +143,8 @@ int read_options(void)
SCPY(options.tones_dir, param);
} else
- if (!strcmp(option,"fetch_tones"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"fetch_tones")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
goto error;
}
@@ -174,70 +153,47 @@ int read_options(void)
SCPY(options.fetch_tones, param);
} else
- if (!strcmp(option,"extensions_dir"))
- {
+ if (!strcmp(option,"extensions_dir")) {
// obsolete
} else
- if (!strcmp(option,"national"))
- {
+ if (!strcmp(option,"national")) {
SCPY(options.national, param);
} else
- if (!strcmp(option,"international"))
- {
+ if (!strcmp(option,"international")) {
SCPY(options.international, param);
} else
- if (!strcmp(option,"dummyid"))
- {
+ if (!strcmp(option,"dummyid")) {
SCPY(options.dummyid, param);
} else
- if (!strcmp(option,"dsptones"))
- {
- if (!strcasecmp(param, "american"))
- options.dsptones = DSP_AMERICAN;
- else if (!strcasecmp(param, "german"))
- options.dsptones = DSP_GERMAN;
- else if (!strcasecmp(param, "oldgerman"))
- options.dsptones = DSP_OLDGERMAN;
- else if (!strcasecmp(param, "none"))
- options.dsptones = DSP_NONE;
- else {
- SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
- goto error;
- }
-
+ if (!strcmp(option,"dsptones")) {
+ SPRINT(options_error, "Error in %s (line %d): parameter 'dsptones' is obsolete. Just define the tones (american,german,oldgerman) at 'tones_dir' option.\n",filename,line,option);
+ goto error;
} else
- if (!strcmp(option,"schedule"))
- {
+ if (!strcmp(option,"schedule")) {
options.schedule = atoi(param);
- if (options.schedule < 0)
- {
+ if (options.schedule < 0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s must be at least '0'.\n", filename,line,option);
goto error;
}
- if (options.schedule > 99)
- {
+ if (options.schedule > 99) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s must be '99' or less.\n", filename,line,option);
goto error;
}
} else
- if (!strcmp(option,"email"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"email")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n", filename,line,option);
goto error;
}
SCPY(options.email, param);
} else
- if (!strcmp(option,"lock"))
- {
- if (param[0]==0)
- {
+ if (!strcmp(option,"lock")) {
+ if (param[0]==0) {
SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
goto error;
}
@@ -246,29 +202,18 @@ int read_options(void)
SCPY(options.lock, param);
} else
- if (!strcmp(option,"socketrights"))
- {
+ if (!strcmp(option,"socketrights")) {
options.socketrights = strtol(param, NULL, 0);
} else
- if (!strcmp(option,"gsm"))
- {
+ if (!strcmp(option,"gsm")) {
options.gsm = 1;
- } else
- {
+ } else {
SPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
goto error;
}
}
-#if 0
- if (!options.dsptones)
- {
- SPRINT(options_error, "Error in %s (line %d): option 'dsptones' missing.\n", filename);
- goto error;
- }
-#endif
- if (!options.tones_dir[0])
- {
+ if (!options.tones_dir[0]) {
SPRINT(options_error, "Error in %s (line %d): option 'tones_dir' with parameter missing.\n", filename);
goto error;
}