strsep had an incorrect function prototype
[unix-history] / usr / src / usr.bin / ar / delete.c
CommitLineData
c43c747e
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Hugh Smith at The University of Guelph.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#ifndef lint
12static char sccsid[] = "@(#)delete.c 5.1 (Berkeley) %G%";
13#endif /* not lint */
14
15#include <sys/param.h>
16#include <sys/stat.h>
17#include <fcntl.h>
18#include <unistd.h>
19#include <dirent.h>
20#include <stdio.h>
21#include <ar.h>
22#include "archive.h"
23#include "pathnames.h"
24
25extern CHDR chdr; /* converted header */
26extern char *archive; /* archive name */
27extern char *tname; /* temporary file "name" */
28
29/*-
30 * delete --
31 * Deletes named members from the archive.
32 */
33delete(argv)
34 register char **argv;
35{
36 CF cf;
37 off_t size;
38 int afd, eval, tfd;
39
40 afd = open_archive(O_RDWR);
41 tfd = tmp();
42
43 SETCF(afd, archive, tfd, tname, RPAD|WPAD);
44 while (get_header(afd)) {
45 if (*argv && files(argv)) {
46 if (options & AR_V)
47 (void)printf("d - %s\n", chdr.name);
48 SKIP(afd, chdr.size, archive);
49 continue;
50 }
51 put_header(&cf, (struct stat *)NULL);
52 copyfile(&cf, chdr.size);
53 }
54 ORPHANS;
55
56 size = lseek(tfd, (off_t)0, SEEK_CUR);
57 (void)lseek(tfd, (off_t)0, SEEK_SET);
58 (void)lseek(afd, (off_t)SARMAG, SEEK_SET);
59 SETCF(tfd, tname, afd, archive, RPAD|WPAD);
60 copyfile(&cf, size);
61 (void)close(tfd);
62 (void)ftruncate(afd, size + SARMAG);
63 close_archive(afd);
64 return(eval);
65}