Author: Fish
Date: Tue Jun 21 19:44:37 2005
New Revision: 2634
Removed:
trunk/include/dotconf.h
trunk/src/dotconf.c
Modified:
trunk/ChangeLog
trunk/include/Makefile.am
trunk/include/Makefile.in
trunk/makeconf
trunk/src/Makefile.am
trunk/src/Makefile.in
trunk/src/conf.c
trunk/src/sock.c
Log:
move config file processing over to confuse and update makeconf
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Tue Jun 21 19:44:37 2005
@@ -4,6 +4,8 @@
Fish (F), Mark (M), DeadNotBuried (D)
===============================================================================
* NeoStats * Version 3.0.a3-dev
+ - Move Config file over to confuse engine, and redo makeconf to work with
+ new config file format (F)
- Move Secure.irc-chat.net update code to core to allow OPSB to use it as
well (F)
- Store the IP address we connect to in tme so we can reference it from
Modified: trunk/include/Makefile.am
==============================================================================
--- trunk/include/Makefile.am (original)
+++ trunk/include/Makefile.am Tue Jun 21 19:44:37 2005
@@ -6,7 +6,7 @@
adns.h protocol.h
noinst_HEADERS = commands.h dns.h servers.h users.h conf.h \
- dotconf.h log.h services.h modes.h signals.h \
+ log.h services.h modes.h signals.h \
auth.h config.h.in exclude.h modules.h sock.h \
bans.h base64.h ctcp.h helpstrings.h support.h \
ircprotocol.h ircsend.h ircrecv.h \
Modified: trunk/include/Makefile.in
==============================================================================
--- trunk/include/Makefile.in (original)
+++ trunk/include/Makefile.in Tue Jun 21 19:44:37 2005
@@ -194,7 +194,7 @@
adns.h protocol.h
noinst_HEADERS = commands.h dns.h servers.h users.h conf.h \
- dotconf.h log.h services.h modes.h signals.h \
+ log.h services.h modes.h signals.h \
auth.h config.h.in exclude.h modules.h sock.h \
bans.h base64.h ctcp.h helpstrings.h support.h \
ircprotocol.h ircsend.h ircrecv.h \
Modified: trunk/makeconf
==============================================================================
--- trunk/makeconf (original)
+++ trunk/makeconf Tue Jun 21 19:44:37 2005
@@ -19,9 +19,10 @@
LINKPASS="linkpassword"
NEOCHAN="#services"
NEOCONN="10"
-BINDIP="127.0.0.1"
+BINDIP="127.0.0.1 <- CHANGETHIS!!"
LOGFNAMEFORMAT="-%m-%d"
SETSERVERTIMES="24"
+DATABASE="gdbm"
# these are so I can use stuff like $1 without it replacing it...like by
# using $dlrsgn$uno for $1
@@ -303,7 +304,7 @@
fi
echo " "
-echo "What IP should NeoStats Bind to? (ie: $BINDIP)"
+echo "What IP should NeoStats Bind to? (ie: 203.208.228.144)"
echo "This is optional. See neostats.conf for more information"
echo $n " [$BINDIP] -> $c"
read cc
@@ -328,180 +329,142 @@
# [DISCOURAGED] - may cause undesirable side effects if enabled.
##################################################
-##############################
-# IRCd Linking Configuration #
-##############################
+#################################
+# NeoStats Server Configuration #
+#################################
-# PROTOCOL <protocol> [REQUIRED]
-# Specifies the protocol module to use.
-# Valid protocol options are:
-# unreal31 unreal32 ultimate2 ultimate3
-# hybrid7 bahamut14 bahamut18 plexus
-# ircup10 asuka nefarious
-# client
-#
-# PROTOCOL "unreal32"
-#
-
-PROTOCOL "$IRCD"
-
-# DBM <dbm> [OPTIONAL]
-# Specifies the database manager module to use.
-# NeoStats will default to GDBM if this is not provided.
-# Valid options are:
-# gdbm
-#
-# DBM "gdbm"
-#
-#
-#DBM "$DATABASE"
-
-# SERVER_NAME <hostname> [REQUIRED]
+ServerConfig {
+# NAME = "<hostname>" [REQUIRED]
# Specifies the name of the NeoStats Server as it will appear on
# the network. e.g.
#
-# SERVER_NAME stats.neostats.net
+# SERVER_NAME = "stats.neostats.net"
#
# When NeoStats links, it will appear as stats.neostats.net.
+ Name = "$SERVNAME"
-SERVER_NAME $SERVNAME
-
-# SERVER_PORT <port number> [REQUIRED]
-# Specifies the port to connect to on the IRC Server e.g.
-#
-# SERVER_PORT 6667
-#
-# When connecting, NeoStats will connect to port 6667
-
-SERVER_PORT $LINKPORT
-
-# CONNECT_TO <ip address> [REQUIRED]
-# Specifies the IP address to connect to. e.g.
-#
-# CONNECT_TO 127.0.0.1
-#
-# This will force stats to connect to 127.0.0.1
-
-CONNECT_TO $LINKSERVER
-
-# CONNECT_PASS <link password> [REQUIRED]
-# Specifies the password used to connect. This must match your C/N
-# lines in your IRCD configuration e.g.
-#
-# CONNECT_PASS linkpass
-#
-# Send "linkpass" as the password to connect
-
-CONNECT_PASS $LINKPASS
-
-# SERVER_INFOLINE <info line> [REQUIRED]
+# INFO = "<info line>" [REQUIRED]
# Specify the description of the server that
# appears when you do /links e.g.
#
-# SERVER_INFOLINE Network Auxiliary Services
+# INFO "Network Auxiliary Services"
+ Info = "$INFOLINE"
-SERVER_INFOLINE "$INFOLINE"
-
-# SERVER_NUMERIC <numeric> [RECOMMENDED]
-# Specify the numeric of the server to send on connect.
-# This must be a value between 1 and 254, and must not be in use by
-# any other IRC server on the network.
-#
-# SERVER_NUMERIC 1
-
-SERVER_NUMERIC "$SERVNUMERIC"
-
-##########################
-# NeoStats Configuration #
-##########################
-
-# ROOT_NICK <nick> [REQUIRED]
-# Specifies the nick of the NeoStats root bot
-# e.g.
-#
-# ROOT_NICK NeoStats
-#
-# When NeoStats links, it create a root bot with nick NeoStats
-
-ROOT_NICK "$ROOTNICK"
-
-# SERVICE_HOST <nick> [REQUIRED]
-# Specifies the default host of NeoStats service bots
-# e.g.
-#
-# SERVICE_HOST stats.net
-#
-# Service bots will now we [email protected]
-# If not specified NeoStats will default to the server name
-
-#SERVICE_HOST "$SERVICEHOST"
-
-# SERVICES_CHAN #<channel name> [REQUIRED]
+# SERVICECHANNEL="#<channel name>" [REQUIRED]
# Specify the channel that all bots on NeoStats
# will automatically join, and echo out any
# important information e.g.
#
-# SERVICES_CHAN #services
+# SERVICECHANNEL="#services"
#
# Makes NeoStats, and all the other bots join #services channel on
# start-up/load.
+ ServiceChannel = "$NEOCHAN"
-SERVICES_CHAN $NEOCHAN
+# SERVER_NUMERIC = <numeric> [RECOMMENDED]
+# Specify the numeric of the server to send on connect.
+# This must be a value between 1 and 254, and must not be in use by
+# any other IRC server on the network.
+#
+# SERVER_NUMERIC = 1
+ ServerNumeric = $SERVNUMERIC
-# WANT_PRIVMSG [DISCOURAGED]
-# Specify if the bots should send all messages as privmsgs or as
-# notices (Most Services use notice) e.g.
-#
-# WANT_PRIVMSG
+# BINDTO = <ip address or hostname> [OPTIONAL]
+# Make NeoStats bind to a particular IP Address. If not
+# specified NeoStats will attempt to find this address
+# itself. e.g.
#
-# If present, will send all messages as privmsgs (if commented out,
-# it will send as Notices) *NOTE:* This option Violates IRC RFC, and
-# can cause flooding problems on your network. Its NOT recommended.
+# BINDTO 203.203.123.12
+#
+# All outgoing connections from NeoStats will originate from this
+# IP address
+# This IP address should not be localhost (127.0.0.1)
+ BindTo = "$BINDIP"
+
+# PROTOCOL = "<protocol>" [REQUIRED]
+# Specifies the protocol module to use.
+# Valid protocol options are:
+# unreal31 unreal32 ultimate2 ultimate3
+# hybrid7 bahamut14 bahamut18 plexus
+# ircup10 asuka nefarious
+# client
+#
+# PROTOCOL = "unreal32"
+#
+ Protocol = "$IRCD"
+}
+
+#################################
+# NeoStats Option Configuration #
+#################################
-#WANT_PRIVMSG
-# RECONNECT_TIME <seconds> [RECOMMENDED]
+Options {
+# RECONNECTTIME = <seconds> [RECOMMENDED]
# If NeoStats server gets split from the network, how long to wait
# before attempting to reconnect to the network. A value of 0 will
# cause NeoStats to shutdown and not attempt to reconnect. e.g.
#
-# RECONNECT_TIME 10
+# RECONNECTTIME = 10
#
# Specifies wait 10 seconds before trying to reconnect
#
-# RECONNECT_TIME 0
+# RECONNECT_TIME = 0
#
# Tells NeoStats to never reconnect to the network
#
# If not specified, NeoStats will default to 10 seconds.
+ ReconnectTime = $NEOCONN
-RECONNECT_TIME $NEOCONN
+# USEPRIVMSG = <true/false> [DISCOURAGED]
+# Specify if the bots should send all messages as privmsgs or as
+# notices (Most Services use notice) e.g.
+#
+# USEPRIVMSG true
+#
+# If present or set to true, will send all messages as privmsgs (if commented out,
+# it will send as Notices) *NOTE:* This option Violates IRC RFC, and
+# can cause flooding problems on your network. Its NOT recommended.
+ UsePrivmsg = false
-# ONLY_OPERS [OPTIONAL]
+# OPERONLY = <true/false> [OPTIONAL]
# Restrict NeoStats and StatServ to opers use only.
# If not specified, users will have some access to NeoStats
# and StatServ commands. e.g.
#
-# ONLY_OPERS
+# OPERONLY=true
#
# Only opers may use NeoStats and StatServ.
+ OperOnly = false
-#ONLY_OPERS
-
-# BIND_TO [OPTIONAL]
-# Make NeoStats bind to a particular IP Address. If not
-# specified NeoStats will attempt to find this address
-# itself. e.g.
-#
-# BIND_TO 203.203.123.12
+# SERVERSETTIME=<INTERVAL> [OPTIONAL]
+# Cause NeoStats to sync server times at the given interval
+# INTERVAL is an integer representing the number of hours
+#
+# Examples
+#
+# SERVERSETTIME=24
#
-# All outgoing connections from NeoStats will originate from this
-# IP address
-# This IP address should not be localhost (127.0.0.1)
+# Cause NeoStats to sync server times every 24 hours
+# If not present, NeoStats will not sync times.
+# This option only works on servers that support this and
+# defaults to a sync interval of 24 hours. Enabling this
+# option will also cause NeoStats to sync servers when it
+# first joins the network.
+ ServerSettime = 24
-#BIND_TO $BINDIP
+# DatabaseType = "<dbm>" [OPTIONAL]
+# Specifies the database manager module to use.
+# NeoStats will default to GDBM if this is not provided.
+# Valid options are:
+# gdbm
+#
+# DatabaseType = "gdbm"
+#
+#
+ DatabaseType = "$DATABASE"
-# LOG_FILENAME_FORMAT <format> [OPTIONAL]
+# LOGFILENAMEFORMAT = "<format>" [OPTIONAL]
# Defines the format for dated log files. This allows you to choose
# what date format is used for log file names when they are rotated at
# midnight. The option uses the parameters passed to strftime so you
@@ -518,119 +481,176 @@
# Examples using 30 September 2003 as the date:
# For NeoStats0930.log:
#
-# LOG_FILENAME_FORMAT %m%d
+# LOGFILENAMEFORMAT="%m%d"
#
# For NeoStats20030930.log:
#
-# LOG_FILENAME_FORMAT %Y%m%d
+# LOGFILENAMEFORMAT="%Y%m%d"
#
# If not defined, the default is the original NeoStats log format of
# "-%m-%d" i.e. NeoStats-09-30.log
+ #LogFileNameFormat = "$LOGFNAMEFORMAT"
-#LOG_FILENAME_FORMAT $LOGFNAMEFORMAT
+# ROOTNICK = "<nick>" [REQUIRED]
+# Specifies the nick of the NeoStats root bot
+# e.g.
+#
+# ROOTNICK="NeoStats"
+#
+# When NeoStats links, it create a root bot with nick NeoStats
+ RootNick = "$ROOTNICK"
-# SET_SERVER_TIMES <INTERVAL> [OPTIONAL]
-# Cause NeoStats to sync server times at the given interval
-# INTERVAL is an integer representing the number of hours
+# SERVICESHOST = "<hostname>" [REQUIRED]
+# Specifies the default host of NeoStats service bots
+# e.g.
+#
+# SERVICEHOST="stats.net"
+#
+# Service bots will now we [email protected]
+# If not specified NeoStats will default to the server name
+ ServicesHost = "$SERVICEHOST"
+
+# NOLOAD = true [YOU MUST REMOVE THIS]
+# If this is in the neostats.conf your NeoStats WILL NOT START UP. To
+# disable this simply comment this line out. e.g.
#
-# Examples
+# NOLOAD = true <- NeoStats will not load.
#
-# SET_SERVER_TIMES 24
+# #NOLOAD = true <- NeoStats will load.
+#
+# NOLOAD = false <- Neostats will load.
+ NOLOAD = true
+}
+
+##################################
+# NeoStats Linking Configuration #
+##################################
+
+# This section defines the Server that NeoStats will
+# attempt to link to. You must configure this server
+# with the correct C/N and U lines for Neostats
+
+Servers {
+
+# IPADDRESS ="<ip address or hostname>" [REQUIRED]
+# Specifies the IP address to connect to. e.g.
+#
+# IPADDRESS="127.0.0.1"
#
-# Cause NeoStats to sync server times every 24 hours
-# If not present, NeoStats will not sync times.
-# This option only works on servers that support this and
-# defaults to a sync interval of 24 hours. Enabling this
-# option will also cause NeoStats to sync servers when it
-# first joins the network.
+# This will force stats to connect to 127.0.0.1
+ IpAddress = "$LINKSERVER"
+
+# PORT = <port number> [REQUIRED]
+# Specifies the port to connect to on the IRC Server e.g.
+#
+# PORT=6667
+#
+# When connecting, NeoStats will connect to port 6667
+ Port = $LINKPORT
+
+# PASSWORD="<link password>" [REQUIRED]
+# Specifies the password used to connect. This must match your C/N
+# lines in your IRCD configuration e.g.
+#
+# PASSWORD="linkpass"
+#
+# Send "linkpass" as the password to connect
+ Password = "$LINKPASS"
+}
-SET_SERVER_TIMES 24
########################################
-# NeoStats ROOT user #
+# NeoStats Administrator Configuration #
########################################
-#SERVICE_ROOT <nick!ident@host> [REQUIRED]
+
+ServiceRoots {
+#MASK="<nick!ident@host>" [REQUIRED]
# Who should get master access to manage NeoStats regardless of
# authentication systems. Only one entry allowed. e.g.
#
-# SERVICE_ROOT fish!?Fish@*.neostats.net
+# MASK="fish!?Fish@*.neostats.net"
#
# Will give "fish" complete access to NeoStats if fish has
# umode +r and comes from the specified hostname and ident.
+ #Mask = "ircop!*@*"
+}
-#SERVICE_ROOT nick!ident@host
-
-# NO_LOAD [YOU MUST REMOVE THIS]
-# If this is in the neostats.conf your NeoStats WILL NOT START UP. To
-# disable this simply comment this line out. e.g.
-#
-# NO_LOAD <- NeoStats will not load.
-#
-# #NO_LOAD <- NeoStats will load.
-NO_LOAD
+#################################
+# NeoStats Module Configuration #
+#################################
+Modules {
#####################################
# Module Configurations and Loading #
#####################################
-# LOAD_MODULE <module name> [OPTIONAL]
+# MODULENAME = {"<module name>", "<module name>", "<module_name>"} [OPTIONAL]
# What modules to load at start-up. e.g.
#
-# LOAD_MODULE statserv
+# MODULENAME = { "statserv" }
#
-# Will load up StatServ at boot
+# Will load up StatServ only at boot
#
-# Multiple instances of LOAD_MODULE may be specified
+# To specify NeoStats to load multiple modules, place a comma after
+# each module and specify the next one e.g.
+#
+# MODULENAME = { "statserv", "extauth" }
+#
+# will load up both statserv and extauth modules
#
# We have provided example lines for convenience for
# official modules but you must download and install
# external modules before trying to load them.
+MODULENAME = {
+
# StatServ, maintain and report various networks statistics
-#LOAD_MODULE statserv
+# "statserv",
# HostServ, vhost services for users
-#LOAD_MODULE hostserv
+# "hostserv",
# TextServ, text messaging service
-#LOAD_MODULE textserv
+# "textserv",
# ConnectServ, monitor connections to the network: user connections, oper
# modes, server connections and nick changes.
-#LOAD_MODULE connectserv
+# "connectserv",
# Operlog, operator command logging service
-#LOAD_MODULE operlog
+# "operlog",
# IRCdauth, authenticate users based on their user modes.
-#LOAD_MODULE ircdauth
+# "ircdauth"
# Extauth, authenticate users based on nick!user@host access lists
-#LOAD_MODULE extauth
+# "extauth"
# SecureServ. You must download and install SecureServ first.
-#LOAD_MODULE secureserv
+# "secureserv",
# OPSB. You must download and install OPSB first.
-#LOAD_MODULE opsb
+# "opsb",
# LogServ. You must download and install LogServ first.
-#LOAD_MODULE logserv
+# "logserv",
# TriviaServ. You must download and install TriviaServ first.
-#LOAD_MODULE triviaserv
+# "triviaserv",
# WarServ. You must download and install WarServ first.
-#LOAD_MODULE warserv
+# "warserv",
# GameServ. You must download and install GameServ first.
-#LOAD_MODULE gameserv
+# "gameserv",
# YahzteeServ. You must download and install YahzteeServ first.
-#LOAD_MODULE yahtzeeserv
+# "yahtzeeserv",
+}
+}
###############################################################################
## End of Configuration ##
###############################################################################
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Jun 21 19:44:37 2005
@@ -3,7 +3,7 @@
bin_PROGRAMS = neostats
neostats_SOURCES = auth.c bans.c bots.c channels.c commands.c confuse.c confuselexer.c nsdba.c \
- dotconf.c conf.c dl.c dns.c exclude.c hash.c ircstring.c \
+ conf.c dl.c dns.c exclude.c hash.c ircstring.c \
ircprotocol.c ircsend.c ircrecv.c \
lang.c list.c log.c main.c match.c misc.c modules.c \
helpstrings.c servers.c services.c signals.c sock.c support.c \
Modified: trunk/src/Makefile.in
==============================================================================
--- trunk/src/Makefile.in (original)
+++ trunk/src/Makefile.in Tue Jun 21 19:44:37 2005
@@ -59,22 +59,21 @@
PROGRAMS = $(bin_PROGRAMS)
am_neostats_OBJECTS = auth.$(OBJEXT) bans.$(OBJEXT) bots.$(OBJEXT) \
channels.$(OBJEXT) commands.$(OBJEXT) confuse.$(OBJEXT) \
- confuselexer.$(OBJEXT) nsdba.$(OBJEXT) dotconf.$(OBJEXT) \
- conf.$(OBJEXT) dl.$(OBJEXT) dns.$(OBJEXT) exclude.$(OBJEXT) \
- hash.$(OBJEXT) ircstring.$(OBJEXT) ircprotocol.$(OBJEXT) \
- ircsend.$(OBJEXT) ircrecv.$(OBJEXT) lang.$(OBJEXT) \
- list.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) match.$(OBJEXT) \
- misc.$(OBJEXT) modules.$(OBJEXT) helpstrings.$(OBJEXT) \
- servers.$(OBJEXT) services.$(OBJEXT) signals.$(OBJEXT) \
- sock.$(OBJEXT) support.$(OBJEXT) timer.$(OBJEXT) \
- transfer.$(OBJEXT) users.$(OBJEXT) modes.$(OBJEXT) \
- ctcp.$(OBJEXT) dcc.$(OBJEXT) nsmemory.$(OBJEXT) \
- base64.$(OBJEXT) numerics.$(OBJEXT) settings.$(OBJEXT) \
- botinfo.$(OBJEXT) adnscheck.$(OBJEXT) adnsevent.$(OBJEXT) \
- adnsgeneral.$(OBJEXT) adnsparse.$(OBJEXT) adnsquery.$(OBJEXT) \
- adnsreply.$(OBJEXT) adnssetup.$(OBJEXT) adnstransmit.$(OBJEXT) \
- adnstypes.$(OBJEXT) oscalls.$(OBJEXT) ossocket.$(OBJEXT) \
- osfile.$(OBJEXT) updates.$(OBJEXT)
+ confuselexer.$(OBJEXT) nsdba.$(OBJEXT) conf.$(OBJEXT) \
+ dl.$(OBJEXT) dns.$(OBJEXT) exclude.$(OBJEXT) hash.$(OBJEXT) \
+ ircstring.$(OBJEXT) ircprotocol.$(OBJEXT) ircsend.$(OBJEXT) \
+ ircrecv.$(OBJEXT) lang.$(OBJEXT) list.$(OBJEXT) log.$(OBJEXT) \
+ main.$(OBJEXT) match.$(OBJEXT) misc.$(OBJEXT) \
+ modules.$(OBJEXT) helpstrings.$(OBJEXT) servers.$(OBJEXT) \
+ services.$(OBJEXT) signals.$(OBJEXT) sock.$(OBJEXT) \
+ support.$(OBJEXT) timer.$(OBJEXT) transfer.$(OBJEXT) \
+ users.$(OBJEXT) modes.$(OBJEXT) ctcp.$(OBJEXT) dcc.$(OBJEXT) \
+ nsmemory.$(OBJEXT) base64.$(OBJEXT) numerics.$(OBJEXT) \
+ settings.$(OBJEXT) botinfo.$(OBJEXT) adnscheck.$(OBJEXT) \
+ adnsevent.$(OBJEXT) adnsgeneral.$(OBJEXT) adnsparse.$(OBJEXT) \
+ adnsquery.$(OBJEXT) adnsreply.$(OBJEXT) adnssetup.$(OBJEXT) \
+ adnstransmit.$(OBJEXT) adnstypes.$(OBJEXT) oscalls.$(OBJEXT) \
+ ossocket.$(OBJEXT) osfile.$(OBJEXT) updates.$(OBJEXT)
neostats_OBJECTS = $(am_neostats_OBJECTS)
neostats_DEPENDENCIES = $(top_srcdir)/lib/event/libevent.a
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
@@ -223,7 +222,7 @@
wi_PWD = @wi_PWD@
SUBDIRS = dbm protocol
neostats_SOURCES = auth.c bans.c bots.c channels.c commands.c confuse.c confuselexer.c nsdba.c \
- dotconf.c conf.c dl.c dns.c exclude.c hash.c ircstring.c \
+ conf.c dl.c dns.c exclude.c hash.c ircstring.c \
ircprotocol.c ircsend.c ircrecv.c \
lang.c list.c log.c main.c match.c misc.c modules.c \
helpstrings.c servers.c services.c signals.c sock.c support.c \
@@ -325,7 +324,6 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dcc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dotconf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helpstrings.Po@am__quote@
Modified: trunk/src/conf.c
==============================================================================
--- trunk/src/conf.c (original)
+++ trunk/src/conf.c Tue Jun 21 19:44:37 2005
@@ -23,14 +23,9 @@
** $Id$
*/
-/* #define USE_CONFUSE */
#include "neostats.h"
-#ifdef USE_CONFUSE
#include "confuse.h"
-#else
-#include "dotconf.h"
-#endif
#include "conf.h"
#include "log.h"
#include "services.h"
@@ -38,28 +33,26 @@
#define CONFIG_NAME "neostats.conf"
-static void cb_Server( char *arg, int configtype );
-static void cb_Module( char *arg, int configtype );
/** @brief The list of modules to load
*/
static void *load_mods[NUM_MODULES];
-#ifdef USE_CONFUSE
-static void set_config_values(cfg_t *cfg);
-int cb_verify_chan(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_numeric(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_bind(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_file(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_log(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_mask(cfg_t *cfg, cfg_opt_t *opt);
-int cb_noload(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_host(cfg_t *cfg, cfg_opt_t *opt);
-int cb_verify_settime(cfg_t *cfg, cfg_opt_t *opt);
+static void cb_Module (char *arg);
+static void set_config_values (cfg_t * cfg);
+int cb_verify_chan (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_numeric (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_bind (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_file (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_log (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_mask (cfg_t * cfg, cfg_opt_t * opt);
+int cb_noload (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_host (cfg_t * cfg, cfg_opt_t * opt);
+int cb_verify_settime (cfg_t * cfg, cfg_opt_t * opt);
typedef struct validate_args {
- char name[BUFSIZE];
- cfg_validate_callback_t cb;
+ char name[BUFSIZE];
+ cfg_validate_callback_t cb;
} validate_args;
/** @brief Core Configuration Items
@@ -68,65 +61,68 @@
*/
cfg_opt_t server_details[] = {
- CFG_STR("Name", "neostats.nonetwork.org", CFGF_NONE),
- CFG_STR("Info", "NeoStats 3.0 Services", CFGF_NONE),
- CFG_STR("ServiceChannel", "#services", CFGF_NONE),
- CFG_INT("UnrealNumeric", 123, CFGF_NONE),
- CFG_STR("BindTo", 0, CFGF_NONE),
- CFG_STR("Protocol", "unreal32", CFGF_NONE)
+ CFG_STR ("Name", "neostats.nonetwork.org", CFGF_NONE),
+ CFG_STR ("Info", "NeoStats 3.0 Services", CFGF_NONE),
+ CFG_STR ("ServiceChannel", "#services", CFGF_NONE),
+ CFG_INT ("ServerNumeric", 123, CFGF_NONE),
+ CFG_STR ("BindTo", 0, CFGF_NONE),
+ CFG_STR ("Protocol", "unreal32", CFGF_NONE)
};
cfg_opt_t options[] = {
- CFG_INT("ReconnectTime", 10, CFGF_NONE),
- CFG_BOOL("UsePrivmsg", cfg_false, CFGF_NONE),
- CFG_BOOL("OperOnly", cfg_false, CFGF_NONE),
- CFG_INT("UnrealSettime", 1, CFGF_NONE),
- CFG_STR("DatabaseType", "gdbm", CFGF_NONE),
- CFG_STR("LogFileNameFormat", "-%m-%d", CFGF_NONE),
- CFG_STR("RootNick", "NeoStats", CFGF_NONE),
- CFG_STR("ServicesHost", "services.neostats.net", CFGF_NONE),
- CFG_BOOL("NOLOAD", cfg_true, CFGF_NONE)
+ CFG_INT ("ReconnectTime", 10, CFGF_NONE),
+ CFG_BOOL ("UsePrivmsg", cfg_false, CFGF_NONE),
+ CFG_BOOL ("OperOnly", cfg_false, CFGF_NONE),
+ CFG_INT ("ServerSettime", 1, CFGF_NONE),
+ CFG_STR ("DatabaseType", "gdbm", CFGF_NONE),
+ CFG_STR ("LogFileNameFormat", "-%m-%d", CFGF_NONE),
+ CFG_STR ("RootNick", "NeoStats", CFGF_NONE),
+ CFG_STR ("ServicesHost", "services.neostats.net", CFGF_NONE),
+ CFG_BOOL ("NOLOAD", cfg_true, CFGF_NONE)
};
cfg_opt_t servers[] = {
- CFG_STR("IpAddress", 0, CFGF_NONE),
- CFG_INT("Port", 6667, CFGF_NONE),
- CFG_STR("Password", 0, CFGF_NONE)
+ CFG_STR ("IpAddress", 0, CFGF_NONE),
+ CFG_INT ("Port", 6667, CFGF_NONE),
+ CFG_STR ("Password", 0, CFGF_NONE)
};
cfg_opt_t serviceroots[] = {
- CFG_STR("Mask", 0, CFGF_NONE)
+ CFG_STR ("Mask", 0, CFGF_NONE)
};
cfg_opt_t modules[] = {
- CFG_STR("Name", 0, CFGF_MULTI)
+ CFG_STR_LIST ("ModuleName", 0, CFGF_NONE)
};
cfg_opt_t fileconfig[] = {
- CFG_SEC("ServerConfig", server_details, CFGF_NONE),
- CFG_SEC("Options", options, CFGF_NONE),
+ CFG_SEC ("ServerConfig", server_details, CFGF_NONE),
+ CFG_SEC ("Options", options, CFGF_NONE),
+/* XXX do we want to specify backup linking servers? */
#if 0
- CFG_SEC("Servers", servers, CFGF_MULTI | CFGF_TITLE),
- CFG_SEC("ServiceRoots", serviceroots, CFGF_MULTI | CFGF_TITLE),
+ CFG_SEC ("Servers", servers, CFGF_MULTI | CFGF_TITLE),
+/* Multiple Service Roots? Only usefull if extauth is loaded */
+ CFG_SEC ("ServiceRoots", serviceroots, CFGF_MULTI | CFGF_TITLE),
#endif
- CFG_SEC("Servers", servers, CFGF_NONE),
- CFG_SEC("ServiceRoots", serviceroots, CFGF_NONE),
- CFG_SEC("Modules", modules, CFGF_NONE)
+ CFG_SEC ("Servers", servers, CFGF_NONE),
+ CFG_SEC ("ServiceRoots", serviceroots, CFGF_NONE),
+ CFG_SEC ("Modules", modules, CFGF_NONE)
};
validate_args arg_validate[] = {
- {"ServerConfig|ServiceChannel", &cb_verify_chan },
- {"ServerConfig|UnrealNumeric", &cb_verify_numeric },
- {"ServerConfig|BindTo", &cb_verify_bind },
- {"ServerConfig|Protocol", &cb_verify_file },
- {"Options|UnrealSettime", &cb_verify_settime },
- {"Options|DataBaseType", &cb_verify_file },
- {"Options|LogFileNameFormat", &cb_verify_log },
- {"Options|RootNick", &cb_verify_mask },
- {"Options|NOLOAD", &cb_noload },
- {"Servers|IpAddress", &cb_verify_host },
- {"ServiceRoots|Mask", &cb_verify_mask },
- {"Modules|Name", &cb_verify_file}
+ {"ServerConfig|Name", &cb_verify_host},
+ {"ServerConfig|ServiceChannel", &cb_verify_chan},
+ {"ServerConfig|ServerNumeric", &cb_verify_numeric},
+ {"ServerConfig|BindTo", &cb_verify_bind},
+ {"ServerConfig|Protocol", &cb_verify_file},
+ {"Options|ServerSettime", &cb_verify_settime},
+ {"Options|DataBaseType", &cb_verify_file},
+ {"Options|LogFileNameFormat", &cb_verify_log},
+ {"Options|RootNick", &cb_verify_mask},
+ {"Options|NOLOAD", &cb_noload},
+ {"Servers|IpAddress", &cb_verify_host},
+ {"ServiceRoots|Mask", &cb_verify_mask},
+ {"Modules|ModuleName", &cb_verify_file}
};
/** @brief Load configuration file
@@ -136,124 +132,146 @@
* @returns nothing
*/
-int ConfLoad( void )
+int
+ConfLoad (void)
{
- cfg_t *cfg;
- int i, ret;
+ cfg_t *cfg;
+ int i, ret;
+#if 0
FILE *fp;
-
+#endif
/* Read in the Config File */
- printf( "Reading the Config File. Please wait.....\n" );
- cfg = cfg_init(fileconfig, CFGF_NOCASE);
- for ( i = 0; i < arraylen(arg_validate); i++) {
-printf("%d %s\n", i, arg_validate[i].name);
- cfg_set_validate_func(cfg, arg_validate[i].name, arg_validate[i].cb);
- }
- fp = fopen("neostats.conf.out", "wt");
- cfg_print(cfg, fp);
- fclose(fp);
- if((ret = cfg_parse(cfg, CONFIG_NAME)) != 0 ) {
- printf( "***************************************************\n" );
- printf( "* Error! *\n" );
- printf( "* *\n" );
- switch (ret) {
- case CFG_FILE_ERROR:
- printf( "* Config file not found *\n" );
- break;
- case CFG_PARSE_ERROR:
- printf( "* Config Parse Error *\n" );
- break;
- default:
- printf( "* Uknown Error *\n" );
- break;
- }
- printf( "* *\n" );
- printf( "* NeoStats NOT Started *\n" );
- printf( "***************************************************\n" );
- cfg_free(cfg);
+ printf ("Reading the Config File. Please wait.....\n");
+ cfg = cfg_init (fileconfig, CFGF_NOCASE);
+ for (i = 0; i < arraylen (arg_validate); i++) {
+ cfg_set_validate_func (cfg, arg_validate[i].name, arg_validate[i].cb);
+ }
+#if 0
+ fp = fopen ("neostats.conf.out", "wt");
+ cfg_print (cfg, fp);
+ fclose (fp);
+#endif
+ if ((ret = cfg_parse (cfg, CONFIG_NAME)) != 0) {
+ printf ("***************************************************\n");
+ printf ("* Error! *\n");
+ printf ("* *\n");
+ switch (ret) {
+ case CFG_FILE_ERROR:
+ printf ("* Config file not found *\n");
+ break;
+ case CFG_PARSE_ERROR:
+ printf ("* Config Parse Error *\n");
+ break;
+ default:
+ printf ("* Uknown Error *\n");
+ break;
+ }
+ printf ("* *\n");
+ printf ("* NeoStats NOT Started *\n");
+ printf ("***************************************************\n");
+ cfg_free (cfg);
return NS_FAILURE;
}
- if( nsconfig.die ) {
- printf( "\n-----> ERROR: Read the README file then edit %s <-----\n\n",CONFIG_NAME );
- nlog( LOG_CRITICAL, "Read the README file then edit %s",CONFIG_NAME );
- cfg_free(cfg);
+ if (nsconfig.die) {
+ printf ("\n-----> ERROR: Read the README file then edit %s <-----\n\n", CONFIG_NAME);
+ nlog (LOG_CRITICAL, "Read the README file then edit %s", CONFIG_NAME);
+ cfg_free (cfg);
return NS_FAILURE;
}
- if( nsconfig.error ) {
- printf( "\n-----> CONFIG ERROR: Check log file for more information then edit %s <-----\n\n",CONFIG_NAME );
- nlog( LOG_CRITICAL, "CONFIG ERROR: Check log file for more information then edit %s",CONFIG_NAME );
- cfg_free(cfg);
+ if (nsconfig.error) {
+ printf ("\n-----> CONFIG ERROR: Check log file for more information then edit %s <-----\n\n", CONFIG_NAME);
+ nlog (LOG_CRITICAL, "CONFIG ERROR: Check log file for more information then edit %s", CONFIG_NAME);
+ cfg_free (cfg);
return NS_FAILURE;
}
- printf( "Sucessfully loaded config file, booting NeoStats\n" );
- set_config_values(cfg);
- cfg_free(cfg);
+ printf ("-----------------------------------------------\n");
+ set_config_values (cfg);
+ cfg_free (cfg);
+ printf ("Sucessfully loaded config file, booting NeoStats\n");
+ printf ("If NeoStats does not connect, please check logs/neostats-<date>.log for further information\n");
return NS_SUCCESS;
}
-void set_config_values(cfg_t *cfg) {
- /* Server name has a default*/
-printf("hello\n");
- strlcpy( me.name, cfg_getstr(cfg, "ServerConfig|Name"), sizeof( me.name ) );
-printf("ehh\n");
- /* Server Port has a default*/
- me.port = cfg_getint(cfg, "Servers|Port");
- /* Connect To */
- if (cfg_size(cfg, "Servers|IpAddress") > 0) {
- strlcpy( me.uplink, cfg_getstr(cfg,"Servers|IpAddress"), sizeof( me.uplink ) );
- } else {
- printf("no server\n");
- exit(-1);
- }
- if (cfg_size(cfg, "Servers|Password")> 0) {
- /* Connect Pass */
- strlcpy( nsconfig.pass, cfg_getstr(cfg,"Servers|Password"), sizeof( nsconfig.pass ) );
- } else {
- exit(-1);
- }
- /* Server InfoLine has a default*/
- strlcpy( me.infoline, cfg_getstr(cfg,"ServerConfig|Info"), sizeof( me.infoline ) );
- /* Service host has a default*/
- strlcpy( me.servicehost, cfg_getstr(cfg,"Options|ServicesHost"), sizeof( me.servicehost ) );
- /* Reconnect time has a default*/
- nsconfig.r_time = cfg_getint(cfg, "Options|ReconnectTime");
- /* want privmsg has a default */
- nsconfig.want_privmsg = cfg_getbool(cfg, "Options|UsePrivMsg");
- /* service chan has a default */
- strlcpy( me.serviceschan, cfg_getstr(cfg, "ServerConfig|ServiceChannel"), sizeof( me.serviceschan ) );
- /* only opers has a default */
- nsconfig.onlyopers = cfg_getbool(cfg, "Options|OperOnly");
- /* vhost has no default, nor is it required */
- if (cfg_size(cfg, "ServerConfig|BindTo") > 0) {
- strlcpy( me.local, cfg_getstr(cfg, "ServerConfig|BindTo"), sizeof( me.local ) );
- }
- /* LogFile Format has a default */
- strlcpy(LogFileNameFormat,cfg_getstr(cfg, "Options|LogFileNameFormat"),MAX_LOGFILENAME );
- /* numeric has a default */
- me.numeric = cfg_getint(cfg, "ServerConfig|UnrealNumeric");
- /* has a default */
- nsconfig.setservertimes = cfg_getint(cfg, "Options|UnrealSettime") * 60 * 60;
- if (cfg_size(cfg, "ServiceRoots|Mask") > 0) {
- char *nick;
- char *user;
- char *host;
- char *arg;
- /* already validate */
- arg = cfg_getstr(cfg, "ServiceRoots|Mask");
- nick = strtok(arg, "!" );
- user = strtok(NULL, "@" );
- host = strtok(NULL, "" );
- strlcpy(nsconfig.rootuser.nick, nick, MAXNICK );
- strlcpy(nsconfig.rootuser.user, user, MAXUSER );
- strlcpy(nsconfig.rootuser.host, host, MAXHOST );
- nsconfig.rootuser.level = NS_ULEVEL_ROOT;
- }
- /* protocol is required */
- strlcpy(me.protocol,cfg_getstr(cfg, "ServerConfig|Protocol"),MAXHOST );
- /* dbm has a default */
- strlcpy(me.dbm,cfg_getstr(cfg, "Options|DataBaseType"),MAXHOST );
- /* has a default */
- strlcpy(me.rootnick,cfg_getstr(cfg, "Options|RootNick"),MAXNICK );
+void
+set_config_values (cfg_t * cfg)
+{
+ int i;
+ /* Server name has a default */
+ strlcpy (me.name, cfg_getstr (cfg, "ServerConfig|Name"), sizeof (me.name));
+
+ /* Server Port has a default */
+ me.port = cfg_getint (cfg, "Servers|Port");
+ /* Connect To */
+ if (cfg_size (cfg, "Servers|IpAddress") > 0) {
+ strlcpy (me.uplink, cfg_getstr (cfg, "Servers|IpAddress"), sizeof (me.uplink));
+ } else {
+ printf ("ERROR: No Server was configured for Linking. Please fix this\n");
+ exit (-1);
+ }
+ if (cfg_size (cfg, "Servers|Password") > 0) {
+ /* Connect Pass */
+ strlcpy (nsconfig.pass, cfg_getstr (cfg, "Servers|Password"), sizeof (nsconfig.pass));
+ } else {
+ printf ("ERROR: No Password was specified for Linking. Please fix this\n");
+ exit (-1);
+ }
+ printf("NeoStats ServerName: %s\n", me.name);
+ printf("Connecting To: %s:%d\n", me.uplink, me.port);
+ /* Server InfoLine has a default */
+ strlcpy (me.infoline, cfg_getstr (cfg, "ServerConfig|Info"), sizeof (me.infoline));
+ /* Service host has a default */
+ strlcpy (me.servicehost, cfg_getstr (cfg, "Options|ServicesHost"), sizeof (me.servicehost));
+ /* Reconnect time has a default */
+ nsconfig.r_time = cfg_getint (cfg, "Options|ReconnectTime");
+ /* want privmsg has a default */
+ nsconfig.want_privmsg = cfg_getbool (cfg, "Options|UsePrivMsg");
+ /* service chan has a default */
+ strlcpy (me.serviceschan, cfg_getstr (cfg, "ServerConfig|ServiceChannel"), sizeof (me.serviceschan));
+ /* only opers has a default */
+ nsconfig.onlyopers = cfg_getbool (cfg, "Options|OperOnly");
+ /* vhost has no default, nor is it required */
+ if (cfg_size (cfg, "ServerConfig|BindTo") > 1) {
+ strlcpy (me.local, cfg_getstr (cfg, "ServerConfig|BindTo"), sizeof (me.local));
+ printf("Source IP: %s\n", me.local);
+ }
+ /* LogFile Format has a default */
+ strlcpy (LogFileNameFormat, cfg_getstr (cfg, "Options|LogFileNameFormat"), MAX_LOGFILENAME);
+ /* numeric has a default */
+ me.numeric = cfg_getint (cfg, "ServerConfig|ServerNumeric");
+ /* has a default */
+ nsconfig.setservertimes = cfg_getint (cfg, "Options|ServerSettime") * 60 * 60;
+ /* serviceroots has no default */
+ if (cfg_size (cfg, "ServiceRoots|Mask") > 0) {
+ char *nick;
+ char *user;
+ char *host;
+ char *arg;
+ /* already validate */
+ arg = cfg_getstr (cfg, "ServiceRoots|Mask");
+ nick = strtok (arg, "!");
+ user = strtok (NULL, "@");
+ host = strtok (NULL, "");
+ strlcpy (nsconfig.rootuser.nick, nick, MAXNICK);
+ strlcpy (nsconfig.rootuser.user, user, MAXUSER);
+ strlcpy (nsconfig.rootuser.host, host, MAXHOST);
+/* nsconfig.rootuser.level = NS_ULEVEL_ROOT; */
+ printf("ServiceRoot: %s!%s@%s\n", nsconfig.rootuser.nick, nsconfig.rootuser.user, nsconfig.rootuser.host);
+ } else {
+ printf("\nWARNING: No ServiceRoot Entry Defined\n\n");
+ }
+ /* protocol is required, but defaults to unreal32 */
+ strlcpy (me.protocol, cfg_getstr (cfg, "ServerConfig|Protocol"), MAXHOST);
+ /* dbm has a default */
+ strlcpy (me.dbm, cfg_getstr (cfg, "Options|DataBaseType"), MAXHOST);
+ /* has a default */
+ strlcpy (me.rootnick, cfg_getstr (cfg, "Options|RootNick"), MAXNICK);
+ /* now load the modules */
+ printf("Modules Loaded:\n");
+ for (i = 0; i < cfg_size(cfg, "Modules|ModuleName"); i++) {
+ cb_Module(cfg_getnstr(cfg, "Modules|ModuleName", i));
+ printf(" %s\n", cfg_getnstr(cfg, "Modules|ModuleName", i));
+ }
+ printf ("-----------------------------------------------\n");
}
@@ -266,292 +284,177 @@
* @bugs if a single module fails to load, it stops trying to load any other modules
*/
-int ConfLoadModules( void )
+int
+ConfLoadModules (void)
{
-#if 0
int i;
- SET_SEGV_LOCATION( );
- if(load_mods[0] == 0 ) {
- nlog( LOG_NORMAL, "No modules configured for loading" );
+ SET_SEGV_LOCATION ();
+ if (load_mods[0] == 0) {
+ nlog (LOG_NORMAL, "No modules configured for loading");
} else {
- nlog( LOG_NORMAL, "Loading configured modules" );
- for( i = 0;( i < NUM_MODULES ) &&( load_mods[i] != 0 ); i++ ) {
- dlog(DEBUG1, "ConfLoadModules: Loading Module %s",( char * )load_mods[i] );
- if( load_module( load_mods[i], NULL ) ) {
- nlog( LOG_NORMAL, "Loaded module %s",( char * )load_mods[i] );
+ nlog (LOG_NORMAL, "Loading configured modules");
+ for (i = 0; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
+ dlog (DEBUG1, "ConfLoadModules: Loading Module %s", (char *) load_mods[i]);
+ if (load_module (load_mods[i], NULL)) {
+ nlog (LOG_NORMAL, "Loaded module %s", (char *) load_mods[i]);
} else {
- nlog( LOG_WARNING, "Failed to load module %s. Please check above error messages",( char * )load_mods[i] );
+ nlog (LOG_WARNING, "Failed to load module %s. Please check above error messages", (char *) load_mods[i]);
}
- ns_free(load_mods[i] );
+ ns_free (load_mods[i]);
}
- nlog( LOG_NORMAL, "Completed loading configured modules" );
+ nlog (LOG_NORMAL, "Completed loading configured modules");
}
-#endif
return NS_SUCCESS;
}
-int cb_verify_chan(cfg_t *cfg, cfg_opt_t *opt) {
+int
+cb_verify_chan (cfg_t * cfg, cfg_opt_t * opt)
+{
- if (ValidateChannel(opt->values[0]->string) == NS_FAILURE) {
- cfg_error(cfg, "Invalid Channel Name %s for Option %s", opt->values[0]->string, opt->name);
- return CFG_PARSE_ERROR;
- }
- return CFG_SUCCESS;
-}
-int cb_verify_numeric(cfg_t *cfg, cfg_opt_t *opt) {
- long int num = opt->values[0]->number;
- /* limit value - really need to print error and quit */
- if((num<=0) || (num>254)) {
- cfg_error(cfg, "Numeric Value %d is out of Range for %s", num, opt->name);
- return CFG_PARSE_ERROR;
- }
- return CFG_SUCCESS;
-}
-int cb_verify_bind(cfg_t *cfg, cfg_opt_t *opt) {
- return CFG_SUCCESS;
-}
-int cb_verify_file(cfg_t *cfg, cfg_opt_t *opt) {
- return CFG_SUCCESS;
-}
-int cb_verify_log(cfg_t *cfg, cfg_opt_t *opt) {
- return CFG_SUCCESS;
-}
-int cb_verify_mask(cfg_t *cfg, cfg_opt_t *opt) {
- char *value = opt->values[0]->string;
- if( strstr(value, "!" )&& !strstr(value, "@" ) ) {
- cfg_error(cfg, "Invalid HostMask %s for %s", value, opt->name);
- return CFG_PARSE_ERROR;
- }
- return CFG_SUCCESS;
-}
-int cb_noload(cfg_t *cfg, cfg_opt_t *opt) {
- if (opt->values[0]->boolean == cfg_true) {
- cfg_error(cfg, "Error. You didn't edit NeoStats.conf");
- return CFG_PARSE_ERROR;
- }
- return CFG_SUCCESS;
-}
-int cb_verify_host(cfg_t *cfg, cfg_opt_t *opt) {
- return CFG_SUCCESS;
-}
-int cb_verify_settime(cfg_t *cfg, cfg_opt_t *opt) {
- long int time = opt->values[0]->number;
-
- if (time <= 0) {
- cfg_error(cfg, "SetTime Value of %d is out of range for %s", time, opt->name);
- return CFG_PARSE_ERROR;
- }
- return CFG_SUCCESS;
-}
-
-
-#else /* USE_CONFUSE */
-
-static config_option options[] = {
- {"SERVER_NAME", ARG_STR, cb_Server, 0},
- {"SERVER_PORT", ARG_STR, cb_Server, 1},
- {"CONNECT_TO", ARG_STR, cb_Server, 2},
- {"CONNECT_PASS", ARG_STR, cb_Server, 3},
- {"SERVER_INFOLINE", ARG_STR, cb_Server, 4},
- {"SERVICE_HOST", ARG_STR, cb_Server, 5},
- {"RECONNECT_TIME", ARG_STR, cb_Server, 6},
- {"WANT_PRIVMSG", ARG_STR, cb_Server, 9},
- {"SERVICES_CHAN", ARG_STR, cb_Server, 10},
- {"LOAD_MODULE", ARG_STR, cb_Module, 0},
- {"ONLY_OPERS", ARG_STR, cb_Server, 11},
- {"NO_LOAD", ARG_STR, cb_Server, 12},
- {"BIND_TO", ARG_STR, cb_Server, 13},
- {"LOG_FILENAME_FORMAT", ARG_STR, cb_Server, 14},
- {"SERVER_NUMERIC", ARG_STR, cb_Server, 15},
- {"SET_SERVER_TIMES", ARG_STR, cb_Server, 16},
- {"SERVICE_ROOT", ARG_STR, cb_Server, 17},
- {"PROTOCOL", ARG_STR, cb_Server, 18},
- {"DBM", ARG_STR, cb_Server, 19},
- {"ROOT_NICK", ARG_STR, cb_Server, 20},
-};
+ if (ValidateChannel (opt->values[0]->string) == NS_FAILURE) {
+ cfg_error (cfg, "Invalid Channel Name %s for Option %s", opt->values[0]->string, opt->name);
+ return CFG_PARSE_ERROR;
+ }
+ return CFG_SUCCESS;
+}
-/** @brief Load configuration file
- *
- * Parses the configuration file
- *
- * @returns nothing
- */
+int
+cb_verify_numeric (cfg_t * cfg, cfg_opt_t * opt)
+{
+ long int num = opt->values[0]->number;
+ /* limit value - really need to print error and quit */
+ if ((num <= 0) || (num > 254)) {
+ cfg_error (cfg, "Numeric Value %d is out of Range for %s", num, opt->name);
+ return CFG_PARSE_ERROR;
+ }
+ return CFG_SUCCESS;
+}
-int ConfLoad( void )
+int
+cb_verify_bind (cfg_t * cfg, cfg_opt_t * opt)
{
- /* Read in the Config File */
- printf( "Reading the Config File %s. Please wait.....\n", CONFIG_NAME);
- if( config_read( CONFIG_NAME, options ) != 0 ) {
- printf( "***************************************************\n" );
- printf( "* Error! *\n" );
- printf( "* *\n" );
- printf( "* Config file not found, or unable to open. Check *\n" );
- printf( "* its location and permissions and try again. *\n" );
- printf( "* *\n" );
- printf( "* NeoStats NOT Started *\n" );
- printf( "***************************************************\n" );
- return NS_FAILURE;
+ OS_SOCKET s;
+ struct hostent *hp;
+ /* test if we can bind */
+ s = os_sock_socket(AF_INET, SOCK_STREAM, 0);
+ if (s == INVALID_SOCKET) {
+ cfg_error(cfg, "Error Testing Bind Setting.");
+ return CFG_PARSE_ERROR;
}
- if( nsconfig.die ) {
- printf( "\n-----> ERROR: Read the README file then edit %s <-----\n\n",CONFIG_NAME );
- nlog( LOG_CRITICAL, "Read the README file then edit %s",CONFIG_NAME );
- return NS_FAILURE;
+ os_memset(&me.lsa, 0, sizeof(me.lsa));
+ if ((hp = gethostbyname(opt->values[0]->string)) == NULL) {
+ cfg_error(cfg, "Unable to Bind to Address %s for Option %s: %s", opt->values[0]->string, opt->name, strerror(errno));
+ return CFG_PARSE_ERROR;
+ } else {
+ os_memcpy((char *)&me.lsa.sin_addr, hp->h_addr, hp->h_length);
+ me.lsa.sin_family = hp->h_addrtype;
+ if (os_sock_bind(s, (struct sockaddr *) &me.lsa, sizeof(me.lsa)) == SOCKET_ERROR) {
+ cfg_error(cfg, "Unable to Bind to Address %s for Option %s: %s", opt->values[0]->string, opt->name, os_sock_getlasterrorstring());
+ return CFG_PARSE_ERROR;
+ }
+ /* if we get here, the socket is ok*/
+ os_close(s);
+/* ns_free(hp); */
+ me.dobind = 1;
}
- if( nsconfig.error ) {
- printf( "\n-----> CONFIG ERROR: Check log file for more information then edit %s <-----\n\n",CONFIG_NAME );
- nlog( LOG_CRITICAL, "CONFIG ERROR: Check log file for more information then edit %s",CONFIG_NAME );
- return NS_FAILURE;
+
+ return CFG_SUCCESS;
+}
+
+int
+cb_verify_file (cfg_t * cfg, cfg_opt_t * opt)
+{
+ char *file = opt->values[0]->string;
+ char buf2[MAXPATH];
+ struct stat buf;
+ ircsnprintf(buf2, MAXPATH, "%s/%s.so", MOD_PATH, file);
+ if (stat(buf2, &buf) == -1) {
+ cfg_error(cfg, "File %s Specified in Option %s is Invalid: %s", buf2, opt->name, strerror(errno));
+ return CFG_PARSE_ERROR;
}
- printf( "Sucessfully loaded config file, booting NeoStats\n" );
- return NS_SUCCESS;
+ if (!S_ISREG(buf.st_mode)) {
+ cfg_error(cfg, "File %s Specified in Option %s is Invalid: Not a Regular File", buf2, opt->name);
+ return CFG_PARSE_ERROR;
+ }
+ return CFG_SUCCESS;
}
+int
+cb_verify_log (cfg_t * cfg, cfg_opt_t * opt)
+{
+ return CFG_SUCCESS;
+}
-/** @brief prepare Modules defined in the config file
- *
- * When the config file encounters directives to Load Modules, it calls this function which prepares to load the modules( but doesn't actually load them )
- *
- * @param arg the module name in this case
- * @param configtype an index of what config item is currently being processed. Ignored
- * @returns Nothing
- */
-void
-cb_Module( char *arg, int configtype )
+int
+cb_verify_mask (cfg_t * cfg, cfg_opt_t * opt)
{
- int i;
+ char *value = opt->values[0]->string;
+ if (strstr (value, "!") && !strstr (value, "@")) {
+ cfg_error (cfg, "Invalid HostMask %s for %s", value, opt->name);
+ return CFG_PARSE_ERROR;
+ }
+ return CFG_SUCCESS;
+}
- SET_SEGV_LOCATION( );
- if( !nsconfig.modnoload ) {
- for( i = 0;( i < NUM_MODULES ) &&( load_mods[i] != 0 ); i++ ) {
- if( !ircstrcasecmp( load_mods[i], arg ) ) {
- return;
- }
- }
- load_mods[i] = sstrdup( arg );
- dlog(DEBUG1, "Added Module %d :%s", i,( char * )load_mods[i] );
+int
+cb_noload (cfg_t * cfg, cfg_opt_t * opt)
+{
+ if (opt->values[0]->boolean == cfg_true) {
+ cfg_error (cfg, "Error. You didn't edit NeoStats.conf");
+ return CFG_PARSE_ERROR;
}
+ return CFG_SUCCESS;
}
-/** @brief Load the modules
- *
- * Actually load the modules that were found in the config file
- *
- * @returns 1 on success, -1 when a module failed to load
- * @bugs if a single module fails to load, it stops trying to load any other modules
- */
+int
+cb_verify_host (cfg_t * cfg, cfg_opt_t * opt)
+{
+ /* this should actually be a validate ip as well */
+ if (ValidateHost (opt->values[0]->string) == NS_FAILURE) {
+ cfg_error (cfg, "Invalid HostName %s for Option %s", opt->values[0]->string, opt->name);
+ return CFG_PARSE_ERROR;
+ }
+ return CFG_SUCCESS;
+}
-int ConfLoadModules( void )
+int
+cb_verify_settime (cfg_t * cfg, cfg_opt_t * opt)
{
- int i;
+ long int time = opt->values[0]->number;
- SET_SEGV_LOCATION( );
- if(load_mods[0] == 0 ) {
- nlog( LOG_NORMAL, "No modules configured for loading" );
- } else {
- nlog( LOG_NORMAL, "Loading configured modules" );
- for( i = 0;( i < NUM_MODULES ) &&( load_mods[i] != 0 ); i++ ) {
- dlog(DEBUG1, "ConfLoadModules: Loading Module %s",( char * )load_mods[i] );
- if( load_module( load_mods[i], NULL ) ) {
- nlog( LOG_NORMAL, "Loaded module %s",( char * )load_mods[i] );
- } else {
- nlog( LOG_WARNING, "Failed to load module %s. Please check above error messages",( char * )load_mods[i] );
- }
- ns_free(load_mods[i] );
- }
- nlog( LOG_NORMAL, "Completed loading configured modules" );
+ if (time <= 0) {
+ cfg_error (cfg, "SetTime Value of %d is out of range for %s", time, opt->name);
+ return CFG_PARSE_ERROR;
}
- return NS_SUCCESS;
+ return CFG_SUCCESS;
}
-
-/** @brief Process config file items
+/** @brief prepare Modules defined in the config file
*
- * Processes the config file and sets up the variables. No Error Checking is performed :(
+ * When the config file encounters directives to Load Modules, it calls this function which prepares to load the modules( but doesn't actually load them )
*
- * @param arg the variable value as a string
- * @param configtype the index of the variable being called now
+ * @param arg the module name in this case
+ * @param configtype an index of what config item is currently being processed. Ignored
* @returns Nothing
*/
-
void
-cb_Server( char *arg, int configtype )
+cb_Module (char *arg)
{
- if( configtype == 0 ) {
- /* Server name */
- strlcpy( me.name, arg, sizeof( me.name ) );
- } else if( configtype == 1 ) {
- /* Server Port */
- me.port = atoi( arg );
- } else if( configtype == 2 ) {
- /* Connect To */
- strlcpy( me.uplink, arg, sizeof( me.uplink ) );
- } else if( configtype == 3 ) {
- /* Connect Pass */
- strlcpy( nsconfig.pass, arg, sizeof( nsconfig.pass ) );
- } else if( configtype == 4 ) {
- /* Server InfoLine */
- strlcpy( me.infoline, arg, sizeof( me.infoline ) );
- } else if( configtype == 5 ) {
- /* Service host */
- strlcpy( me.servicehost, arg, sizeof( me.servicehost ) );
- } else if( configtype == 6 ) {
- /* Reconnect time */
- nsconfig.r_time = atoi( arg );
- } else if( configtype == 9 ) {
- nsconfig.want_privmsg = 1;
- } else if( configtype == 10 ) {
- strlcpy( me.serviceschan, arg, sizeof( me.serviceschan ) );
- } else if( configtype == 11 ) {
- nsconfig.onlyopers = 1;
- } else if( configtype == 12 ) {
- nsconfig.die = 1;
- } else if( configtype == 13 ) {
- strlcpy( me.local, arg, sizeof( me.local ) );
- } else if( configtype == 14 ) {
- strlcpy(LogFileNameFormat,arg,MAX_LOGFILENAME );
- } else if( configtype == 15 ) {
- me.numeric = atoi( arg );
- /* limit value - really need to print error and quit */
- if(me.numeric<=0 )
- me.numeric=1;
- if(me.numeric>254 )
- me.numeric=254;
- } else if( configtype == 16 ) {
- nsconfig.setservertimes = atoi( arg );
- /* Convert hours input to seconds */
- nsconfig.setservertimes = nsconfig.setservertimes * 60 * 60;
- /* limit value - really need to print error and quit */
- if(nsconfig.setservertimes <= 0 ) {
- nsconfig.setservertimes =( 24 * 60 * 60 );
- }
- } else if( configtype == 17 ) {
- char *nick;
- char *user;
- char *host;
+ int i;
- if( strstr(arg, "!" )&& !strstr(arg, "@" ) ) {
- nlog(LOG_WARNING,
- "Invalid SERVICEROOT. Must be of the form nick!ident@host, was %s",
- arg );
- nsconfig.error = 1;
- } else {
- nick = strtok(arg, "!" );
- user = strtok(NULL, "@" );
- host = strtok(NULL, "" );
- strlcpy(nsconfig.rootuser.nick, nick, MAXNICK );
- strlcpy(nsconfig.rootuser.user, user, MAXUSER );
- strlcpy(nsconfig.rootuser.host, host, MAXHOST );
+ SET_SEGV_LOCATION ();
+ if (!nsconfig.modnoload) {
+ for (i = 0; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
+ if (!ircstrcasecmp (load_mods[i], arg)) {
+ return;
+ }
}
- } else if( configtype == 18 ) {
- strlcpy(me.protocol,arg,MAXHOST );
- } else if( configtype == 19 ) {
- strlcpy(me.dbm,arg,MAXHOST );
- } else if( configtype == 20 ) {
- strlcpy(me.rootnick,arg,MAXNICK );
+ load_mods[i] = sstrdup (arg);
}
}
-#endif /* USE_CONFUSE */
+
+
Modified: trunk/src/sock.c
==============================================================================
--- trunk/src/sock.c (original)
+++ trunk/src/sock.c Tue Jun 21 19:44:37 2005
@@ -470,6 +470,8 @@
nlog (LOG_CRITICAL, "Unable to create socks hash");
return NS_FAILURE;
}
+/* done in the confuse callback now */
+#if 0
me.dobind = 0;
/* bind to a local ip */
os_memset( &me.lsa, 0, sizeof( me.lsa ) );
@@ -482,6 +484,7 @@
me.dobind = 1;
}
}
+#endif
event_set_log_callback(libevent_log);
event_init();
return NS_SUCCESS;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.