use configfile

This commit is contained in:
Olaf Rempel 2007-12-04 16:56:05 +01:00
parent 7a243e8cad
commit ef25dbe436
2 changed files with 22 additions and 16 deletions

View File

@ -9,19 +9,30 @@
#include "logging.h" #include "logging.h"
#include "sockaddr.h" #include "sockaddr.h"
#define DEFAULT_CONFIG "irclogbot.conf"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct irc_session *session = irc_create_session(); /* parse config file */
if (config_parse(DEFAULT_CONFIG))
exit(1);
parse_sockaddr("83.140.172.211:6667", &session->srv_addr); char *server_str = (char *)config_get_string("global", "server", NULL);
session->server_pass = NULL; if (server_str == NULL)
session->nickname = "logtest_"; exit(1);
// session->username = "logtest_";
// session->realname = "logtest_"; struct irc_session *session = irc_create_session();
parse_sockaddr(server_str, &session->srv_addr);
session->server_pass = (char *)config_get_string("global", "server-pass", NULL);
session->nickname = (char *)config_get_string("global", "nickname", "logbot");
session->username = (char *)config_get_string("global", "username", NULL);
session->realname = (char *)config_get_string("global", "realname", NULL);
irc_connect(session); irc_connect(session);
event_loop(); event_loop();
config_free();
return 0; return 0;
} }

View File

@ -1,12 +1,7 @@
[global] [global]
server irc.quakenet.org server 83.140.172.211:6667
channel #logtest #server-pass test
client 127.0.0.1 nickname logtest_
client 10.10.250.133 #username logtest_
#realname logtest_
[127.0.0.1]
nickname logtest1
[10.10.250.133]
nickname logtest2