1 |
/* IRC - Internet Relay Chat, ircd/channel.c |
2 |
* Copyright (C) 1996 Carlo Wood |
3 |
* |
4 |
* [Taken from Undernet ircd] |
5 |
* This file is part of pxyservd (from pxys) |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or |
8 |
* modify it under the terms of the GNU General Public License |
9 |
* as published by the Free Software Foundation; either version 2 |
10 |
* of the License, or (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
* |
21 |
*/ |
22 |
#define RCSID "$Id: irc_numnicks.c,v 1.1.1.1 2003/12/30 17:09:31 mbuna Exp $" |
23 |
|
24 |
#include "irc_numnicks.h" |
25 |
|
26 |
/* *INDENT-OFF* */ |
27 |
|
28 |
|
29 |
/* |
30 |
* The internal counter for the 'XX' of local clients |
31 |
*/ |
32 |
|
33 |
|
34 |
const char convert2y[64] = { |
35 |
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', |
36 |
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', |
37 |
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
38 |
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','[',']' |
39 |
}; |
40 |
|
41 |
const unsigned int convert2n[256] = { |
42 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
43 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
44 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
45 |
52,53,54,55,56,57,58,59,60,61, 0, 0, 0, 0, 0, 0, |
46 |
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, |
47 |
15,16,17,18,19,20,21,22,23,24,25,62, 0,63, 0, 0, |
48 |
0,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, |
49 |
41,42,43,44,45,46,47,48,49,50,51, 0, 0, 0, 0, 0, |
50 |
|
51 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
52 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
53 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
54 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
55 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
56 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
57 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
58 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
59 |
}; |
60 |
|
61 |
/* *INDENT-ON* */ |
62 |
|
63 |
unsigned int |
64 |
base64toint(const char *s) |
65 |
{ |
66 |
unsigned int i = convert2n[(unsigned char) *s++]; |
67 |
while(*s) { |
68 |
i <<= NUMNICKLOG; |
69 |
i += convert2n[(unsigned char) *s++]; |
70 |
} |
71 |
return i; |
72 |
} |
73 |
|
74 |
const char * |
75 |
inttobase64(char *buf, unsigned int v, unsigned int count) |
76 |
{ |
77 |
buf[count] = '\0'; |
78 |
while(count > 0) { |
79 |
buf[--count] = convert2y[(v & NUMNICKMASK)]; |
80 |
v >>= NUMNICKLOG; |
81 |
} |
82 |
return buf; |
83 |
} |
84 |
|