From 1e9d2ef0202aa02d95ba5f15899cdce6434cee48 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 23 Apr 2016 14:37:14 -0400 Subject: [PATCH] Removed all references to ctdl_hlp_dir. cmd_mesg() and cmd_emsg() now only look in the messages directory. --- citadel/include/citadel_dirs.h | 1 - citadel/modules/ctdlproto/serv_file.c | 55 +++------------------------ citadel/support.c | 25 ------------ citadel/support.h | 2 - citadel/utillib/citadel_dirs.c | 13 ------- 5 files changed, 6 insertions(+), 90 deletions(-) diff --git a/citadel/include/citadel_dirs.h b/citadel/include/citadel_dirs.h index db669ba9b..a7fddb9d5 100644 --- a/citadel/include/citadel_dirs.h +++ b/citadel/include/citadel_dirs.h @@ -13,7 +13,6 @@ extern char ctdl_bb_dir[PATH_MAX]; extern char ctdl_data_dir[PATH_MAX]; extern char ctdl_dspam_dir[PATH_MAX]; extern char ctdl_file_dir[PATH_MAX]; -extern char ctdl_hlp_dir[PATH_MAX]; extern char ctdl_shared_dir[PATH_MAX]; extern char ctdl_image_dir[PATH_MAX]; extern char ctdl_info_dir[PATH_MAX]; diff --git a/citadel/modules/ctdlproto/serv_file.c b/citadel/modules/ctdlproto/serv_file.c index 738c80b3f..9ffb51b05 100644 --- a/citadel/modules/ctdlproto/serv_file.c +++ b/citadel/modules/ctdlproto/serv_file.c @@ -763,22 +763,17 @@ void cmd_mesg(char *mname) char targ[256]; char buf[256]; char buf2[256]; - char *dirs[2]; DIR *dp; struct dirent *d; extract_token(buf, mname, 0, '|', sizeof buf); - dirs[0] = strdup(ctdl_message_dir); - dirs[1] = strdup(ctdl_hlp_dir); - - snprintf(buf2, sizeof buf2, "%s.%d.%d", - buf, CC->cs_clientdev, CC->cs_clienttyp); + snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp); /* If the client requested "?" then produce a listing */ if (!strcmp(buf, "?")) { cprintf("%d %s\n", LISTING_FOLLOWS, buf); - dp = opendir(dirs[1]); + dp = opendir(ctdl_message_dir); if (dp != NULL) { while (d = readdir(dp), d != NULL) { if (d->d_name[0] != '.') { @@ -788,43 +783,15 @@ void cmd_mesg(char *mname) closedir(dp); } cprintf("000\n"); - free(dirs[0]); - free(dirs[1]); return; } /* Otherwise, look for the requested file by name. */ - else { - mesg_locate(targ, sizeof targ, buf2, 2, (const ccharp*)dirs); - if (IsEmptyStr(targ)) { - snprintf(buf2, sizeof buf2, "%s.%d", - buf, CC->cs_clientdev); - mesg_locate(targ, sizeof targ, buf2, 2, - (const ccharp*)dirs); - if (IsEmptyStr(targ)) { - mesg_locate(targ, sizeof targ, buf, 2, - (const ccharp*)dirs); - } - } - } - - free(dirs[0]); - free(dirs[1]); - - if (IsEmptyStr(targ)) { - cprintf("%d '%s' not found. (Searching in %s and %s)\n", - ERROR + FILE_NOT_FOUND, - mname, - ctdl_message_dir, - ctdl_hlp_dir - ); - return; - } - + snprintf(targ, sizeof targ, "%s/%s", ctdl_message_dir, buf); mfp = fopen(targ, "r"); if (mfp==NULL) { cprintf("%d Cannot open '%s': %s\n", - ERROR + INTERNAL_ERROR, targ, strerror(errno)); + ERROR + FILE_NOT_FOUND, targ, strerror(errno)); return; } cprintf("%d %s\n", LISTING_FOLLOWS,buf); @@ -848,7 +815,6 @@ void cmd_emsg(char *mname) FILE *mfp; char targ[256]; char buf[256]; - char *dirs[2]; int a; unbuffer_output(); @@ -860,20 +826,11 @@ void cmd_emsg(char *mname) if (buf[a] == '/') buf[a] = '.'; } - dirs[0] = strdup(ctdl_message_dir); - dirs[1] = strdup(ctdl_hlp_dir); - - mesg_locate(targ, sizeof targ, buf, 2, (const ccharp*)dirs); - free(dirs[0]); - free(dirs[1]); - if (IsEmptyStr(targ)) { - snprintf(targ, sizeof targ, - "%s/%s", - ctdl_hlp_dir, buf); + snprintf(targ, sizeof targ, "%s/%s", ctdl_message_dir, buf); } - mfp = fopen(targ,"w"); + mfp = fopen(targ, "w"); if (mfp==NULL) { cprintf("%d Cannot open '%s': %s\n", ERROR + INTERNAL_ERROR, targ, strerror(errno)); diff --git a/citadel/support.c b/citadel/support.c index 56941c36f..af155d31d 100644 --- a/citadel/support.c +++ b/citadel/support.c @@ -81,28 +81,3 @@ int getstring(FILE *fp, char *string) } while(string[0]=='#'); return(strlen(string)); } - - - - -/* - * mesg_locate() - locate a message or help file, case insensitive - */ -void mesg_locate(char *targ, size_t n, const char *searchfor, - int numdirs, const char * const *dirs) -{ - int a; - char buf[SIZ]; - struct stat test; - - for (a=0; a