home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / unixlib / !UnixLib / src / unix / c / utime < prev    next >
Encoding:
Text File  |  1994-09-30  |  737 b   |  48 lines

  1. static char sccs_id[] = "@(#) utime.c 1.2 " __DATE__ " HJR";
  2.  
  3. /* utime.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <errno.h>
  6. #include <time.h>
  7.  
  8. #include "sys/unix.h"
  9. #include "sys/os.h"
  10.  
  11. int
  12. utime (char *file, register time_t * tp)
  13. {
  14.   int r[6];
  15.   os_error *e;
  16.  
  17.   if (!tp)
  18.     {
  19.       errno = EINVAL;
  20.       return (-1);
  21.     }
  22.  
  23.   file = __uname (file, 0);
  24.  
  25.   if (e = os_file (0x05, file, r))
  26.     {
  27.       __seterr (e);
  28.       return (-1);
  29.     }
  30.   if (!r[0])
  31.     {
  32.       errno = ENOENT;
  33.       return (-1);
  34.     }
  35.  
  36.   r[2] = (r[2] & 0x000fff00U) | 0xfff00000U |
  37.     ((((tp[1] >> 8) * 100) >> 24) + 0x33);
  38.   r[3] = tp[1] * 100 + 0x6e996a00U;
  39.  
  40.   if (e = os_file (0x01, file, r))
  41.     {
  42.       __seterr (e);
  43.       return (-1);
  44.     }
  45.  
  46.   return (0);
  47. }
  48.