Subject: Re: SUP when.xxx files are bad.
To: Arthur Hoffmann <hoffmann@it.ntu.edu.au>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
List: current-users
Date: 04/18/1995 21:01:15
> Is there any way to change the when.xxx files so that they show the
> date in ascii? 

The when files contain a binary time stamp.  Originally I wrote
fakelast to allow me to create a vailid timestamp file that repesented
the tar_files I used prior to the first SUP.

When I load a tape of a the suped tree on my i386 (the tree being made
on a sparc) I needed to re-write the when files to have the correct
endian-ness. So I hacked fakelast to read the files too and display
the content in both native and after ntohl form.  Worked for me...

As for converting seconds to/from ascii I just use a perl
script...

If the arg to fakelast can be opened for reading, it reads else it
writes a time stamp (provided arg or current time) to stdout.

#!/bin/sh
# This is a shell archive.
# remove everything above the "#!/bin/sh" line
# and feed to /bin/sh
# Use -c option to overwrite existing files
#
# Contents: 
#	fakelast.c
#
# packed by: <sjg@zen.void.oz.au> on Tue Apr 18 20:59:23 EST 1995
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f fakelast.c -a x$1 != x-c ; then
  echo shar: Will not over-write existing file \"fakelast.c\"
else
  echo shar: Extracting \"fakelast.c\" \(695 characters\)
  sed 's/^X//' >fakelast.c << '!EOF'
X#include <stdio.h>
X#include <string.h>
X#include <fcntl.h>
X
Xint
Xwrite_last(arg)
X	char *arg;
X{
X	unsigned long now = 0;
X
X	if (arg)
X		now = atoi(arg);
X	if (now <= 0)
X		now = time((long *) 0);
X	return write(1, (char *)&now, sizeof(long));
X}
X
Xint
Xread_last(arg)
X	char *arg;
X{
X	int f;
X	unsigned long nnow, now = 0;
X
X	if (arg) {
X		if ((f = open(arg, O_RDONLY)) > 0) {
X			if (read(f, (char *)&now, sizeof(long)) > 0) {
X				nnow = ntohl(now);
X				printf("%lu\n%lu\n", now, nnow);
X			}
X			close(f);
X			return 1;
X		}
X	}
X	return 0;
X}
X
Xint
Xmain(argc, argv)
X	int argc;
X	char **argv;
X{
X	unsigned long nnow, now = 0;
X	int f;
X
X	if (argc == 1 ||
X	    read_last(argv[1]) <= 0)
X		write_last(argv[1]);
X		
X	exit(0);
X}
!EOF
  if test 695 -ne `wc -c < fakelast.c`; then
    echo shar: \"fakelast.c\" unpacked with wrong size!
  fi
  
fi
exit 0