void Initialize( void ) { char *err; RWBuff[0] = '\0'; _DBG(("About to remote link in initialize.\n" )); err = RemoteLink( RWBuff, 1 ); _DBG(( "Back from PM remote link\n" )); if( err ) { _DBG(( "ERROR! '%s'\n", err )); } if( err != NULL ) { #ifdef ACAD for( ;; ) ads_link( RSERR ); #else StartupErr( err ); #endif } _DBG(( "No Remote link error. About to TrapInit." )); TrapVer = TrapInit( NULL, RWBuff, FALSE ); if( RWBuff[0] != '\0' ) { // NO, NO, NO! RemoteUnLink(); StartupErr( RWBuff ); } _DBG(( "No TrapInit error. Initialize complete" )); Out[0].len = sizeof( RWBuff ); Out[0].ptr = RWBuff; }
/* * ProcAppl - receives server specific messages for the main window */ void ProcAppl( HWND windhandle, unsigned message, WORD worddata, LONG longdata ) { char name[80]; const char *err; int i; char buff[80]; windhandle = windhandle; message = message; longdata = longdata; switch( worddata ) { case SELECT_1: i = GetWindowTextLength( EditChild ); if( i == 0 ) { Output( TRP_ERR_null_name ); Output( "\r\n" ); } else { *name = '\0'; GetWindowText( EditChild, name, sizeof( name ) ); if( RemoteLinkObtained ) RemoteUnLink(); err = RemoteLink( name, TRUE ); if( err != NULL ) { StartupErr( err ); RemoteLinkObtained = FALSE; } else { sprintf( buff, TRP_WIN_setting_name, name ); Output( buff ); Output( "\r\n" ); RemoteLinkObtained = TRUE; } /* if */ } /* if */ break; } /* switch */ } /* ProcAppl */
int main( int argc, char *argv[] ) { char *err; unsigned len; #ifdef __WINDOWS__ Instance = *_MainWindowData; #endif err = RemoteLink( ( argc > 1 ) ? argv[1] : "", TRUE ); if( err != 0 ) { printf( "%s\n", err ); return( 1 ); } printf( "server running\n" ); for( ;; ) { NothingToDo(); #if defined(__WATCOMC__) // How to do the equivalent of kbhit()? if( kbhit() && getch() == 'q' ) break; #endif if( RemoteConnect() ) { printf( "\nCONNECT\n" ); for( ;; ) { len = RemoteGet( (byte *)&Data, sizeof( Data ) ); if( len == -1 ) { printf( "\nlink broken\n" ); break; } if( Data[0] == TEST_OVER ) break; if( Data[0] == TEST_STRING ) { printf( "'%s' - %d bytes\n", &Data[1], len ); RemotePut( (byte *)&Data, len ); } else { RunTime(); } } RemoteDisco(); printf( "\nDISCO\n" ); } } RemoteUnLink(); return( 0 ); }
void Initialize( void ) { const char *err; char trapparms[PARMS_MAXLEN]; char cmdline[PARMS_MAXLEN]; #define servparms RWBuff getcmd( cmdline ); ParseCommandLine( cmdline, trapparms, servparms, &OneShot ); err = RemoteLink( servparms, TRUE ); #undef servparms if( err == NULL ) { err = LoadTrap( trapparms, RWBuff, &TrapVersion ); } if( err != NULL ) { StartupErr( err ); } }
unsigned ReqProg_load( void ) { char buffer[160]; char *src; char *dst; char *name; char *endparm; char *err; tiny_ret_t rc; prog_load_ret *ret; unsigned_16 len; SaveVectors( OrigVectors ); _DBG_EnterFunc( "AccLoadProg()" ); ret = GetOutPtr( 0 ); src = name = GetInPtr( sizeof( prog_load_req ) ); rc = FindFilePath( src, buffer, DosXExtList ); endparm = LinkParm; while( *endparm++ != '\0' ) {} // skip program name strcpy( endparm, buffer ); err = RemoteLink( LinkParm, 0 ); if( err != NULL ) { _DBG_Writeln( "Can't RemoteLink" ); TinyWrite( TINY_ERR, err, strlen( err ) ); LoadError = err; ret->err = 1; len = 0; } else { if( TINY_OK( rc ) ) { while( *src++ != '\0' ) {} len = GetTotalSize() - ( src - name ) - sizeof( prog_load_req ); dst = (char *)buffer; while( *dst++ != '\0' ) {}; memcpy( dst, src, len ); dst += len; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( sizeof( prog_load_req ), In_Mx_Ptr[0].ptr ); _DBG_Writeln( "AddPacket" ); AddPacket( dst - buffer, buffer ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); len = GetPacket(); _DBG_Writeln( "RemovePacket" ); RemovePacket( sizeof( *ret ), ret ); } else { len = DoAccess(); } _DBG_Writeln( "Linked --" ); if( ret->err != 0 ) { get_err_text_req erracc; prog_kill_req killacc; int msg_len; _DBG_Writeln( "loadret->errcode != 0" ); if( LoadError == NULL ) { _DBG_Writeln( "making a REQ_GET_ERR_TEXT request" ); erracc.req = REQ_GET_ERR_TEXT; erracc.err = ret->err; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( sizeof( erracc ), &erracc ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); msg_len = GetPacket(); _DBG_Writeln( "RemovePacket" ); RemovePacket( msg_len, FailMsg ); _DBG_Write( "FailMsg : " ); _DBG_NoTabWriteln( FailMsg ); LoadError = FailMsg; } _DBG_Writeln( "making a REQ_PROG_KILL request" ); killacc.req = REQ_PROG_KILL; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( sizeof( killacc ), &killacc ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); GetPacket(); //RemovePacket( msg_len, &erracc ); RemoteUnLink(); TaskLoaded = FALSE; } } if( ret->err == 0 ) { _DBG_Writeln( "loadret->error_code == 0" ); TaskLoaded = TRUE; } SaveVectors( LoadVectors ); SaveVectors( CurrVectors ); _DBG_ExitFunc( "AccLoadProg()" ); return( len ); }
trap_retval ReqProg_load( void ) { char buffer[160]; char *src; char *dst; char *name; char *endparm; const char *err; tiny_ret_t rc; prog_load_ret *ret; trap_elen len; SaveVectors( OrigVectors ); _DBG_EnterFunc( "AccLoadProg()" ); ret = GetOutPtr( 0 ); src = name = GetInPtr( sizeof( prog_load_req ) ); rc = FindProgFile( src, buffer, DosExtList ); endparm = LinkParms; while( *endparm++ != '\0' ) {} // skip trap parameters strcpy( endparm, buffer ); // add command line // result is as follow // "trap parameters string"+"\0"+"command line string"+"\0" err = RemoteLink( LinkParms, false ); if( err != NULL ) { _DBG_Writeln( "Can't RemoteLink" ); TinyWrite( TINY_ERR, err, strlen( err ) ); LoadError = err; ret->err = 1; len = 0; } else { if( TINY_OK( rc ) ) { while( *src++ != '\0' ) {} len = GetTotalSize() - ( src - name ) - sizeof( prog_load_req ); dst = (char *)buffer; while( *dst++ != '\0' ) {}; memcpy( dst, src, len ); dst += len; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( In_Mx_Ptr[0].ptr, sizeof( prog_load_req ) ); _DBG_Writeln( "AddPacket" ); AddPacket( buffer, dst - buffer ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); len = GetPacket(); _DBG_Writeln( "RemovePacket" ); RemovePacket( ret, sizeof( *ret ) ); } else { len = DoAccess(); } _DBG_Writeln( "Linked --" ); if( ret->err != 0 ) { get_err_text_req erracc; prog_kill_req killacc; trap_elen msg_len; _DBG_Writeln( "loadret->errcode != 0" ); if( LoadError == NULL ) { _DBG_Writeln( "making a REQ_GET_ERR_TEXT request" ); erracc.req = REQ_GET_ERR_TEXT; erracc.err = ret->err; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( &erracc, sizeof( erracc ) ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); msg_len = GetPacket(); _DBG_Writeln( "RemovePacket" ); RemovePacket( FailMsg, msg_len ); _DBG_Write( "FailMsg : " ); _DBG_NoTabWriteln( FailMsg ); LoadError = FailMsg; } _DBG_Writeln( "making a REQ_PROG_KILL request" ); killacc.req = REQ_PROG_KILL; _DBG_Writeln( "StartPacket" ); StartPacket(); _DBG_Writeln( "AddPacket" ); AddPacket( &killacc, sizeof( killacc ) ); _DBG_Writeln( "PutPacket" ); PutPacket(); _DBG_Writeln( "GetPacket" ); GetPacket(); //RemovePacket( &erracc, msg_len ); RemoteUnLink(); TaskLoaded = false; } } if( ret->err == 0 ) { _DBG_Writeln( "loadret->error_code == 0" ); TaskLoaded = true; } SaveVectors( LoadVectors ); SaveVectors( CurrVectors ); _DBG_ExitFunc( "AccLoadProg()" ); return( len ); }