Exemplo n.º 1
0
int AsciiSendFileData(STREAM *InStream,STREAM * OutStream, int Direction)
{
char *Tempstr=NULL;
int result;
struct stat FStat;
double FileSize=0;
int RetVal=FALSE;


Tempstr=STREAMReadLine(Tempstr,InStream);
while (Tempstr)
{
		StripCRLF(Tempstr);
		Tempstr=CatStr(Tempstr,"\r\n");
		result=StrLen(Tempstr);

	STREAMWriteLine(Tempstr,OutStream);
	Tempstr=STREAMReadLine(Tempstr,InStream);
	RetVal=TRUE;
}

STREAMFlush(OutStream);
DestroyString(Tempstr);

return(RetVal);
}
Exemplo n.º 2
0
/////////////////////////////////////////////////////////////////////////////
// CDlgLogAndDecode message handlers
DWORD WINAPI StartLogging(LPVOID lpParameter) 
{
	bool	loopDone = false;
	DWORD	dwWaitResult;
	char	rBuf[ 2048 ], tBuf[ 20 ];
	int		len;
	
	sLogThreadParams *p = (sLogThreadParams *)lpParameter;
	CDalsuRichEdit *eCtrl = p->m_pDalRich;

	while ( !loopDone ) {
		dwWaitResult = WSAWaitForMultipleEvents(cntEvents, p->events, FALSE, WSA_INFINITE, TRUE);
		switch ( dwWaitResult )
		{
			case (WSA_WAIT_EVENT_0 + eNetworkEvent):
				len = recvfrom( p->sRecv, rBuf, sizeof(rBuf), 0, NULL, NULL );
				rBuf[len] = '\0';
				StripCRLF( rBuf );
				time_t ltime;
				time( &ltime );
				struct tm now;
				memcpy( &now, localtime( &ltime ), sizeof(now) );
				sprintf( tBuf, "(%02d:%02d:%02d) ", now.tm_hour, now.tm_min, now.tm_sec );
	
				eCtrl->AddText(tBuf,crBlue);
				eCtrl->AddText(rBuf,crBlue);
				eCtrl->AddText("\n",crBlue);
//				cout << tBuf << rBuf << endl << flush;

#ifdef DO_MESSAGEPARSE
				if ( decode )
					DecodeMessage( rBuf );
#endif
				break;
			case (WSA_WAIT_EVENT_0 + eAbortEvent):
				eCtrl->AddText("Stopping...\n",crBlue);
				loopDone = true;
				break;
			case (WSA_WAIT_EVENT_0 + eKeypressEvent):
/*				switch ( toupper(chKeyHit) ) 
				{
					case 'L':
						// toggle program logging
						additionalLogging = !additionalLogging;
						cout << TIMEPAD << "Additional logging turned " << ( additionalLogging ? "ON" : "OFF" ) << endl;
						break;
					case 'M':
						// record a marker in the file
						break;
					case 'C':
						// close the log file
						break;
					case 'O':
						//open the log file
						break;
					case 'Q':
						// key press to quit the application
						loopdone = true;
						break;
				}*/
				break;
			default:
				sprintf(rBuf,"Error in event wait...(err=%d)",WSAGetLastError());
				eCtrl->AddText(rBuf,crRed);
				loopDone = true;
				break;
		}
	}
	return 0;
}