From: Joey Schulze Date: Fri, 3 Jul 1998 14:46:56 +0000 (+0000) Subject: . Put version string into separate variable X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fdtaus;a=commitdiff_plain;h=6d024173f26dc823bc1bd05cbe4de99caeef7466 . Put version string into separate variable . Added mechanism that will prevent function calls for not existing files. This prevents us from unneccessary empty files. --- diff --git a/main.c b/main.c index c024c8c..94029a0 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,11 @@ $Id$ */ +static char version[] = "0.2.1"; + #include +#include +#include #include "dtaus.h" void help () @@ -45,6 +49,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 +61,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 \n"); + printf ("dtaus version %s - Copyright (c) 1997,8 by Martin Schulze \n", version); exit (0); } else if ( !strcmp(argv[i], "-d") ) { if (argc - i > 1) { @@ -85,10 +90,16 @@ 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)) + control2dtaus ((char *)control, (char *)dtaus, (char *)beleg, (char *)check); + 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); + } }