From c90d46c4d12eaa7a29945e03a7f715db4b74686e Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Wed, 28 Jun 2017 12:13:44 -0400 Subject: [PATCH 1/6] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c03f27e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Open Water Analytics + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 5d687d7d2ca88a535bd6110e4797d310a9511c0e Mon Sep 17 00:00:00 2001 From: Markus Sunela <30700548+makusuko@users.noreply.github.com> Date: Thu, 2 May 2019 16:35:55 +0300 Subject: [PATCH 2/6] Fixed NULL pointer error, if no label is provided after the rule keyword. --- src/rules.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rules.c b/src/rules.c index 7ad038f..fc63a1c 100755 --- a/src/rules.c +++ b/src/rules.c @@ -237,7 +237,13 @@ int ruledata() { case -1: err = 201; /* Unrecognized keyword */ break; - case r_RULE: Nrules++; + case r_RULE: /* Missing the rule label -> set error */ + if (parser->Ntokens != 2) + { + err = 201; + break; + } + Nrules++; newrule(); RuleState = r_RULE; break; From d34748e933ff000ae71a3112aba35a9a7c9a88d6 Mon Sep 17 00:00:00 2001 From: mariosmsk Date: Thu, 2 May 2019 20:56:38 +0300 Subject: [PATCH 3/6] Create Makefile2.bat Co-Authored-By: Demetrios G. Eliades Co-Authored-By: Elad Salomons --- win_build/WinSDK/Makefile2.bat | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 win_build/WinSDK/Makefile2.bat diff --git a/win_build/WinSDK/Makefile2.bat b/win_build/WinSDK/Makefile2.bat new file mode 100644 index 0000000..204aad7 --- /dev/null +++ b/win_build/WinSDK/Makefile2.bat @@ -0,0 +1,45 @@ +rem : set the path to CMAKE +SET CMAKE_PATH=cmake.exe + +SET Build_PATH=%CD% + +rem : set genarator +SET GENERATOR=Visual Studio 15 2017 + +rem : the directory where the program will be compiled to +SET COMPILE_PATH_WIN64TMP=%Build_PATH%\tmp64\ +SET COMPILE_PATH_WIN64=%Build_PATH%\64bit\ + +rem : the directory where the program will be compiled to +SET COMPILE_PATH_WIN32TMP=%Build_PATH%\tmp32\ +SET COMPILE_PATH_WIN32=%Build_PATH%\32bit\ + +rem : CMAKE the root directory of the EPANET project +rem : 64 bit +MKDIR "%COMPILE_PATH_WIN64TMP%" +CD "%COMPILE_PATH_WIN64TMP%" +MKDIR "%COMPILE_PATH_WIN64%" +%CMAKE_PATH% -G "%GENERATOR% Win64" ../../../ +rem : %CMAKE_PATH% --build . --config Debug +%CMAKE_PATH% --build . --config Release + +XCOPY "%COMPILE_PATH_WIN64TMP%bin\Release\epanet2.dll" "%COMPILE_PATH_WIN64%epanet2.dll*" /y +XCOPY "%COMPILE_PATH_WIN64TMP%bin\Release\runepanet.exe" "%COMPILE_PATH_WIN64%epanet2.exe*" /y + +rem : CMAKE the root directory of the EPANET project +rem : 32 bit +MKDIR "%COMPILE_PATH_WIN32TMP%" +CD "%COMPILE_PATH_WIN32TMP%" +MKDIR "%COMPILE_PATH_WIN32%" +%CMAKE_PATH% -G "%GENERATOR%" ../../../ +rem : %CMAKE_PATH% --build . --config Debug +%CMAKE_PATH% --build . --config Release + +XCOPY "%COMPILE_PATH_WIN32TMP%bin\Release\epanet2.dll" "%COMPILE_PATH_WIN32%epanet2.dll*" /y +XCOPY "%COMPILE_PATH_WIN32TMP%bin\Release\runepanet.exe" "%COMPILE_PATH_WIN32%epanet2.exe*" /y + +CD "%Build_PATH%" + +rem : cleaning +RMDIR /s /q "%COMPILE_PATH_WIN64TMP%" +RMDIR /s /q "%COMPILE_PATH_WIN32TMP%" From d3e989b62128c0bc5871b439f21fbb6d031102ea Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Wed, 28 Jun 2017 12:13:44 -0400 Subject: [PATCH 4/6] Create LICENSE --- LICENSE | 5 ----- 1 file changed, 5 deletions(-) diff --git a/LICENSE b/LICENSE index 828c521..c03f27e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,11 +1,6 @@ MIT License -<<<<<<< HEAD -Works are copyright (c) 2018 their respective AUTHORS, -unless such work is in the Public Domain (again, see AUTHORS) -======= Copyright (c) 2017 Open Water Analytics ->>>>>>> master Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 1aef998b812fd21933b322900b30971649c31d48 Mon Sep 17 00:00:00 2001 From: Markus Sunela <30700548+makusuko@users.noreply.github.com> Date: Thu, 2 May 2019 16:35:55 +0300 Subject: [PATCH 5/6] Fixed NULL pointer error, if no label is provided after the rule keyword. Add NULL guard in freerules function. Use strncat and strncpy to ensure the buffer lengths are adhered to. --- src/rules.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/rules.c b/src/rules.c index d0addb8..7ee4d8a 100644 --- a/src/rules.c +++ b/src/rules.c @@ -110,6 +110,10 @@ void initrules(Project *pr) //-------------------------------------------------------------- { pr->rules.RuleState = r_PRIORITY; + pr->rules.LastPremise = NULL; + pr->rules.LastThenAction = NULL; + pr->rules.LastElseAction = NULL; + pr->rules.ActionList = NULL; pr->network.Rule = NULL; } @@ -169,8 +173,14 @@ void freerules(Project *pr) //-------------------------------------------------------------- { int i; + + // Already freed + if (pr->network.Rule == NULL) + return; + for (i = 1; i <= pr->network.Nrules; i++) clearrule(pr, i); free(pr->network.Rule); + pr->network.Rule = NULL; } int ruledata(Project *pr) @@ -199,6 +209,12 @@ int ruledata(Project *pr) break; case r_RULE: + // Missing the rule label + if (parser->Ntokens != 2) + { + err = 201; + break; + } net->Nrules++; newrule(pr); rules->RuleState = r_RULE; @@ -302,24 +318,24 @@ void ruleerrmsg(Project *pr) // Get label of rule being parsed if (net->Nrules > 0) { - strcpy(label, t_RULE); - strcat(label, " "); - strcat(label, net->Rule[net->Nrules].label); + strncpy(label, t_RULE, MAXMSG); + strncat(label, " ", MAXMSG); + strncat(label, net->Rule[net->Nrules].label, MAXMSG); } - else strcpy(label, t_RULES_SECT); + else strncpy(label, t_RULES_SECT, MAXMSG); // Write rule label and error message to status report - sprintf(pr->Msg, "%s", msg); - strcat(pr->Msg, label); - strcat(pr->Msg, ":"); + snprintf(pr->Msg, MAXMSG, "%s", msg); + strncat(pr->Msg, label, MAXMSG); + strncat(pr->Msg, ":", MAXMSG); writeline(pr, pr->Msg); // Write text of rule clause being parsed to status report strcpy(msg, Tok[0]); for (i = 1; i < parser->Ntokens; i++) { - strcat(msg, " "); - strcat(msg, Tok[i]); + strncat(msg, " ", MAXLINE); + strncat(msg, Tok[i], MAXLINE); } writeline(pr, msg); } From eefc7f7d056bc1e64e80b5ae22ea1277d2e88db0 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Mon, 6 May 2019 11:36:41 +0300 Subject: [PATCH 6/6] For "conditional" do delete a node connected to a link For "conditional" deletion the node is deleted only if all of its links have been explicitly deleted beforehand #473 Co-Authored-By: Lew Rossman --- src/epanet.c | 7 +++---- src/errors.dat | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/epanet.c b/src/epanet.c index ce32c07..a2d86df 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -1867,16 +1867,15 @@ int DLLEXPORT EN_deletenode(EN_Project p, int index, int actionCode) // Can't delete a water quality trace node if (index == p->quality.TraceNode) return 260; - // Count number of simple & rule-based controls that contain the node + // Do not delete a node contained in a control or is connected to a link if (actionCode == EN_CONDITIONAL) { - actionCode = incontrols(p, NODE, index); + if (incontrols(p, NODE, index)) return 261; for (i = 1; i <= net->Nlinks; i++) { if (net->Link[i].N1 == index || - net->Link[i].N2 == index) actionCode += incontrols(p, LINK, i); + net->Link[i].N2 == index) return 259; } - if (actionCode > 0) return 261; } // Get a reference to the node & its type diff --git a/src/errors.dat b/src/errors.dat index 52baec3..cf808a8 100644 --- a/src/errors.dat +++ b/src/errors.dat @@ -54,6 +54,7 @@ DAT(253,"nonexistent demand category") DAT(254,"node with no coordinates") DAT(257,"nonexistent rule") DAT(258,"nonexistent rule clause") +DAT(259,"attempt to delete a node that still has links connected to it") DAT(260,"attempt to delete node assigned as a Trace Node") DAT(261,"attempt to delete a node or link contained in a control") DAT(262,"attempt to modify network structure while solver is active")