/*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. * * %sccs.include.redist.c% */ #ifndef lint static char sccsid[] = "@(#)touch.c 5.2 (Berkeley) 02/26/91"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include extern CHDR chdr; /* converted header */ extern char *archive; /* archive name */ touch() { int afd; afd = open_archive(O_RDWR); if (!get_header(afd) || strncmp(RANLIBMAG, chdr.name, sizeof(RANLIBMAG) - 1)) { (void)fprintf(stderr, "ranlib: %s: no symbol table.\n", archive); return(1); } settime(afd); return(0); } settime(afd) int afd; { struct ar_hdr *hdr; off_t size; char buf[50]; size = SARMAG + sizeof(hdr->ar_name); if (lseek(afd, size, SEEK_SET) == (off_t)-1) error(archive); (void)sprintf(buf, "%-12ld", time((time_t *)NULL) + RANLIBSKEW); if (write(afd, buf, sizeof(hdr->ar_date)) != sizeof(hdr->ar_date)) error(archive); }