MCPcopy Create free account
hub / github.com/assaultcube/AC / connectprotocol

Function connectprotocol

source/src/main.cpp:1096–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094}
1095
1096void connectprotocol(char *protocolstring) // assaultcube://example.org[:28763][/][?[port=28763][&password=secret]]
1097{
1098 urlparse u;
1099 u.set(protocolstring);
1100 if(strcmp(u.scheme, "assaultcube") || !*u.domain) { conoutf("\f3bad commandline syntax (\"%s\")", protocolstring); return; }
1101 if(*u.userpassword) clientlogf(" ignoring user:password part of url (%s)", u.userpassword);
1102 if(*u.fragment) clientlogf(" ignoring fragment part of url (%s)", u.fragment);
1103 if(*u.path) clientlogf(" ignoring path part of url (%s)", u.path);
1104 int port = ATOI(u.port);
1105 const char *q = u.query, *passwd = NULL;
1106 while(q && *q)
1107 {
1108 if(*q == '&') q++;
1109 if(!strncmp(q, "port=", 5))
1110 {
1111 q += 5;
1112 port = ATOI(q);
1113 q = strchr(q, '&');
1114 }
1115 else if(!strncmp(q, "password=", 9))
1116 {
1117 q += 9;
1118 const char *e = strchr(q, '&');
1119 passwd = e ? newstring(q, e - q) : newstring(q);
1120 q = e;
1121 }
1122 else break;
1123 }
1124 defformatstring(cmd)("connect %s %d %s", u.domain, port, passwd ? passwd : "");
1125 DEBUGCODE(clientlogf("connectprotocol: %s", cmd));
1126 addsleep(5, cmd, true);
1127 DELSTRING(passwd);
1128}
1129
1130int bakshowmenuonstartup = -1;
1131static char *aaconnect = NULL;

Callers 1

afterauthFunction · 0.85

Calls 5

clientlogfFunction · 0.85
newstringFunction · 0.85
addsleepFunction · 0.85
setMethod · 0.80
conoutfFunction · 0.70

Tested by

no test coverage detected