dahdi_cfg: can optionally read config from stdin

Allow for the convention of '-' marking stdin:

  dahdi_cfg -c -

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2013-10-06 16:10:48 +03:00 committed by Tzafrir Cohen
parent 1e81ed14cf
commit dc5c7de9fc
2 changed files with 6 additions and 1 deletions

View File

@ -1500,7 +1500,10 @@ int main(int argc, char *argv[])
error("Unable to open master device '%s'\n", MASTER_DEVICE); error("Unable to open master device '%s'\n", MASTER_DEVICE);
goto finish; goto finish;
} }
cf = fopen(filename, "r"); if (strcmp(filename, "-") == 0)
cf = fdopen(STDIN_FILENO, "r");
else
cf = fopen(filename, "r");
if (cf) { if (cf) {
while((buf = readline())) { while((buf = readline())) {
if (*buf == 10) /* skip new line */ if (*buf == 10) /* skip new line */

View File

@ -24,6 +24,8 @@ the DAHDI init script.
.RS .RS
Use an alternative configuration file instead of Use an alternative configuration file instead of
.I /etc/dahdi/system.conf .I /etc/dahdi/system.conf
If \fICFG_FILE\fR is '\fB\-\fR', it is read from stdin.
.RE .RE
.B \-C \fICHANNELS .B \-C \fICHANNELS