1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** reading options.conf and filling structure **
10 \*****************************************************************************/
18 #include "extension.h"
21 struct options options = {
22 "/usr/local/lcr/log", /* log file */
23 0x0000, /* debug mode */
25 "0", /* national prefix */
26 "00", /* international prefix */
27 "tones_american", /* directory of tones */
28 "", /* directories of tones to fetch */
29 "", /* dummy caller id */
30 0, /* by default use priority 0 */
31 "lcr@your.machine", /* source mail adress */
32 "/var/tmp", /* path of lock files */
33 0700, /* rights of lcr admin socket */
37 char options_error[256];
41 * read options from options.conf
43 int read_options(void)
53 SPRINT(filename, "%s/options.conf", CONFIG_DATA);
55 if (!(fp=fopen(filename,"r"))) {
56 SPRINT(options_error, "Cannot open %s\n",filename);
61 while((fgets(buffer,sizeof(buffer),fp))) {
63 buffer[sizeof(buffer)-1]=0;
64 if (buffer[0]) buffer[strlen(buffer)-1]=0;
67 while(*p <= 32) { /* skip spaces */
72 if (*p==0 || *p=='#') /* ignore comments and empty line */
76 i=0; /* read option */
78 if (i+1 >= sizeof(option)) {
79 SPRINT(options_error, "Error in %s (line %d): option too long.\n",filename,line);
86 while(*p <= 32) { /* skip spaces */
93 if (*p!=0 && *p!='#') { /* param */
96 if (i+1 >= sizeof(param)) {
97 SPRINT(options_error, "Error in %s (line %d): param too long.\n",filename,line);
105 /* at this point we have option and param */
108 if (!strcmp(option,"nt_if") || !strcmp(option,"te_if")) {
109 SPRINT(options_error, "Error in %s (line %d): obsolete option %s. Use multiple 'port' options to define ports to use.\n",filename,line,option);
112 if (!strcmp(option,"debug")) {
114 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
117 options.deb = strtol(param, NULL, 0);
120 if (!strcmp(option,"log")) {
122 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
125 SCPY(options.log, param);
128 if (!strcmp(option,"alaw")) {
132 if (!strcmp(option,"ulaw")) {
136 if (!strcmp(option,"tones_dir")) {
138 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
141 if (param[strlen(param)-1] == '/')
142 param[strlen(param)-1]=0;
143 SCPY(options.tones_dir, param);
146 if (!strcmp(option,"fetch_tones")) {
148 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
151 if (param[strlen(param)-1] == '/')
152 param[strlen(param)-1]=0;
153 SCPY(options.fetch_tones, param);
156 if (!strcmp(option,"extensions_dir")) {
159 if (!strcmp(option,"national")) {
160 SCPY(options.national, param);
163 if (!strcmp(option,"international")) {
164 SCPY(options.international, param);
167 if (!strcmp(option,"dummyid")) {
168 SCPY(options.dummyid, param);
171 if (!strcmp(option,"dsptones")) {
172 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);
175 if (!strcmp(option,"schedule")) {
176 options.schedule = atoi(param);
177 if (options.schedule < 0) {
178 SPRINT(options_error, "Error in %s (line %d): parameter for option %s must be at least '0'.\n", filename,line,option);
181 if (options.schedule > 99) {
182 SPRINT(options_error, "Error in %s (line %d): parameter for option %s must be '99' or less.\n", filename,line,option);
187 if (!strcmp(option,"email")) {
189 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n", filename,line,option);
192 SCPY(options.email, param);
195 if (!strcmp(option,"lock")) {
197 SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
200 if (param[strlen(param)-1] == '/')
201 param[strlen(param)-1]=0;
202 SCPY(options.lock, param);
205 if (!strcmp(option,"socketrights")) {
206 options.socketrights = strtol(param, NULL, 0);
208 if (!strcmp(option,"gsm")) {
211 SPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
216 if (!options.tones_dir[0]) {
217 SPRINT(options_error, "Error in %s (line %d): option 'tones_dir' with parameter missing.\n", filename);