static int FindPartner( void ) { BYTE property_value[130]; LONG transport_time; if( ReadPropertyValue( (char *)SAPStruct.ASServerIDpacket.serverName, DBG_SERVER_TYPE, "NET_ADDRESS", 1, (BYTE *)&property_value ) != 0 ) return( 0 ); AssignArray( ServHead.destination, property_value ); if( CIPXGetLocalTarget( ServHead.destination.network, ServECB.immediateAddress, &transport_time ) != 0 ) { _DBG_IPX(( "FindPartner -- nobody home\r\n" )); return( FALSE ); } RespECB.fragmentDescriptor[1].address = &PartnerSPXSocket; CIPXListen( &RespECB ); CIPXSendPacket( &ServECB ); while( InUse( ServECB ) ) NothingToDo(); if( !Completed( ServECB ) ) return( FALSE ); NothingToDo(); Tick = 0; for( ;; ) { if( !InUse( RespECB ) ) { _DBG_IPX(( "FindPartner -- %s answered\r\n", Completed( RespECB ) ? "someone" : "noone" )); return( Completed( RespECB ) ); } NothingToDo(); if( Tick > MAX_PARTNER_WAIT ) break; } CIPXCancelECB( &RespECB ); return( FALSE ); }
static void MyDelay( unsigned amount ) { Tick = 0; while( Tick < amount ) { NothingToDo(); } }
bool Session( void ) { unsigned req; bool want_return; Out[0].len = sizeof( RWBuff ); Out[0].ptr = RWBuff; for( ;; ) { #ifdef __WINDOWS__ NothingToDo(); #endif In[0].len = GetPacket(); In[0].ptr = GetPacketBuffPtr(); In_Mx_Ptr = &In[0]; Out_Mx_Ptr = &Out[0]; In_Mx_Num = 1; Out_Mx_Num = 1; req = TRP_REQUEST( In ); TRP_REQUEST( In ) &= ~0x80; if( req & 0x80 ) { req &= ~0x80; want_return = false; } else { want_return = true; } switch( req ) { case REQ_CONNECT: if( !AccConnect() ) return( true ); break; case REQ_DISCONNECT: AccTrap( false ); return( true ); case REQ_SUSPEND: AccTrap( false ); RemoteDisco(); for(;;) { while( !RemoteConnect() ) ; if( !Session() ) break; RemoteDisco(); } break; case REQ_RESUME: AccTrap( false ); return( false ); case REQ_PROG_LOAD: AccLoadProg(); break; default: AccTrap( want_return ); break; } } }
static trap_retval DoRemotePut( void *data, trap_elen len ) { _DBG_IPX(("RemotePut\r\n")); _INITSPXECB( Send, 2, data, len ); SendHead.connectionControl |= 0x10; SendHead.length = _SWAPINT( sizeof( SendHead ) + len ); CSPXSendSequencedPacket( Connection, &SendECB ); while( InUse( SendECB ) ) NothingToDo(); return( len ); }
int WaitByte( unsigned timer_ticks ) { unsigned wait_time; /* timer variable for testing time-out */ int data; /* storing data from receive buffer */ wait_time = WaitCount() + timer_ticks; for( ;; ) { data = GetByte(); if( data != SDATA_NO_DATA ) break; /* character received */ if( WaitCount() >= wait_time ) break; NothingToDo(); } return( data ); }
bool RemoteConnect( void ) { PostListens(); if( !Listening ) { _DBG_IPX(("Listening for connection\r\n")); _INITSPXECB( Conn, 1, 0, 0 ); CSPXListenForConnection( 0, 0, &Connection, &ConnECB ); Listening = 1; } else if( !InUse( ConnECB ) && Completed( ConnECB ) ) { _DBG_IPX(("Found a connection\r\n")); return( TRUE ); } NothingToDo(); return( FALSE ); }
void PecoApp::MessageReceived(BMessage *msg) { switch( msg->what ) { case B_SIMPLE_DATA: RefsReceived (msg); break; case MSG_MENU_NEW: New(); NoRenamer(); break; case MSG_SELECT_FILES: fFilePanel->Show(); break; case MSG_DO_IT: MakeList(); DoIt(); break; case MSG_RENAMER: ChangeRenamer(); break; case MSG_RENAME_SETTINGS: MakeList(); break; case MSG_MENU_SCRIPT: if (!NothingToDo()) fScriptFilePanel->Show(); break; case B_SAVE_REQUESTED: CreateScript(msg); break; default: BApplication::MessageReceived(msg); } };
int main( int argc, char **argv ) { char key; #ifndef __WATCOMC__ _argc = argc; _argv = argv; #endif Initialize(); OpeningStatement(); for( ;; ) { Output( TRP_MSG_press_q ); Output( "\r\n" ); for( ;; ) { if( RemoteConnect() ) break; NothingToDo(); if( KeyPress() ) { key = KeyGet(); if( key == 'q' || key == 'Q' ) { KillTrap(); RemoteUnLink(); SayGNiteGracey( 0 ); } } } Output( TRP_MSG_session_started ); Output( "\r\n\r\n" ); Session(); #ifndef NETWARE /* flush keyboard input */ while( KeyPress() ) KeyGet(); #endif Output( "\r\n\r\n" ); Output( TRP_MSG_session_ended ); Output( "\r\n\r\n" ); RemoteDisco(); if( OneShot ) { KillTrap(); RemoteUnLink(); SayGNiteGracey( 0 ); } } return( 0 ); }
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 ); }
static trap_retval DoRemoteGet( void *data, trap_elen len ) { trap_elen recvd; int i; trap_elen got; int p; len = len; _DBG_IPX(("RemoteGet\r\n")); recvd = 0; for( ;; ) { i = NUM_REC_BUFFS-1; p = -1; for( ;; ) { if( i < 0 ) { if( p != -1 ) break; NothingToDo(); i = NUM_REC_BUFFS-1; } if( !InUse( RecECB[i] ) ) { if( p == -1 || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) { p = i; } } --i; } got = _SWAPINT( RecHead[p].length ) - sizeof( RecHead[p] ); _DBG_IPX(("Got a packet - size=%d\r\n", got)); memcpy( data, Buffer[p], got ); recvd += got; PostAListen( p ); if( got != MAX_DATA_SIZE ) break; data = (char *)data + got; } return( recvd ); }
void PecoApp::DoIt() { if (NothingToDo()) return; FileListItem *ListItem; BAlert *myAlert = new BAlert(NULL, MESSAGE_REALLY_DOIT, STR_CONTINUE, STR_CANCEL); if (myAlert->Go() == 1) return; for (int32 i = 0; (ListItem = (FileListItem *)fListView->ItemAt(i)) != NULL; i++ ) { if (ListItem->fErrorStatus == 1 ) { BAlert *myAlert = new BAlert(NULL, MESSAGE_WILL_HAVE_PROBS, STR_CONTINUE, STR_CANCEL); if (myAlert->Go() == 1) return; break; } } bool noerror = true, nomoreerrors=false, canceled=false; fWindow->Lock(); fStatusBar->SetText(STATUS_RENAMING); fStatusBar->SetMaxValue(fList->CountItems()); BButton *okButton = (BButton *)fWindow->FindView("DoIt"); okButton->SetEnabled(false); BTextControl* pfadView = (BTextControl *)fWindow->FindView("pfadView"); BString Pfad(pfadView->Text()); fWindow->Unlock(); BString AlterName, NeuerName; BEntry Datei; for (int32 i = 0; (ListItem = (FileListItem *)fListView->ItemAt(i)) != NULL; i++ ) { fWindow->Lock(); fStatusBar->Update(1); fWindow->Unlock(); if (canceled) { ListItem->fErrorStatus=0; continue; } if (ListItem->fNewName.String() != "" ) { AlterName = Pfad; AlterName.Append("/").Append(ListItem->fName); NeuerName = Pfad; NeuerName.Append("/").Append(ListItem->fNewName); Datei.SetTo(AlterName.String()); if ( Datei.Rename(NeuerName.String()) != B_OK ) { ListItem->fErrorStatus=1; fWindow->Lock(); fListView->InvalidateItem(i); fWindow->Unlock(); if (!nomoreerrors) { noerror = false; BString ErrorMessage(MESSAGE_HAVE_PROBLEM); ErrorMessage.ReplaceFirst("%1", ListItem->fName.String()); ErrorMessage.ReplaceFirst("%2", ListItem->fNewName.String()); BAlert *myAlert = new BAlert(NULL, ErrorMessage.String(), STR_CANCEL, STR_CONTINUE, STR_CONTINUE_WO_MSG, B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 result = myAlert->Go(); if (result == 0) { canceled = true; continue; } if (result == 2) nomoreerrors = true; } } else { fWindow->Lock(); ListItem->SetName(ListItem->fNewName); ListItem->SetNewName(""); fListView->InvalidateItem(i); fWindow->Unlock(); } } } // NoRenamer(); fWindow->Lock(); fStatusBar->Reset(STATUS_STATUS); fWindow->Unlock(); if (noerror) MakeList(); else { fStatusBar->SetText(STATUS_DIDIT_BAD); BAlert *myAlert = new BAlert(NULL, MESSAGE_MARKED_FILES, STR_OK); myAlert->Go(); } }