]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Remove an extern, partly because it's unused, partly because it then gets shadowed...
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 46a85da2cd1bbde36455b4ed5e0d91b59754a55d..6412175b1666da23799d5414bd4310463af9c33f 100644 (file)
  * ---------------------------------------------------
  */
 
-using namespace std;
-
+#include <stdarg.h>
 #include "inspircd_config.h"
 #include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/errno.h>
+#include <signal.h>
 #include <time.h>
 #include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
 #include <sstream>
-#include <vector>
-#include <deque>
-#include <stdarg.h>
 #include "connection.h"
 #include "users.h"
 #include "ctables.h"
@@ -50,7 +42,7 @@ using namespace std;
 #include "typedefs.h"
 
 extern int MODCOUNT;
-extern std::vector<Module*> modules;
+extern ModuleList modules;
 extern ServerConfig *Config;
 extern InspIRCd* ServerInstance;
 extern time_t TIME;
@@ -278,8 +270,6 @@ void WriteServ(int sock, char* text, ...)
 {
        va_list argsPtr;
        char textbuffer[MAXBUF];
-       char tb[MAXBUF];
-       int bytes;
 
        if ((sock < 0) || (sock > MAX_DESCRIPTORS))
                return;
@@ -293,31 +283,8 @@ void WriteServ(int sock, char* text, ...)
        va_start(argsPtr, text);
        vsnprintf(textbuffer, MAXBUF, text, argsPtr);
        va_end(argsPtr);
-       bytes = snprintf(tb,MAXBUF,":%s %s\r\n",Config->ServerName,textbuffer);
-       chop(tb);
-
-       if (fd_ref_table[sock])
-       {
-               if (Config->GetIOHook(fd_ref_table[sock]->port))
-               {
-                       try
-                       {
-                               Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
-                       }
-                       catch (ModuleException& modexcept)
-                       {
-                               log(DEBUG,"Module exception caught: %s",modexcept.GetReason());
-                       }
-               }
-               else
-               {
-                       fd_ref_table[sock]->AddWriteBuf(tb);
-               }
-
-               ServerInstance->stats->statsSent += bytes;
-       }
-       else
-               log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
+       
+       WriteServ_NoFormat(sock, textbuffer);
 }
 
 /** WriteFrom_NoFormat()
@@ -1626,6 +1593,34 @@ bool AllModulesReportReady(userrec* user)
        return true;
 }
 
+/* Make Sure Modules Are Avaliable!
+ * (BugFix By Craig.. See? I do work! :p)
+ * Modified by brain, requires const char*
+ * to work with other API functions
+ */
+
+/* XXX - Needed? */
+bool FileExists (const char* file)
+{
+       FILE *input;
+       if ((input = fopen (file, "r")) == NULL)
+       {
+               return(false);
+       }
+       else
+       {
+               fclose (input);
+               return(true);
+       }
+}
+
+char* CleanFilename(char* name)
+{
+       char* p = name + strlen(name);
+       while ((p != name) && (*p != '/')) p--;
+       return (p != name ? ++p : p);
+}
+
 bool DirValid(char* dirandfile)
 {
        char work[MAXBUF];