diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d6bfd8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.core +logs/*.log diff --git a/Makefile b/Makefile index 3ed496c..35be742 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ # Application Makefile (C) 2002-2004 The UbixOS Project #Compiler -CC = gcc -CXX = g++ +CC = cc +CXX = c++ #Linker LD = ld @@ -15,9 +15,9 @@ REMOVE = rm -f #Objects -OBJS = lib.o mysql.o server.o nick.o botthread.o main.o socket.o tuve.o channel.o +OBJS = lib.o mysql.o server.o nick.o botthread.o main.o socket.o tuve.o channel.o config.o -LIBRARIES = -lthr -L/usr/local/lib/mysql -lmysqlclient +LIBRARIES = -lthr -L/usr/local/lib/mysql -lmysqlclient -L/usr/local/lib -lconfig CFLAGS = -Wall -W -ggdb INCLUDES = -I/usr/local/include diff --git a/config.c b/config.c new file mode 100644 index 0000000..bf4de58 --- /dev/null +++ b/config.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int parseConfig() { + config_t cfg; + + config_setting_t *setting; + + config_init(&cfg); + + if (!config_read_file(&cfg, "./tuved.cfg")) { + fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); + config_destroy(&cfg); + return(EXIT_FAILURE); + } + + setting = config_lookup(&cfg, "daemon"); + + if (setting != NULL) { + int i = 9999; + + config_setting_lookup_int(setting, "port", &i); + + printf("port: %i", i); + } + +} diff --git a/main.c b/main.c index 0f470fe..d3d890b 100644 --- a/main.c +++ b/main.c @@ -61,6 +61,8 @@ argc -= optind; argv += optind; + parseConfig(); + /* Prepare log file */ if (logFile == 0x0) { diff --git a/tuved.cfg b/tuved.cfg new file mode 100644 index 0000000..13823de --- /dev/null +++ b/tuved.cfg @@ -0,0 +1,10 @@ +daemon = { + sport = 2007; +} + +database = { + hostname = "SPBX-DB002.SpherePBX.com"; + database = "tuve"; + username = "tuve"; + password = "5558585"; +} diff --git a/tuved.h b/tuved.h index bed631b..970a71d 100644 --- a/tuved.h +++ b/tuved.h @@ -16,7 +16,7 @@ /* TUved Information */ #define VERSION "v1.93" // Current Version Of Tuved #define NUM_THREADS 1 // Number Of Threads In The Deamon -#define MYPORT 9999 // the port users will be connecting to +#define MYPORT 2007 // the port users will be connecting to #define BACKLOG 10 // how many pending connections queue will hold #define LOG_FILE "./logs/tuved.log" // Default Log File #define PING_INTERVAL 20 // Interval For Pings