mirror of
https://github.com/pissnet/pissircd.git
synced 2025-07-30 23:12:25 +01:00
+- #define CHINESE_NICK will make you able to use chinese nicks
+ thanks to RexHsu and Aim
This commit is contained in:
parent
ae0dcf2bbf
commit
d2d806697b
3 changed files with 82 additions and 10 deletions
2
Changes
2
Changes
|
@ -221,3 +221,5 @@
|
|||
- Changed CONNECTTIMEOUT to 30sec
|
||||
- Changed some _more_ credits
|
||||
- Fixed compile error found by Headbang
|
||||
- #define CHINESE_NICK will make you able to use chinese nicks
|
||||
thanks to RexHsu and Aim
|
18
src/hash.c
18
src/hash.c
|
@ -290,7 +290,7 @@ aClient *hash_find_client(char *name, aClient *cptr)
|
|||
* Got the bucket, now search the chain.
|
||||
*/
|
||||
for (tmp = (aClient *)tmp3->list; tmp; tmp = tmp->hnext)
|
||||
if (mycmp(name, tmp->name) == 0)
|
||||
if (smycmp(name, tmp->name) == 0)
|
||||
{
|
||||
return (tmp);
|
||||
}
|
||||
|
@ -328,8 +328,8 @@ aClient *hash_find_nickserver(char *name, aClient *cptr)
|
|||
* Got the bucket, now search the chain.
|
||||
*/
|
||||
for (tmp = (aClient *)tmp3->list; tmp; tmp = tmp->hnext)
|
||||
if (mycmp(name, tmp->name) == 0 && tmp->user &&
|
||||
mycmp(serv, tmp->user->server) == 0)
|
||||
if (smycmp(name, tmp->name) == 0 && tmp->user &&
|
||||
smycmp(serv, tmp->user->server) == 0)
|
||||
{
|
||||
*--serv = '\0';
|
||||
return (tmp);
|
||||
|
@ -359,7 +359,7 @@ aClient *hash_find_server(char *server, aClient *cptr)
|
|||
{
|
||||
if (!IsServer(tmp) && !IsMe(tmp))
|
||||
continue;
|
||||
if (mycmp(server, tmp->name) == 0)
|
||||
if (smycmp(server, tmp->name) == 0)
|
||||
{
|
||||
return (tmp);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ aChannel *hash_find_channel(char *name, aChannel *chptr)
|
|||
tmp3 = &channelTable[hashv];
|
||||
|
||||
for (tmp = (aChannel *)tmp3->list; tmp; tmp = tmp->hnextch)
|
||||
if (mycmp(name, tmp->chname) == 0)
|
||||
if (smycmp(name, tmp->chname) == 0)
|
||||
{
|
||||
return (tmp);
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ int add_to_notify_hash_table(nick, cptr)
|
|||
|
||||
/* Find the right nick (header) in the bucket, or NULL... */
|
||||
if ((anptr = (aNotify *) notifyTable[hashv]))
|
||||
while (anptr && mycmp(anptr->nick, nick))
|
||||
while (anptr && smycmp(anptr->nick, nick))
|
||||
anptr = anptr->hnext;
|
||||
|
||||
/* If found NULL (no header for this nick), make one... */
|
||||
|
@ -563,7 +563,7 @@ int hash_check_notify(cptr, reply)
|
|||
|
||||
/* Find the right header in this bucket */
|
||||
if ((anptr = (aNotify *) notifyTable[hashv]))
|
||||
while (anptr && mycmp(anptr->nick, cptr->name))
|
||||
while (anptr && smycmp(anptr->nick, cptr->name))
|
||||
anptr = anptr->hnext;
|
||||
if (!anptr)
|
||||
return 0; /* This nick isn't on notify */
|
||||
|
@ -596,7 +596,7 @@ aNotify *hash_get_notify(name)
|
|||
hashv = hash_nn_name(name) % NOTIFYHASHSIZE;
|
||||
|
||||
if ((anptr = (aNotify *) notifyTable[hashv]))
|
||||
while (anptr && mycmp(anptr->nick, name))
|
||||
while (anptr && smycmp(anptr->nick, name))
|
||||
anptr = anptr->hnext;
|
||||
|
||||
return anptr;
|
||||
|
@ -619,7 +619,7 @@ int del_from_notify_hash_table(nick, cptr)
|
|||
|
||||
/* Find the right header, maintaining last-link pointer... */
|
||||
if ((anptr = (aNotify *) notifyTable[hashv]))
|
||||
while (anptr && mycmp(anptr->nick, nick))
|
||||
while (anptr && smycmp(anptr->nick, nick))
|
||||
{
|
||||
nlast = anptr;
|
||||
anptr = anptr->hnext;
|
||||
|
|
72
src/s_user.c
72
src/s_user.c
|
@ -435,7 +435,77 @@ int check_for_target_limit(aClient *sptr, void *target, const char *name)
|
|||
** a change should be global, some confusion would
|
||||
** result if only few servers allowed it...
|
||||
*/
|
||||
#ifdef CHINESE_NICK
|
||||
/* Chinese Nick Verification Code - Added by RexHsu on 08/09/00 (beta2)
|
||||
* Now Support All GBK Words,Thanks to Mr.WebBar <climb@guomai.sh.cn>!
|
||||
* Special Char Bugs Fixed by RexHsu 09/01/00 I dont know whether it is
|
||||
* okay now?May I am right ;p
|
||||
* Thanks dilly for providing me Japanese code range!
|
||||
* Now I am meeting a nickname conflicting problem....
|
||||
*
|
||||
* GBK Libary Reference:
|
||||
* 1. GBK2312非汉字符号区(A1A1----A9FE)
|
||||
* 2. GBK2312汉字区(B0A1----F7FE)
|
||||
* 3. GBK扩充汉字区(8140----A0FE)
|
||||
* 4. GBK扩充汉字区(AA40----FEA0)
|
||||
* 5. GBK扩充非汉字区(A840----A9A0)
|
||||
* 6. 日文平假名编码区(a4a1-a4f3) -->work correctly?maybe...
|
||||
* 7. 日文片假名编码区(a5a1-a5f7) -->work correctly?maybe...
|
||||
* 8. 韩文编码区(xxxx-yyyy)
|
||||
*/
|
||||
int isvalidChinese(const unsigned char c1, const unsigned char c2)
|
||||
{
|
||||
const unsigned int GBK_S = 0xb0a1;
|
||||
const unsigned int GBK_E = 0xf7fe;
|
||||
const unsigned int GBK_2_S = 0x8140;
|
||||
const unsigned int GBK_2_E = 0xa0fe;
|
||||
const unsigned int GBK_3_S = 0xaa40;
|
||||
const unsigned int GBK_3_E = 0xfea0;
|
||||
const unsigned int JPN_PING_S = 0xa4a1;
|
||||
const unsigned int JPN_PING_E = 0xa4f3;
|
||||
const unsigned int JPN_PIAN_S = 0xa5a1;
|
||||
const unsigned int JPN_PIAN_E = 0xa5f7;
|
||||
unsigned int AWord = c1 * 256 + c2;
|
||||
return (AWord >= GBK_S && AWord <= GBK_E || AWord >= GBK_2_S && AWord <= GBK_2_E || AWord >= GBK_3_S && AWord <= GBK_3_E || AWord >= JPN_PING_S && AWord <= JPN_PING_E || AWord >= JPN_PIAN_S && AWord <= JPN_PIAN_E) ? 1 : 0;
|
||||
//return (AWord >= GBK_S && AWord <= GBK_E) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Chinese Nick Supporting Code (Switch Mode) - Modified by RexHsu on 08/09/00 */
|
||||
int do_nick_name(char *pnick)
|
||||
{
|
||||
unsigned char *ch;
|
||||
unsigned char *nick=pnick;
|
||||
int firstChineseChar=0;
|
||||
char lastChar;
|
||||
|
||||
if (*nick == '-' || isdigit(*nick)) /* first character in [0..9-] */
|
||||
return 0;
|
||||
|
||||
for (ch = nick; *ch && (ch - nick) < NICKLEN; ch++)
|
||||
{
|
||||
if ((!isvalid(*ch) && !((*ch)&0x80) ) || isspace(*ch) || (*ch)=='@' || (*ch)=='!' || (*ch)==':' || (*ch)==' ')
|
||||
break;
|
||||
if(firstChineseChar)
|
||||
{
|
||||
if (!isvalidChinese(lastChar,*ch))
|
||||
break;
|
||||
firstChineseChar=0;
|
||||
}
|
||||
else if((*ch)&0x80)
|
||||
firstChineseChar=1;
|
||||
lastChar=*ch;
|
||||
}
|
||||
|
||||
if(firstChineseChar)
|
||||
ch--;
|
||||
|
||||
*ch = '\0';
|
||||
|
||||
return (ch - nick);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
int do_nick_name(nick)
|
||||
char *nick;
|
||||
{
|
||||
|
@ -452,7 +522,7 @@ int do_nick_name(nick)
|
|||
|
||||
return (ch - nick);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
** canonize
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue