static int clean_nick(const char *nick) { int len = 0; if(*nick == '-') return 0; /* This is used to check logins, which are often * numeric. Don't check for leading digits, if * services wants to set someone's nick to something * starting with a number, let it try. * --gxti */ for (; *nick; nick++) { len++; if(!IsNickChar(*nick)) return 0; } /* nicklen is +1 */ if(len >= NICKLEN) return 0; return 1; }
int clean_resv_nick(char *nick) { char tmpch; int as=0; int q=0; int ch=0; if(*nick == '-' || IsDigit(*nick)) return 0; while((tmpch = *nick++)) { if(tmpch == '?') q++; else if(tmpch == '*') as++; else if(IsNickChar(tmpch)) ch++; else return 0; } if(!ch && as) return 0; return 1; }
u_short check_nm(user_t *cptr, char *nm) { if (strlen(nm) > NICKLEN) return (cptr ? reply(OS, cptr->nick, "The nickmask is too long.") : 1); for (; *nm; nm++) if (!IsNickChar(*nm) && *nm != '?' && *nm != '*') return (cptr ? reply(OS, cptr->nick, "The character '%c' is not allowed in your nickmask.", *nm) : 1); return 0; }
int ValidateNickWild( const char *nick ) { if( nick == NULL ) return NS_FAILURE; while( *nick != '\0' ) { if( !IsNickChar( *nick ) && !IsWildChar( *nick ) ) return NS_FAILURE; nick++; } return NS_SUCCESS; }
u_short check_nick(user_t *cptr, char *nick) { if (strlen(nick) > NICKLEN) return (cptr ? reply(OS, cptr->nick, "The nickname is too long.") : 1); if (isdigit(*nick) || *nick == '-') return (cptr ? reply(OS, cptr->nick, "Erroneus Nickname.") : 1); for (; *nick; nick++) if (!IsNickChar(*nick)) return (cptr ? reply(OS, cptr->nick, "The character '%c' is not allowed in your nick.", *nick) : 1); return 0; }
/** Look up a command in the message trie. * @param cmd Text of command to look up. * @param root Root of message trie. * @return Pointer to matching message, or NULL if non exists. */ static struct Message * msg_tree_parse(char *cmd, struct MessageTree *root) { struct MessageTree *mtree; for (mtree = root; mtree; mtree = mtree->pointers[(*cmd++) & (MAXPTRLEN-1)]) { if (*cmd == '\0' && mtree->msg) return mtree->msg; else if (!IsNickChar(*cmd)) return NULL; } return NULL; }
int irc_IsValidNick(const char* nick) { const char* ch = nick; const char* endp = ch + NICKLEN; if (*nick == '-' || IsDigit(*nick)) /* first character in [0..9-] */ return 0; for ( ; ch < endp && *ch; ++ch) { if (!IsNickChar(*ch)) return 0; } return 1; }
/* * 'do_nick_name' ensures that the given parameter (nick) is really a proper * string for a nickname (note, the 'nick' may be modified in the process...) * * RETURNS the length of the final NICKNAME (0, if nickname is invalid) * * Nickname characters are in range 'A'..'}', '_', '-', '0'..'9' * anything outside the above set will terminate nickname. * In addition, the first character cannot be '-' or a Digit. * * Note: * The '~'-character should be allowed, but a change should be global, * some confusion would result if only few servers allowed it... */ static int do_nick_name(char* nick) { char* ch = nick; char* end = ch + NICKLEN; assert(0 != ch); /* first character in [0..9-] */ if (*ch == '-' || IsDigit(*ch)) return 0; for ( ; (ch < end) && *ch; ++ch) if (!IsNickChar(*ch)) break; *ch = '\0'; return (ch - nick); }
/* clean_nick_name() * * input - nickname * - whether it's a local nick (1) or remote (0) * output - none * side effects - walks through the nickname, returning 0 if erroneous */ static int clean_nick_name(const char *nick, const int local) { const char *p = nick; assert(nick && *nick); /* nicks can't start with a digit or - or be 0 length */ /* This closer duplicates behaviour of hybrid-6 */ if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') return 0; for (; *p; ++p) if (!IsNickChar(*p)) return 0; return p - nick <= (NICKLEN - 1); }
/* Converts a string to irc lowercase for letters which can be used on both cases for nicks */ void irc_lower_nick(char *str) { char *c; char cl; if(str == NULL) return; c = str; while(*c) { cl = ToLower(*c); if(IsNickChar(cl)) *c = cl; ++c; } }
/* clean_nick_name() * * input - nickname * output - none * side effects - walks through the nickname, returning 0 if erroneous */ static int clean_nick_name(char *nick) { s_assert(nick); if(nick == NULL) return 0; /* nicks cant start with a digit or -, and must have a length */ if(*nick == '-' || IsDigit(*nick) || !*nick) return 0; for (; *nick; nick++) { if(!IsNickChar(*nick)) return 0; } return 1; }
static int clean_nick(const char *nick) { int len = 0; if(EmptyString(nick) || *nick == '-' || IsDigit(*nick)) return 0; for(; *nick; nick++) { len++; if(!IsNickChar(*nick)) return 0; } if(len >= NICKLEN) return 0; return 1; }
static int clean_nick_name(char *nick) { assert(nick); if(nick == NULL) return 0; /* nicks cant start with a digit or - or be 0 length */ /* This closer duplicates behaviour of hybrid-6 */ if (*nick == '-' || IsDigit(*nick) || *nick == '\0') return 0; for(; *nick; nick++) { if(!IsNickChar(*nick)) return 0; } return 1; }
int eval_nick_char(char c) { return (0 != IsNickChar(c)); }