adds client callback API function
This commit is contained in:
13
src/epanet.c
13
src/epanet.c
@@ -841,6 +841,19 @@ int DLLEXPORT EN_closeQ(EN_Project p)
|
||||
|
||||
********************************************************************/
|
||||
|
||||
|
||||
int DLLEXPORT EN_setReportCallback(EN_Project p, void (*callback)(void*,void*,char*))
|
||||
{
|
||||
p->report.reportCallback = callback;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_setReportCallbackUserData(EN_Project p, void *userData)
|
||||
{
|
||||
p->report.reportCallbackUserData = userData;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_writeline(EN_Project p, char *line)
|
||||
/*----------------------------------------------------------------
|
||||
** Input: line = line of text
|
||||
|
||||
@@ -281,6 +281,8 @@ void initpointers(Project *pr)
|
||||
pr->hydraul.smatrix.NZSUB = NULL;
|
||||
pr->hydraul.smatrix.LNZ = NULL;
|
||||
|
||||
pr->report.reportCallback = NULL;
|
||||
|
||||
initrules(pr);
|
||||
}
|
||||
|
||||
|
||||
@@ -885,6 +885,12 @@ void writeline(Project *pr, char *s)
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
if (pr->report.reportCallback != NULL)
|
||||
{
|
||||
pr->report.reportCallback(pr->report.reportCallbackUserData, pr, s);
|
||||
return;
|
||||
}
|
||||
|
||||
Report *rpt = &pr->report;
|
||||
|
||||
if (rpt->RptFile == NULL) return;
|
||||
|
||||
@@ -629,7 +629,10 @@ typedef struct {
|
||||
Rpt2Fname[MAXFNAME+1], // Secondary report file name
|
||||
DateStamp[26]; // Current date & time
|
||||
|
||||
SField Field[MAXVAR]; // Output reporting fields
|
||||
SField Field[MAXVAR]; // Output reporting fields
|
||||
|
||||
void (*reportCallback)(void*,void*,char*); // user-supplied reporting callback
|
||||
void *reportCallbackUserData; // user-supplied reporting context
|
||||
|
||||
} Report;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user