xref: /openbsd/gnu/usr.bin/cvs/vms/utime.c (revision 73471bf0)
1 /* This is REALLY gross, but at least it is a full implementation */
2 
3 #include <ctype.h>
4 #include <time.h>
5 #include "vmsmunch.h"
6 
7 #define ASCTIMEMAX 23
8 
9 struct utimbuf {
10   long actime;
11   long modtime;
12  };
13 
14 utime(file, buf)
15 char *file;
16 struct utimbuf *buf;
17 {
18   static struct VMStimbuf vtb;
19   static char conversion_buf[80];
20   static char vms_actime[80];
21   static char vms_modtime[80];
22 
23   strcpy(conversion_buf, ctime(&buf->actime));
24   conversion_buf[ASCTIMEMAX + 1] = '\0';
25   sprintf(vms_actime, "%2.2s-%3.3s-%4.4s %8.5s.00",
26       &(conversion_buf[8]), &(conversion_buf[4]),
27       &(conversion_buf[20]), &(conversion_buf[11]));
28   vms_actime[4] = _toupper(vms_actime[4]);
29   vms_actime[5] = _toupper(vms_actime[5]);
30 
31   strcpy(conversion_buf, ctime(&buf->modtime));
32   conversion_buf[ASCTIMEMAX + 1] = '\0';
33   sprintf(vms_modtime, "%2.2s-%3.3s-%4.4s %8.5s.00",
34       &(conversion_buf[8]), &(conversion_buf[4]),
35       &(conversion_buf[20]), &(conversion_buf[11]));
36   vms_modtime[4] = _toupper(vms_modtime[4]);
37   vms_modtime[4] = _toupper(vms_modtime[5]);
38 
39   vtb.actime = vms_actime;
40   vtb.modtime = vms_modtime;
41   VMSmunch(file, SET_TIMES, &vtb);
42 }
43