Permalink
Browse files

Basic command line parsing. Only -c/--config has any effect now.

  • Loading branch information...
1 parent 52b9c71 commit c084f47aa66d0294bc705e2313eefa08460f3507 @tm512 committed Jan 30, 2012
Showing with 48 additions and 4 deletions.
  1. +1 −0 TODO
  2. +2 −0 src/config.c
  3. +45 −4 src/main.c
View
1 TODO
@@ -12,6 +12,7 @@ incomplete ispolin roadmap
- More handlers
- Logging
- Parse command line options
+- SSL support
- Less hacky loop for ircclient_t instances
(use select in irc_getln or something similar in order to wait for something to read, rather than failing)
- Add Lua scripting API
View
@@ -32,6 +32,8 @@ int config_load (char *filename, config_t *cfg, ircclient_t **clients)
int i;
lua_State *L = lua_open ();
+ iprint ("Loading configuration file: %s", filename);
+
if (!L)
{
eprint (1, "Could not initialize Lua", filename);
View
@@ -1,30 +1,71 @@
-// crappy test main here
-// needs to be replaced, of course...
+/*
+ ispolin
+ Copyright [c] 2011-2012 tm512 (Kyle Davis), All Rights Reserved.
+
+ Ispolin is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 3, as
+ published by the Free Software Foundation.
+
+ Ispolin 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
+ along with Ispolin. If not, see <http://www.gnu.org/licenses/>.
+*/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <pthread.h>
#include "version.h"
+#include "prints.h"
#include "net.h"
#include "irc.h"
#include "module.h"
#include "config.h"
ircclient_t *clients [MAXCLIENTS] = { 0 };
pthread_t threads [MAXCLIENTS];
+char *configpath = "./config.lua";
config_t globalcfg;
-int main (void)
+void parseargs (int argc, char **argv)
+{
+ int i;
+ for (i = 1; i < argc; i++)
+ {
+ int arglen = strlen (argv [i]);
+ if (!strcmp (argv [i], "--config") || !strcmp (argv [i], "-c"))
+ {
+ configpath = argv [i + 1];
+ continue;
+ }
+
+ if (!strcmp (argv [i], "--daemon") || !strcmp (argv [i], "-d"))
+ {
+ eprint (0, "%s: not implemented yet.", argv [i]);
+ continue;
+ }
+ }
+
+ return;
+}
+
+int main (int argc, char **argv)
{
int i;
fprintf (stdout, "[\033[1m-\033[0m] \033[1mispolin\033[0m\n");
fprintf (stdout, "[\033[1m-\033[0m] \033[2mversion %s%s compiled on " __DATE__ "\033[0m\n", ISP_VERSION, GIT_VERSION);
+ parseargs (argc, argv);
+
+ config_load (configpath, &globalcfg, clients);
module_load ("./modules/core.so");
- config_load ("./config.lua", &globalcfg, clients);
for (i = 0; i < MAXCLIENTS; i++)
if (clients [i])

0 comments on commit c084f47

Please sign in to comment.