AW: AW: [IRCServices] nick.db version 8 format (Addendum)
Georges Berscheid
Georges at berscheid.lu
Wed May 16 21:12:01 PDT 2001
Re,
I think you didn't really understand the nicklists structure. This is an
array with 255 pointers (one for each ascii char). These pointers point to a
list of ni's starting with the corresponding char. If you want to build your
nicklists you should use nickserv.c:static void alpha_insert_nick(NickInfo
*ni) It does all the work for you.
Georges
-----Ursprüngliche Nachricht-----
Von: ircservices-admin at ircservices.za.net
[mailto:ircservices-admin at ircservices.za.net]Im Auftrag von Johan Yves
August Grasmo
Gesendet: Mittwoch, 16. Mai 2001 20:58
An: ircservices at ircservices.za.net
Betreff: Re: AW: [IRCServices] nick.db version 8 format (Addendum)
On Wed, 16 May 2001 20:54:28 +0200 Georges Berscheid <Georges Berscheid
<Georges at berscheid.lu>> wrote:
> Re,
> if you want to link services to your mysql db, use the C API which is
> documented at http://www.mysql.com/doc/C/_/C_API_function_overview.html
Thank you very much Georges.
My main problem wasn't that I couldn't fetch the information
from the mysql-db, but I didn't seem to construct the
nicklists correctly.
Below is a snippet of my code in load_ns_dbase in nickserv.c
Sorry for spamming like this, but I'm on the brink of giving
up :(
Johan
[snip]
i = 0;
while ((row = mysql_fetch_row(res))) {
ni = scalloc( sizeof *ni, 1 );
nicklists[i++] = ni;
strcpy(ni->nick,row[1]);
strcpy(ni->pass,row[0]);
ni->email = sstrdup(row[2]);
log("debug: Loading user from mysql : %s %s %s",
ni->nick,
ni->pass,
ni->email);
ni->link = NULL;
ni->accesscount = 0;
ni->last_quit = 0;
ni->time_registered = 0;
ni->last_seen = 0;
ni->url = NULL;
ni->status &= ~NS_TEMPORARY;
if (!ni->last_usermask)
ni->last_usermask = sstrdup("@");
if (!ni->last_realname)
ni->last_realname = sstrdup("");
ni->id_timestamp = 999936289;
}
log("debug: Loaded users from database, found %d nicks", i);
mysql_close(sock);
/* Adjust next/prev pointers for all records.
Remember: i points past the last element */
nicklists[ 0 ]->prev = NULL;
for ( j = 0; j < i; ++j ) {
if (j > 0) {
nicklists[ j ]->prev = nicklists[ j-1 ];
nicklists[ j-1 ]->next = nicklists[ j ];
}
}
nicklists[ i-1 ]->next = NULL;
/* ... and insert sentinel */
nicklists[ i ] = NULL;
[/snip]
-----------------------------------------------------------
To unsubscribe, mail ircservices-request at ircservices.za.net
with the word UNSUBSCRIBE in the subject of the mail.
http://www.ircservices.za.net/mailman/listinfo/ircservices