2332 |
|
|
2333 |
|
/* oper_privs_as_string() |
2334 |
|
* |
2335 |
< |
* inputs - pointer to client_p or NULL |
2335 |
> |
* inputs - pointer to client_p |
2336 |
|
* output - pointer to static string showing oper privs |
2337 |
|
* side effects - return as string, the oper privs as derived from port |
2338 |
|
*/ |
2339 |
< |
|
2340 |
< |
static const unsigned int oper_flags_table[] = |
2341 |
< |
{ 'O', 'R', 'U', 'G', 'N', 'K', 'X', 'D', 'H', 'A' , 0 }; |
2339 |
> |
static const struct oper_privs |
2340 |
> |
{ |
2341 |
> |
const unsigned int oprivs; |
2342 |
> |
const unsigned int hidden; |
2343 |
> |
const unsigned char c; |
2344 |
> |
} flag_list[] = { |
2345 |
> |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2346 |
> |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2347 |
> |
{ OPER_FLAG_DIE, 0, 'D' }, |
2348 |
> |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2349 |
> |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2350 |
> |
{ OPER_FLAG_K, 0, 'K' }, |
2351 |
> |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2352 |
> |
{ OPER_FLAG_N, 0, 'N' }, |
2353 |
> |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2354 |
> |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2355 |
> |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2356 |
> |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2357 |
> |
{ OPER_FLAG_X, 0, 'X' }, |
2358 |
> |
{ 0, 0, '\0' } |
2359 |
> |
}; |
2360 |
|
|
2361 |
|
char * |
2362 |
|
oper_privs_as_string(const unsigned int port) |
2363 |
|
{ |
2364 |
< |
static char privs_out[12]; |
2364 |
> |
static char privs_out[16]; |
2365 |
> |
char *privs_ptr = privs_out; |
2366 |
> |
unsigned int i = 0; |
2367 |
> |
|
2368 |
> |
for (; flag_list[i].oprivs; ++i) |
2369 |
> |
{ |
2370 |
> |
if ((port & flag_list[i].oprivs) && |
2371 |
> |
(port & flag_list[i].hidden) == 0) |
2372 |
> |
*privs_ptr++ = flag_list[i].c; |
2373 |
> |
else |
2374 |
> |
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2375 |
> |
} |
2376 |
> |
|
2377 |
> |
*privs_ptr = '\0'; |
2378 |
|
|
2348 |
– |
if (port & OPER_FLAG_HIDDEN_ADMIN) |
2349 |
– |
flags_to_ascii(port & ~OPER_FLAG_ADMIN, oper_flags_table, privs_out, 1); |
2350 |
– |
else |
2351 |
– |
flags_to_ascii(port, oper_flags_table, privs_out, 1); |
2379 |
|
return privs_out; |
2380 |
|
} |
2381 |
|
|