Module: sip-router
Branch: master
Commit: 6f96f4fbc788940f8dd1135e73107445d204b553
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6f96f4fbc788940f8dd1135e73107445d204b553

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Sat Mar 15 00:29:43 2014 +0100

core: -f parameter can take the value '-' to read config from stdin

- allos piping the config from various sources (e.g., downloading from
  web)
- example: cat /etc/kamailio/kamailio.cfg | /usr/sbin/kamailio -f -

---

 main.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/main.c b/main.c
index dbabaf0..b86b67d 100644
--- a/main.c
+++ b/main.c
@@ -1224,6 +1224,7 @@ int fix_cfg_file(void)
        
        if (cfg_file == NULL) cfg_file = CFG_FILE;
        if (cfg_file[0] == '/') return 0;
+       if (cfg_file[0] == '-' && strlen(cfg_file)==1) return 0;
        
        /* cfg_file contains a relative pathname, get the current
         * working directory and add it at the beginning
@@ -2044,7 +2045,11 @@ int main(int argc, char** argv)
        if (fix_cfg_file() < 0) goto error;
 
        /* load config file or die */
-       cfg_stream=fopen (cfg_file, "r");
+       if (cfg_file[0] == '-' && strlen(cfg_file)==1) {
+               cfg_stream=stdin;
+       } else {
+               cfg_stream=fopen (cfg_file, "r");
+       }
        if (cfg_stream==0){
                fprintf(stderr, "ERROR: loading config file(%s): %s\n", 
cfg_file,
                                strerror(errno));


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to