home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / yield.cpp < prev   
Encoding:
C/C++ Source or Header  |  1994-10-25  |  2.3 KB  |  87 lines

  1. //    Copyright (c) 1994, University of Kansas, All Rights Reserved
  2. //
  3. //    Include File:    none
  4. //    Purpose:    'C' function to do background stuff while wattcp
  5. //            is running.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        01-14-94    created
  9. #define Uses_TKeys
  10. #include"tdoslynx.h"
  11. #include"tcapture.h"
  12. #include"trace.h"
  13. extern "C"    {
  14. #include"msdostcp.h"
  15. };
  16.  
  17. extern "C" void yield(void)    {
  18. //    Purpose:    Do idle processing while wattcp waiting for input.
  19. //    Arguments:    void
  20. //    Return Value:    void
  21. //    Remarks/Portability/Dependencies/Restrictions:
  22. //        Requires that this function is registered via a wattcp
  23. //        routine in code elsewhere.
  24. //        This function is called by 'C' code only.
  25. //    Revision History:
  26. //        01-14-94    created
  27.  
  28.     TEvent TE;
  29.  
  30.     //    Call our application's getEvent function.
  31.     TDosLynx::application->getEvent(TE);
  32.  
  33. #ifdef TODO
  34. #error yield:  Change status bar to only handle hot keys for cancel and handle here.
  35. #endif // TODO
  36.  
  37.     //    Abort transfer on ESC
  38.     if(TE.what & evKeyDown)    {
  39.         if(TE.keyDown.keyCode == kbEsc)    {
  40. #ifndef RELEASE
  41.             trace("Attempt to abort socket IO.");
  42. #endif // RELEASE
  43.             //    Clear the event.
  44.             TDosLynx::application->clearEvent(TE);
  45.             //    Find out if the socket is valid
  46.             if(ssi_sockfd > -1)    {
  47.                 //    Find out if the socket is open
  48.                 if(sock_table[ssi_sockfd].usi_OPEN)    {
  49.                     //    Find out if the socket had IO
  50.                     if(sock_table[ssi_sockfd].usi_IO)
  51.                     {
  52.                         //    Set the socket to EOF
  53.                         //    As an interrupt to IO
  54.                         sock_table[ssi_sockfd].usi_EOF
  55.                             = 1;
  56.                         doslynxmessage("Interrup"
  57.                             "ting....  please"
  58.                             " wait.");
  59.                     }
  60.                     else    {
  61.                         doslynxmessage("Unable to "
  62.                             "interrupt.... no io "
  63.                             "has occured.");
  64.                     }
  65.                 }
  66.                 else    {
  67.                     doslynxmessage("Unable to "
  68.                         "interrupt....  socket not "
  69.                         "opened.");
  70.                 }
  71.             }
  72.             else    {
  73.                 doslynxmessage("Unable to interrupt.... "
  74.                     "not a valid socket, try CTRL-C");
  75.             }
  76.         }
  77.     }
  78.     //    Print message on any event except a mouse move and mouse
  79.     //        button release.
  80.     if(TE.what != evNothing && !(TE.what & evMouseMove) && !(TE.what &
  81.         evMouseUp))    {
  82.         doslynxmessage("Networking.... press ESC to interrupt.");
  83.     }
  84.  
  85.     //    Clear the event message.
  86.     TDosLynx::application->clearEvent(TE);
  87. }