Reverted back to old main()

Trying to see why new version of main causes some CI reg tests to fail.
This commit is contained in:
Lew Rossman
2018-10-27 11:31:06 -04:00
parent 320dec3ff7
commit 27cc088c4a

View File

@@ -1,26 +1,33 @@
#include <stdio.h>
#include <string.h>
#include "epanet2.h"
#define MAXMSG 255 /* Max. # characters in message text */
#define MAXWARNCODE 99
/* text copied here, no more need of include "text.h" */
#define FMT01 "\nEPANET Version %d.%d.%d\n"
#define FMT03 "\nUsage:\n %s <input_filename> <report_filename> [<binary_filename>]\n"
#define FMT09 "\n\nEPANET completed.\n"
#define FMT10 "\nEPANET completed. There are warnings.\n"
#define FMT11 "\nEPANET completed. There are errors.\n"
void writeConsole(char *s);
/* /*
---------------------------------------------------------------- ----------------------------------------------------------------
Command line executable for the EPANET water distribution system Entry point used to compile a stand-alone executable.
analysis program using the EPANET API library.
---------------------------------------------------------------- ----------------------------------------------------------------
*/ */
#include <stdio.h>
#include "epanet2.h"
// Function for writing progress messages to the console int main(int argc, char *argv[])
void writeConsole(char *s)
{
fprintf(stdout, "\r%s", s);
fflush(stdout);
}
int main(int argc, char *argv[])
/*-------------------------------------------------------------- /*--------------------------------------------------------------
** Input: argc = number of command line arguments ** Input: argc = number of command line arguments
** *argv[] = array of command line arguments ** *argv[] = array of command line arguments
** Output: none ** Output: none
** Purpose: main program stub for command line EPANET ** Purpose: main program segment
** **
** Command line for stand-alone operation is: ** Command line for stand-alone operation is:
** progname f1 f2 f3 ** progname f1 f2 f3
@@ -31,56 +38,70 @@ int main(int argc, char *argv[])
**-------------------------------------------------------------- **--------------------------------------------------------------
*/ */
{ {
char *f1,*f2,*f3; char *f1,*f2,*f3;
char blank[] = ""; char blank[] = "";
int errcode, version, major, minor, patch; char errmsg[MAXMSG+1]="";
EN_ProjectHandle ph; int errcode;
int version;
// Check for proper number of command line arguments int major;
if (argc < 2) int minor;
{ int patch;
printf(
"\nUsage:\n %s <input_filename> <report_filename> [<binary_filename>]\n",
argv[0]);
return 0;
}
// Get version number and display in Major.Minor.Patch format /* get version from DLL and trasform in Major.Minor.Patch format
ENgetversion(&version); instead of hardcoded version */
major = version/10000; ENgetversion(&version);
minor = (version%10000)/100; major= version/10000;
patch = version%100; minor= (version%10000)/100;
printf("\n... Running EPANET Version %d.%d.%d\n", major, minor, patch); patch= version%100;
printf(FMT01, major, minor, patch);
// Assign pointers to file names /* Check for proper number of command line arguments */
f1 = argv[1]; if (argc < 2) {
if (argc > 2) f2 = argv[2]; // set rptfile name printf(FMT03, argv[0]);
else f2 = blank; // use stdout for rptfile return(1);
if (argc > 3) f3 = argv[3]; // set binary output file name }
else f3 = blank; // no binary output file
// Create a project, run it, and delete it /* set inputfile name */
EN_createproject(&ph); f1 = argv[1];
errcode = EN_runproject(ph, f1, f2, f3, &writeConsole); if (argc > 2) {
EN_deleteproject(&ph); /* set rptfile name */
f2 = argv[2];
}
else {
/* use stdout for rptfile */
f2 = blank;
}
if (argc > 3) {
/* set binary output file name */
f3 = argv[3];
}
else {
/* NO binary output*/
f3 = blank;
}
// Blank out the last progress message /* Call the main control function */
printf("\r "); errcode = ENepanet(f1,f2,f3,NULL);
// Report run's status /* Error/Warning check */
if (errcode == 0) if (errcode == 0) {
{ /* no errors */
printf("\n... EPANET ran successfully.\n"); printf(FMT09);
} return(0);
else if (errcode < 100) }
{ else {
printf( if (errcode > MAXWARNCODE) printf("\n Fatal Error: ");
"\n... EPANET ran with warnings - see the Status Report.\n"); ENgeterror(errcode, errmsg, MAXMSG);
} printf("%s\n", errmsg);
else if (errcode > MAXWARNCODE) {
{ // error //
printf( printf(FMT11);
"\n... EPANET failed with ERROR %d - see the Status Report\n", errcode); return(errcode);
} }
return errcode; else {
} // warning //
printf(FMT10);
return(0);
}
}
} /* End of main */