#include "../lib/irc_string.h"
#include "../nick/nick.h"
#include "../core/hooks.h"
+#include "../lib/strlfunc.h"
+#include "../lib/version.h"
#include <string.h>
#include <stdio.h>
+MODULE_VERSION("")
+
#define ALLOCUNIT 100
#define authnamehash(x) ((x)%AUTHNAMEHASHSIZE)
/* internal access only */
static authname *authnametablebyname[AUTHNAMEHASHSIZE];
-sstring *authnameextnames[MAXAUTHNAMEEXTS];
+static struct {
+ sstring *name;
+ int persistent;
+} authnameexts[MAXAUTHNAMEEXTS];
static void authextstats(int hooknum, void *arg);
freeauthnames=anp;
}
-int registerauthnameext(const char *name) {
+int registerauthnameext(const char *name, int persistent) {
int i;
if (findauthnameext(name)!=-1) {
}
for (i=0;i<MAXAUTHNAMEEXTS;i++) {
- if (authnameextnames[i]==NULL) {
- authnameextnames[i]=getsstring(name,100);
+ if (authnameexts[i].name==NULL) {
+ authnameexts[i].name=getsstring(name,100);
+ authnameexts[i].persistent=persistent;
return i;
}
}
int i;
for (i=0;i<MAXAUTHNAMEEXTS;i++) {
- if (authnameextnames[i]!=NULL && !ircd_strcmp(name,authnameextnames[i]->content)) {
+ if (authnameexts[i].name!=NULL && !ircd_strcmp(name,authnameexts[i].name->content)) {
return i;
}
}
int i;
authname *anp;
- freesstring(authnameextnames[index]);
- authnameextnames[index]=NULL;
+ freesstring(authnameexts[index].name);
+ authnameexts[index].name=NULL;
for (i=0;i<AUTHNAMEHASHSIZE;i++) {
for (anp=authnametable[i];anp;anp=anp->next) {
return NULL;
for (anp=authnametablebyname[authnamehashbyname(name)];anp;anp=(authname *)anp->nextbyname)
- if (!ircd_strcmp(anp->nicks->authname, name))
+ if (!ircd_strcmp(anp->name, name))
return anp;
return NULL;
anp=newauthname();
anp->userid=userid;
+ strlcpy(anp->name, name, sizeof(anp->name));
anp->usercount=0;
anp->marker=0;
anp->flags=0;
anp->nicks = NULL;
for(i=0;i<MAXAUTHNAMEEXTS;i++)
- if(anp->exts[i]!=NULL)
+ if(authnameexts[i].persistent && anp->exts[i]!=NULL)
return;
+ triggerhook(HOOK_AUTH_LOSTAUTHNAME, (void *)anp);
found = 0;
for(manp=&(authnametable[authnamehash(anp->userid)]);*manp;manp=(authname **)&((*manp)->next)) {
if ((*manp)==anp) {