Added support for special files "-" as placeholder for stdin/stdout
authorJoey Schulze <joey@infodrom.org>
Sun, 11 Nov 2001 16:41:31 +0000 (16:41 +0000)
committerJoey Schulze <joey@infodrom.org>
Sun, 11 Nov 2001 16:41:31 +0000 (16:41 +0000)
for dtaus and control files

dtaus.c

diff --git a/dtaus.c b/dtaus.c
index 0a5602c..35ebd44 100644 (file)
--- a/dtaus.c
+++ b/dtaus.c
@@ -720,18 +720,25 @@ void dtaus2control (char *cdtaus, char *ccontrol)
   char x[30];
   int index, countC;
 
   char x[30];
   int index, countC;
 
-  if (!cdtaus)
+  if (!cdtaus) {{
     if (!(fdtaus = fopen("DTAUS0.TXT", "r")))
       if (!(fdtaus = fopen("dtaus0.txt", "r")))
        return;
     if (!(fdtaus = fopen("DTAUS0.TXT", "r")))
       if (!(fdtaus = fopen("dtaus0.txt", "r")))
        return;
-  if (cdtaus)
-    if (!(fdtaus = fopen(cdtaus, "r")))
-      return;
-  if (!ccontrol)
+  } else {
+    if (!strcmp (cdtaus, "-"))
+      fdtaus = stdin;
+    else
+      if (!(fdtaus = fopen(cdtaus, "r")))
+       return;
+  }
+  if (!ccontrol) 
     fcontrol = stdout;
   else
     fcontrol = stdout;
   else
-    if (!(fcontrol = fopen(ccontrol, "w")))
-      return;
+    if (!strcmp (ccontrol, "-"))
+      fcontrol = stdout;
+    else
+      if (!(fcontrol = fopen(ccontrol, "w")))
+       return;
   if (!(buf = (char *)malloc (512)))
     return;
 
   if (!(buf = (char *)malloc (512)))
     return;
 
@@ -856,25 +863,34 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   char *cp;
   int textindex = 0;
 
   char *cp;
   int textindex = 0;
 
-  if (!cdtaus)
+  if (!cdtaus) {
     if (!(fdtaus = fopen("dtaus0.txt", "w")))
       return 0;
     if (!(fdtaus = fopen("dtaus0.txt", "w")))
       return 0;
-  if (cdtaus)
-    if (!(fdtaus = fopen(cdtaus, "w")))
-      return 0;
-  if (!ccontrol)
+  } else {
+    if (!strcmp (cdtaus, "-"))
+      fdtaus = stdout;
+    else
+      if (!(fdtaus = fopen(cdtaus, "w")))
+       return 0;
+  }
+  if (!ccontrol) {
     if (!(fcontrol = fopen("dtaus0.ctl", "r")))
       if (!(fcontrol = fopen("DTAUS0.CTL", "r")))
        return 0;
     if (!(fcontrol = fopen("dtaus0.ctl", "r")))
       if (!(fcontrol = fopen("DTAUS0.CTL", "r")))
        return 0;
-  if (ccontrol)
-    if (!(fcontrol = fopen(ccontrol, "r")))
-      return 0;
-  if (!cbeleg)
+  } else {
+    if (!strcmp (ccontrol, "-"))
+      fcontrol = stdin;
+    else
+      if (!(fcontrol = fopen(ccontrol, "r")))
+       return 0;
+  }
+  if (!cbeleg) {
     if (!(fbeleg = fopen("dtaus0.doc", "w")))
       return 0;
     if (!(fbeleg = fopen("dtaus0.doc", "w")))
       return 0;
-  if (cbeleg)
+  } else {
     if (!(fbeleg = fopen(cbeleg, "w")))
       return 0;
     if (!(fbeleg = fopen(cbeleg, "w")))
       return 0;
+  }
   if (!ccheck)
     fcheck = stdout;
   else
   if (!ccheck)
     fcheck = stdout;
   else