File: utime.c

package info (click to toggle)
cvs 2%3A1.12.13%2Breal-28%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,156 kB
  • sloc: ansic: 100,617; sh: 33,909; asm: 3,281; perl: 2,818; ada: 1,681; makefile: 1,605; yacc: 1,244; pascal: 1,082; cpp: 1,001; lisp: 35
file content (42 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (16)
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); 
}