void Exit (int);
void Start (void);
int DaemonSeed (void);
-int CheckModule (char* module);
-int CheckConfig (void);
+int FileExists (char* file);
int OpenTCPSocket (void);
int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
* This method retrieves one line from the text file. If an empty non-NULL string is returned,
* the index was out of bounds, or the line had no data on it.
*/
+ bool Exists();
std::string GetLine(int x);
/** Returns the size of the file in lines.
* This method returns the number of lines in the read file. If it is 0, no lines have been
{
Start();
log(DEBUG,"*** InspIRCd starting up!");
- if (!CheckConfig())
+ if (!FileExists(CONFIG_FILE))
{
+ printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
log(DEBUG,"main: no config");
printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
Exit(ERROR);
/* If The File Doesnt exist, Trying to load it
* Will Segfault the IRCd.. So, check to see if
* it Exists, Before Proceeding. */
- if (CheckModule(modfile))
+ if (FileExists(modfile))
{
factory[count] = new ircd_module(modfile);
if (factory[count]->LastError())
/* Make Sure Modules Are Avaliable!
* (BugFix By Craig.. See? I do work! :p) */
-int CheckModule (char* module)
+int FileExists (char* file)
{
FILE *input;
- if ((input = fopen (module, "r")) == NULL) { return(FALSE); }
- else { fclose (input); return(TRUE); }
+ if ((input = fopen (file, "r")) == NULL) { return(false); }
+ else { fclose (input); return(true); }
}
-/* Make sure the config file is available */
-int CheckConfig (void)
-{
- FILE *input;
-
- if ((input = fopen (CONFIG_FILE, "r")) == NULL)
- {
- printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
- return(FALSE);
- }
- else
- fclose (input);
-
-return(TRUE);
-}
/* Counts the number of tags of a certain type within the config file, e.g. to enumerate opers */
this->fc = c;
}
+
FileReader::~FileReader()
{
}
+bool FileReader::Exists()
+{
+ if (fc.size() == 0)
+ {
+ return(false);
+ }
+ else
+ {
+ return(true);
+ }
+}
+
std::string FileReader::GetLine(int x)
{
if ((x<0) || (x>fc.size()))
quotes = new FileReader(q_file);
+ if(!quotes->Exists())
+ {
+ printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n");
+ exit(0);
+ }
}
virtual ~ModuleRandQuote()