home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / time / settimeo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-27  |  562 b   |  31 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <time.h>
  3. #include <dpmi.h>
  4.  
  5. int
  6. settimeofday(struct timeval *_tp, ...)
  7. {
  8.   __dpmi_regs r;
  9.   struct tm tm;
  10.  
  11.   tm = *localtime(&(_tp->tv_sec));
  12.  
  13.   if (tm.tm_year < 80)
  14.     return -1;
  15.  
  16.   r.h.ah = 0x2b;
  17.   r.x.cx = tm.tm_year + 1900;
  18.   r.h.dh = tm.tm_mon + 1;
  19.   r.h.dl = tm.tm_mday;
  20.   __dpmi_int(0x21, &r);
  21.  
  22.   r.h.ah = 0x2d;
  23.   r.h.ch = tm.tm_hour;
  24.   r.h.cl = tm.tm_min;
  25.   r.h.dh = tm.tm_sec;
  26.   r.h.dl = _tp->tv_usec / 10000;
  27.   __dpmi_int(0x21, &r);
  28.  
  29.   return 0;
  30. }
  31.