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 c6d3e60b authored by deuce's avatar deuce

Use 19200 as the default baud for stdio

Use STDIN_FILENO rather than fileno(stdin)
Clean up buffer write for use with fwrite()
parent 0699aabf
...@@ -1771,11 +1771,12 @@ no_fossil: ...@@ -1771,11 +1771,12 @@ no_fossil:
if(pPortInfo->Method == kComMethodStdIO || if(pPortInfo->Method == kComMethodStdIO ||
pPortInfo->Method == kComMethodUnspecified) pPortInfo->Method == kComMethodUnspecified)
{ {
if (isatty(fileno(stdin))) { if (isatty(STDIN_FILENO)) {
tcgetattr(fileno(stdin),&tio_default); tcgetattr(STDIN_FILENO,&tio_default);
tio_raw = tio_default; tio_raw = tio_default;
cfmakeraw(&tio_raw); cfmakeraw(&tio_raw);
tcsetattr(fileno(stdin),TCSANOW,&tio_raw); tcsetattr(STDIN_FILENO,TCSANOW,&tio_raw);
setvbuf(stdout, NULL, _IONBF, 0);
} }
/* Set port state as open. */ /* Set port state as open. */
...@@ -1960,7 +1961,7 @@ tODResult ODComClose(tPortHandle hPort) ...@@ -1960,7 +1961,7 @@ tODResult ODComClose(tPortHandle hPort)
#ifdef INCLUDE_STDIO_COM #ifdef INCLUDE_STDIO_COM
case kComMethodStdIO: case kComMethodStdIO:
tcsetattr(fileno(stdin),TCSANOW,&tio_default); tcsetattr(STDIN_FILENO,TCSANOW,&tio_default);
break; break;
#endif #endif
...@@ -2975,6 +2976,7 @@ keep_going: ...@@ -2975,6 +2976,7 @@ keep_going:
if((send_ret=fwrite(&btToSend,1,1,stdout))!=1) if((send_ret=fwrite(&btToSend,1,1,stdout))!=1)
return(kODRCGeneralFailure); return(kODRCGeneralFailure);
break; break;
} }
#endif #endif
...@@ -3439,7 +3441,6 @@ try_again: ...@@ -3439,7 +3441,6 @@ try_again:
case kComMethodStdIO: case kComMethodStdIO:
{ {
int pos=0; int pos=0;
int oldpos=-1;
fd_set fdset; fd_set fdset;
struct timeval tv; struct timeval tv;
int send_ret; int send_ret;
...@@ -3455,22 +3456,10 @@ try_again: ...@@ -3455,22 +3456,10 @@ try_again:
return(kODRCGeneralFailure); return(kODRCGeneralFailure);
send_ret=fwrite(pbtBuffer+pos,1,nSize-pos,stdout); send_ret=fwrite(pbtBuffer+pos,1,nSize-pos,stdout);
/* send_ret=fwrite(pbtBuffer+pos,1,1,stdout); */ if(send_ret!=nSize-pos) {
if(send_ret==0) od_sleep(1);
return (kODRCGeneralFailure);
if(send_ret==-1) {
switch(errno) {
case EINTR:
case EAGAIN:
od_sleep(1);
send_ret=0;
break;
default:
return (kODRCGeneralFailure);
}
} }
oldpos=pos;
pos+=send_ret; pos+=send_ret;
} }
break; break;
......
...@@ -2221,16 +2221,16 @@ malloc_error: ...@@ -2221,16 +2221,16 @@ malloc_error:
if(bPromptForUserName) if(bPromptForUserName)
{ {
od_control.od_com_method=COM_STDIO; od_control.od_com_method=COM_STDIO;
od_control.baud=300; od_control.baud=19200;
gethostname(od_control.system_name,sizeof(od_control.system_name)); gethostname(od_control.system_name,sizeof(od_control.system_name));
od_control.system_name[sizeof(od_control.system_name)-1]=0; od_control.system_name[sizeof(od_control.system_name)-1]=0;
if (isatty(fileno(stdin))) { if (isatty(STDIN_FILENO)) {
tcgetattr(fileno(stdin),&term); tcgetattr(STDIN_FILENO,&term);
od_control.baud=cfgetispeed(&term); od_control.baud=cfgetispeed(&term);
if(!od_control.baud) if(!od_control.baud)
od_control.baud=cfgetispeed(&term); od_control.baud=cfgetispeed(&term);
if(!od_control.baud) if(!od_control.baud)
od_control.baud=300; od_control.baud=19200;
} }
uinfo=getpwuid(getuid()); uinfo=getpwuid(getuid());
ODStringCopy(od_control.user_handle, uinfo->pw_name,sizeof(od_control.user_handle)); ODStringCopy(od_control.user_handle, uinfo->pw_name,sizeof(od_control.user_handle));
......
...@@ -189,7 +189,7 @@ tODResult ODKrnlInitialize(void) ...@@ -189,7 +189,7 @@ tODResult ODKrnlInitialize(void)
/* HUP Detection */ /* HUP Detection */
act.sa_handler=sig_no_carrier; act.sa_handler=sig_no_carrier;
/* If two HUP signals are recieved, die on the second */ /* If two HUP signals are recieved, die on the second */
act.sa_flags=SA_RESETHAND; act.sa_flags=SA_RESETHAND|SA_RESTART;
sigemptyset(&(act.sa_mask)); sigemptyset(&(act.sa_mask));
sigaction(SIGHUP,&act,NULL); sigaction(SIGHUP,&act,NULL);
......
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