Skip to content
Snippets Groups Projects
Commit b2b0d622 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

sbbs_t::protnum() and protname() now accept the transfer type as argument

It's possible to have multiple transfer protocols with the same mmemonic, but
with different transfer types supports (which would be weird, but possible).
This allows us to use protnum() to replace a lot of copy/pasted prot looping
and comparing logic throughout sbbs.

Also added a variant of sbbs_t::quit_key() that takes and returns a string
(for easy concatenation to strings of key chars).
parent 53675de7
No related branches found
No related tags found
No related merge requests found
......@@ -600,6 +600,7 @@ public:
char yes_key(void) { return toupper(*text[Yes]); }
char no_key(void) { return toupper(*text[No]); }
char quit_key(void) { return toupper(*text[Quit]); }
char* quit_key(char* str) { str[0] = quit_key(); str[1] = '\0'; return str; }
char all_key(void) { return toupper(*text[All]); }
char list_key(void) { return toupper(*text[List]); }
char next_key(void) { return toupper(*text[Next]); }
......@@ -839,8 +840,8 @@ public:
char cmdstr_output[512]{};
char* ultoac(uint32_t, char*, char sep=',');
char* u64toac(uint64_t, char*, char sep=',');
int protnum(char prot);
const char* protname(char prot);
int protnum(char prot, enum XFER_TYPE xfer_type = XFER_DOWNLOAD);
const char* protname(char prot, enum XFER_TYPE xfer_type = XFER_DOWNLOAD);
void subinfo(int subnum);
void dirinfo(int dirnum);
......
......@@ -1437,20 +1437,38 @@ char* sbbs_t::u64toac(uint64_t val, char* str, char sep)
return ::u64toac(val, str, sep);
}
int sbbs_t::protnum(char prot)
int sbbs_t::protnum(char prot, enum XFER_TYPE type)
{
int i;
for(i = 0; i < cfg.total_prots; ++i) {
if(prot == cfg.prot[i]->mnemonic && chk_ar(cfg.prot[i]->ar, &useron, &client))
break;
if(prot != cfg.prot[i]->mnemonic || !chk_ar(cfg.prot[i]->ar, &useron, &client))
continue;
switch(type) {
case XFER_UPLOAD:
if(cfg.prot[i]->ulcmd[0])
return i;
break;
case XFER_DOWNLOAD:
if(cfg.prot[i]->dlcmd[0])
return i;
break;
case XFER_BATCH_UPLOAD:
if(cfg.prot[i]->batulcmd[0])
return i;
break;
case XFER_BATCH_DOWNLOAD:
if(cfg.prot[i]->batdlcmd[0])
return i;
break;
}
}
return i;
}
const char* sbbs_t::protname(char prot)
const char* sbbs_t::protname(char prot, enum XFER_TYPE type)
{
int i = protnum(prot);
int i = protnum(prot, type);
if(i < cfg.total_prots)
return cfg.prot[i]->name;
return text[None];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment