adds client callback API function

This commit is contained in:
Sam Hatchett
2022-07-27 16:37:49 -04:00
parent 44ad2488e4
commit 41887e9016
5 changed files with 37 additions and 1 deletions

View File

@@ -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

View File

@@ -281,6 +281,8 @@ void initpointers(Project *pr)
pr->hydraul.smatrix.NZSUB = NULL;
pr->hydraul.smatrix.LNZ = NULL;
pr->report.reportCallback = NULL;
initrules(pr);
}

View File

@@ -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;

View File

@@ -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;