Changes in commands.c [b73ac9c:5c09a59]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rb73ac9c r5c09a59 86 86 int cmd_identify( irc_t *irc, char **cmd ) 87 87 { 88 storage_status_t status = storage_load( irc->nick, cmd[1], irc);89 90 switch (status) {91 case STORAGE_INVALID_PASSWORD:88 int checkie = bitlbee_load( irc, cmd[1] ); 89 90 if( checkie == -1 ) 91 { 92 92 irc_usermsg( irc, "Incorrect password" ); 93 break; 94 case STORAGE_NO_SUCH_USER: 93 } 94 else if( checkie == 0 ) 95 { 95 96 irc_usermsg( irc, "The nick is (probably) not registered" ); 96 break; 97 case STORAGE_OK: 97 } 98 else if( checkie == 1 ) 99 { 98 100 irc_usermsg( irc, "Password accepted" ); 99 break; 100 default: 101 } 102 else 103 { 101 104 irc_usermsg( irc, "Something very weird happened" ); 102 break; 103 } 104 105 } 106 105 107 return( 0 ); 106 108 } … … 108 110 int cmd_register( irc_t *irc, char **cmd ) 109 111 { 112 int checkie; 113 char path[512]; 114 110 115 if( global.conf->authmode == AUTHMODE_REGISTERED ) 111 116 { … … 113 118 return( 0 ); 114 119 } 115 116 irc_setpass( irc, cmd[1] ); 117 switch( 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; 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" ); 129 136 } 130 137 … … 134 141 int cmd_drop( irc_t *irc, char **cmd ) 135 142 { 136 storage_status_t status; 137 138 status = storage_remove (irc->nick, cmd[1]); 139 switch (status) { 140 case STORAGE_NO_SUCH_USER: 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 { 141 150 irc_usermsg( irc, "That account does not exist" ); 142 151 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 } 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 ); 154 172 } 155 173 … … 616 634 int cmd_save( irc_t *irc, char **cmd ) 617 635 { 618 if( storage_save( irc, TRUE ) == STORAGE_OK)636 if( bitlbee_save( irc ) ) 619 637 irc_usermsg( irc, "Configuration saved" ); 620 638 else
Note: See TracChangeset
for help on using the changeset viewer.