aboutsummaryrefslogtreecommitdiff
path: root/src/Main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.c')
-rw-r--r--src/Main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Main.c b/src/Main.c
new file mode 100644
index 0000000..ad08f3e
--- /dev/null
+++ b/src/Main.c
@@ -0,0 +1,36 @@
+#include <beaker.h>
+#include <curl/curl.h>
+#include <libxml/parser.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "Config.h"
+#include "Routes/Home.h"
+#include "Routes/Images.h"
+#include "Routes/Search.h"
+
+int main() {
+ LIBXML_TEST_VERSION
+ xmlInitParser();
+
+ curl_global_init(CURL_GLOBAL_DEFAULT);
+
+ set_handler("/", home_handler);
+ set_handler("/search", results_handler);
+ set_handler("/images", images_handler);
+
+ fprintf(stderr, "Starting Omnisearch on %s:%d\n", host, port);
+
+ int result = beaker_run(host, port);
+
+ if (result != 0) {
+ fprintf(stderr, "Error: Beaker server failed to start.\n");
+ curl_global_cleanup();
+ xmlCleanupParser();
+ return EXIT_FAILURE;
+ }
+
+ curl_global_cleanup();
+ xmlCleanupParser();
+ return EXIT_SUCCESS;
+}