MCPcopy Create free account
hub / github.com/3proxy/3proxy / parseusername

Function parseusername

src/common.c:280–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280int 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
314int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port){
315 char *sb, *se;

Callers 1

parseconnusernameFunction · 0.85

Calls 2

myfreeFunction · 0.85
mystrdupFunction · 0.85

Tested by

no test coverage detected