s_user: clean up return types and can YES/NO.

This commit is contained in:
Elizabeth Myers 2016-03-08 05:06:29 -06:00
parent 07554369bd
commit 6287d57fa9
3 changed files with 37 additions and 41 deletions

View file

@ -32,16 +32,16 @@ struct User;
struct oper_conf; struct oper_conf;
extern time_t LastUsedWallops; extern time_t LastUsedWallops;
extern int valid_hostname(const char *hostname); extern bool valid_hostname(const char *hostname);
extern int valid_username(const char *username); extern bool valid_username(const char *username);
extern int user_mode(struct Client *, struct Client *, int, const char **); extern int user_mode(struct Client *, struct Client *, int, const char **);
extern void send_umode(struct Client *, struct Client *, int, char *); extern void send_umode(struct Client *, struct Client *, int, char *);
extern void send_umode_out(struct Client *, struct Client *, int); extern void send_umode_out(struct Client *, struct Client *, int);
extern int show_lusers(struct Client *source_p); extern void show_lusers(struct Client *source_p);
extern int register_local_user(struct Client *, struct Client *); extern int register_local_user(struct Client *, struct Client *);
extern int introduce_client(struct Client *client_p, struct Client *source_p, extern void introduce_client(struct Client *client_p, struct Client *source_p,
struct User *user, const char *nick, int use_euid); struct User *user, const char *nick, int use_euid);
extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user, extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user,
@ -51,6 +51,6 @@ extern int user_modes[256];
extern unsigned int find_umode_slot(void); extern unsigned int find_umode_slot(void);
extern void construct_umodebuf(void); extern void construct_umodebuf(void);
extern int oper_up(struct Client *, struct oper_conf *); extern void oper_up(struct Client *, struct oper_conf *);
#endif #endif

View file

