home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / MSDOS / WATTCP / WNWATTCP.ZIP / ELIB / TIMEOUT.C < prev   
Encoding:
C/C++ Source or Header  |  1992-02-10  |  784 b   |  44 lines

  1. /*
  2. *       timeout.c - Timeout calculation/checking functions.
  3. *
  4. *    Based on timeout.asm.
  5. *
  6. *    
  7. */
  8.  
  9. extern unsigned long far *realclock;    /* PCTCP.C */
  10. static unsigned long date;
  11. static char oldhour;
  12.  
  13. #define MAXTICKS 0x1800b0L
  14.  
  15. unsigned long
  16. set_ttimeout(unsigned int ticks)
  17. {
  18.     return(*realclock + date + ticks);
  19. }
  20.  
  21. unsigned long set_timeout(unsigned int seconds)
  22. {
  23.     return(*realclock + date + (((unsigned long)seconds * 1165L) >> 6));
  24. }
  25.  
  26. int
  27. chk_timeout(unsigned long timeout)
  28. {
  29.     unsigned long this_time;
  30.     char this_hour;
  31.  
  32.     this_time = *realclock;
  33.     this_hour = (this_time >> 16) & 0xff;
  34.     if(this_hour != oldhour) {
  35.         if(this_hour < oldhour)
  36.             date += MAXTICKS;
  37.         oldhour = this_hour;
  38.     }
  39.     this_time += date;
  40.  
  41.     return(timeout < this_time);
  42. }
  43.  
  44.