dahdi_cfg: can optionally read config from stdin
authorOron Peled <oron.peled@xorcom.com>
Sun, 6 Oct 2013 13:10:48 +0000 (16:10 +0300)
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>
Tue, 8 Oct 2013 14:05:09 +0000 (10:05 -0400)
Allow for the convention of '-' marking stdin:

  dahdi_cfg -c -

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

dahdi_cfg.c
doc/dahdi_cfg.8

index 3dfaf42..349a0af 100644 (file)
@@ -1500,7 +1500,10 @@ int main(int argc, char *argv[])
                error("Unable to open master device '%s'\n", MASTER_DEVICE);
                goto finish;
        }
-       cf = fopen(filename, "r");
+       if (strcmp(filename, "-") == 0)
+               cf = fdopen(STDIN_FILENO, "r");
+       else
+               cf = fopen(filename, "r");
        if (cf) {
                while((buf = readline())) {
                        if (*buf == 10) /* skip new line */
index 5e1eaa2..a5d0595 100644 (file)
@@ -24,6 +24,8 @@ the DAHDI init script.
 .RS
 Use an alternative configuration file instead of
 .I /etc/dahdi/system.conf
+
+If \fICFG_FILE\fR is '\fB\-\fR', it is read from stdin.
 .RE
 
 .B \-C \fICHANNELS