AW: [IRCServices] nick.db version 8 format (Addendum)

Johan Yves August Grasmo johanyg at ifi.uio.no
Wed May 16 20:59:01 PDT 2001


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]