diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-15 00:47:59 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-15 00:47:59 +0100 |
commit | c831eaa35f180b8ec0254ca8a4539e9fb012657d (patch) | |
tree | 7efd1a7a03a968237e0296d3c74d4cd6b76495e0 | |
parent | b928e98f7415fa2b8d65b5dff186c69522600e66 (diff) |
Reformatted com_showlist()
-rw-r--r-- | FICS/lists.c | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/FICS/lists.c b/FICS/lists.c index 174ef8b..cc92297 100644 --- a/FICS/lists.c +++ b/FICS/lists.c @@ -379,40 +379,56 @@ PUBLIC int com_sublist(int p,param_list param) return list_addsub(p, param[0].val.word, param[1].val.word, 2); } -PUBLIC int com_showlist(int p, param_list param) +PUBLIC int +com_showlist(int p, param_list param) { - List *gl; - int i, rights; - - char *rightnames[] = {"EDIT HEAD, READ ADMINS", "EDIT GODS, READ ADMINS", "READ/WRITE ADMINS", "PUBLIC", "PERSONAL"}; + List *gl; + char *rightnames[] = { + "EDIT HEAD, READ ADMINS", + "EDIT GODS, READ ADMINS", + "READ/WRITE ADMINS", + "PUBLIC", + "PERSONAL" + }; + int i, rights; + + if (param[0].type == 0) { // Show all lists + pprintf(p, "Lists:\n\n"); + + for (i = 0; ListArray[i].name != NULL; i++) { + if ((rights = ListArray[i].rights) > P_ADMIN || + parray[p].adminLevel >= ADMIN_ADMIN) { + pprintf(p, "%-20s is %s\n", ListArray[i].name, + rightnames[rights]); + } + } + } else { // find match in index + if ((gl = list_findpartial(p, param[0].val.word, 0)) == NULL) + return COM_OK; + + rights = ListArray[gl->which].rights; + + { // display the list + multicol *m = multicol_start(gl->numMembers); + + pprintf(p, "-- %s list: %d %s --", + ListArray[gl->which].name, + gl->numMembers, + ((!strcmp(ListArray[gl->which].name, "filter")) + ? "ips" + : (!strcmp(ListArray[gl->which].name, "removedcom")) + ? "commands" + : (!strcmp(ListArray[gl->which].name, "channel")) + ? "channels" + : "names")); + for (i = 0; i < gl->numMembers; i++) + multicol_store_sorted(m, gl->member[i]); + multicol_pprint(m, p, 78, 2); + multicol_end(m); + } + } - if (param[0].type == 0) { /* Show all lists */ - pprintf(p, "Lists:\n\n"); - for (i = 0; ListArray[i].name != NULL; i++) { - rights = ListArray[i].rights; - if ((rights > P_ADMIN) || (parray[p].adminLevel >= ADMIN_ADMIN)) - pprintf(p, "%-20s is %s\n", ListArray[i].name, rightnames[rights]); - } - } else { /* find match in index */ - gl = list_findpartial(p, param[0].val.word, 0); - if (!gl) { - return COM_OK; - } - rights = ListArray[gl->which].rights; - /* display the list */ - { - multicol *m = multicol_start(gl->numMembers); - - pprintf(p, "-- %s list: %d %s --", ListArray[gl->which].name, - gl->numMembers, - ((!(strcmp(ListArray[gl->which].name,"filter"))) ? "ips" : (!(strcmp(ListArray[gl->which].name,"removedcom"))) ? "commands" : (!(strcmp(ListArray[gl->which].name,"channel"))) ? "channels" : "names")); - for (i = 0; i < gl->numMembers; i++) - multicol_store_sorted(m, gl->member[i]); - multicol_pprint(m, p, 78, 2); - multicol_end(m); - } - } - return COM_OK; + return COM_OK; } PUBLIC int |