]> jfr.im git - irc/thales.git/blobdiff - src/main.c
First implementation of actual db usage. Not linking yet
[irc/thales.git] / src / main.c
index ea7621c73d40273042c61a71adf9788bcabb8419..e5c685e0fca2034e46514a5ec370e30047777082 100644 (file)
@@ -6,7 +6,7 @@ terms of the GNU General Public License as published by the Free Software
 Foundation; either version 3 of the License, or (at your option) any later
 version.
 
-GNU Make is distributed in the hope that it will be useful, but
+GNU Thales 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.
@@ -16,14 +16,35 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "cmd.h"
+#include "error.h"
+#include "irc.h"
+#include "mysql_sentry.h"
+
 int
-main(int argc, char **argv)
+main (int argc, char **argv)
 {
-  struct cmd_options opts = {
-    .debug = 0,
-    .conf_filename = NULL;
-  };
-  parse_cmdopts(&opts, argc, argv);
+  struct irc_options irc_opts = { 0 };
+  struct mysql_options mysql_opts = { 0 };
+  struct config_options config_opts = { 0 };
+
+
+  parse_cmd_options (&irc_opts, &config_opts, argc, argv);
+  FILE *config_file = config_opts.conf_filename ? fopen (config_opts.conf_filename, "r")
+    : default_config_file ();
+
+  if (!config_file)
+    fatal ("failed to open config file");
+
+  parse_mysql_options(&mysql_opts, config_file);
+
+SENTRY *sentry = sentry_initialize(&mysql_opts);
+#warning "mysql is not used"
+/* if (!sentry) */
+/*   fatal("failed to connect to database"); */
+
+  start_listen_irc(&irc_opts, sentry);
   return 0;
 }