ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/uid.C
Revision: 1.4
Committed: Tue Aug 28 17:08:12 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -9 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# Content
1 /*
2 * uid.C: UID management.
3 * Rights to this code are documented in doc/pod/license.pod.
4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */
7
8 static char const rcsid[] = "$Id: uid.C,v 1.3 2007-07-21 13:23:22 pippijn Exp $";
9
10 #include "atheme.h"
11
12 static char new_uid[9]; /* allow for \0 */
13 static unsigned int uindex = 0;
14
15 void
16 init_uid (void)
17 {
18 unsigned int i;
19 char buf[BUFSIZE];
20
21 if (ircd->uses_p10 == true)
22 {
23 me.numeric = sstrdup (uinttobase64 (buf, atoi (me.numeric), 2));
24 uindex = 5;
25 }
26 else
27 uindex = 9;
28
29
30 memset (new_uid, 0, sizeof (new_uid));
31
32 if (me.numeric != NULL)
33 memcpy (new_uid, me.numeric, strlen (me.numeric));
34 else
35 return;
36
37 for (i = 0; i < strlen (me.numeric); i++)
38 if (new_uid[i] == '\0')
39 new_uid[i] = 'A';
40
41 for (i = strlen (me.numeric); i < uindex; i++)
42 new_uid[i] = 'A';
43 }
44
45 static void
46 add_one_to_uid (unsigned int i)
47 {
48 if (i != strlen (me.numeric)) /* Not reached server SID portion yet? */
49 {
50 if (new_uid[i] == 'Z')
51 new_uid[i] = '0';
52 else if (new_uid[i] == '9')
53 {
54 new_uid[i] = 'A';
55 add_one_to_uid (i - 1);
56 }
57 else
58 new_uid[i] = new_uid[i] + 1;
59 }
60 else
61 {
62 if (new_uid[i] == 'Z')
63 for (i = strlen (me.numeric); i < 9; i++)
64 new_uid[i] = 'A';
65 else
66 new_uid[i] = new_uid[i] + 1;
67 }
68 }
69
70 char *
71 uid_get (void)
72 {
73 add_one_to_uid (uindex - 1); /* index from 0 */
74 return (new_uid);
75 }