From dfe879af19fe6609af73ab16c7c0ddf3ed11e86c Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Fri, 12 Jun 2015 10:34:25 -0400 Subject: [PATCH] standalone utility --- run/main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 run/main.c diff --git a/run/main.c b/run/main.c new file mode 100644 index 0000000..83949a7 --- /dev/null +++ b/run/main.c @@ -0,0 +1,75 @@ +#include +#include "epanet2.h" +#include "text.h" + +void writeConsole(char *s); + +extern char Warnflag; + +/* +---------------------------------------------------------------- + Entry point used to compile a stand-alone executable. +---------------------------------------------------------------- +*/ + + +int main(int argc, char *argv[]) +/*-------------------------------------------------------------- + ** Input: argc = number of command line arguments + ** *argv[] = array of command line arguments + ** Output: none + ** Purpose: main program segment + ** + ** Command line for stand-alone operation is: + ** progname f1 f2 f3 + ** where progname = name of executable this code was compiled to, + ** f1 = name of input file, f2 = name of report file, and + ** f3 = name of binary output file (optional). + **-------------------------------------------------------------- + */ +{ + char *f1,*f2,*f3; + char blank[] = ""; + int errcode; + + /* Check for proper number of command line arguments */ + if (argc < 3) { + writeConsole(FMT03); + } + else { + /* Call the main control function */ + f1 = argv[1]; + f2 = argv[2]; + if (argc > 3) { + f3 = argv[3]; + } + else { + f3 = blank; + } + writeConsole(FMT01); + errcode = ENepanet(f1,f2,f3,NULL); + if (errcode > 0) { + writeConsole(FMT11); + } + else if (Warnflag > 0) { + writeConsole(FMT10); + } + else { + writeConsole(FMT09); + } + } + return(0); +} /* End of main */ + + +void writeConsole(char *s) +/*---------------------------------------------------------------- + ** Input: text string + ** Output: none + ** Purpose: writes string of characters to console + **---------------------------------------------------------------- + */ +{ + fprintf(stdout,"%s",s); + fflush(stdout); +}