Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit f8c041f9 authored by rswindell's avatar rswindell

Added optional protocol key argument to sendfile() and recvfile() for JS

equivalent of Baja SEND_FILE_VIA and RECEIVE_FILE_VIA.
parent 0eed11a7
......@@ -450,25 +450,28 @@ void sbbs_t::seqwait(uint devnum)
}
bool sbbs_t::sendfile(char* fname)
bool sbbs_t::sendfile(char* fname, char prot)
{
char keys[128];
char ch;
size_t i;
bool result=false;
xfer_prot_menu(XFER_DOWNLOAD);
mnemonics(text[ProtocolOrQuit]);
strcpy(keys,"Q");
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->dlcmd[0] && chk_ar(cfg.prot[i]->ar,&useron))
sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic);
ch=(char)getkeys(keys,0);
if(prot)
ch=toupper(prot);
else {
xfer_prot_menu(XFER_DOWNLOAD);
mnemonics(text[ProtocolOrQuit]);
strcpy(keys,"Q");
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->dlcmd[0] && chk_ar(cfg.prot[i]->ar,&useron))
sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic);
if(ch=='Q' || sys_status&SS_ABORT)
return(false);
ch=(char)getkeys(keys,0);
if(ch=='Q' || sys_status&SS_ABORT)
return(false);
}
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron))
break;
......
......@@ -827,10 +827,10 @@ static jsSyncPropertySpec js_bbs_properties[] = {
{ "file_cmds" ,BBS_PROP_FILE_CMDS ,JSPROP_ENUMERATE ,310},
{ "curgrp" ,BBS_PROP_CURGRP ,JSPROP_ENUMERATE ,310},
{ "cursub" ,BBS_PROP_CURSUB ,JSPROP_ENUMERATE ,310},
{ "cursub_code" ,BBS_PROP_CURSUB_CODE ,JSPROP_ENUMERATE ,31301},
{ "cursub_code" ,BBS_PROP_CURSUB_CODE ,JSPROP_ENUMERATE ,314},
{ "curlib" ,BBS_PROP_CURLIB ,JSPROP_ENUMERATE ,310},
{ "curdir" ,BBS_PROP_CURDIR ,JSPROP_ENUMERATE ,310},
{ "curdir_code" ,BBS_PROP_CURDIR_CODE ,JSPROP_ENUMERATE ,31301},
{ "curdir_code" ,BBS_PROP_CURDIR_CODE ,JSPROP_ENUMERATE ,314},
{ "connection" ,BBS_PROP_CONNECTION ,PROP_READONLY ,310},
{ "rlogin_name" ,BBS_PROP_RLOGIN_NAME ,JSPROP_ENUMERATE ,310},
{ "client_name" ,BBS_PROP_CLIENT_NAME ,JSPROP_ENUMERATE ,310},
......@@ -1582,11 +1582,16 @@ static JSBool
js_sendfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
sbbs_t* sbbs;
char prot=0;
char* p;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
*rval = BOOLEAN_TO_JSVAL(sbbs->sendfile(JS_GetStringBytes(JS_ValueToString(cx, argv[0]))));
if(argc>1 && (p=js_ValueToStringBytes(cx, argv[1], NULL))!=NULL)
prot=*p;
*rval = BOOLEAN_TO_JSVAL(sbbs->sendfile(JS_GetStringBytes(JS_ValueToString(cx, argv[0])),prot));
return(JS_TRUE);
}
......@@ -1595,11 +1600,16 @@ static JSBool
js_recvfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
sbbs_t* sbbs;
char prot=0;
char* p;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
*rval = BOOLEAN_TO_JSVAL(sbbs->recvfile(JS_GetStringBytes(JS_ValueToString(cx, argv[0]))));
if(argc>1 && (p=js_ValueToStringBytes(cx, argv[1], NULL))!=NULL)
prot=*p;
*rval = BOOLEAN_TO_JSVAL(sbbs->recvfile(JS_GetStringBytes(JS_ValueToString(cx, argv[0])),prot));
return(JS_TRUE);
}
......@@ -2657,13 +2667,15 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("add file list to batch download queue")
,310
},
{"send_file", js_sendfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename")
,JSDOCSTR("send specified filename (complete path) to user via user-prompted protocol")
,31301
{"send_file", js_sendfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol]")
,JSDOCSTR("send specified filename (complete path) to user via user-prompted "
"(or optionally specified) protocol")
,314
},
{"receive_file", js_recvfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename")
,JSDOCSTR("received specified filename (complete path) frome user via user-prompted protocol")
,31301
{"receive_file", js_recvfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol]")
,JSDOCSTR("received specified filename (complete path) frome user via user-prompted "
"(or optionally specified) protocol")
,314
},
{"temp_xfer", js_temp_xfer, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("enter the temporary file tranfer menu")
......@@ -2799,7 +2811,7 @@ static jsSyncMethodSpec js_bbs_functions[] = {
{"list_msgs", js_listmsgs, 1, JSTYPE_NUMBER, JSDOCSTR("[sub-board=<i>current</i>] [,mode=<tt>SCAN_READ</tt>] [,message_number=<tt>0</tt>] [,string find]")
,JSDOCSTR("list messages in the specified message sub-board (number or internal code), "
"optionally search for 'find' string, returns number of messages listed")
,31301
,314
},
/* menuing */
{"menu", js_menu, 1, JSTYPE_VOID, JSDOCSTR("base_filename")
......
......@@ -609,8 +609,8 @@ public:
void autohangup(void);
bool checkdszlog(file_t*);
bool checkprotresult(prot_t*, int error, file_t*);
bool sendfile(char* fname);
bool recvfile(char* fname);
bool sendfile(char* fname, char prot=0);
bool recvfile(char* fname, char prot=0);
/* file.cpp */
void fileinfo(file_t* f);
......
......@@ -599,25 +599,28 @@ bool sbbs_t::bulkupload(uint dirnum)
return(false);
}
bool sbbs_t::recvfile(char *fname)
bool sbbs_t::recvfile(char *fname, char prot)
{
char keys[32];
char ch;
size_t i;
bool result=false;
xfer_prot_menu(XFER_UPLOAD);
mnemonics(text[ProtocolOrQuit]);
strcpy(keys,"Q");
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->ulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron))
sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic);
ch=(char)getkeys(keys,0);
if(prot)
ch=toupper(prot);
else {
xfer_prot_menu(XFER_UPLOAD);
mnemonics(text[ProtocolOrQuit]);
strcpy(keys,"Q");
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->ulcmd[0] && chk_ar(cfg.prot[i]->ar,&useron))
sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic);
if(ch=='Q' || sys_status&SS_ABORT)
return(false);
ch=(char)getkeys(keys,0);
if(ch=='Q' || sys_status&SS_ABORT)
return(false);
}
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron))
break;
......
Markdown is supported
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