diff options
| author | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-29 18:34:07 +0000 |
|---|---|---|
| committer | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-29 18:34:07 +0000 |
| commit | 071a08c7ec0baba9060b00ef264768592ff36d9a (patch) | |
| tree | 88ecb6129e50be2d52580861c59f640ac4288951 /src/servers.c | |
| parent | 53fbcea42156d8196c06177966f59afbbcbe0925 (diff) | |
BUILD : 1.7.19 (1286) BUGS : 731 NOTES : Fixed TS6 UID generation
git-svn-id: svn://svn.anope.org/anope/trunk@1286 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1004 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/servers.c')
| -rw-r--r-- | src/servers.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/servers.c b/src/servers.c index 31d7425dd..4aaebc302 100644 --- a/src/servers.c +++ b/src/servers.c @@ -558,4 +558,61 @@ void finish_sync(Server * serv, int sync_links) alog("Server %s is done syncing", serv->name); } +/*******************************************************************/ + +/* TS6 UID generator common code. + * + * Derived from atheme-services, uid.c (hg 2954:116d46894b4c). + * -nenolod + */ +static int ts6_uid_initted = 0; +static char ts6_new_uid[10]; /* allow for \0 */ +static unsigned int ts6_uid_index = 9; /* last slot in uid buf */ + +void ts6_uid_init(void) +{ + unsigned int i; + char buf[BUFSIZE]; + + /* check just in case... you can never be too safe. */ + if (TS6SID != NULL) { + snprintf(ts6_new_uid, 10, "%sAAAAAA", TS6SID); + ts6_uid_initted = 1; + } else { + alog("warning: no TS6SID specified, disabling TS6 support."); + UseTS6 = 0; + + return; + } +} + +void ts6_uid_increment(unsigned int slot) +{ + if (slot != strlen(TS6SID)) { + if (ts6_new_uid[slot] == 'Z') + ts6_new_uid[slot] = '0'; + else if (ts6_new_uid[slot] == '9') { + ts6_new_uid[slot] = 'A'; + ts6_uid_increment(slot - 1); + } else + ts6_new_uid[slot]++; + } else { + if (ts6_new_uid[slot] == 'Z') + for (slot = 3; slot < 9; slot++) + ts6_new_uid[slot] = 'A'; + else + ts6_new_uid[slot]++; + } +} + +char *ts6_uid_retrieve(void) +{ + if (ts6_uid_initted != 1) + ts6_uid_init(); + + ts6_uid_increment(ts6_uid_index - 1); + + return ts6_new_uid; +} + /* EOF */ |