@ -138,7 +138,7 @@ int user_modes[256] = {
* output - * output -
* side effects - display to client user counts etc. * side effects - display to client user counts etc.
*/ */
int void
show_lusers(struct Client *source_p) show_lusers(struct Client *source_p)
{ {
if(rb_dlink_list_length(&lclient_list) > (unsigned long)MaxClientCount) if(rb_dlink_list_length(&lclient_list) > (unsigned long)MaxClientCount)
@ -188,8 +188,6 @@ show_lusers(struct Client *source_p)
form_str(RPL_STATSCONN), form_str(RPL_STATSCONN),
MaxConnectionCount, MaxClientCount, MaxConnectionCount, MaxClientCount,
Count.totalrestartcount); Count.totalrestartcount);
return 0;
} }
/* /*
@ -575,7 +573,8 @@ register_local_user(struct Client *client_p, struct Client *source_p)
free_pre_client(source_p); free_pre_client(source_p);
return (introduce_client(client_p, source_p, user, source_p->name, 1)); introduce_client(client_p, source_p, user, source_p->name, 1);
return 0;
} }
/* /*
@ -587,7 +586,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
* of the net, either from a local client connect or * of the net, either from a local client connect or
* from a remote connect. * from a remote connect.
*/ */
int void
introduce_client(struct Client *client_p, struct Client *source_p, struct User *user, const char *nick, int use_euid) introduce_client(struct Client *client_p, struct Client *source_p, struct User *user, const char *nick, int use_euid)
{ {
char ubuf[BUFSIZE]; char ubuf[BUFSIZE];
@ -698,21 +697,19 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
hdata2.client = client_p; hdata2.client = client_p;
hdata2.target = source_p; hdata2.target = source_p;
call_hook(h_introduce_client, &hdata2); call_hook(h_introduce_client, &hdata2);
return 0;
} }
/* /*
* valid_hostname - check hostname for validity * valid_hostname - check hostname for validity
* *
* Inputs - pointer to user * Inputs - pointer to user
* Output - YES if valid, NO if not * Output - true if valid, false if not
* Side effects - NONE * Side effects - NONE
* *
* NOTE: this doesn't allow a hostname to begin with a dot and * NOTE: this doesn't allow a hostname to begin with a dot and
* will not allow more dots than chars. * will not allow more dots than chars.
*/ */
int bool
valid_hostname(const char *hostname) valid_hostname(const char *hostname)
{ {
const char *p = hostname, *last_slash = 0; const char *p = hostname, *last_slash = 0;
@ -721,18 +718,18 @@ valid_hostname(const char *hostname)
s_assert(NULL != p); s_assert(NULL != p);
if(hostname == NULL) if(hostname == NULL)
return NO; return false;
if(!strcmp(hostname, "localhost")) if(!strcmp(hostname, "localhost"))
return YES; return true;
if('.' == *p || ':' == *p || '/' == *p) if('.' == *p || ':' == *p || '/' == *p)
return NO; return false;
while (*p) while (*p)
{ {
if(!IsHostChar(*p)) if(!IsHostChar(*p))
return NO; return false;
if(*p == '.' || *p == ':') if(*p == '.' || *p == ':')
found_sep++; found_sep++;
else if(*p == '/') else if(*p == '/')
@ -744,19 +741,19 @@ valid_hostname(const char *hostname)
} }
if(found_sep == 0) if(found_sep == 0)
return NO; return false;
if(last_slash && IsDigit(last_slash[1])) if(last_slash && IsDigit(last_slash[1]))
return NO; return false;
return YES; return true;
} }
/* /*
* valid_username - check username for validity * valid_username - check username for validity
* *
* Inputs - pointer to user * Inputs - pointer to user
* Output - YES if valid, NO if not * Output - true if valid, false if not
* Side effects - NONE * Side effects - NONE
* *
* Absolutely always reject any '*' '!' '?' '@' in an user name * Absolutely always reject any '*' '!' '?' '@' in an user name
@ -764,7 +761,7 @@ valid_hostname(const char *hostname)
* Allow '.' in username to allow for "first.last" * Allow '.' in username to allow for "first.last"
* style of username * style of username
*/ */
int bool
valid_username(const char *username) valid_username(const char *username)
{ {
int dots = 0; int dots = 0;
@ -773,7 +770,7 @@ valid_username(const char *username)
s_assert(NULL != p); s_assert(NULL != p);
if(username == NULL) if(username == NULL)
return NO; return false;
if('~' == *p) if('~' == *p)
++p; ++p;
@ -783,7 +780,7 @@ valid_username(const char *username)
* or "-hi-@somehost", "h-----@somehost" would still be accepted. * or "-hi-@somehost", "h-----@somehost" would still be accepted.
*/ */
if(!IsAlNum(*p)) if(!IsAlNum(*p))
return NO; return false;
while (*++p) while (*++p)
{ {
@ -791,14 +788,14 @@ valid_username(const char *username)
{ {
dots++; dots++;
if(dots > ConfigFileEntry.dots_in_ident) if(dots > ConfigFileEntry.dots_in_ident)
return NO; return false;
if(!IsUserChar(p[1])) if(!IsUserChar(p[1]))
return NO; return false;
} }
else if(!IsUserChar(*p)) else if(!IsUserChar(*p))
return NO; return false;
} }
return YES; return true;
} }
/* report_and_set_user_flags /* report_and_set_user_flags
@ -914,8 +911,8 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
const char *pm; const char *pm;
struct Client *target_p; struct Client *target_p;
int what, setflags; int what, setflags;
int badflag = NO; /* Only send one bad flag notice */ bool badflag = false; /* Only send one bad flag notice */
int showsnomask = NO; bool showsnomask = false;
unsigned int setsnomask; unsigned int setsnomask;
char buf[BUFSIZE]; char buf[BUFSIZE];
hook_data_umode_changed hdata; hook_data_umode_changed hdata;
@ -1021,7 +1018,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
if (!(source_p->umodes & UMODE_SERVNOTICE) && source_p->snomask != 0) if (!(source_p->umodes & UMODE_SERVNOTICE) && source_p->snomask != 0)
{ {
source_p->snomask = 0; source_p->snomask = 0;
showsnomask = YES; showsnomask = true;
} }
source_p->flags2 &= ~OPER_FLAGS; source_p->flags2 &= ~OPER_FLAGS;
@ -1057,10 +1054,10 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
&& (ConfigFileEntry.oper_only_umodes & UMODE_SERVNOTICE)) && (ConfigFileEntry.oper_only_umodes & UMODE_SERVNOTICE))
{ {
if (what == MODE_ADD || source_p->umodes & UMODE_SERVNOTICE) if (what == MODE_ADD || source_p->umodes & UMODE_SERVNOTICE)
badflag = YES; badflag = true;
continue; continue;
} }
showsnomask = YES; showsnomask = true;
if(what == MODE_ADD) if(what == MODE_ADD)
{ {
if (parc > 3) if (parc > 3)
@ -1080,7 +1077,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
default: default:
if (MyConnect(source_p) && *pm == 'Q' && !ConfigChannel.use_forward) if (MyConnect(source_p) && *pm == 'Q' && !ConfigChannel.use_forward)
{ {
badflag = YES; badflag = true;
break; break;
} }
@ -1092,7 +1089,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
|| (orphaned_umodes & flag))) || (orphaned_umodes & flag)))
{ {
if (what == MODE_ADD || source_p->umodes & flag) if (what == MODE_ADD || source_p->umodes & flag)
badflag = YES; badflag = true;
} }
else else
{ {
@ -1105,7 +1102,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
else else
{ {
if(MyConnect(source_p)) if(MyConnect(source_p))
badflag = YES; badflag = true;
} }
break; break;
} }
@ -1282,7 +1279,7 @@ user_welcome(struct Client *source_p)
* output - none * output - none
* side effects - opers up source_p using aconf for reference * side effects - opers up source_p using aconf for reference
*/ */
int void
oper_up(struct Client *source_p, struct oper_conf *oper_p) oper_up(struct Client *source_p, struct oper_conf *oper_p)
{ {
unsigned int old = source_p->umodes, oldsnomask = source_p->snomask; unsigned int old = source_p->umodes, oldsnomask = source_p->snomask;
@ -1348,8 +1345,6 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
sendto_one_notice(source_p, ":*** Oper privilege set is %s", oper_p->privset->name); sendto_one_notice(source_p, ":*** Oper privilege set is %s", oper_p->privset->name);
sendto_one_notice(source_p, ":*** Oper privs are %s", oper_p->privset->privs); sendto_one_notice(source_p, ":*** Oper privs are %s", oper_p->privset->privs);
send_oper_motd(source_p); send_oper_motd(source_p);
return (1);
} }
/* /*

View file

@ -1138,7 +1138,8 @@ register_client(struct Client *client_p, struct Client *server,
call_hook(h_new_remote_user, source_p); call_hook(h_new_remote_user, source_p);
return (introduce_client(client_p, source_p, user, nick, parc == 12)); introduce_client(client_p, source_p, user, nick, parc == 12);
return 0;
} }
/* Check if we can do SAVE. target_p can be a client to save or a /* Check if we can do SAVE. target_p can be a client to save or a