diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-01-03 00:13:22 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-01-03 00:13:22 +0100 |
commit | 55465461306367de7777bc349aef0960a8a18387 (patch) | |
tree | 6c2407c8c0694421a9bec8faa81ef9780179bdaf | |
parent | ed755d0f6a9154db14528c6520bb65a7dd8a4502 (diff) |
Reformatted com_index()
-rw-r--r-- | FICS/comproc.c | 64 |
1 files changed, 37 insertions, 27 deletions
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 |