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:
143
run/main.c
143
run/main.c
@@ -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;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int patch;
|
||||||
|
|
||||||
// Check for proper number of command line arguments
|
/* get version from DLL and trasform in Major.Minor.Patch format
|
||||||
if (argc < 2)
|
instead of hardcoded version */
|
||||||
{
|
ENgetversion(&version);
|
||||||
printf(
|
major= version/10000;
|
||||||
"\nUsage:\n %s <input_filename> <report_filename> [<binary_filename>]\n",
|
minor= (version%10000)/100;
|
||||||
argv[0]);
|
patch= version%100;
|
||||||
return 0;
|
printf(FMT01, major, minor, patch);
|
||||||
}
|
|
||||||
|
|
||||||
// Get version number and display in Major.Minor.Patch format
|
/* Check for proper number of command line arguments */
|
||||||
ENgetversion(&version);
|
if (argc < 2) {
|
||||||
major = version/10000;
|
printf(FMT03, argv[0]);
|
||||||
minor = (version%10000)/100;
|
return(1);
|
||||||
patch = version%100;
|
}
|
||||||
printf("\n... Running EPANET Version %d.%d.%d\n", major, minor, patch);
|
|
||||||
|
|
||||||
// Assign pointers to file names
|
/* set inputfile name */
|
||||||
f1 = argv[1];
|
f1 = argv[1];
|
||||||
if (argc > 2) f2 = argv[2]; // set rptfile name
|
if (argc > 2) {
|
||||||
else f2 = blank; // use stdout for rptfile
|
/* set rptfile name */
|
||||||
if (argc > 3) f3 = argv[3]; // set binary output file name
|
f2 = argv[2];
|
||||||
else f3 = blank; // no binary output file
|
}
|
||||||
|
else {
|
||||||
|
/* use stdout for rptfile */
|
||||||
|
f2 = blank;
|
||||||
|
}
|
||||||
|
if (argc > 3) {
|
||||||
|
/* set binary output file name */
|
||||||
|
f3 = argv[3];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* NO binary output*/
|
||||||
|
f3 = blank;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a project, run it, and delete it
|
/* Call the main control function */
|
||||||
EN_createproject(&ph);
|
errcode = ENepanet(f1,f2,f3,NULL);
|
||||||
errcode = EN_runproject(ph, f1, f2, f3, &writeConsole);
|
|
||||||
EN_deleteproject(&ph);
|
|
||||||
|
|
||||||
// Blank out the last progress message
|
/* Error/Warning check */
|
||||||
printf("\r ");
|
if (errcode == 0) {
|
||||||
|
/* no errors */
|
||||||
// Report run's status
|
printf(FMT09);
|
||||||
if (errcode == 0)
|
return(0);
|
||||||
{
|
}
|
||||||
printf("\n... EPANET ran successfully.\n");
|
else {
|
||||||
}
|
if (errcode > MAXWARNCODE) printf("\n Fatal Error: ");
|
||||||
else if (errcode < 100)
|
ENgeterror(errcode, errmsg, MAXMSG);
|
||||||
{
|
printf("%s\n", errmsg);
|
||||||
printf(
|
if (errcode > MAXWARNCODE) {
|
||||||
"\n... EPANET ran with warnings - see the Status Report.\n");
|
// error //
|
||||||
}
|
printf(FMT11);
|
||||||
else
|
return(errcode);
|
||||||
{
|
}
|
||||||
printf(
|
else {
|
||||||
"\n... EPANET failed with ERROR %d - see the Status Report\n", errcode);
|
// warning //
|
||||||
}
|
printf(FMT10);
|
||||||
return errcode;
|
return(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} /* End of main */
|
||||||
|
|||||||
Reference in New Issue
Block a user