1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 15:53:12 +02:00

Add "irc_is_nick" for function info_get to check if a string is a valid IRC nick name (patch #7133)

This commit is contained in:
Sebastien Helleu
2010-03-25 10:39:07 +01:00
parent 96e6ae3fc3
commit e59bbbb40a
16 changed files with 144 additions and 56 deletions
+29
View File
@@ -56,6 +56,35 @@ irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick)
return 0;
}
/*
* irc_nick_is_nick: check if string is a valid nick string (RFC 1459)
* return 1 if string valid nick
* 0 if not a valid nick
*/
int
irc_nick_is_nick (const char *string)
{
const char *ptr;
if (!string || !string[0])
return 0;
/* first char must not be a number or hyphen */
ptr = string;
if (strchr ("0123456789-", *ptr))
return 0;
while (ptr && ptr[0])
{
if (!strchr (IRC_NICK_VALID_CHARS, *ptr))
return 0;
ptr++;
}
return 1;
}
/*
* irc_nick_find_color: find a color for a nick (according to nick letters)
*/