MCPcopy Index your code
hub / github.com/3proxy/3proxy / parsehostname

Function parsehostname

src/common.c:255–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255int parsehostname(char *hostname, struct clientparam *param, unsigned short port){
256 char *sp=NULL,*se=NULL;
257 int ret = 0;
258
259 if(!hostname || !*hostname)return 2;
260 if(*hostname == '[') se=strchr(hostname, ']');
261 if ( (sp = strchr(se?se:hostname, ':')) && !strchr(sp+1, ':')) *sp = 0;
262 if(se){
263 *se = 0;
264 }
265 if(hostname != (char *)param->hostname){
266 if(param->hostname) myfree(param->hostname);
267 param->hostname = (unsigned char *)mystrdup(hostname + (se!=0));
268 }
269 if(sp){
270 port = atoi(sp+1);
271 }
272 ret = !getip46(param->srv->family, param->hostname, (struct sockaddr *)&param->req);
273 if(se) *se = ']';
274 if(sp) *sp = ':';
275 *SAPORT(&param->req) = htons(port);
276 memset(&param->sinsr, 0, sizeof(param->sinsr));
277 return ret;
278}
279
280int parseusername(char *username, struct clientparam *param, int extpasswd){
281 char *sb = NULL, *se = NULL, *sp = NULL;

Callers 7

proxymain.cFile · 0.85
proxychildFunction · 0.85
parseconnusernameFunction · 0.85
ftpprchildFunction · 0.85
tcppmchildFunction · 0.85
icqprchildFunction · 0.85
udppmchildFunction · 0.85

Calls 2

myfreeFunction · 0.85
mystrdupFunction · 0.85

Tested by

no test coverage detected