*/
#include <string.h>
+#include <strings.h>
#include "../chanserv.h"
#include "../../lib/irc_string.h"
rup->nextbyname=regusernicktable[hash];
regusernicktable[hash]=rup;
- anp=findorcreateauthname(rup->ID);
+ anp=findorcreateauthname(rup->ID, rup->username);
anp->exts[chanservaext]=rup;
}
for (i=0;i<REGUSERHASHSIZE;i++) {
for (rup=regusernicktable[i];rup;rup=rup->nextbyname) {
- if (!strcasecmp(email,rup->email->content)) {
+ if (rup->email && !strcasecmp(email,rup->email->content)) {
return rup;
}
}
if(!m && (p=strchr(domain, '.')))
return findnearestmaildomain(++p);
- return NULL;
+ return m;
}
maildomain *findmaildomainbyemail(char *email) {
}
void delreguserfrommaildomain(reguser *rup, maildomain *mdp) {
- maildomain *smdp;
+ maildomain *smdp, *nmdp;
reguser *ruh, *pruh=NULL;
int found=0;
+ if(!mdp)
+ return;
+
for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) {
if (ruh==rup) {
/* Found the user */
return;
}
- for(smdp=mdp;smdp;smdp=smdp->parent) {
- smdp->count--;
+ /* Free it from all the parent domains, cleaning up as we go.. */
+ for(smdp=mdp;smdp;smdp=nmdp) {
+ nmdp=smdp->parent;
+
+ /* Keep it if there are users left or we're remembering something about it. */
+ if (--smdp->count || (smdp->flags != MDFLAG_DEFAULT) || (smdp->actlimit != MD_DEFAULTACTLIMIT))
+ continue;
+
+ removemaildomainfromhash(smdp);
+ freesstring(smdp->name);
+ freemaildomain(smdp);
}
+
rup->domain=NULL;
freesstring(rup->localpart);
rup->localpart=NULL;
-
- if (!mdp->count && !MDHasLimit(mdp)) {
- removemaildomainfromhash(mdp);
- freemaildomain(mdp);
- }
}