From: Jason Ish Date: Thu, 22 Feb 2024 20:27:50 +0000 (-0600) Subject: examples/lib: replicate Suricata using the library X-Git-Tag: suricata-8.0.0-beta1~1597 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dc39d31c669abcb38d57bce5cbd7764da53a4e9;p=thirdparty%2Fsuricata.git examples/lib: replicate Suricata using the library With more functions exposed via the library, a library user can now replicate the Suricata "main" function. --- diff --git a/examples/lib/simple/main.c b/examples/lib/simple/main.c index 0ebb125bf2..c577525116 100644 --- a/examples/lib/simple/main.c +++ b/examples/lib/simple/main.c @@ -1,7 +1,35 @@ +/* Copyright (C) 2024 Open Information Security Foundation + * + * You can copy, redistribute or modify this Program under the terms of + * the GNU General Public License version 2 as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + #include "suricata.h" int main(int argc, char **argv) { - SuricataMain(argc, argv); - return 0; + SuricataPreInit(argv[0]); + SuricataInit(argc, argv); + SuricataPostInit(); + + /* Suricata is now running, but we enter a loop to keep it running + * until it shouldn't be running anymore. */ + SuricataMainLoop(); + + /* Shutdown engine. */ + SuricataShutdown(); + GlobalsDestroy(); + + return EXIT_SUCCESS; }