1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** reading options.conf and filling structure **
10 \*****************************************************************************/
17 * read options from options.conf
19 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error)
31 SCPY(gsm_conf->debug, "");
32 SCPY(gsm_conf->hlr, "hlr.sqlite3");
33 SCPY(gsm_conf->openbsc_cfg, "openbsc.cfg");
34 gsm_conf->reject_cause = 0;
35 gsm_conf->keep_l2 = 0;
37 SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
39 if (!(fp=fopen(filename,"r"))) {
40 UPRINT(conf_error, "Cannot open %s\n",filename);
45 while((GETLINE(buffer, fp))) {
49 while(*p <= 32) { /* skip spaces */
54 if (*p==0 || *p=='#') /* ignore comments and empty line */
58 i=0; /* read option */
60 if (i+1 >= sizeof(option)) {
61 UPRINT(conf_error, "Error in %s (line %d): option too long.\n",filename,line);
68 while(*p <= 32) { /* skip spaces */
76 while(*p!=0 && *p!='#' && pnum < 10) { /* param */
79 if (i+1 >= sizeof(params[pnum])) {
80 UPRINT(conf_error, "Error in %s (line %d): param too long.\n",filename,line);
83 params[pnum][i+1] = '\0';
84 params[pnum][i++] = *p++;
86 while(*p <= 32) { /* skip spaces */
95 /* at this point we have option and param */
98 if (!strcmp(option,"debug")) {
99 if (params[0][0]==0) {
100 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
103 SCPY(gsm_conf->debug, params[0]);
106 if (!strcmp(option,"config")) {
107 if (params[0][0]==0) {
108 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
111 SCPY(gsm_conf->openbsc_cfg, params[0]);
114 if (!strcmp(option,"hlr")) {
115 if (params[0][0]==0) {
116 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
119 SCPY(gsm_conf->hlr, params[0]);
122 if (!strcmp(option,"reject-cause")) {
123 UPRINT(conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
126 if (!strcmp(option,"allow-all")) {
127 gsm_conf->allow_all = 1;
129 if (!strcmp(option,"keep-l2")) {
130 gsm_conf->keep_l2 = 1;
133 if (!strcmp(option,"pcapfile")) {
134 if (params[0][0]==0) {
135 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
138 SCPY(gsm_conf->pcapfile, params[0]);
140 UPRINT(conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);