Finalizing so 0.5.1 can be released
[infodrom/dtaus] / main.c
diff --git a/main.c b/main.c
index c024c8c..af2e385 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,6 +1,6 @@
 /*
-    main.c - Datentraegeraustausch mit einer Bank
-    Copyright (c) 1996  Martin Schulze <joey@orgatech.de>
+    main.c - Belegloser Datenträgeraustausch mit einer Bank
+    Copyright (c) 1996,8,2001  Martin Schulze <joey@infodrom.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
 
     $Id$
  */
 
+static char version[] = "0.5";
+
 #include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
 #include "dtaus.h"
 
 void help ()
@@ -37,7 +43,7 @@ void help ()
 #define DTAUS   1
 #define CONTROL 2
 
-void main (int argc, char **argv)
+int main (int argc, char **argv)
 {
   char *dtaus[60];
   char *control[60];
@@ -45,6 +51,7 @@ void main (int argc, char **argv)
   char *check[60];
   int action = 0;
   int i = 0;
+  struct stat sbuf;
 
   strcpy ((char *)dtaus, "dtaus0.txt");
   strcpy ((char *)control, "dtaus0.ctl");
@@ -56,7 +63,7 @@ void main (int argc, char **argv)
     if ( !strcmp(argv[i], "-h") ) {
       help(); exit(0);
     } else if ( !strcmp(argv[i], "-v") ) {
-      printf ("dtaus version 0.2 - Copyright (c) 1997 by Martin Schulze <joey@infodrom.north.de>\n");
+      printf ("dtaus version %s - Copyright (c) 1997,8,2001 by Martin Schulze <joey@infodrom.org>\n", version);
       exit (0);
     } else if ( !strcmp(argv[i], "-d") ) {
       if (argc - i > 1) {
@@ -85,10 +92,19 @@ void main (int argc, char **argv)
     } 
   }
 
-  if (action == DTAUS)
-    control2dtaus ((char *)control, (char *)dtaus, (char *)beleg, (char *)check);
-  else if (action == CONTROL)
-    dtaus2control ((char *)dtaus, (char *)control);
-  else
+  if (action == DTAUS) {
+    if (!stat((char *)control, &sbuf)) {
+      if (control2dtaus ((char *)control, (char *)dtaus, (char *)beleg, (char *)check) == 0)
+       exit (1);
+    }
+    else exit (1);
+  } else if (action == CONTROL) {
+    if (!stat((char *)dtaus, &sbuf))
+      dtaus2control ((char *)dtaus, (char *)control);
+    else exit (1);
+  } else {
     printf ("Keine Routine angegeben (-dtaus bzw. -control vergessen).\n");
+    exit (1);
+  }
+  exit (0);
 }