]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd_io.h
Added config_f to serverconfig, UNTESTED
[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
24 // flags for use with log()
25
26 #define DEBUG 10
27 #define VERBOSE 20
28 #define DEFAULT 30
29 #define SPARSE 40
30 #define NONE 50
31
32 class ServerConfig
33 {
34   public:
35         char ServerName[MAXBUF];
36         char Network[MAXBUF];
37         char ServerDesc[MAXBUF];
38         char AdminName[MAXBUF];
39         char AdminEmail[MAXBUF];
40         char AdminNick[MAXBUF];
41         char diepass[MAXBUF];
42         char restartpass[MAXBUF];
43         char motd[MAXBUF];
44         char rules[MAXBUF];
45         char PrefixQuit[MAXBUF];
46         char DieValue[MAXBUF];
47         char DNSServer[MAXBUF];
48         char DisabledCommands[MAXBUF];
49         char ModPath[1024];
50         char MyExecutable[1024];
51         FILE *log_file;
52         bool nofork;
53         bool unlimitcore;
54         bool AllowHalfop;
55         int dns_timeout;
56         int NetBufferSize;      // NetBufferSize used as the buffer size for all read() ops
57         int MaxConn;            // size of accept() backlog (128 by default on *BSD)
58         unsigned int SoftLimit;
59         int MaxWhoResults;
60         int debugging;
61         int LogLevel;
62         int DieDelay;
63         char addrs[MAXBUF][255];
64         file_cache MOTD;
65         file_cache RULES;
66         char PID[1024];
67         std::stringstream config_f;
68
69         ServerConfig()
70         {
71                 *ServerName = '\0';
72                 *Network = '\0';
73                 *ServerDesc = '\0';
74                 *AdminName = '\0';
75                 *AdminEmail = '\0';
76                 *AdminNick = '\0';
77                 *diepass = '\0';
78                 *restartpass = '\0';
79                 *motd = '\0';
80                 *rules = '\0';
81                 *PrefixQuit = '\0';
82                 *DieValue = '\0';
83                 *DNSServer = '\0';
84                 *ModPath = '\0';
85                 *MyExecutable = '\0';
86                 *DisabledCommands = '\0';
87                 *PID = '\0';
88                 log_file = NULL;
89                 nofork = false;
90                 unlimitcore = false;
91                 AllowHalfop = true;
92                 dns_timeout = 5;
93                 NetBufferSize = 10240;
94                 SoftLimit = MAXCLIENTS;
95                 MaxConn = SOMAXCONN;
96                 MaxWhoResults = 100;
97                 debugging = 0;
98                 LogLevel = DEFAULT;
99                 DieDelay = 5;
100         }
101 };
102
103
104 void Exit (int); 
105 void Start (void); 
106 int DaemonSeed (void); 
107 bool FileExists (const char* file);
108 int OpenTCPSocket (void); 
109 int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
110
111 bool LoadConf(const char* filename, std::stringstream *target, std::stringstream* errorstream);
112 int ConfValue(char* tag, char* var, int index, char *result, std::stringstream *config);
113 int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int index, char *result);
114 int ConfValueEnum(char* tag,std::stringstream *config);
115 int EnumConf(std::stringstream *config_f,const char* tag);
116 int EnumValues(std::stringstream *config, const char* tag, int index);
117 void WritePID(std::string filename);
118
119 #endif