aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-15 20:55:49 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-15 20:55:49 +0100
commit03003b46667be73b1cc5388d57d83ff0e6157748 (patch)
tree0797bc1e38bbf76a61f8bd1c4a4ef1c148157597
parent2a1e34dd78be0257029ac80712de8d417207c0d0 (diff)
Reformatted functions
-rw-r--r--FICS/lists.c85
1 files changed, 49 insertions, 36 deletions
diff --git a/FICS/lists.c b/FICS/lists.c
index db6a7a1..cb1685f 100644
--- a/FICS/lists.c
+++ b/FICS/lists.c
@@ -99,46 +99,59 @@ PRIVATE List *list_find(int p, enum ListWhich l)
return tempList;
}
-/* add item to list */
-PUBLIC int list_add(int p, enum ListWhich l, char *s)
+/*
+ * Add item to list
+ */
+PUBLIC int
+list_add(int p, enum ListWhich l, char *s)
{
- List *gl = list_find(p, l);
-
- if (gl) {
- if (gl->numMembers < MAX_GLOBAL_LIST_SIZE) {
- gl->member[gl->numMembers] = xstrdup(s);
- gl->numMembers++;
- return 0;
- } else {
- return 1;
- }
- } else {
- return 1;
- }
+ List *gl;
+
+ if ((gl = list_find(p, l)) != NULL) {
+ if (gl->numMembers < MAX_GLOBAL_LIST_SIZE) {
+ gl->member[gl->numMembers] = xstrdup(s);
+ gl->numMembers++;
+ return 0;
+ } else {
+ return 1;
+ }
+ } else {
+ return 1;
+ }
}
-/* remove item from list */
-PUBLIC int list_sub(int p, enum ListWhich l, char *s)
+/*
+ * Remove item from list.
+ */
+PUBLIC int
+list_sub(int p, enum ListWhich l, char *s)
{
- List *gl = list_find(p, l);
-
- if (gl) {
- int i, found = -1;
- for (i = 0; i < gl->numMembers; i++)
- if (!strcasecmp(s, gl->member[i])) {
- found = i;
- break;
- }
- if (found == -1)
- return 1;
- rfree(gl->member[found]);
- for (i = found; i < (gl->numMembers - 1); i++)
- gl->member[i] = gl->member[i + 1];
- gl->numMembers--;
- return 0;
- } else {
- return 1;
- }
+ List *gl;
+
+ if ((gl = list_find(p, l)) != NULL) {
+ int i, found = -1;
+
+ for (i = 0; i < gl->numMembers; i++) {
+ if (!strcasecmp(s, gl->member[i])) {
+ found = i;
+ break;
+ }
+ }
+
+ if (found == -1)
+ return 1;
+
+ rfree(gl->member[found]);
+
+ for (i = found; i < (gl->numMembers - 1); i++)
+ gl->member[i] = gl->member[i + 1];
+
+ gl->numMembers--;
+
+ return 0;
+ }
+
+ return 1;
}
/* pretty cheesy: print each member of a list, 1 per line */