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

Function printban

source/src/master.cpp:81–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79COMMANDF(gban, "s", (char *name) { addban(gbans, name); });
80
81char *printban(const baninfo &ban, char *buf)
82{
83 union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ip, mask;
84 ip.i = ban.ip;
85 mask.i = ban.mask;
86 int lastdigit = -1;
87 loopi(4) if(mask.b[i])
88 {
89 if(lastdigit >= 0) *buf++ = '.';
90 loopj(i - lastdigit - 1) { *buf++ = '*'; *buf++ = '.'; }
91 buf += sprintf(buf, "%d", ip.b[i]);
92 lastdigit = i;
93 }
94 return buf;
95}
96
97bool checkban(vector<baninfo> &bans, enet_uint32 host)
98{

Callers 1

loopvFunction · 0.85

Calls 2

loopiFunction · 0.70
loopjFunction · 0.70

Tested by

no test coverage detected