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

Use fread()/fwrite for stdio rather than read()/write()

Use correct constants for STDIN_FILENO etc. rather than 0 and 1
Use OD_GLOBAL_WORK_STRING_SIZE as the size when reading to the string.
Increase OD_GLOBAL_WORK_STRING_SIZE to 1025
parent 6ce55e9f
......@@ -68,6 +68,7 @@
#include <signal.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#endif
#include "ODCore.h"
#include "ODGen.h"
......@@ -2783,18 +2784,18 @@ tODResult ODComGetByte(tPortHandle hPort, char *pbtNext, BOOL bWait)
int select_ret, recv_ret;
FD_ZERO(&socket_set);
FD_SET(0,&socket_set);
FD_SET(STDIN_FILENO,&socket_set);
tv.tv_sec=0;
tv.tv_usec=0;
select_ret = select(1, &socket_set, NULL, NULL, bWait ? NULL : &tv);
select_ret = select(STDIN_FILENO+1, &socket_set, NULL, NULL, bWait ? NULL : &tv);
if (select_ret == -1)
return (kODRCGeneralFailure);
if (select_ret == 0)
return (kODRCNothingWaiting);
recv_ret = read(0, pbtNext, 1);
recv_ret = fread(pbtNext, 1, 1, stdin);
if(recv_ret != -1)
break;
return (kODRCGeneralFailure);
......@@ -2964,15 +2965,15 @@ keep_going:
int send_ret;
FD_ZERO(&fdset);
FD_SET(1,&fdset);
FD_SET(STDOUT_FILENO,&fdset);
tv.tv_sec=1;
tv.tv_usec=0;
if(select(2,NULL,&fdset,NULL,&tv) != 1)
if(select(STDOUT_FILENO+1,NULL,&fdset,NULL,&tv) != 1)
return(kODRCGeneralFailure);
if((send_ret=write(1,&btToSend,1,0))!=1)
if((send_ret=fwrite(&btToSend,1,1,stdout))!=1)
return(kODRCGeneralFailure);
break;
}
......@@ -3443,17 +3444,18 @@ try_again:
struct timeval tv;
int send_ret;
while(pos>oldpos && pos<nSize) {
while(pos<nSize) {
FD_ZERO(&fdset);
FD_SET(1,&fdset);
FD_SET(STDOUT_FILENO,&fdset);
tv.tv_sec=1;
tv.tv_usec=0;
if(select(2,NULL,&fdset,NULL,&tv) != 1)
if(select(STDOUT_FILENO+1,NULL,&fdset,NULL,&tv) != 1)
return(kODRCGeneralFailure);
send_ret=write(1,pbtBuffer,nSize-pos);
send_ret=fwrite(pbtBuffer+pos,1,nSize-pos,stdout);
/* send_ret=fwrite(pbtBuffer+pos,1,1,stdout); */
if(send_ret==0)
return (kODRCGeneralFailure);
if(send_ret==-1) {
......
......@@ -60,7 +60,7 @@ extern BOOL bIsCallbackActive;
extern BOOL bShellChatActive;
/* Global working space. */
#define OD_GLOBAL_WORK_STRING_SIZE 257
#define OD_GLOBAL_WORK_STRING_SIZE 1025
extern char szODWorkString[OD_GLOBAL_WORK_STRING_SIZE];
/* Global instance of the text information structure for general use. */
......
......@@ -417,13 +417,13 @@ abort_send:
}
/* Get next line, if any. */
if(fgets(szODWorkString, 256, pfRemoteFile) == NULL)
if(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfRemoteFile) == NULL)
{
/* If different local file. */
if(pfLocalFile)
{
/* Display rest of it. */
while(fgets(szODWorkString, 256, pfLocalFile))
while(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfLocalFile))
{
/* Pass each line to terminal emulator. */
ODEmulateFromBuffer(szODWorkString, FALSE);
......@@ -464,9 +464,9 @@ abort_send:
{
od_disp(szODWorkString, strlen(szODWorkString), FALSE);
if(fgets(szODWorkString, 256, pfLocalFile) == NULL)
if(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfLocalFile) == NULL)
{
while(fgets(szODWorkString, 256, pfRemoteFile))
while(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfRemoteFile))
{
od_disp(szODWorkString, strlen(szODWorkString), FALSE);
}
......@@ -763,13 +763,13 @@ abort_send:
}
/* Get next line, if any. */
if(fgets(szODWorkString, 256, pfRemoteFile) == NULL)
if(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfRemoteFile) == NULL)
{
/* If different local file. */
if(pfLocalFile)
{
/* Display rest of it. */
while(fgets(szODWorkString, 256, pfLocalFile))
while(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfLocalFile))
{
if (!bSectionFound && strncmp(szFullSectionName, szODWorkString, uSectionNameLength) == 0)
{
......@@ -846,9 +846,9 @@ abort_send:
{
od_disp(szODWorkString, strlen(szODWorkString), FALSE);
if(fgets(szODWorkString, 256, pfLocalFile) == NULL)
if(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfLocalFile) == NULL)
{
while(fgets(szODWorkString, 256, pfRemoteFile))
while(fgets(szODWorkString, OD_GLOBAL_WORK_STRING_SIZE-1, pfRemoteFile))
{
od_disp(szODWorkString, strlen(szODWorkString), FALSE);
}
......
......@@ -2381,7 +2381,7 @@ void ODInitError(char *pszErrorText)
}
#endif
#ifdef ODPLAT_NIX
write(2,pszErrorText,strlen(pszErrorText));
fwrite(pszErrorText,strlen(pszErrorText),1,stderr);
#endif
}
......
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