Commits (1)
...@@ -1076,8 +1076,8 @@ public: ...@@ -1076,8 +1076,8 @@ public:
/* viewfile.cpp */ /* viewfile.cpp */
int viewfile(file_t* f, bool extdesc); int viewfile(file_t* f, bool extdesc);
void viewfiles(uint dirnum, char *fspec); bool viewfile(const char* path);
void viewfilecontents(file_t* f); bool viewfilecontents(file_t* f);
/* xtrn.cpp */ /* xtrn.cpp */
int external(const char* cmdline, long mode, const char* startup_dir=NULL); int external(const char* cmdline, long mode, const char* startup_dir=NULL);
......
...@@ -209,9 +209,14 @@ void xfer_opts() ...@@ -209,9 +209,14 @@ void xfer_opts()
uifc.helpbuf= uifc.helpbuf=
"`Viewable File Types:`\n" "`Viewable File Types:`\n"
"\n" "\n"
"This is a list of file types that have content information that can be\n" "This is a list of file types (extensions) that have content information\n"
"viewed on the Terminal Server through the execution of an external\n" "that can be viewed on the Terminal Server through the execution of an\n"
"program." "external program or script.\n"
"\n"
"The file types/extensions are case insensitive and may contain wildcard\n"
"characters (i.e. `?` or `*`).\n"
"\n"
"Specify the filename argument on the command-line with `%s` or `%f`."
; ;
i=uifc.list(i,0,0,50,&fview_dflt,&fview_bar,"Viewable File Types",opt); i=uifc.list(i,0,0,50,&fview_dflt,&fview_bar,"Viewable File Types",opt);
if(i==-1) if(i==-1)
...@@ -245,8 +250,8 @@ void xfer_opts() ...@@ -245,8 +250,8 @@ void xfer_opts()
continue; continue;
} }
memset(cfg.fview[0],0,sizeof(fview_t)); memset(cfg.fview[0],0,sizeof(fview_t));
strcpy(cfg.fview[0]->ext,"ZIP"); strcpy(cfg.fview[0]->ext,"*");
strcpy(cfg.fview[0]->cmd,"%@unzip -vq %s"); strcpy(cfg.fview[0]->cmd,"?archive list %f");
} }
else { else {
for(j=cfg.total_fviews;j>i;j--) for(j=cfg.total_fviews;j>i;j--)
...@@ -464,6 +469,7 @@ void xfer_opts() ...@@ -464,6 +469,7 @@ void xfer_opts()
"\n" "\n"
"This is a list of file types that will have a command line executed to\n" "This is a list of file types that will have a command line executed to\n"
"perform an event upon their download (e.g. trigger a download event).\n" "perform an event upon their download (e.g. trigger a download event).\n"
"\n"
"The file types are specified by `extension` and if one file extension\n" "The file types are specified by `extension` and if one file extension\n"
"is listed more than once, each command line will be executed. The\n" "is listed more than once, each command line will be executed. The\n"
"command lines must return a error level of 0 (no error) in order\n" "command lines must return a error level of 0 (no error) in order\n"
...@@ -597,10 +603,11 @@ void xfer_opts() ...@@ -597,10 +603,11 @@ void xfer_opts()
uifc.helpbuf= uifc.helpbuf=
"`Extractable File Types:`\n" "`Extractable File Types:`\n"
"\n" "\n"
"This is a list of archive file types that can be extracted to the temp\n" "List of external extraction methods available by file type/extension.\n"
"directory by an external program. The file types are specified by their\n" "\n"
"extension. For each file type you must specify the command line used to\n" "Support for extracting archives of common formats (i.e. `zip`, etc.)\n"
"extract the file(s).\n" "is built-into Synchronet (requires no external program), however may be\n"
"extended via external archive/extraction programs configured here."
; ;
i=uifc.list(i,0,0,50,&fextr_dflt,&fextr_bar,"Extractable File Types",opt); i=uifc.list(i,0,0,50,&fextr_dflt,&fextr_bar,"Extractable File Types",opt);
if(i==-1) if(i==-1)
...@@ -717,9 +724,11 @@ void xfer_opts() ...@@ -717,9 +724,11 @@ void xfer_opts()
uifc.helpbuf= uifc.helpbuf=
"`Compressible File Types:`\n" "`Compressible File Types:`\n"
"\n" "\n"
"This is a list of compression methods available for different file types.\n" "List of external compression methods available by file type/extension.\n"
"These will be used for items such as creating QWK packets, temporary\n" "\n"
"files from the transfer section, and more.\n" "Support for creating archives of common formats (i.e. `zip`, `7z`, `tgz`, `tbz`)\n"
"is built-into Synchronet (requires no external program), however may be\n"
"extended via external compression/archive programs configured here."
; ;
i=uifc.list(i,0,0,50,&fcomp_dflt,&fcomp_bar,"Compressible File Types",opt); i=uifc.list(i,0,0,50,&fcomp_dflt,&fcomp_bar,"Compressible File Types",opt);
if(i==-1) if(i==-1)
......
...@@ -85,67 +85,47 @@ int sbbs_t::viewfile(file_t* f, bool ext) ...@@ -85,67 +85,47 @@ int sbbs_t::viewfile(file_t* f, bool ext)
} }
/*****************************************************************************/ /*****************************************************************************/
/* View viewable file types from dir 'dirnum' */
/* 'fspec' must be padded */
/*****************************************************************************/ /*****************************************************************************/
void sbbs_t::viewfiles(uint dirnum, char *fspec) bool sbbs_t::viewfile(const char* path)
{ {
char tmp[512];
char viewcmd[256]; char viewcmd[256];
int i; int i;
curdirnum=dirnum; /* for ARS */ if(!fexist(path)) {
SAFEPRINTF2(viewcmd,"%s%s",cfg.dir[dirnum]->path,fspec);
if(!fexist(viewcmd)) {
bputs(text[FileNotFound]); bputs(text[FileNotFound]);
return; return false;
} }
char* file_ext = getfext(fspec); char* file_ext = getfext(path);
if(file_ext == NULL) { if(file_ext == NULL) {
bprintf(text[NonviewableFile], fspec); bprintf(text[NonviewableFile], getfname(path));
return; return false;
} }
for(i=0;i<cfg.total_fviews;i++) for(i=0;i<cfg.total_fviews;i++)
if(!stricmp(file_ext + 1, cfg.fview[i]->ext) && chk_ar(cfg.fview[i]->ar,&useron,&client)) { if(wildmatchi(file_ext + 1, cfg.fview[i]->ext, /* path: */false) && chk_ar(cfg.fview[i]->ar,&useron,&client)) {
SAFECOPY(viewcmd,cfg.fview[i]->cmd); SAFECOPY(viewcmd,cfg.fview[i]->cmd);
break; break;
} }
if(i==cfg.total_fviews) { if(i >= cfg.total_fviews) {
bprintf(text[NonviewableFile], file_ext); bprintf(text[NonviewableFile], file_ext);
return; return false;
} }
SAFEPRINTF2(tmp, "%s%s", cfg.dir[dirnum]->path, fspec); if((i=external(cmdstr(viewcmd, path, path, NULL), EX_STDIO|EX_SH))!=0) {
if((i=external(cmdstr(viewcmd,tmp,tmp,NULL),EX_STDIO|EX_SH))!=0)
errormsg(WHERE,ERR_EXEC,viewcmd,i); /* must have EX_SH to ^C */ errormsg(WHERE,ERR_EXEC,viewcmd,i); /* must have EX_SH to ^C */
return false;
}
return true;
} }
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
void sbbs_t::viewfilecontents(file_t* f) bool sbbs_t::viewfilecontents(file_t* f)
{ {
char cmd[128]; char path[MAX_PATH + 1];
char path[MAX_PATH+1];
char* ext;
int i;
getfilepath(&cfg, f, path); getfilepath(&cfg, f, path);
if(getfilesize(&cfg, f) < 1) { uint savedir = curdirnum;
bprintf(text[FileDoesNotExist], path); curdirnum = f->dir; /* for ARS */
return; bool result = viewfile(path);
} curdirnum = savedir;
if((ext=getfext(path))!=NULL) { return result;
ext++;
for(i=0;i<cfg.total_fviews;i++) {
if(!stricmp(ext,cfg.fview[i]->ext)
&& chk_ar(cfg.fview[i]->ar,&useron,&client)) {
SAFECOPY(cmd,cfg.fview[i]->cmd);
break;
}
}
}
if(ext==NULL || i==cfg.total_fviews)
bprintf(text[NonviewableFile],ext);
else
if((i=external(cmdstr(cmd,path,path,NULL),EX_STDIO))!=0)
errormsg(WHERE,ERR_EXEC,cmdstr(cmd,path,path,NULL),i);
} }