summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 4905cfabd..073b5b37c 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -61,6 +61,8 @@ extern std::vector<userrec*> all_opers;
extern user_hash clientlist;
extern chan_hash chanlist;
+char LOG_FILE[MAXBUF];
+
extern std::vector<userrec*> local_users;
static char TIMESTR[26];
@@ -1791,3 +1793,84 @@ bool charremove(char* mp, char remove)
return shift_down;
}
+
+void OpenLog(char** argv, int argc)
+{
+ if (!*LOG_FILE)
+ {
+ if (Config->logpath == "")
+ {
+ Config->logpath = GetFullProgDir(argv,argc) + "/ircd.log";
+ }
+ }
+ else
+ {
+ Config->log_file = fopen(LOG_FILE,"a+");
+
+ if (!Config->log_file)
+ {
+ printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
+ Exit(ERROR);
+ }
+
+ return;
+ }
+
+ Config->log_file = fopen(Config->logpath.c_str(),"a+");
+
+ if (!Config->log_file)
+ {
+ printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
+ Exit(ERROR);
+ }
+}
+
+void CheckRoot()
+{
+ if (geteuid() == 0)
+ {
+ printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
+ log(DEFAULT,"InspIRCd: startup: not starting with UID 0!");
+ Exit(ERROR);
+ }
+}
+
+void CheckDie()
+{
+ if (*Config->DieValue)
+ {
+ printf("WARNING: %s\n\n",Config->DieValue);
+ log(DEFAULT,"Uh-Oh, somebody didn't read their config file: '%s'",Config->DieValue);
+ Exit(ERROR);
+ }
+}
+
+/* We must load the modules AFTER initializing the socket engine, now */
+void LoadAllModules(InspIRCd* ServerInstance)
+{
+ char configToken[MAXBUF];
+ Config->module_names.clear();
+ MODCOUNT = -1;
+
+ for (int count = 0; count < Config->ConfValueEnum("module",&Config->config_f); count++)
+ {
+ Config->ConfValue("module","name",count,configToken,&Config->config_f);
+ printf("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken);
+
+ if (!ServerInstance->LoadModule(configToken))
+ {
+ log(DEFAULT,"Exiting due to a module loader error.");
+ printf("\nThere was an error loading a module: %s\n\n",ServerInstance->ModuleError());
+ Exit(0);
+ }
+
+ if (!ServerInstance->LoadModule(configToken))
+ {
+ log(DEFAULT,"Exiting due to a module loader error.");
+ printf("\nThere was an error loading a module: %s\n\n",ServerInstance->ModuleError());
+ Exit(0);
+ }
+ }
+
+ log(DEFAULT,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1);
+}