From 55465461306367de7777bc349aef0960a8a18387 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 3 Jan 2024 00:13:22 +0100 Subject: Reformatted com_index() --- FICS/comproc.c | 64 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'FICS') diff --git a/FICS/comproc.c b/FICS/comproc.c index 7a09683..988c8e5 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -1454,36 +1454,46 @@ PUBLIC int com_servers(int p, param_list param) "PORT"); for (i = 0; i < numServers; i++) pprintf(p, "%-30s%-7d\n", serverNames[i], serverPorts[i]); return COM_OK; } */ -PUBLIC int com_index(int p, param_list param) +PUBLIC int +com_index(int p, param_list param) { - int i; - char index_default[] = "_index"; - char *iwant, *filenames[100]; /* enough for all index filenames */ + char *iwant, *filenames[100]; + char index_default[] = "_index"; + int i; - if (param[0].type == TYPE_NULL) { - iwant = index_default; - } else { - iwant = param[0].val.word; - if (!safestring(iwant)) { - pprintf(p, "Illegal character in category %s.\n", iwant); - return COM_OK; - } - } + if (param[0].type == TYPE_NULL) { + iwant = index_default; + } else { + iwant = param[0].val.word; - i = search_directory(index_dir, iwant, filenames, 1000); - if (i == 0) { - pprintf(p, "No index entry for \"%s\".\n", iwant); - } else if ((i == 1) || !strcmp(*filenames, iwant)) { - if (psend_file(p, index_dir, *filenames)) { - /* we should never reach this unless the file was just deleted */ - pprintf(p, "Index file %s could not be found! ", *filenames); - pprintf(p, "Please inform an admin of this. Thank you.\n"); - } - } else { - pprintf(p, "Matches:"); - display_directory(p, filenames, i); - } - return COM_OK; + if (!safestring(iwant)) { + pprintf(p, "Illegal character in category %s.\n", + iwant); + return COM_OK; + } + } + + i = search_directory(index_dir, iwant, filenames, 1000); + + if (i == 0) { + pprintf(p, "No index entry for \"%s\".\n", iwant); + } else if ((i == 1) || !strcmp(*filenames, iwant)) { + if (psend_file(p, index_dir, *filenames)) { + /* + * We should never reach this unless the file + * was just deleted. + */ + pprintf(p, "Index file %s could not be found! ", + *filenames); + pprintf(p, "Please inform an admin of this. " + "Thank you.\n"); + } + } else { + pprintf(p, "Matches:"); + display_directory(p, filenames, i); + } + + return COM_OK; } PUBLIC int -- cgit v1.2.3