Merge pull request #348 from michaeltryby/dev

Rolling back errormanager
This commit is contained in:
Michael Tryby
2018-11-19 17:05:49 -05:00
committed by GitHub
6 changed files with 731 additions and 870 deletions

View File

@@ -69,8 +69,8 @@ ENDIF (MSVC)
# configure file groups
file(GLOB EPANET_SOURCES src/*.c src/util/*.c)
file(GLOB EPANET_LIB_ALL src/* src/util/*)
file(GLOB EPANET_SOURCES src/*.c)
file(GLOB EPANET_LIB_ALL src/*.c src/*.h)
source_group("Library" FILES ${EPANET_LIB_ALL})

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,10 @@ QUALROUTE.C -- water quality routing module for the EPANET program
*********************************************************************
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "mempool.h"
#include "types.h"

View File

@@ -22,7 +22,6 @@ AUTHOR: L. Rossman
//#include "epanet2.h"
#include "hash.h"
#include "util/errormanager.h"
#include <stdio.h>
@@ -925,8 +924,6 @@ typedef struct EN_Project {
TmpOutFname[MAXFNAME+1], // Temporary output file name
TmpStatFname[MAXFNAME+1]; // Temporary statistic file name
error_handle_t* error_handle; // Simple error manager
void (* viewprog) (char *); // Pointer to progress viewing function
} EN_Project;

View File

@@ -1,73 +0,0 @@
//-----------------------------------------------------------------------------
//
// errormanager.c
//
// Purpose: Provides a simple interface for managing runtime error messages.
//
// Date: 08/25/2017
//
// Author: Michael E. Tryby
// US EPA - ORD/NRMRL
//-----------------------------------------------------------------------------
#include "errormanager.h"
error_handle_t* new_errormanager(void (*p_error_message)(int, char*, int))
//
// Purpose: Constructs a new error handle.
//
{
error_handle_t* error_handle;
error_handle = (error_handle_t*)calloc(1, sizeof(error_handle_t));
if (error_handle != NULL)
error_handle->p_msg_lookup = p_error_message;
return error_handle;
}
void dst_errormanager(error_handle_t* error_handle)
//
// Purpose: Destroys the error handle.
//
{
free(error_handle);
}
int set_error(error_handle_t* error_handle, int errorcode)
//
// Purpose: Sets an error code in the handle.
//
{
// If the error code is 0 no action is taken and 0 is returned.
// This is a feature not a bug.
if (errorcode)
error_handle->error_status = errorcode;
return errorcode;
}
char* check_error(error_handle_t* error_handle)
//
// Purpose: Returns the error message or NULL.
//
// Note: Caller must free memory allocated by check_error
//
{
char* temp = NULL;
if (error_handle->error_status != 0) {
temp = (char*) calloc(ERR_MAXMSG, sizeof(char));
if (temp)
error_handle->p_msg_lookup(error_handle->error_status, temp, ERR_MAXMSG);
}
return temp;
}
void clear_error(error_handle_t* error_handle)
//
// Purpose: Clears the error from the handle.
//
{
error_handle->error_status = 0;
}

View File

@@ -1,30 +0,0 @@
/*
* errormanager.h
*
* Created on: Aug 25, 2017
*
* Author: Michael E. Tryby
* US EPA - ORD/NRMRL
*/
#ifndef ERRORMANAGER_H_
#define ERRORMANAGER_H_
#include <stdlib.h>
#include <string.h>
#define ERR_MAXMSG 256
typedef struct error_s {
int error_status;
void (*p_msg_lookup)(int, char*, int);
} error_handle_t;
error_handle_t* new_errormanager(void (*p_error_message)(int, char*, int));
void dst_errormanager(error_handle_t* error_handle);
int set_error(error_handle_t* error_handle, int errorcode);
char* check_error(error_handle_t* error_handle);
void clear_error(error_handle_t* error_handle);
#endif /* ERRORMANAGER_H_ */