aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/lists.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-15 20:36:45 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-15 20:36:45 +0100
commit9b18064b89d21eefcc47402589db35e344d28c9d (patch)
treee066407f3b76e46a3bea9e912a0ca84420e0dcf2 /FICS/lists.c
parent7d5fbd58e7a02444102270cff8fb73fa0d351ba1 (diff)
Reformatted list_findpartial()
Diffstat (limited to 'FICS/lists.c')
-rw-r--r--FICS/lists.c104
1 files changed, 57 insertions, 47 deletions
diff --git a/FICS/lists.c b/FICS/lists.c
index 5a19d30..4a974a5 100644
--- a/FICS/lists.c
+++ b/FICS/lists.c
@@ -164,55 +164,65 @@ PUBLIC int list_size(int p, enum ListWhich l)
return 0;
}
-/* find list by name, doesn't have to be the whole name */
-PRIVATE List *list_findpartial(int p, char *which, int gonnado)
+/*
+ * Find list by name
+ * (doesn't have to be the whole name)
+ */
+PRIVATE List *
+list_findpartial(int p, char *which, int gonnado)
{
- List *gl;
- int i, foundit, slen;
-
- slen = strlen(which);
- for (i = 0, foundit = -1; ListArray[i].name != NULL; i++) {
- if (!strncasecmp(ListArray[i].name, which, slen)) {
- if (foundit == -1)
- foundit = i;
- else
- return NULL; /* ambiguous */
- }
- }
+ List *gl;
+ int foundit, slen;
- if (foundit != -1) {
- int rights = ListArray[foundit].rights;
- int youlose = 0;
-
- switch (rights) { /* check rights */
- case P_HEAD:
- if (gonnado && !player_ishead(p))
- youlose = 1;
- break;
- case P_GOD:
- if ((gonnado && (parray[p].adminLevel < ADMIN_GOD)) ||
- (!gonnado && (parray[p].adminLevel < ADMIN_ADMIN)))
- youlose = 1;
- break;
- case P_ADMIN:
- if (parray[p].adminLevel < ADMIN_ADMIN)
- youlose = 1;
- break;
- case P_PUBLIC:
- if (gonnado && (parray[p].adminLevel < ADMIN_ADMIN))
- youlose = 1;
- break;
- }
- if (youlose) {
- pprintf(p, "\"%s\" is not an appropriate list name or you have insufficient rights.\n", which);
- return NULL;
- }
- gl = list_find(p, foundit);
- } else {
- pprintf(p, "\"%s\" does not match any list name.\n", which);
- return NULL;
- }
- return gl;
+ foundit = -1;
+ slen = strlen(which);
+
+ for (int i = 0; ListArray[i].name != NULL; i++) {
+ if (!strncasecmp(ListArray[i].name, which, slen)) {
+ if (foundit == -1)
+ foundit = i;
+ else
+ return NULL; // ambiguous
+ }
+ }
+
+ if (foundit != -1) {
+ int rights = ListArray[foundit].rights;
+ int youlose = 0;
+
+ switch (rights) { // check rights
+ case P_HEAD:
+ if (gonnado && !player_ishead(p))
+ youlose = 1;
+ break;
+ case P_GOD:
+ if ((gonnado && parray[p].adminLevel < ADMIN_GOD) ||
+ (!gonnado && parray[p].adminLevel < ADMIN_ADMIN))
+ youlose = 1;
+ break;
+ case P_ADMIN:
+ if (parray[p].adminLevel < ADMIN_ADMIN)
+ youlose = 1;
+ break;
+ case P_PUBLIC:
+ if (gonnado && (parray[p].adminLevel < ADMIN_ADMIN))
+ youlose = 1;
+ break;
+ }
+
+ if (youlose) {
+ pprintf(p, "\"%s\" is not an appropriate list name or "
+ "you have insufficient rights.\n", which);
+ return NULL;
+ }
+
+ gl = list_find(p, foundit);
+ } else {
+ pprintf(p, "\"%s\" does not match any list name.\n", which);
+ return NULL;
+ }
+
+ return gl;
}
/*