X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/3f1af975911f8dc0423876a3f1679e599ea7f682..8c684fca9c7dbb4a2601628c744be9236ee68641:/authext/authext.c?ds=inline diff --git a/authext/authext.c b/authext/authext.c index 54f71e72..828428fc 100644 --- a/authext/authext.c +++ b/authext/authext.c @@ -5,10 +5,14 @@ #include "../lib/irc_string.h" #include "../nick/nick.h" #include "../core/hooks.h" +#include "../lib/strlfunc.h" +#include "../lib/version.h" #include #include +MODULE_VERSION("") + #define ALLOCUNIT 100 #define authnamehash(x) ((x)%AUTHNAMEHASHSIZE) @@ -20,7 +24,10 @@ authname *authnametable[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); @@ -59,7 +66,7 @@ void freeauthname (authname *anp) { freeauthnames=anp; } -int registerauthnameext(const char *name) { +int registerauthnameext(const char *name, int persistent) { int i; if (findauthnameext(name)!=-1) { @@ -68,8 +75,9 @@ int registerauthnameext(const char *name) { } for (i=0;icontent)) { + if (authnameexts[i].name!=NULL && !ircd_strcmp(name,authnameexts[i].name->content)) { return i; } } @@ -94,8 +102,8 @@ void releaseauthnameext(int index) { int i; authname *anp; - freesstring(authnameextnames[index]); - authnameextnames[index]=NULL; + freesstring(authnameexts[index].name); + authnameexts[index].name=NULL; for (i=0;inext) { @@ -126,7 +134,7 @@ authname *findauthnamebyname(const char *name) { 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; @@ -145,6 +153,7 @@ authname *findorcreateauthname(unsigned long userid, const char *name) { anp=newauthname(); anp->userid=userid; + strlcpy(anp->name, name, sizeof(anp->name)); anp->usercount=0; anp->marker=0; anp->flags=0; @@ -167,9 +176,10 @@ void releaseauthname(authname *anp) { anp->nicks = NULL; for(i=0;iexts[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) {