Commit 3823fea1 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Allow sysop-choice of source of virtual sub-directory source name

By default, each file transfer directory's internal code suffix is
used as the source of the sub-directory of the virtual path used
to represent a file area in the FTP and Web servers. Now, a sysop
can change that source to either each directory's short name or
long name, if they prefer.

For MRO, because he asked (on DOVE-Net).
parent 938b9c91
Pipeline #3119 passed with stage
in 10 minutes and 30 seconds
......@@ -310,6 +310,13 @@ enum area_sort {
AREA_SORT_TYPES,
};
// Values for lib[x].vdir_name
enum vdir_name {
VDIR_NAME_CODE,
VDIR_NAME_SHORT,
VDIR_NAME_LONG
};
enum {
clr_mnehigh
,clr_mnelow
......
......@@ -36,6 +36,13 @@ char* file_sort_desc[] = {
NULL
};
char* vdir_name_desc[] = {
"Internal Code Suffix",
"Short Name",
"Long Name",
NULL
};
static bool new_dir(unsigned new_dirnum, unsigned libnum)
{
dir_t* new_directory = malloc(sizeof(dir_t));
......@@ -425,6 +432,7 @@ void xfer_cfg()
sprintf(opt[j++],"%-27.27s%s","Access to Sub-directories"
,cfg.lib[libnum]->parent_path[0] ? (cfg.lib[libnum]->misc&LIB_DIRS ? "Yes":"No") : "N/A");
sprintf(opt[j++],"%-27.27s%s","Sort Library By Directory", area_sort_desc[cfg.lib[libnum]->sort]);
sprintf(opt[j++],"%-27.27s%s","Virtual Sub-directories", vdir_name_desc[cfg.lib[libnum]->vdir_name]);
strcpy(opt[j++],"Clone Options");
strcpy(opt[j++],"Export Areas...");
strcpy(opt[j++],"Import Areas...");
......@@ -564,6 +572,21 @@ void xfer_cfg()
uifc.changes = TRUE;
}
break;
case __COUNTER__:
uifc.helpbuf="`Source of Virtual Sub-directory Names:`\n"
"\n"
"File areas accessed via the FTP server or Web server are represented\n"
"by a virtual path. This setting determines the source of the\n"
"sub-directory portion of the virtual paths used to represent directories\n"
"within this file library.\n"
;
j = cfg.lib[libnum]->vdir_name;
j = uifc.list(WIN_MID|WIN_SAV, 0, 0, 0, &j, 0, "Source of Virtual Sub-directory Names", vdir_name_desc);
if(j >= 0) {
cfg.lib[libnum]->vdir_name = j;
uifc.changes = TRUE;
}
break;
case __COUNTER__: /* clone options */
j=0;
uifc.helpbuf=
......
......@@ -73,7 +73,7 @@ typedef struct { /* Message group info */
typedef struct { /* Transfer Directory Info */
char code[LEN_EXTCODE+1]; /* Internal code (with optional lib prefix) */
char code_suffix[LEN_CODE+1]; /* Eight character code suffix */
char* vdir; /* Virtual Directory name */
char vdir[LEN_SLNAME+1]; /* Virtual Directory name */
char area_tag[41];
char lname[LEN_SLNAME+1], /* Long name - used for listing */
sname[LEN_SSNAME+1], /* Short name - used for prompts */
......@@ -114,6 +114,7 @@ typedef struct { /* Transfer Library Information */
uint32_t offline_dir; /* Offline file directory */
uint32_t misc; /* Miscellaneous bits */
enum area_sort sort;
enum vdir_name vdir_name;
} lib_t;
......
......@@ -23,13 +23,25 @@
#include "nopen.h"
#include "ars_defs.h"
static void pathify(char* str)
{
char* p;
if(strchr(str, '.') == NULL) {
REPLACE_CHARS(str, ' ', '.', p);
} else {
REPLACE_CHARS(str, ' ', '_', p);
}
REPLACE_CHARS(str, '\\', '-', p);
REPLACE_CHARS(str, '/', '-', p);
}
/****************************************************************************/
/* Reads in FILE.CNF and initializes the associated variables */
/****************************************************************************/
BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
{
char str[MAX_PATH+1],c,cmd[LEN_CMD+1];
char* p;
short i,j;
int16_t n;
long offset=0;
......@@ -292,11 +304,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
get_str(cfg->lib[i]->lname,instream);
get_str(cfg->lib[i]->sname,instream);
SAFECOPY(cfg->lib[i]->vdir, cfg->lib[i]->sname);
if(strchr(cfg->lib[i]->vdir, '.') == NULL) {
REPLACE_CHARS(cfg->lib[i]->vdir, ' ', '.', p);
} else {
REPLACE_CHARS(cfg->lib[i]->vdir, ' ', '_', p);
}
pathify(cfg->lib[i]->vdir);
get_str(cfg->lib[i]->arstr,instream);
arstr(NULL, cfg->lib[i]->arstr, cfg, cfg->lib[i]->ar);
......@@ -309,9 +317,11 @@ BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
cfg->lib[i]->sort = c;
get_int(cfg->lib[i]->misc, instream);
for(j=0;j<1;j++)
get_int(n,instream); /* 0x0000 */
get_int(c,instream);
cfg->lib[i]->vdir_name = c;
get_int(c,instream); /* 0x00 */
for(j=0;j<16;j++)
get_int(n,instream); /* 0xffff */
......@@ -353,8 +363,19 @@ BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
cfg->lib[cfg->dir[i]->lib]->offline_dir=i;
get_str(cfg->dir[i]->code_suffix,instream);
cfg->dir[i]->vdir = cfg->dir[i]->code_suffix;
switch(cfg->lib[cfg->dir[i]->lib]->vdir_name) {
case VDIR_NAME_SHORT:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->sname);
break;
case VDIR_NAME_LONG:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->lname);
break;
default:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->code_suffix);
break;
}
pathify(cfg->dir[i]->vdir);
get_str(cfg->dir[i]->data_dir,instream);
get_str(cfg->dir[i]->arstr,instream);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment