Fixed output problems of error messages while parsing options.conf / gsm.conf.
authorAndreas Eversberg <jolly@eversberg.eu>
Wed, 17 Mar 2010 07:31:07 +0000 (08:31 +0100)
committerAndreas Eversberg <jolly@eversberg.eu>
Wed, 17 Mar 2010 07:31:07 +0000 (08:31 +0100)
modified:   Makefile.in
modified:   bchannel.c
modified:   chan_lcr.c
modified:   genext.c
modified:   gsm.cpp
modified:   gsm.h
modified:   gsm_conf.c
modified:   lcradmin.c
modified:   main.c
modified:   options.c
modified:   options.h

Makefile.in
bchannel.c
chan_lcr.c
genext.c
gsm.cpp
gsm.h
gsm_conf.c
lcradmin.c
main.c
options.c
options.h

index 6bd502b..099f47c 100644 (file)
@@ -294,15 +294,15 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
            *$$dep*) \
-             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
-             cd $(srcdir) && $(AUTOMAKE) --gnu  \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
+             cd $(srcdir) && $(AUTOMAKE) --foreign  \
                && exit 0; \
              exit 1;; \
          esac; \
        done; \
-       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  Makefile'; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
        cd $(top_srcdir) && \
-         $(AUTOMAKE) --gnu  Makefile
+         $(AUTOMAKE) --foreign  Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
        @case '$?' in \
index f49572b..baa8434 100644 (file)
@@ -23,7 +23,7 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <sys/socket.h>
-#include <mISDNif.h>
+#include <mISDN/mISDNif.h>
 
 #include <mISDN/mISDNcompat.h>
 int __af_isdn = MISDN_AF_ISDN;
index 6a953a2..72bca9f 100644 (file)
@@ -2748,13 +2748,14 @@ static int lcr_config_exec(struct ast_channel *ast, void *data, char **argv)
 int load_module(void)
 {
        u_short i;
+       char options_error[256];
 
        for (i = 0; i < 256; i++) {
                flip_bits[i] = (i>>7) | ((i>>5)&2) | ((i>>3)&4) | ((i>>1)&8)
                             | (i<<7) | ((i&2)<<5) | ((i&4)<<3) | ((i&8)<<1);
        }
 
-       if (read_options() == 0) {
+       if (read_options(options_error) == 0) {
                CERROR(NULL, NULL, "%s", options_error);
 
                #ifdef LCR_FOR_ASTERISK
index 486af09..4d34bbe 100644 (file)
--- a/genext.c
+++ b/genext.c
@@ -52,8 +52,9 @@ int main(int argc, char *argv[])
        struct extension ext;
        char pathname[256];
        FILE *fp;
+       char options_error[256];
 
-       if (!read_options()) {
+       if (!read_options(options_error)) {
                PERROR("%s", options_error);
                return(-1);
        }
diff --git a/gsm.cpp b/gsm.cpp
index b2bdd6b..b378df6 100644 (file)
--- a/gsm.cpp
+++ b/gsm.cpp
@@ -44,12 +44,9 @@ static struct timer_list db_sync_timer;
 
 #include "gsm_audio.h"
 
-#undef AF_ISDN
-#undef PF_ISDN
-extern  int     AF_ISDN;
-#define PF_ISDN AF_ISDN
 }
 
+#include <mISDN/mISDNcompat.h>
 
 struct lcr_gsm *gsm = NULL;
 
@@ -1607,6 +1604,8 @@ int gsm_init(void)
        char hlr[128], cfg[128], filename[128];
         mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
        int pcapfd, rc;
+       char conf_error[128] = "";
+
 
        debug_init();
        tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
@@ -1632,8 +1631,8 @@ int gsm_init(void)
        gsm->gsm_sock = -1;
 
        /* parse options */
-       if (!gsm_conf(&gsm->conf)) {
-               PERROR("%s", gsm_conf_error);
+       if (!gsm_conf(&gsm->conf, conf_error)) {
+               PERROR("%s", conf_error);
                return gsm_exit(-EINVAL);
        }
 
diff --git a/gsm.h b/gsm.h
index 6c09fa8..4959e00 100644 (file)
--- a/gsm.h
+++ b/gsm.h
@@ -76,8 +76,7 @@ class Pgsm : public PmISDN
        int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
 };
 
-extern char *gsm_conf_error;
-int gsm_conf(struct gsm_conf *gsm_conf);
+int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
 int handle_gsm(void);
 int gsm_exit(int rc);
 int gsm_init(void);
index 560d9b3..f5af15a 100644 (file)
 #include "main.h"
 
 
-char *gsm_conf_error = (char *)"";
-
 /* read options
  *
  * read options from options.conf
  */
-int gsm_conf(struct gsm_conf *gsm_conf)
+int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error)
 {
        FILE *fp=NULL;
        char filename[128];
@@ -42,7 +40,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
        SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
 
        if (!(fp=fopen(filename,"r"))) {
-               SPRINT(gsm_conf_error, "Cannot open %s\n",filename);
+               UPRINT(conf_error, "Cannot open %s\n",filename);
                return(0);
        }
 
@@ -63,7 +61,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                i=0; /* read option */
                while(*p > 32) {
                        if (i+1 >= sizeof(option)) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): option too long.\n",filename,line);
+                               UPRINT(conf_error, "Error in %s (line %d): option too long.\n",filename,line);
                                goto error;
                        }
                        option[i+1] = '\0';
@@ -82,7 +80,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                        i=0; /* read param */
                        while(*p > 32) {
                                if (i+1 >= sizeof(params[pnum])) {
-                                       SPRINT(gsm_conf_error, "Error in %s (line %d): param too long.\n",filename,line);
+                                       UPRINT(conf_error, "Error in %s (line %d): param too long.\n",filename,line);
                                        goto error;
                                }
                                params[pnum][i+1] = '\0';
@@ -102,7 +100,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                /* check option */
                if (!strcmp(option,"debug")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
                                goto error;
                        }
                        SCPY(gsm_conf->debug, params[0]);
@@ -110,7 +108,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                } else
                if (!strcmp(option,"interface-bsc")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(gsm_conf->interface_bsc, params[0]);
@@ -118,7 +116,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                } else
                if (!strcmp(option,"interface-lcr")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(gsm_conf->interface_lcr, params[0]);
@@ -126,7 +124,7 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                } else
                if (!strcmp(option,"config")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(gsm_conf->openbsc_cfg, params[0]);
@@ -134,14 +132,14 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                } else
                if (!strcmp(option,"hlr")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(gsm_conf->hlr, params[0]);
 
                } else
                if (!strcmp(option,"reject-cause")) {
-                       SPRINT(gsm_conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
+                       UPRINT(conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
                        goto error;
                } else
                if (!strcmp(option,"allow-all")) {
@@ -156,12 +154,12 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                } else
                if (!strcmp(option,"pcapfile")) {
                        if (params[0][0]==0) {
-                               SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
+                               UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(gsm_conf->pcapfile, params[0]);
                } else {
-                       SPRINT(gsm_conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
+                       UPRINT(conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
                        goto error;
                }
        }
index 0b6d627..c7691ee 100644 (file)
@@ -1680,7 +1680,7 @@ int main(int argc, char *argv[])
        int sock, conn;
        struct sockaddr_un sock_address;
        const char *ret = "invalid mode";
-
+       char options_error[256];
 
        /* show options */
        if (argc <= 1) {
@@ -1756,7 +1756,7 @@ int main(int argc, char *argv[])
                goto usage;
        }
 
-       if (read_options() == 0) {
+       if (read_options(options_error) == 0) {
                exit(EXIT_FAILURE);
        }
 
diff --git a/main.c b/main.c
index b425abe..9d7f834 100644 (file)
--- a/main.c
+++ b/main.c
@@ -174,6 +174,7 @@ int main(int argc, char *argv[])
                                created_lock = 0, created_signal = 0, created_debug = 0,
                                created_misdn = 0;
        char                    tracetext[256], lock[128];
+       char                    options_error[256];
 
 #if 0
        /* init fdset */
@@ -250,7 +251,7 @@ int main(int argc, char *argv[])
        }
 
        /* read options */
-       if (read_options() == 0) {
+       if (read_options(options_error) == 0) {
                PERROR("%s", options_error);
                goto free;
        }
index eff38ce..1cadbe5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -44,7 +44,7 @@ char options_error[256];
  *
  * read options from options.conf
  */
-int read_options(void)
+int read_options(char *options_error)
 {
        FILE *fp=NULL;
        char filename[128];
@@ -57,7 +57,7 @@ int read_options(void)
        SPRINT(filename, "%s/options.conf", CONFIG_DATA);
 
        if (!(fp=fopen(filename,"r"))) {
-               SPRINT(options_error, "Cannot open %s\n",filename);
+               UPRINT(options_error, "Cannot open %s\n",filename);
                return(0);
        }
 
@@ -80,7 +80,7 @@ int read_options(void)
                i=0; /* read option */
                while(*p > 32) {
                        if (i+1 >= sizeof(option)) {
-                               SPRINT(options_error, "Error in %s (line %d): option too long.\n",filename,line);
+                               UPRINT(options_error, "Error in %s (line %d): option too long.\n",filename,line);
                                goto error;
                        }
                        option[i+1] = '\0';
@@ -98,7 +98,7 @@ int read_options(void)
                        i=0; /* read param */
                        while(*p > 31) {
                                if (i+1 >= sizeof(param)) {
-                                       SPRINT(options_error, "Error in %s (line %d): param too long.\n",filename,line);
+                                       UPRINT(options_error, "Error in %s (line %d): param too long.\n",filename,line);
                                        goto error;
                                }
                                param[i+1] = '\0';
@@ -110,12 +110,12 @@ int read_options(void)
 
                /* check option */
                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);
+                       UPRINT(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) {
-                               SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
                                goto error;
                        }
                        options.deb = strtol(param, NULL, 0);
@@ -123,7 +123,7 @@ int read_options(void)
                } else
                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);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
                                goto error;
                        }
                        SCPY(options.log, param);
@@ -139,7 +139,7 @@ int read_options(void)
                } else
                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);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
                                goto error;
                        }
                        if (param[strlen(param)-1] == '/')
@@ -149,7 +149,7 @@ int read_options(void)
                } else
                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);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
                                goto error;
                        }
                        if (param[strlen(param)-1] == '/')
