1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __INSPIRCD_IO_H__
18 #define __INSPIRCD_IO_H__
26 /** Flags for use with log()
34 /** This class holds the bulk of the runtime configuration for the ircd.
35 * It allows for reading new config values, accessing configuration files,
36 * and storage of the configuration data needed to run the ircd, such as
37 * the servername, connect classes, /ADMIN data, MOTDs and filenames etc.
39 class ServerConfig : public classbase
42 /** This variable holds the names of all
43 * files included from the main one. This
44 * is used to make sure that no files are
45 * recursively included.
47 std::vector<std::string> include_stack;
49 /** Used by the config file subsystem to
50 * safely read a C-style string without
51 * dependency upon any certain style of
52 * linefeed, e.g. it can read both windows
53 * and UNIX style linefeeds transparently.
55 int fgets_safe(char* buffer, size_t maxsize, FILE* &file);
57 /** This private method processes one line of
58 * configutation, appending errors to errorstream
59 * and setting error if an error has occured.
61 std::string ConfProcess(char* buffer, long linenumber, std::stringstream* errorstream, bool &error, std::string filename);
65 /** Holds the server name of the local server
66 * as defined by the administrator.
68 char ServerName[MAXBUF];
70 /* Holds the network name the local server
71 * belongs to. This is an arbitary field defined
72 * by the administrator.
76 /** Holds the description of the local server
77 * as defined by the administrator.
79 char ServerDesc[MAXBUF];
81 /** Holds the admin's name, for output in
84 char AdminName[MAXBUF];
86 /** Holds the email address of the admin,
87 * for output in the /ADMIN command.
89 char AdminEmail[MAXBUF];
91 /** Holds the admin's nickname, for output
92 * in the /ADMIN command
94 char AdminNick[MAXBUF];
96 /** The admin-configured /DIE password
100 /** The admin-configured /RESTART password
102 char restartpass[MAXBUF];
104 /** The pathname and filename of the message of the
105 * day file, as defined by the administrator.
109 /** The pathname and filename of the rules file,
110 * as defined by the administrator.
114 /** The quit prefix in use, or an empty string
116 char PrefixQuit[MAXBUF];
118 /** The last string found within a <die> tag, or
121 char DieValue[MAXBUF];
123 /** The DNS server to use for DNS queries
125 char DNSServer[MAXBUF];
127 /** This variable contains a space-seperated list
128 * of commands which are disabled by the
129 * administrator of the server for non-opers.
131 char DisabledCommands[MAXBUF];
133 /** The full path to the modules directory.
134 * This is either set at compile time, or
135 * overridden in the configuration file via
140 /** The full pathname to the executable, as
141 * given in argv[0] when the program starts.
143 char MyExecutable[1024];
145 /** The file handle of the logfile. If this
146 * value is NULL, the log file is not open,
147 * probably due to a permissions error on
148 * startup (this should not happen in normal
153 /** If this value is true, the owner of the
154 * server specified -nofork on the command
155 * line, causing the daemon to stay in the
160 /** If this value is true, the owner of the
161 * server has chosen to unlimit the coredump
162 * size to as large a value as his account
163 * settings will allow. This is often used
168 /** If this value is true, halfops have been
169 * enabled in the configuration file.
173 /** The number of seconds the DNS subsystem
174 * will wait before timing out any request.
178 /** The size of the read() buffer in the user
179 * handling code, used to read data into a user's
184 /** The value to be used for listen() backlogs
189 /** The soft limit value assigned to the irc server.
190 * The IRC server will not allow more than this
191 * number of local users.
193 unsigned int SoftLimit;
195 /** The maximum number of /WHO results allowed
196 * in any single /WHO command.
200 /** True if the DEBUG loglevel is selected.
204 /** The loglevel in use by the IRC server
208 /** How many seconds to wait before exiting
209 * the program when /DIE is correctly issued.
213 /** A list of IP addresses the server is listening
216 char addrs[MAXBUF][255];
218 /** The MOTD file, cached in a file_cache type.
222 /** The RULES file, cached in a file_cache type.
226 /** The full pathname and filename of the PID
227 * file as defined in the configuration.
231 /** The parsed configuration file as a stringstream.
232 * You should pass this to any configuration methods
233 * of this class, and not access it directly. It is
234 * recommended that modules use ConfigReader instead
235 * which provides a simpler abstraction of configuration
238 std::stringstream config_f;
240 /** The connect classes in use by the IRC server.
244 /** A list of module names (names only, no paths)
245 * which are currently loaded by the server.
247 std::vector<std::string> module_names;
251 /** Clears the include stack in preperation for
256 /** Read the entire configuration into memory
257 * and initialize this class. All other methods
258 * should be used only by the core.
260 void Read(bool bail, userrec* user);
262 bool LoadConf(const char* filename, std::stringstream *target, std::stringstream* errorstream);
263 int ConfValue(char* tag, char* var, int index, char *result, std::stringstream *config);
264 int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int index, char *result);
265 int ConfValueEnum(char* tag,std::stringstream *config);
266 int EnumConf(std::stringstream *config_f,const char* tag);
267 int EnumValues(std::stringstream *config, const char* tag, int index);
273 int DaemonSeed (void);
274 bool FileExists (const char* file);
275 int OpenTCPSocket (void);
276 int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
277 void WritePID(std::string filename);