aboutsummaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-08 14:41:53 +0100
committerJelmer Vernooij <jelmer@samba.org>2005-12-08 14:41:53 +0100
commit1ee6c18cfb5eb03f33a5938b37e357dd3fd2c164 (patch)
tree6b6806ac2c13634c7a7c5419e95a0c8bd1fe6884 /commands.c
parentd636233a518fbe46264230866d4b8ea463f1474e (diff)
Add abstraction layer for storage
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/commands.c b/commands.c
index 504a9345..1fe6cae3 100644
--- a/commands.c
+++ b/commands.c
@@ -85,7 +85,7 @@ int cmd_help( irc_t *irc, char **cmd )
int cmd_identify( irc_t *irc, char **cmd )
{
- int checkie = bitlbee_load( irc, cmd[1] );
+ int checkie = global.storage->load( irc->nick, cmd[1], irc );
if( checkie == -1 )
{
@@ -109,22 +109,13 @@ int cmd_identify( irc_t *irc, char **cmd )
int cmd_register( irc_t *irc, char **cmd )
{
- int checkie;
- char path[512];
-
if( global.conf->authmode == AUTHMODE_REGISTERED )
{
irc_usermsg( irc, "This server does not allow registering new accounts" );
return( 0 );
}
-
- g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
- checkie = access( path, F_OK );
-
- g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
- checkie += access( path, F_OK );
-
- if( checkie == -2 )
+
+ if( !global.storage->exists( irc->nick ))
{
setpassnc( irc, cmd[1] );
root_command_string( irc, user_find( irc, irc->mynick ), "save", 0 );
@@ -140,30 +131,19 @@ int cmd_register( irc_t *irc, char **cmd )
int cmd_drop( irc_t *irc, char **cmd )
{
- char s[512];
- FILE *fp;
-
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
- fp = fopen( s, "r" );
- if( !fp )
+ if( ! global.storage->exists (irc->nick) )
{
irc_usermsg( irc, "That account does not exist" );
return( 0 );
}
-
- fscanf( fp, "%32[^\n]s", s );
- fclose( fp );
- if( setpass( irc, cmd[1], s ) < 0 )
+
+ if ( global.storage->check_pass (irc->nick, cmd[1]) )
{
- irc_usermsg( irc, "Incorrect password" );
+ irc_usermsg( irc, "Password invalid" );
return( 0 );
}
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
- unlink( s );
-
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
- unlink( s );
+ global.storage->remove (irc->nick);
setpassnc( irc, NULL );
irc_usermsg( irc, "Files belonging to account `%s' removed", irc->nick );
@@ -633,7 +613,7 @@ int cmd_set( irc_t *irc, char **cmd )
int cmd_save( irc_t *irc, char **cmd )
{
- if( bitlbee_save( irc ) )
+ if( global.storage->save( irc ) )
irc_usermsg( irc, "Configuration saved" );
else
irc_usermsg( irc, "Configuration could not be saved!" );