#include <stdio.h>
#include <string.h>
-MODULE_VERSION("$Id")
+MODULE_VERSION("");
int findserver(const char *name);
void completelink(int servernum);
server serverlist[MAXSERVERS];
-int myhub;
+long myhub;
+
+const flag smodeflags[] = {
+ { 'h', SMODE_HUB },
+ { '6', SMODE_IPV6 },
+ { 's', SMODE_SERVICE },
+ { 'n', SMODE_OPERNAME },
+ { '\0', 0 } };
void _init() {
/* Initialise the server tree */
serverlist[numerictolong(mynumeric->content,2)].description=getcopyconfigitem("irc","serverdescription","newserv",100);
serverlist[numerictolong(mynumeric->content,2)].maxusernum=MAXLOCALUSER;
serverlist[numerictolong(mynumeric->content,2)].linkstate=LS_LINKED;
+ /* remember to update the mode line in irc/irc.c */
+ serverlist[numerictolong(mynumeric->content,2)].flags=SMODE_SERVICE|SMODE_IPV6|SMODE_HUB|SMODE_OPERNAME;
/* Register the protocol messages we handle */
registerserverhandler("SERVER",&handleservermsg,8);
deregisterhook(HOOK_IRC_DISCON,&handledisconnect);
for (i=0;i<MAXSERVERS;i++) {
- if (serverlist[i].name!=NULL)
- freesstring(serverlist[i].name);
+ freesstring(serverlist[i].name);
+ freesstring(serverlist[i].description);
}
}
int handleservermsg(void *source, int cargc, char **cargv) {
- int servernum;
+ long servernum;
servernum=numerictolong(cargv[5],2);
if (serverlist[servernum].name!=NULL) {
- Error("server",ERR_ERROR,"New server %d already exists in servertable.",servernum);
+ Error("server",ERR_ERROR,"New server %ld already exists in servertable.",servernum);
return CMD_ERROR;
}
serverlist[servernum].name=getsstring(cargv[0],HOSTLEN);
serverlist[servernum].description=getsstring(cargv[cargc-1],REALLEN);
serverlist[servernum].maxusernum=numerictolong(cargv[5]+2,3);
-
+ setflags(&serverlist[servernum].flags,SMODE_ALL,cargv[6],smodeflags,REJECT_NONE);
+
if (!strncmp((char *)source,"INIT",4)) {
/* This is the initial server */
myhub=servernum;
}
int handleeobmsg(void *source, int cargc, char **argv) {
- int servernum;
+ long servernum;
servernum=numerictolong(source,2);
completelink(servernum);
}
int handlesquitmsg(void *source, int cargc, char **cargv) {
- int servernum=findserver(cargv[0]);
+ long servernum=findserver(cargv[0]);
if (servernum<0) {
Error("server",ERR_WARNING,"Received SQUIT for unknown server %s\n",cargv[0]);
return CMD_ERROR;
/* This server is now fully linked. */
serverlist[servernum].linkstate=LS_LINKED;
+ triggerhook(HOOK_SERVER_LINKED, (void *)(long)servernum);
Error("server",ERR_DEBUG,"Setting link state on %s to LS_LINKED",serverlist[servernum].name->content);
}
-void deleteserver(int servernum) {
+void deleteserver(long servernum) {
int i;
if (serverlist[servernum].name==NULL) {
- Error("server",ERR_WARNING,"Tried to remove server %d which doesn't exist.",servernum);
+ Error("server",ERR_WARNING,"Tried to remove server %ld which doesn't exist.",servernum);
return;
}