@@ -173,24 +173,24 @@ int read_options(void)
 
                } else
                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);
+                       UPRINT(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);
                        goto error;
                } else
                if (!strcmp(option,"schedule")) {
                        options.schedule = atoi(param);
                        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);
+                               UPRINT(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) {
-                               SPRINT(options_error, "Error in %s (line %d): parameter for option %s must be '99' or less.\n", filename,line,option);
+                               UPRINT(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) {
-                               SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n", filename,line,option);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n", filename,line,option);
                                goto error;
                        }
                        SCPY(options.email, param);
@@ -198,7 +198,7 @@ int read_options(void)
                } else
                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);
+                               UPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
                                goto error;
                        }
                        if (param[strlen(param)-1] == '/')
@@ -212,7 +212,7 @@ int read_options(void)
                        if (*endptr != '\0') {
                                struct passwd * pwd = getpwnam(param);
                                if (pwd == NULL) {
-                                       SPRINT(options_error, "Error in %s (line %d): no such user: %s.\n",filename,line,param);
+                                       UPRINT(options_error, "Error in %s (line %d): no such user: %s.\n",filename,line,param);
                                        goto error;
                                }
                                options.socketuser = pwd->pw_uid;
@@ -224,7 +224,7 @@ int read_options(void)
                        if (*endptr != '\0') {
                                struct group * grp = getgrnam(param);
                                if (grp == NULL) {
-                                       SPRINT(options_error, "Error in %s (line %d): no such group: %s.\n",filename,line,param);
+                                       UPRINT(options_error, "Error in %s (line %d): no such group: %s.\n",filename,line,param);
                                        goto error;
                                }
                                options.socketgroup = grp->gr_gid;
@@ -236,13 +236,13 @@ int read_options(void)
                if (!strcmp(option,"gsm")) {
                        options.gsm = 1;
                } else {
-                       SPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
+                       UPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
                        goto error;
                }
        }
 
        if (!options.tones_dir[0]) {
-               SPRINT(options_error, "Error in %s (line %d): option 'tones_dir' with parameter missing.\n", filename);
+               UPRINT(options_error, "Error in %s (line %d): option 'tones_dir' with parameter missing.\n", filename,line);
                goto error;
        }
        if (fp) fclose(fp);
index ecf8244..1a256e2 100644 (file)
--- a/options.h
+++ b/options.h
@@ -34,9 +34,7 @@ struct options {
 
 extern struct options options;
 
-extern char options_error[256];
-
-int read_options(void);
+int read_options(char *options_error);
 
 #ifdef __cplusplus
 }