| 278 | } |
| 279 | |
| 280 | int parseusername(char *username, struct clientparam *param, int extpasswd){ |
| 281 | char *sb = NULL, *se = NULL, *sp = NULL; |
| 282 | |
| 283 | if(!username || !*username) return 1; |
| 284 | if(param->srv->needuser && (sb = strchr(username, ':')) && (se = strchr(sb + 1, ':')) && (!extpasswd || (sp = strchr(se + 1, ':')))){ |
| 285 | *sb = 0; |
| 286 | *se = 0; |
| 287 | if(sp) *sp = 0; |
| 288 | if(*(sb+1)) { |
| 289 | if(param->password) myfree(param->password); |
| 290 | param->password = (unsigned char *)mystrdup(sb+1); |
| 291 | } |
| 292 | if(*username) { |
| 293 | if(param->username) myfree(param->username); |
| 294 | param->username = (unsigned char *)mystrdup(username); |
| 295 | } |
| 296 | username = se+1; |
| 297 | } |
| 298 | if(extpasswd){ |
| 299 | if(!sp) sp = strchr(username, ':'); |
| 300 | if(sp){ |
| 301 | *sp = 0; |
| 302 | if(param->extpassword) myfree(param->extpassword); |
| 303 | param->extpassword = (unsigned char *) mystrdup(sp+1); |
| 304 | } |
| 305 | } |
| 306 | if(param->extusername) myfree(param->extusername); |
| 307 | param->extusername = (unsigned char *)mystrdup(username); |
| 308 | if(sb) *sb = ':'; |
| 309 | if(se) *se = ':'; |
| 310 | if(sp) *sp = ':'; |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port){ |
| 315 | char *sb, *se; |
no test coverage detected