1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** reading options.conf and filling structure **
10 \*****************************************************************************/
15 char *gsm_conf_error = (char *)"";
19 * read options from options.conf
21 int gsm_conf(struct gsm_conf *gsm_conf)
33 SCPY(gsm_conf->debug, "");
34 SCPY(gsm_conf->interface_bsc, "mISDN_l1loop.1");
35 SCPY(gsm_conf->interface_lcr, "mISDN_l1loop.2");
36 SCPY(gsm_conf->hlr, "hlr.sqlite3");
37 SCPY(gsm_conf->openbsc_cfg, "openbsc.cfg");
38 gsm_conf->reject_cause = 0;
39 gsm_conf->keep_l2 = 0;
40 gsm_conf->noemergshut = 0;
42 SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
44 if (!(fp=fopen(filename,"r"))) {
45 SPRINT(gsm_conf_error, "Cannot open %s\n",filename);
50 while((GETLINE(buffer, fp))) {
54 while(*p <= 32) { /* skip spaces */
59 if (*p==0 || *p=='#') /* ignore comments and empty line */
63 i=0; /* read option */
65 if (i+1 >= sizeof(option)) {
66 SPRINT(gsm_conf_error, "Error in %s (line %d): option too long.\n",filename,line);
73 while(*p <= 32) { /* skip spaces */
81 while(*p!=0 && *p!='#' && pnum < 10) { /* param */
84 if (i+1 >= sizeof(params[pnum])) {
85 SPRINT(gsm_conf_error, "Error in %s (line %d): param too long.\n",filename,line);
88 params[pnum][i+1] = '\0';
89 params[pnum][i++] = *p++;
91 while(*p <= 32) { /* skip spaces */
100 /* at this point we have option and param */
103 if (!strcmp(option,"debug")) {
104 if (params[0][0]==0) {
105 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
108 SCPY(gsm_conf->debug, params[0]);
111 if (!strcmp(option,"interface-bsc")) {
112 if (params[0][0]==0) {
113 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
116 SCPY(gsm_conf->interface_bsc, params[0]);
119 if (!strcmp(option,"interface-lcr")) {
120 if (params[0][0]==0) {
121 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
124 SCPY(gsm_conf->interface_lcr, params[0]);
127 if (!strcmp(option,"config")) {
128 if (params[0][0]==0) {
129 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
132 SCPY(gsm_conf->openbsc_cfg, params[0]);
135 if (!strcmp(option,"hlr")) {
136 if (params[0][0]==0) {
137 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
140 SCPY(gsm_conf->hlr, params[0]);
143 if (!strcmp(option,"reject-cause")) {
144 SPRINT(gsm_conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
147 if (!strcmp(option,"allow-all")) {
148 gsm_conf->allow_all = 1;
150 if (!strcmp(option,"keep-l2")) {
151 gsm_conf->keep_l2 = 1;
154 if (!strcmp(option,"no-mergency-shutdown")) {
155 gsm_conf->noemergshut = 1;
157 if (!strcmp(option,"pcapfile")) {
158 if (params[0][0]==0) {
159 SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
162 SCPY(gsm_conf->pcapfile, params[0]);
164 SPRINT(gsm_conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);