ftp.nice.ch/pub/next/developer/languages/c/djgpp-NS.s.tar.gz#/djgpp/go32/stamp.c

This is stamp.c in view mode; [Download] [Up]

/* This is file STAMP.C */
/*
** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
**
** This file is distributed under the terms listed in the document
** "copying.dj", available from DJ Delorie at the address above.
** A copy of "copying.dj" should accompany this file; if not, a copy
** should be available from where this file was obtained.  This file
** may not be distributed without a verbatim copy of "copying.dj".
**
** This file is distributed WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <stdio.h>
#include <time.h>

char key[] = "TIMETIME";
char *stamp;

main(int argc, char **argv)
{
  FILE *f;
  int key_p = 0, ch;

  long t;
  time(&t);
  stamp = ctime(&t);
  stamp[strlen(stamp)-1] = 0;

  if (argc != 2)
  {
    fprintf(stderr, "Usage: stamp {program}\n");
    exit(1);
  }
  
  f = fopen(argv[1], "r+b");

  while ((ch = fgetc(f)) != EOF)
  {
    if (ch == key[key_p])
    {
      key_p++;
      if (key[key_p] == 0)
      {
        long pos = ftell(f);
        fseek(f, pos, 0);
        fwrite(stamp, 1, strlen(stamp), f);
        fseek(f, pos, 0);
      }
    }
    else
    key_p = 0;
  }
  fclose(f);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.