Changeset 9df916f for commands.c
- Timestamp:
- 2005-12-09T20:48:45Z (19 years ago)
- Branches:
- master
- Children:
- 34759e6
- Parents:
- c2295f7 (diff), 87c24ba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rc2295f7 r9df916f 86 86 int cmd_identify( irc_t *irc, char **cmd ) 87 87 { 88 int checkie = bitlbee_load( irc, cmd[1]);89 90 if( checkie == -1 )91 {88 storage_status_t status = global.storage->load( irc->nick, cmd[1], irc ); 89 90 switch (status) { 91 case STORAGE_INVALID_PASSWORD: 92 92 irc_usermsg( irc, "Incorrect password" ); 93 } 94 else if( checkie == 0 ) 95 { 93 break; 94 case STORAGE_NO_SUCH_USER: 96 95 irc_usermsg( irc, "The nick is (probably) not registered" ); 97 } 98 else if( checkie == 1 ) 99 { 96 break; 97 case STORAGE_OK: 100 98 irc_usermsg( irc, "Password accepted" ); 101 } 102 else 103 { 99 break; 100 default: 104 101 irc_usermsg( irc, "Something very weird happened" ); 102 break; 105 103 } 106 104 … … 110 108 int cmd_register( irc_t *irc, char **cmd ) 111 109 { 112 int checkie;113 char path[512];114 115 110 if( global.conf->authmode == AUTHMODE_REGISTERED ) 116 111 { … … 118 113 return( 0 ); 119 114 } 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" ); 115 116 irc_setpass( irc, cmd[1] ); 117 switch( global.storage->save( irc, FALSE )) { 118 case STORAGE_ALREADY_EXISTS: 119 irc_usermsg( irc, "Nick is already registered" ); 120 break; 121 122 case STORAGE_OK: 123 irc->status = USTATUS_IDENTIFIED; 124 break; 125 126 default: 127 irc_usermsg( irc, "Error registering" ); 128 break; 136 129 } 137 130 … … 141 134 int cmd_drop( irc_t *irc, char **cmd ) 142 135 { 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 { 136 storage_status_t status; 137 138 status = global.storage->remove (irc->nick, cmd[1]); 139 switch (status) { 140 case STORAGE_NO_SUCH_USER: 150 141 irc_usermsg( irc, "That account does not exist" ); 151 142 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 ); 143 case STORAGE_INVALID_PASSWORD: 144 irc_usermsg( irc, "Password invalid" ); 145 return( 0 ); 146 case STORAGE_OK: 147 irc_setpass( irc, NULL ); 148 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 149 return( 0 ); 150 default: 151 irc_usermsg( irc, "Error: '%d'", status ); 152 return( 0 ); 153 } 172 154 } 173 155 … … 634 616 int cmd_save( irc_t *irc, char **cmd ) 635 617 { 636 if( bitlbee_save( irc ))618 if( global.storage->save( irc, TRUE ) == STORAGE_OK ) 637 619 irc_usermsg( irc, "Configuration saved" ); 638 620 else
Note: See TracChangeset
for help on using the changeset viewer.