mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-29 16:14:43 +00:00
2018 progress
This commit is contained in:
45
src/user.c
45
src/user.c
@@ -69,12 +69,12 @@ void cfg_pass(char *rest)
|
||||
|
||||
void cfg_mask(char *rest)
|
||||
{
|
||||
addtouser(&cfgUser->mask,rest);
|
||||
addtouser(&cfgUser->mask,rest,TRUE);
|
||||
}
|
||||
|
||||
void cfg_chan(char *rest)
|
||||
{
|
||||
addtouser(&cfgUser->chan,rest);
|
||||
addtouser(&cfgUser->chan,rest,TRUE);
|
||||
}
|
||||
|
||||
LS struct
|
||||
@@ -447,8 +447,8 @@ void rehash_chanusers(void)
|
||||
}
|
||||
}
|
||||
|
||||
__attr(CORE_SEG, __regparm (2))
|
||||
void addtouser(Strp **pp, const char *string)
|
||||
__attr(CORE_SEG, __regparm (3))
|
||||
void addtouser(Strp **pp, const char *string, int rehash)
|
||||
{
|
||||
Strp *um;
|
||||
|
||||
@@ -463,7 +463,8 @@ void addtouser(Strp **pp, const char *string)
|
||||
set_mallocdoer(addtouser);
|
||||
*pp = um = (Strp*)Calloc(sizeof(Strp) + strlen(string));
|
||||
Strcpy(um->p,string);
|
||||
rehash_chanusers();
|
||||
if (rehash)
|
||||
rehash_chanusers();
|
||||
}
|
||||
|
||||
__attr(CORE_SEG, __regparm (2))
|
||||
@@ -1133,6 +1134,7 @@ void do_user(COMMAND_ARGS)
|
||||
Strp *ump;
|
||||
char *handle,*pt,*mask,*nick,*chan,*anum,*pass,*encpass;
|
||||
char mode;
|
||||
char tmpmask[NUHLEN];
|
||||
int change;
|
||||
int newaccess,uaccess;
|
||||
union usercombo combo;
|
||||
@@ -1209,27 +1211,31 @@ void do_user(COMMAND_ARGS)
|
||||
/*
|
||||
* convert and check nick/mask
|
||||
*/
|
||||
if ((mask = nick2uh(from,nick)) == NULL)
|
||||
if ((mask = nick2uh(from,nick)) == NULL) // nick2uh uses nuh_buf
|
||||
return;
|
||||
Strcpy(tmpmask,mask);
|
||||
#ifdef DEBUG
|
||||
debug("(do_user) nick2uh(from \"%s\", nick \"%s\") = mask \"%s\"\n",from,nick,tmpmask);
|
||||
#endif /* DEBUG */
|
||||
#ifdef NEWBIE
|
||||
if (!matches(mask,"!@"))
|
||||
if (!matches(tmpmask,"!@"))
|
||||
{
|
||||
to_user(from,"Problem adding %s (global mask)",mask);
|
||||
to_user(from,"Problem adding %s (global mask)",tmpmask);
|
||||
return;
|
||||
}
|
||||
if (matches("*@?*.?*",mask))
|
||||
if (matches("*@?*.?*",tmpmask))
|
||||
{
|
||||
to_user(from,"Problem adding %s (invalid mask)",mask);
|
||||
to_user(from,"Problem adding %s (invalid mask)",tmpmask);
|
||||
return;
|
||||
}
|
||||
#endif /* NEWBIE */
|
||||
format_uh(mask,FUH_USERHOST);
|
||||
format_uh(tmpmask,FUH_USERHOST); // format_uh uses local temporary buffer but copies result back into tmpmask
|
||||
/*
|
||||
* dont duplicate users
|
||||
*/
|
||||
if (get_useraccess(mask,chan))
|
||||
if (get_useraccess(tmpmask,chan))
|
||||
{
|
||||
to_user(from,"%s (%s) on %s is already a user",nick,mask,chan);
|
||||
to_user(from,"%s (%s) on %s is already a user",nick,tmpmask,chan);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
@@ -1246,9 +1252,12 @@ void do_user(COMMAND_ARGS)
|
||||
* add_user() touches current->ul_save for us
|
||||
*/
|
||||
user = add_user(handle,encpass,newaccess);
|
||||
addtouser(&user->mask,mask);
|
||||
addtouser(&user->chan,chan);
|
||||
to_user(from,"%s has been added as %s on %s",handle,mask,chan);
|
||||
addtouser(&user->mask,tmpmask,FALSE); // does not run rehash_chanusers(), does not clobber nuh_buf
|
||||
addtouser(&user->chan,chan,TRUE); // clobbers nuh_buf
|
||||
#ifdef DEBUG
|
||||
debug("(do_user) from %s, handle %s,\n\tmask %s (arg %s),\n\tuser->mask %s, chan %s\n",from,handle,mask,nick,user->mask,chan);
|
||||
#endif /* DEBUG */
|
||||
to_user(from,"%s has been added as %s on %s",handle,tmpmask,chan);
|
||||
to_user(from,"Access level: %i%s%s",newaccess,(pass) ? " Password: " : "",(pass) ? pass : "");
|
||||
#ifdef NEWUSER_SPAM
|
||||
if ((newaccess != BOTLEVEL) && find_nuh(nick))
|
||||
@@ -1418,7 +1427,7 @@ usage:
|
||||
return;
|
||||
}
|
||||
#endif /* NEWBIE */
|
||||
addtouser(&user->chan,mask);
|
||||
addtouser(&user->chan,mask,TRUE);
|
||||
change++;
|
||||
}
|
||||
else
|
||||
@@ -1452,7 +1461,7 @@ usage:
|
||||
return;
|
||||
}
|
||||
#endif /* NEWBIE */
|
||||
addtouser(&user->mask,mask);
|
||||
addtouser(&user->mask,mask,TRUE);
|
||||
change++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user