From 62f0bc6db76ffe62cfa670a5218ddefb7012e10f Mon Sep 17 00:00:00 2001 From: Lew Rossman Date: Thu, 13 Jun 2024 07:49:14 -0400 Subject: [PATCH 1/2] Fix two legacy API functions --- src/epanet2.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/epanet2.c b/src/epanet2.c index 82e74905..c3c8fa29 100644 --- a/src/epanet2.c +++ b/src/epanet2.c @@ -357,7 +357,16 @@ int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value) int DLLEXPORT ENgetnodevalues(int property, EN_API_FLOAT_TYPE *values) { - return EN_getnodevalues(_defaultProject, property, values); + int i, errcode = 0; + EN_API_FLOAT_TYPE value; + + for (i = 1; i <= _defaultProject->network.Nnodes; i++) + { + errcode = ENgetnodevalue(i, property, &value); + values[i-1] = value; + if (errcode != 0) return errcode; + } + return 0; } int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value) @@ -530,7 +539,16 @@ int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value) } int DLLEXPORT ENgetlinkvalues(int property, EN_API_FLOAT_TYPE *values) { - return EN_getlinkvalues(_defaultProject, property, values); + int i, errcode = 0; + EN_API_FLOAT_TYPE value; + + for (i = 1; i <= _defaultProject->network.Nlinks; i++) + { + errcode = ENgetlinkvalue(i, property, &value); + values[i-1] = value; + if (errcode != 0) return errcode; + } + return 0; } int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value) From 6ac4156fd02e9cff1a8ba851551fca10c6294f05 Mon Sep 17 00:00:00 2001 From: Lew Rossman Date: Fri, 14 Jun 2024 09:49:28 -0400 Subject: [PATCH 2/2] Update report.c Change a "printf" statement to "sprintf". --- src/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.c b/src/report.c index 31e0649e..ffdc2d22 100644 --- a/src/report.c +++ b/src/report.c @@ -291,7 +291,7 @@ void writesummary(Project *pr) if (qual->Qualflag == NONE || time->Dur == 0.0) sprintf(s, FMT29); else if (qual->Qualflag == CHEM) sprintf(s, FMT30, qual->ChemName); else if (qual->Qualflag == TRACE) sprintf(s, FMT31, net->Node[qual->TraceNode].ID); - else if (qual->Qualflag == AGE) printf(s, FMT32); + else if (qual->Qualflag == AGE) sprintf(s, FMT32); writeline(pr, s); if (qual->Qualflag != NONE && time->Dur > 0) {