Commit bf897acf authored by deuce's avatar deuce
Browse files

Merge GHost, quiet and nostatus support contributed by Anonymous on

sourceforge.
https://sourceforge.net/p/syncterm/feature-requests/13/
This also addresses request 14
https://sourceforge.net/p/syncterm/feature-requests/14/
And disables uifc during startup.
parent 0178cb16
......@@ -164,6 +164,12 @@ struct sort_order_info sort_order[] = {
,offsetof(struct bbslist, font)
,sizeof(((struct bbslist *)NULL)->font)
}
,{
"Hide Popups"
,0
,offsetof(struct bbslist, hidepopups)
,sizeof(((struct bbslist *)NULL)->hidepopups)
}
,{
NULL
,0
......@@ -230,7 +236,8 @@ char *conn_type_help= "`Connection Type`\n\n"
"`SSH`..............: Connect using the Secure Shell (SSH-2) protocol\n"
"`Modem`............: Connect using a dial-up modem\n"
"`Serial`...........: Connect directly to a serial communications port\n"
"`Shell`............: Connect to a local PTY (*nix only)\n";
"`Shell`............: Connect to a local PTY (*nix only)\n"
"`MBBS GHost`.......: Communicate using the Major BBS 'GHost' protocol\n";
;
ini_style_t ini_style = {
......@@ -619,6 +626,7 @@ void read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id
entry->conn_type=CONN_TYPE_RAW;
entry->screen_mode=iniGetEnum(section,NULL,"ScreenMode",screen_modes_enum,SCREEN_MODE_CURRENT);
entry->nostatus=iniGetBool(section,NULL,"NoStatus",FALSE);
entry->hidepopups=iniGetBool(section,NULL,"HidePopups",FALSE);
iniGetString(section,NULL,"DownloadPath",home,entry->dldir);
iniGetString(section,NULL,"UploadPath",home,entry->uldir);
......@@ -717,7 +725,7 @@ void read_list(char *listpath, struct bbslist **list, struct bbslist *defaults,
int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isdefault)
{
char opt[20][80]; /* <- Beware of magic number! */
char opt[21][80]; /* 21=Holds number of menu items, 80=Number of columns */
char *opts[(sizeof(opt)/sizeof(opt[0]))+1];
int changed=0;
int copt=0,i,j;
......@@ -792,6 +800,7 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
sprintf(opt[i++], "ANSI Music %s",music_names[item->music]);
sprintf(opt[i++], "Address Family %s",address_family_names[item->address_family]);
sprintf(opt[i++], "Font %s",item->font);
sprintf(opt[i++], "Hide Popups %s",item->hidepopups?"Yes":"No");
opt[i][0]=0;
uifc.changes=0;
......@@ -836,6 +845,8 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
" IPv4 or IPv6\n\n"
"~ Font ~\n"
" Select font to use for the entry\n\n"
"~ Hide Popups ~\n"
" Hide all popup dialogs (i.e., Connecting, Disconnected, etc.)\n\n"
;
i=uifc.list(WIN_MID|WIN_SAV|WIN_ACT,0,0,0,&copt,&bar
,isdefault ? "Edit Default Connection":"Edit Directory Entry"
......@@ -1143,6 +1154,11 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
}
}
break;
case 19:
item->hidepopups=!item->hidepopups;
changed=1;
iniSetBool(&inifile,itemname,"HidePopups",item->hidepopups,&ini_style);
break;
}
if(uifc.changes)
changed=1;
......@@ -1190,6 +1206,7 @@ void add_bbs(char *listpath, struct bbslist *bbs)
iniSetInteger(&inifile,bbs->name,"ANSIMusic",bbs->music,&ini_style);
iniSetEnum(&inifile, bbs->name, "AddressFamily", address_families, bbs->address_family, &ini_style);
iniSetString(&inifile,bbs->name,"Font",bbs->font,&ini_style);
iniSetBool(&inifile,bbs->name,"HidePopups",bbs->hidepopups,&ini_style);
if((listfile=fopen(listpath,"w"))!=NULL) {
iniWriteFile(listfile,inifile);
fclose(listfile);
......
......@@ -91,6 +91,8 @@ struct bbslist {
int music;
int address_family;
char font[80];
int hidepopups;
char ghost_program[9]; /* GHost program can only be 8 chars max. */
};
extern char *music_names[];
......
......@@ -44,9 +44,9 @@
#include "conn_telnet.h"
struct conn_api conn_api;
char *conn_types_enum[]={"Unknown","RLogin","RLoginReversed","Telnet","Raw","SSH","Modem","Serial","Shell",NULL};
char *conn_types[]={"Unknown","RLogin","RLogin Reversed","Telnet","Raw","SSH","Modem","Serial","Shell",NULL};
short unsigned int conn_ports[]={0,513,513,23,0,22,0,0
char *conn_types_enum[]={"Unknown","RLogin","RLoginReversed","Telnet","Raw","SSH","Modem","Serial","Shell","MBBSGhost",NULL};
char *conn_types[]={"Unknown","RLogin","RLogin Reversed","Telnet","Raw","SSH","Modem","Serial","Shell","MBBS GHost",NULL};
short unsigned int conn_ports[]={0,513,513,23,0,22,0,0,0
#ifdef __unix__
,65535
#endif
......@@ -334,6 +334,7 @@ int conn_connect(struct bbslist *bbs)
conn_api.binary_mode_off=telnet_binary_mode_off;
break;
case CONN_TYPE_RAW:
case CONN_TYPE_MBBS_GHOST:
conn_api.connect=raw_connect;
conn_api.close=raw_close;
break;
......@@ -421,7 +422,9 @@ int conn_socket_connect(struct bbslist *bbs)
char portnum[6];
char str[LIST_ADDR_MAX+40];
uifc.pop("Looking up host");
if (!bbs->hidepopups) {
uifc.pop("Looking up host");
}
memset(&hints, 0, sizeof(hints));
hints.ai_flags=PF_UNSPEC;
switch(bbs->address_family) {
......@@ -447,8 +450,10 @@ int conn_socket_connect(struct bbslist *bbs)
failcode=FAILURE_RESOLVE;
res=NULL;
}
uifc.pop(NULL);
uifc.pop("Connecting...");
if (!bbs->hidepopups) {
uifc.pop(NULL);
uifc.pop("Connecting...");
}
/* Drain the input buffer to avoid accidental cancel */
while(kbhit())
......@@ -530,7 +535,9 @@ connected:
int keepalives = TRUE;
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void*)&keepalives, sizeof(keepalives));
uifc.pop(NULL);
if (!bbs->hidepopups) {
uifc.pop(NULL);
}
return(sock);
}
failcode=FAILURE_DISCONNECTED;
......@@ -540,39 +547,43 @@ connected:
if(res)
freeaddrinfo(res);
uifc.pop(NULL);
if (!bbs->hidepopups) {
uifc.pop(NULL);
}
conn_api.terminate=-1;
switch(failcode) {
case FAILURE_RESOLVE:
sprintf(str,"Cannot resolve %s!",bbs->addr);
uifcmsg(str, "`Cannot Resolve Host`\n\n"
"The system is unable to resolve the hostname... double check the spelling.\n"
"If it's not an issue with your DNS settings, the issue is probobly\n"
"with the DNS settings of the system you are trying to contact.");
break;
case FAILURE_CANT_CREATE:
sprintf(str,"Cannot create socket (%d)!",ERROR_VALUE);
uifcmsg(str,
"`Unable to create socket`\n\n"
"Your system is either dangerously low on resources, or there\n"
"is a problem with your TCP/IP stack.");
break;
case FAILURE_CONNECT_ERROR:
sprintf(str,"Connect error (%d)!",ERROR_VALUE);
uifcmsg(str
,"`The connect call returned an error`\n\n"
"The call to connect() returned an unexpected error code.");
break;
case FAILURE_ABORTED:
uifcmsg("Connection Aborted.", "`Connection Aborted`\n\n"
"Connection to the remote system aborted by keystroke.");
break;
case FAILURE_DISCONNECTED:
sprintf(str,"Connect error (%d)!",ERROR_VALUE);
uifcmsg(str
,"`SyncTERM failed to connect`\n\n"
"After connect() succeeded, the socket was in a disconnected state.");
break;
if (!bbs->hidepopups) {
switch(failcode) {
case FAILURE_RESOLVE:
sprintf(str,"Cannot resolve %s!",bbs->addr);
uifcmsg(str, "`Cannot Resolve Host`\n\n"
"The system is unable to resolve the hostname... double check the spelling.\n"
"If it's not an issue with your DNS settings, the issue is probobly\n"
"with the DNS settings of the system you are trying to contact.");
break;
case FAILURE_CANT_CREATE:
sprintf(str,"Cannot create socket (%d)!",ERROR_VALUE);
uifcmsg(str,
"`Unable to create socket`\n\n"
"Your system is either dangerously low on resources, or there\n"
"is a problem with your TCP/IP stack.");
break;
case FAILURE_CONNECT_ERROR:
sprintf(str,"Connect error (%d)!",ERROR_VALUE);
uifcmsg(str
,"`The connect call returned an error`\n\n"
"The call to connect() returned an unexpected error code.");
break;
case FAILURE_ABORTED:
uifcmsg("Connection Aborted.", "`Connection Aborted`\n\n"
"Connection to the remote system aborted by keystroke.");
break;
case FAILURE_DISCONNECTED:
sprintf(str,"Connect error (%d)!",ERROR_VALUE);
uifcmsg(str
,"`SyncTERM failed to connect`\n\n"
"After connect() succeeded, the socket was in a disconnected state.");
break;
}
}
conn_close();
if (sock != INVALID_SOCKET)
......
......@@ -24,6 +24,7 @@ enum {
,CONN_TYPE_MODEM
,CONN_TYPE_SERIAL
,CONN_TYPE_SHELL
,CONN_TYPE_MBBS_GHOST
,CONN_TYPE_TERMINATOR
};
......
......@@ -117,7 +117,8 @@ int rlogin_connect(struct bbslist *bbs)
char *ruser;
char *passwd;
init_uifc(TRUE, TRUE);
if (!bbs->hidepopups)
init_uifc(TRUE, TRUE);
ruser=bbs->user;
passwd=bbs->password;
......@@ -168,10 +169,82 @@ int rlogin_connect(struct bbslist *bbs)
}
}
/* Negotiate with GHost and bail if there's apparently no GHost listening. */
if(bbs->conn_type == CONN_TYPE_MBBS_GHOST) {
char sbuf[80];
char rbuf[10];
struct timeval tv;
int idx, ret;
fd_set rds;
FD_ZERO(&rds);
FD_SET(sock, &rds);
tv.tv_sec=1;
tv.tv_usec=0;
/* Check to make sure GHost is actually listening */
sendsocket(sock, "\r\nMBBS: PING\r\n", 14);
idx = 0;
while ((ret = select(sock+1, &rds, NULL, NULL, &tv))==1) {
recv(sock, rbuf+idx, 1, 0);
rbuf[++idx] = 0;
/* It says ERROR, but this is a good response to PING. */
// TODO: Should there be a \r\n after "ERROR"?
if (strstr(rbuf,"ERROR")) {
break;
}
/* We didn't receive the desired response in time, so bail. */
if (idx >= sizeof(rbuf)) {
return(-1);
}
}
if (ret < 1) {
return(-1);
}
sprintf(sbuf, "MBBS: %s %d '%s' %d %s\r\n",
bbs->ghost_program, /* Program name */
2, /* GHost protocol version */
bbs->user, /* User's full name */
999, /* Time remaining */
"GR" /* GR = ANSI, NG = ASCII */
);
sendsocket(sock, sbuf, strlen(sbuf));
idx = 0;
while ((ret = select(sock+1, &rds, NULL, NULL, &tv))==1) {
recv(sock, rbuf+idx, 1, 0);
rbuf[++idx] = 0;
/* GHost says it's launching the program, so pass terminal to user. */
// TODO: Should there be a \r\n after "OK"?
if (strstr(rbuf,"OK")) {
break;
}
/* We didn't receive the desired response in time, so bail. */
if (idx >= sizeof(rbuf)) {
return(-1);
}
}
if (ret < 1) {
return(-1);
}
}
_beginthread(rlogin_output_thread, 0, NULL);
_beginthread(rlogin_input_thread, 0, NULL);
uifc.pop(NULL);
if (!bbs->hidepopups) {
uifc.pop(NULL);
}
return(0);
}
......
......@@ -85,6 +85,8 @@ char *usage =
"-s = enable \"Safe Mode\" which prevents writing/browsing local files\n"
"-T = when the ONLY argument, dumps the terminfo entry to stdout and exits\n"
"-v = when the ONLY argument, dumps the version info to stdout and exits\n"
"-c = Hide the status line\n"
"-q = Quiet mode (Hide various popups such as this during a connect)\n"
"\n"
"URL format is: [(rlogin|telnet|ssh|raw)://][user[:password]@]domainname[:port]\n"
"raw:// URLs MUST include a port.\n"
......@@ -835,6 +837,11 @@ void parse_url(char *url, struct bbslist *bbs, int dflt_conn_type, int force_def
bbs->port=conn_ports[bbs->conn_type];
p1=url+6;
}
else if(!strnicmp("ghost://",url,8)) {
bbs->conn_type=CONN_TYPE_MBBS_GHOST;
bbs->port=conn_ports[bbs->conn_type];
p1=url+8;
}
/* ToDo: RFC2806 */
p3=strchr(p1,'@');
if(p3!=NULL) {
......@@ -859,6 +866,11 @@ void parse_url(char *url, struct bbslist *bbs, int dflt_conn_type, int force_def
else
p2 = p1;
}
p3=strrchr(p1,'/');
if(p3!=NULL) {
*p3=0;
SAFECOPY(bbs->ghost_program,p3+1);
}
SAFECOPY(bbs->name,p1);
p2=strrchr(p2,':');
if(p2!=NULL) {
......@@ -866,10 +878,6 @@ void parse_url(char *url, struct bbslist *bbs, int dflt_conn_type, int force_def
p2++;
bbs->port=atoi(p2);
}
/* Remove trailing / (Win32 adds one 'cause it hates me) */
p2=strrchr(p1,'/');
if(p2!=NULL && *(p2+1)==0)
*p2=0;
SAFECOPY(bbs->addr,p1);
/* Find BBS listing in users phone book */
......@@ -1286,6 +1294,8 @@ int main(int argc, char **argv)
char *p, *lp;
int cvmode;
int ww, wh, sf;
int default_hidepopups=0;
int default_nostatus=0;
const char syncterm_termcap[]="\n# terminfo database entry for SyncTERM\n"
"syncterm|SyncTERM,\n"
// cwin maybe? Or just left/right and top/bottom margins?
......@@ -1436,7 +1446,7 @@ int main(int argc, char **argv)
#endif
/* UIFC initialization */
memset(&uifc,0,sizeof(uifc));
memset(&uifc,0,sizeof(uifc));
uifc.mode=UIFC_NOCTRL|UIFC_NHM;
uifc.size=sizeof(uifc);
uifc.esc_delay=25;
......@@ -1565,6 +1575,12 @@ int main(int argc, char **argv)
case 'S':
safe_mode=1;
break;
case 'Q':
default_hidepopups=1;
break;
case 'C':
default_nostatus=1;
break;
default:
goto USAGE;
}
......@@ -1632,13 +1648,17 @@ int main(int argc, char **argv)
if(!winsock_startup())
return(1);
bbs->hidepopups = default_hidepopups;
bbs->nostatus = default_nostatus;
load_font_files();
while((!quitting) && (bbs!=NULL || (bbs=show_bbslist(last_bbs, FALSE))!=NULL)) {
gettextinfo(&txtinfo); /* Current mode may have changed while in show_bbslist() */
FREE_AND_NULL(last_bbs);
uifcbail();
textmode(screen_to_ciolib(bbs->screen_mode));
init_uifc(TRUE, TRUE);
if (!bbs->hidepopups)
init_uifc(TRUE, TRUE);
load_font_files();
setfont(find_font_id(bbs->font),TRUE,1);
if(conn_connect(bbs)) {
......@@ -1710,14 +1730,16 @@ int main(int argc, char **argv)
/* Started from the command-line with a URL */
init_uifc(TRUE, TRUE);
i=1;
switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,NULL,"Save this directory entry?",YesNo)) {
case 0: /* Yes */
edit_list(NULL, bbs,settings.list_path,FALSE);
add_bbs(settings.list_path,bbs);
last_bbs=strdup(bbs->name);
break;
default: /* ESC/No */
break;
if (!bbs->hidepopups) {
switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,NULL,"Save this directory entry?",YesNo)) {
case 0: /* Yes */
edit_list(NULL, bbs,settings.list_path,FALSE);
add_bbs(settings.list_path,bbs);
last_bbs=strdup(bbs->name);
break;
default: /* ESC/No */
break;
}
}
}
}
......
......@@ -2463,7 +2463,9 @@ BOOL doterm(struct bbslist *bbs)
if(!is_connected(NULL)) {
WRITE_OUTBUF();
hold_update=oldmc;
uifcmsg("Disconnected","`Disconnected`\n\nRemote host dropped connection");
if (!bbs->hidepopups) {
uifcmsg("Disconnected","`Disconnected`\n\nRemote host dropped connection");
}
check_exit(FALSE);
cterm_clearscreen(cterm, cterm->attr); /* Clear screen into scrollback */
scrollback_lines=cterm->backpos;
......@@ -2822,6 +2824,9 @@ BOOL doterm(struct bbslist *bbs)
}
/* FALLTHROUGH for curses/ansi modes */
case 0x2c00: /* ALT-Z */
if (bbs->hidepopups) {
break;
}
i=wherex();
j=wherey();
switch(syncmenu(bbs, &speed)) {
......
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