Changeset 1ee6c18 for commands.c


Ignore:
Timestamp:
2005-12-08T13:41:53Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
a1f17d4
Parents:
d636233
Message:

Add abstraction layer for storage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rd636233 r1ee6c18  
    8686int cmd_identify( irc_t *irc, char **cmd )
    8787{
    88         int checkie = bitlbee_load( irc, cmd[1] );
     88        int checkie = global.storage->load( irc->nick, cmd[1], irc );
    8989       
    9090        if( checkie == -1 )
     
    110110int cmd_register( irc_t *irc, char **cmd )
    111111{
    112         int checkie;
    113         char path[512];
    114        
    115112        if( global.conf->authmode == AUTHMODE_REGISTERED )
    116113        {
     
    118115                return( 0 );
    119116        }
    120        
    121         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    122         checkie = access( path, F_OK );
    123        
    124         g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    125         checkie += access( path, F_OK );
    126        
    127         if( checkie == -2 )
     117
     118        if( !global.storage->exists( irc->nick ))
    128119        {
    129120                setpassnc( irc, cmd[1] );
     
    141132int cmd_drop( irc_t *irc, char **cmd )
    142133{
    143         char s[512];
    144         FILE *fp;
    145        
    146         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    147         fp = fopen( s, "r" );
    148         if( !fp )
     134        if( ! global.storage->exists (irc->nick) )
    149135        {
    150136                irc_usermsg( irc, "That account does not exist" );
    151137                return( 0 );
    152138        }
    153        
    154         fscanf( fp, "%32[^\n]s", s );
    155         fclose( fp );
    156         if( setpass( irc, cmd[1], s ) < 0 )
    157         {
    158                 irc_usermsg( irc, "Incorrect password" );
    159                 return( 0 );
    160         }
    161        
    162         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
    163         unlink( s );
    164        
    165         g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
    166         unlink( s );
     139
     140        if ( global.storage->check_pass (irc->nick, cmd[1]) )
     141        {
     142                irc_usermsg( irc, "Password invalid" );
     143                return( 0 );
     144        }
     145       
     146        global.storage->remove (irc->nick);
    167147       
    168148        setpassnc( irc, NULL );
     
    634614int cmd_save( irc_t *irc, char **cmd )
    635615{
    636         if( bitlbee_save( irc ) )
     616        if( global.storage->save( irc ) )
    637617                irc_usermsg( irc, "Configuration saved" );
    638618        else
Note: See TracChangeset for help on using the changeset viewer.