Added /LOADMODULE (tested and working)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@998 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2005-04-07 16:05:08 +00:00
parent f80d40018a
commit e4a08d4461
4 changed files with 27 additions and 2 deletions

View File

@ -79,6 +79,7 @@ void handle_zline(char **parameters, int pcnt, userrec *user);
void handle_qline(char **parameters, int pcnt, userrec *user);
void handle_eline(char **parameters, int pcnt, userrec *user);
void handle_server(char **parameters, int pcnt, userrec *user);
void handle_loadmodule(char **parameters, int pcnt, userrec *user);
/** Special functions for processing server to server traffic
*/

View File

@ -158,7 +158,8 @@ char islast(const char* s);
long map_count(const char* s);
userrec* ReHashNick(char* Old, char* New);
long GetMaxBans(char* name);
bool LoadModule(const char* filename);
char* ModuleError();
// mesh network functions

View File

@ -270,6 +270,18 @@ void handle_kick(char **parameters, int pcnt, userrec *user)
NetSendToAll(buffer);
}
void handle_loadmodule(char **parameters, int pcnt, userrec *user)
{
if (LoadModule(parameters[0]))
{
WriteOpers("*** NEW MODULE: %s",parameters[0]);
WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
}
else
{
WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ModuleError());
}
}
void handle_die(char **parameters, int pcnt, userrec *user)
{

View File

@ -2985,6 +2985,7 @@ void SetupCommandTable(void)
createcommand("ZLINE",handle_zline,'o',1);
createcommand("QLINE",handle_qline,'o',1);
createcommand("ELINE",handle_eline,'o',1);
createcommand("LOADMODULE",handle_loadmodule,'o',1);
createcommand("SERVER",handle_server,0,0);
}
@ -3233,6 +3234,12 @@ void RemoveServer(const char* name)
int reap_counter = 0;
char MODERR[MAXBUF];
char* ModuleError()
{
return MODERR;
}
bool LoadModule(const char* filename)
{
@ -3246,6 +3253,7 @@ bool LoadModule(const char* filename)
if (module_names[j] == std::string(filename))
{
log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
snprintf(MODERR,MAXBUF,"Module already loaded");
return false;
}
}
@ -3253,6 +3261,7 @@ bool LoadModule(const char* filename)
if (factory[MODCOUNT+1]->LastError())
{
log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
MODCOUNT--;
return false;
}
@ -3266,12 +3275,14 @@ bool LoadModule(const char* filename)
else
{
log(DEFAULT,"Unable to load %s",modfile);
snprintf(MODERR,MAXBUF,"Factory function failed!");
return false;
}
}
else
{
log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
snprintf(MODERR,MAXBUF,"Module file could not be found");
return false;
}
MODCOUNT++;
@ -3371,7 +3382,7 @@ int InspIRCd(void)
if (!LoadModule(configToken))
{
log(DEBUG,"Exiting due to a module loader error.");
printf("There was an error loading a module. View your ircd.log for details.\n");
printf("There was an error loading a module: %s\n",ModuleError());
Exit(0);
}
}