summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/cvs/vms/utime.c
blob: 999aecb748a91b36c64ce120a284a9b2da83445f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* This is REALLY gross, but at least it is a full implementation */ 

#include <ctype.h>
#include <time.h>
#include "vmsmunch.h"

#define ASCTIMEMAX 23

struct utimbuf {
  long actime;
  long modtime;
 }; 

utime(file, buf)
char *file;
struct utimbuf *buf; 
{
  static struct VMStimbuf vtb;
  static char conversion_buf[80];
  static char vms_actime[80];
  static char vms_modtime[80];

  strcpy(conversion_buf, ctime(&buf->actime));
  conversion_buf[ASCTIMEMAX + 1] = '\0';
  sprintf(vms_actime, "%2.2s-%3.3s-%4.4s %8.5s.00",
      &(conversion_buf[8]), &(conversion_buf[4]),
      &(conversion_buf[20]), &(conversion_buf[11]));
  vms_actime[4] = _toupper(vms_actime[4]);
  vms_actime[5] = _toupper(vms_actime[5]);

  strcpy(conversion_buf, ctime(&buf->modtime));
  conversion_buf[ASCTIMEMAX + 1] = '\0';
  sprintf(vms_modtime, "%2.2s-%3.3s-%4.4s %8.5s.00",
      &(conversion_buf[8]), &(conversion_buf[4]),
      &(conversion_buf[20]), &(conversion_buf[11]));
  vms_modtime[4] = _toupper(vms_modtime[4]);
  vms_modtime[4] = _toupper(vms_modtime[5]);

  vtb.actime = vms_actime;    
  vtb.modtime = vms_modtime;
  VMSmunch(file, SET_TIMES, &vtb); 
}