Changes in commands.c [5c09a59:a1f17d4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
r5c09a59 ra1f17d4 86 86 int cmd_identify( irc_t *irc, char **cmd ) 87 87 { 88 int checkie = bitlbee_load( irc, cmd[1]);88 int checkie = global.storage->load( irc->nick, cmd[1], irc ); 89 89 90 90 if( checkie == -1 ) … … 110 110 int cmd_register( irc_t *irc, char **cmd ) 111 111 { 112 int checkie;113 char path[512];114 115 112 if( global.conf->authmode == AUTHMODE_REGISTERED ) 116 113 { … … 118 115 return( 0 ); 119 116 } 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 ) 128 { 129 setpassnc( irc, cmd[1] ); 130 root_command_string( irc, user_find( irc, irc->mynick ), "save", 0 ); 131 irc->status = USTATUS_IDENTIFIED; 132 } 133 else 134 { 135 irc_usermsg( irc, "Nick is already registered" ); 117 118 setpassnc( irc, cmd[1] ); 119 switch( global.storage->save( irc, FALSE )) { 120 case STORAGE_ALREADY_EXISTS: 121 irc_usermsg( irc, "Nick is already registered" ); 122 break; 123 124 case STORAGE_OK: 125 irc->status = USTATUS_IDENTIFIED; 126 break; 127 128 default: 129 irc_usermsg( irc, "Error registering" ); 130 break; 136 131 } 137 132 … … 141 136 int cmd_drop( irc_t *irc, char **cmd ) 142 137 { 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 ) 149 { 138 storage_status_t status; 139 140 status = global.storage->remove (irc->nick, cmd[1]); 141 switch (status) { 142 case STORAGE_NO_SUCH_USER: 150 143 irc_usermsg( irc, "That account does not exist" ); 151 144 return( 0 ); 152 } 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 ); 167 168 setpassnc( irc, NULL ); 169 irc_usermsg( irc, "Files belonging to account `%s' removed", irc->nick ); 170 171 return( 0 ); 145 case STORAGE_INVALID_PASSWORD: 146 irc_usermsg( irc, "Password invalid" ); 147 return( 0 ); 148 case STORAGE_OK: 149 setpassnc( irc, NULL ); 150 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 151 return( 0 ); 152 default: 153 irc_usermsg( irc, "Error: '%d'", status ); 154 return( 0 ); 155 } 172 156 } 173 157 … … 634 618 int cmd_save( irc_t *irc, char **cmd ) 635 619 { 636 if( bitlbee_save( irc) )620 if( global.storage->save( irc, TRUE ) ) 637 621 irc_usermsg( irc, "Configuration saved" ); 638 622 else
Note: See TracChangeset
for help on using the changeset viewer.