diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-01-01 13:37:22 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-01-01 13:37:22 +0100 |
commit | 9303b5c6f93d33fe3de61d6181d7f36559aee4f1 (patch) | |
tree | 349f3bf5b6e4261dea9b8f230d46e569ca0097d6 /FICS | |
parent | 189c77622d9c5e8f7b547f52f37a3ffc5bb8e09a (diff) |
Reformatted create_news_index()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/adminproc.c | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/FICS/adminproc.c b/FICS/adminproc.c index 013e91f..1c1b84a 100644 --- a/FICS/adminproc.c +++ b/FICS/adminproc.c @@ -195,45 +195,66 @@ PRIVATE int add_item(char *new_item, char *filename) } /* - * create_news_index: Adds a new item to either the general or admin news - * index file, depending upon the admin switch. + * Adds a new item to either the general or admin news index file, + * depending upon the admin switch. */ -PRIVATE int create_news_index(int p, param_list param, int admin) +PRIVATE int +create_news_index(int p, param_list param, int admin) { - char filename[MAX_FILENAME_SIZE]; - char new_item[MAX_LINE_SIZE]; + char filename[MAX_FILENAME_SIZE] = { '\0' }; + char new_item[MAX_LINE_SIZE] = { '\0' }; - ASSERT(parray[p].adminLevel >= ADMIN_ADMIN); + ASSERT(parray[p].adminLevel >= ADMIN_ADMIN); - if (admin) { - if (strlen(param[0].val.string) > 50) - pprintf(p, "Sorry, you must limit an index to 50 charaters! Admin news index not created.\n"); - else { - num_anews++; - sprintf(new_item, "%d %d %s\n", (int) time(0), num_anews, param[0].val.string); - sprintf(filename, "%s/newadminnews.index", news_dir); - if (add_item(new_item, filename)) { - pprintf(p, "Index for admin news item #%d created.\n", num_anews); - pprintf(p, "Please use 'canewsf' to include more info.\n"); - } else - pprintf(p, "Something went wrong creating item.\nNotify Marsalis.\n"); - } - } else { - if (strlen(param[0].val.string) > 50) - pprintf(p, "Sorry, you must limit an index to 50 charaters! News index not created.\n"); - else { - num_news++; - sprintf(filename, "%s/newnews.index", news_dir); - sprintf(new_item, "%d %d %s\n", (int) time(0), num_news, param[0].val.string); - if (add_item(new_item, filename)) { - pprintf(p, "Index for news item #%d created.\n", num_news); - pprintf(p, "Please use 'cnewsf' to include more info.\n"); - } else - pprintf(p, "Something went wrong creating item.\nNotify Marsalis.\n"); - } - } + if (admin) { + if (strlen(param[0].val.string) > 50) { + pprintf(p, "Sorry, you must limit an index to 50 " + "charaters! Admin news index not created.\n"); + } else { + num_anews++; + + sprintf(new_item, "%ld %d %s\n", + (long int)time(NULL), + num_anews, + param[0].val.string); + sprintf(filename, "%s/newadminnews.index", news_dir); + + if (add_item(new_item, filename)) { + pprintf(p, "Index for admin news item #%d " + "created.\n", num_anews); + pprintf(p, "Please use 'canewsf' to include " + "more info.\n"); + } else { + pprintf(p, "Something went wrong creating item." + "\nNotify Marsalis.\n"); + } + } + } else { + if (strlen(param[0].val.string) > 50) { + pprintf(p, "Sorry, you must limit an index to 50 " + "charaters! News index not created.\n"); + } else { + num_news++; + + sprintf(filename, "%s/newnews.index", news_dir); + sprintf(new_item, "%ld %d %s\n", + (long int)time(NULL), + num_news, + param[0].val.string); + + if (add_item(new_item, filename)) { + pprintf(p, "Index for news item #%d created.\n", + num_news); + pprintf(p, "Please use 'cnewsf' to include " + "more info.\n"); + } else { + pprintf(p, "Something went wrong creating item." + "\nNotify Marsalis.\n"); + } + } + } - return COM_OK; + return COM_OK; } /* cnewsi |