]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd_io.h
Config fixes for moving MOTD and RULES vectors into the ServerConfig class
[user/henk/code/inspircd.git] / include / inspircd_io.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __INSPIRCD_IO_H__
18 #define __INSPIRCD_IO_H__
19
20 #include <sstream>
21 #include <string>
22 #include "inspircd.h"
23 #include "globals.h"
24
25 // flags for use with log()
26
27 #define DEBUG 10
28 #define VERBOSE 20
29 #define DEFAULT 30
30 #define SPARSE 40
31 #define NONE 50
32
33 class ServerConfig
34 {
35   public:
36         char ServerName[MAXBUF];
37         char Network[MAXBUF];
38         char ServerDesc[MAXBUF];
39         char AdminName[MAXBUF];
40         char AdminEmail[MAXBUF];
41         char AdminNick[MAXBUF];
42         char diepass[MAXBUF];
43         char restartpass[MAXBUF];
44         char motd[MAXBUF];
45         char rules[MAXBUF];
46         char PrefixQuit[MAXBUF];
47         char DieValue[MAXBUF];
48         char DNSServer[MAXBUF];
49         char DisabledCommands[MAXBUF];
50         char ModPath[1024];
51         char MyExecutable[1024];
52         FILE *log_file;
53         bool nofork;
54         bool unlimitcore;
55         bool AllowHalfop;
56         int dns_timeout;
57         int NetBufferSize;      // NetBufferSize used as the buffer size for all read() ops
58         int MaxConn;            // size of accept() backlog (128 by default on *BSD)
59         unsigned int SoftLimit;
60         int MaxWhoResults;
61         int debugging;
62         int LogLevel;
63         int DieDelay;
64         char addrs[MAXBUF][255];
65         file_cache MOTD;
66         file_cache RULES;
67         char PID[1024];
68         std::stringstream config_f;
69
70         ServerConfig()
71         {
72                 *ServerName = '\0';
73                 *Network = '\0';
74                 *ServerDesc = '\0';
75                 *AdminName = '\0';
76                 *AdminEmail = '\0';
77                 *AdminNick = '\0';
78                 *diepass = '\0';
79                 *restartpass = '\0';
80                 *motd = '\0';
81                 *rules = '\0';
82                 *PrefixQuit = '\0';
83                 *DieValue = '\0';
84                 *DNSServer = '\0';
85                 *ModPath = '\0';
86                 *MyExecutable = '\0';
87                 *DisabledCommands = '\0';
88                 *PID = '\0';
89                 log_file = NULL;
90                 nofork = false;
91                 unlimitcore = false;
92                 AllowHalfop = true;
93                 dns_timeout = 5;
94                 NetBufferSize = 10240;
95                 SoftLimit = MAXCLIENTS;
96                 MaxConn = SOMAXCONN;
97                 MaxWhoResults = 100;
98                 debugging = 0;
99                 LogLevel = DEFAULT;
100                 DieDelay = 5;
101         }
102 };
103
104
105 void Exit (int); 
106 void Start (void); 
107 int DaemonSeed (void); 
108 bool FileExists (const char* file);
109 int OpenTCPSocket (void); 
110 int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
111
112 bool LoadConf(const char* filename, std::stringstream *target, std::stringstream* errorstream);
113 int ConfValue(char* tag, char* var, int index, char *result, std::stringstream *config);
114 int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int index, char *result);
115 int ConfValueEnum(char* tag,std::stringstream *config);
116 int EnumConf(std::stringstream *config_f,const char* tag);
117 int EnumValues(std::stringstream *config, const char* tag, int index);
118 void WritePID(std::string filename);
119
120 #endif