From c116475922dc1669d540bf2fa911c126f1dd8c40 Mon Sep 17 00:00:00 2001 From: w00t Date: Tue, 4 Apr 2006 00:41:28 +0000 Subject: This doesn't belong in userprocess.cpp. :P git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3811 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'src/helperfuncs.cpp') 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 all_opers; extern user_hash clientlist; extern chan_hash chanlist; +char LOG_FILE[MAXBUF]; + extern std::vector 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); +} -- cgit v1.2.3