00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __INSPIRCD_IO_H__
00018 #define __INSPIRCD_IO_H__
00019
00020 #include <sstream>
00021 #include <string>
00022 #include <vector>
00023 #include "inspircd.h"
00024 #include "globals.h"
00025
00026
00027
00028 #define DEBUG 10
00029 #define VERBOSE 20
00030 #define DEFAULT 30
00031 #define SPARSE 40
00032 #define NONE 50
00033
00034 class ServerConfig : public classbase
00035 {
00036 private:
00037 std::vector<std::string> include_stack;
00038 int fgets_safe(char* buffer, size_t maxsize, FILE* &file);
00039 std::string ConfProcess(char* buffer, long linenumber, std::stringstream* errorstream, bool &error, std::string filename);
00040
00041 public:
00042 char ServerName[MAXBUF];
00043 char Network[MAXBUF];
00044 char ServerDesc[MAXBUF];
00045 char AdminName[MAXBUF];
00046 char AdminEmail[MAXBUF];
00047 char AdminNick[MAXBUF];
00048 char diepass[MAXBUF];
00049 char restartpass[MAXBUF];
00050 char motd[MAXBUF];
00051 char rules[MAXBUF];
00052 char PrefixQuit[MAXBUF];
00053 char DieValue[MAXBUF];
00054 char DNSServer[MAXBUF];
00055 char DisabledCommands[MAXBUF];
00056 char ModPath[1024];
00057 char MyExecutable[1024];
00058 FILE *log_file;
00059 bool nofork;
00060 bool unlimitcore;
00061 bool AllowHalfop;
00062 int dns_timeout;
00063 int NetBufferSize;
00064 int MaxConn;
00065 unsigned int SoftLimit;
00066 int MaxWhoResults;
00067 int debugging;
00068 int LogLevel;
00069 int DieDelay;
00070 char addrs[MAXBUF][255];
00071 file_cache MOTD;
00072 file_cache RULES;
00073 char PID[1024];
00074 std::stringstream config_f;
00075 ClassVector Classes;
00076 std::vector<std::string> module_names;
00077
00078 ServerConfig();
00079 void ClearStack();
00080 void Read(bool bail, userrec* user);
00081 bool LoadConf(const char* filename, std::stringstream *target, std::stringstream* errorstream);
00082 int ConfValue(char* tag, char* var, int index, char *result, std::stringstream *config);
00083 int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int index, char *result);
00084 int ConfValueEnum(char* tag,std::stringstream *config);
00085 int EnumConf(std::stringstream *config_f,const char* tag);
00086 int EnumValues(std::stringstream *config, const char* tag, int index);
00087 };
00088
00089
00090 void Exit (int);
00091 void Start (void);
00092 int DaemonSeed (void);
00093 bool FileExists (const char* file);
00094 int OpenTCPSocket (void);
00095 int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
00096
00097
00098
00099
00100
00101
00102
00103
00104 void WritePID(std::string filename);
00105
00106 #endif