summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-04-07 23:15:16 +0200
committersijanec <anton@sijanec.eu>2021-04-07 23:15:16 +0200
commita19e3705a228735eacadd713b28d49fe33bb726b (patch)
tree9c5fd6e62a24e7f893686b45da15ecda91b41a58 /src/main.c
parentfuck (diff)
downloadsear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar.gz
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar.bz2
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar.lz
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar.xz
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.tar.zst
sear.c-a19e3705a228735eacadd713b28d49fe33bb726b.zip
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 4bf41eb..8b43389 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,8 +5,10 @@
#include <stdarg.h>
#include <printf.h>
#include <ctype.h>
+#include <math.h>
#include <time.h>
#include <unistd.h>
+#include <signal.h>
#include <pthread.h>
#include <stdatomic.h>
#include <i18n.h>
@@ -46,6 +48,9 @@ char sc_securitytxt[] = "# This content information is provided by the developer
#include <api.c>
#include <httpd.c>
/* this is new in my programs. I am now using _sizeof for the actual alloced size of the array and _length for the count of elements in array. this is done to decrease number of calls to realloc&amis */
+void sc_signalhander (int s) {
+ return;
+}
int main (int argc, char ** argv) {
int rs = 0;
struct sc_cache * c = sc_cache_init();
@@ -54,13 +59,19 @@ int main (int argc, char ** argv) {
rs = 1;
goto rc;
}
+ xmlInitParser();
d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, SC_HTTP_PORT, NULL, NULL, &sc_httpd, c, MHD_OPTION_END);
if (!d) {
rs = 2;
goto rc;
}
+ signal(SIGTERM, sc_signalhander);
+ signal(SIGINT, sc_signalhander);
pause();
+ fprintf(stderr, "cleaning up!\n");
+ fflush(stderr);
rc:
+ xmlCleanupParser();
sc_cache_free(c);
MHD_stop_daemon(d);
return rs;