head	1.8;
access;
symbols
	perseant-exfatfs-base-20250801:1.8
	perseant-exfatfs-base-20240630:1.8
	perseant-exfatfs:1.8.0.46
	perseant-exfatfs-base:1.8
	cjep_sun2x:1.8.0.44
	cjep_sun2x-base:1.8
	cjep_staticlib_x-base1:1.8
	cjep_staticlib_x:1.8.0.42
	cjep_staticlib_x-base:1.8
	phil-wifi-20200421:1.8
	phil-wifi-20200411:1.8
	phil-wifi-20200406:1.8
	pgoyette-compat-merge-20190127:1.8
	pgoyette-compat-20190127:1.8
	pgoyette-compat-20190118:1.8
	pgoyette-compat-1226:1.8
	pgoyette-compat-1126:1.8
	pgoyette-compat-1020:1.8
	pgoyette-compat-0930:1.8
	pgoyette-compat-0906:1.8
	pgoyette-compat-0728:1.8
	pgoyette-compat-0625:1.8
	pgoyette-compat-0521:1.8
	pgoyette-compat-0502:1.8
	pgoyette-compat-0422:1.8
	pgoyette-compat-0415:1.8
	pgoyette-compat-0407:1.8
	pgoyette-compat-0330:1.8
	pgoyette-compat-0322:1.8
	pgoyette-compat-0315:1.8
	pgoyette-compat:1.8.0.40
	pgoyette-compat-base:1.8
	perseant-stdc-iso10646:1.8.0.38
	perseant-stdc-iso10646-base:1.8
	prg-localcount2-base3:1.8
	prg-localcount2-base2:1.8
	prg-localcount2-base1:1.8
	prg-localcount2:1.8.0.36
	prg-localcount2-base:1.8
	pgoyette-localcount-20170426:1.8
	bouyer-socketcan-base1:1.8
	pgoyette-localcount-20170320:1.8
	bouyer-socketcan:1.8.0.34
	bouyer-socketcan-base:1.8
	pgoyette-localcount-20170107:1.8
	pgoyette-localcount-20161104:1.8
	localcount-20160914:1.8
	pgoyette-localcount-20160806:1.8
	pgoyette-localcount-20160726:1.8
	pgoyette-localcount:1.8.0.32
	pgoyette-localcount-base:1.8
	netbsd-5-2-3-RELEASE:1.8
	netbsd-5-1-5-RELEASE:1.8
	yamt-pagecache-base9:1.8
	yamt-pagecache-tag8:1.8
	tls-earlyentropy:1.8.0.28
	tls-earlyentropy-base:1.8
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.8
	riastradh-drm2-base3:1.8
	netbsd-5-2-2-RELEASE:1.8
	netbsd-5-1-4-RELEASE:1.8
	netbsd-5-2-1-RELEASE:1.8
	netbsd-5-1-3-RELEASE:1.8
	agc-symver:1.8.0.30
	agc-symver-base:1.8
	tls-maxphys-base:1.8
	yamt-pagecache-base8:1.8
	netbsd-5-2:1.8.0.26
	yamt-pagecache-base7:1.8
	netbsd-5-2-RELEASE:1.8
	netbsd-5-2-RC1:1.8
	yamt-pagecache-base6:1.8
	yamt-pagecache-base5:1.8
	yamt-pagecache-base4:1.8
	netbsd-5-1-2-RELEASE:1.8
	netbsd-5-1-1-RELEASE:1.8
	yamt-pagecache-base3:1.8
	yamt-pagecache-base2:1.8
	yamt-pagecache:1.8.0.24
	yamt-pagecache-base:1.8
	bouyer-quota2-nbase:1.8
	bouyer-quota2:1.8.0.22
	bouyer-quota2-base:1.8
	matt-nb5-pq3:1.8.0.20
	matt-nb5-pq3-base:1.8
	netbsd-5-1:1.8.0.18
	netbsd-5-1-RELEASE:1.8
	netbsd-5-1-RC4:1.8
	netbsd-5-1-RC3:1.8
	netbsd-5-1-RC2:1.8
	netbsd-5-1-RC1:1.8
	netbsd-5-0-2-RELEASE:1.8
	netbsd-5-0-1-RELEASE:1.8
	jym-xensuspend-nbase:1.8
	netbsd-5-0:1.8.0.16
	netbsd-5-0-RELEASE:1.8
	netbsd-5-0-RC4:1.8
	netbsd-5-0-RC3:1.8
	netbsd-5-0-RC2:1.8
	jym-xensuspend:1.8.0.14
	jym-xensuspend-base:1.8
	netbsd-5-0-RC1:1.8
	netbsd-5:1.8.0.12
	netbsd-5-base:1.8
	mjf-devfs2:1.8.0.10
	mjf-devfs2-base:1.8
	yamt-pf42-base4:1.8
	yamt-pf42-base3:1.8
	hpcarm-cleanup-nbase:1.8
	yamt-pf42-base2:1.8
	yamt-pf42:1.8.0.8
	yamt-pf42-base:1.8
	keiichi-mipv6-nbase:1.8
	keiichi-mipv6:1.8.0.6
	keiichi-mipv6-base:1.8
	cube-autoconf:1.8.0.4
	cube-autoconf-base:1.8
	hpcarm-cleanup:1.8.0.2
	hpcarm-cleanup-base:1.8
	netbsd-1-3-PATCH003:1.7
	netbsd-1-3-PATCH003-CANDIDATE2:1.7
	netbsd-1-3-PATCH003-CANDIDATE1:1.7
	netbsd-1-3-PATCH003-CANDIDATE0:1.7
	netbsd-1-3-PATCH002:1.7
	netbsd-1-3-PATCH001:1.7
	netbsd-1-3-RELEASE:1.7
	netbsd-1-3-BETA:1.7
	netbsd-1-3:1.7.0.2
	netbsd-1-3-base:1.7
	netbsd-1-2-PATCH001:1.5
	netbsd-1-2-RELEASE:1.5
	netbsd-1-2-BETA:1.5
	netbsd-1-2:1.5.0.6
	netbsd-1-2-base:1.5
	netbsd-1-1-PATCH001:1.5
	netbsd-1-1-RELEASE:1.5
	netbsd-1-1:1.5.0.2
	netbsd-1-1-base:1.5
	lite-2:1.1.1.2
	netbsd-1-0-PATCH06:1.2
	netbsd-1-0-PATCH05:1.2
	netbsd-1-0-PATCH04:1.2
	netbsd-1-0-PATCH03:1.2
	netbsd-1-0-PATCH02:1.2
	netbsd-1-0-PATCH1:1.2
	netbsd-1-0-PATCH0:1.2
	netbsd-1-0-RELEASE:1.2
	lite-1:1.1.1.2
	CSRG:1.1.1
	netbsd-1-0:1.2.0.2
	netbsd-1-0-base:1.2
	netbsd-0-9-RELEASE:1.1.1.1
	netbsd-0-9-BETA:1.1.1.1
	netbsd-0-9-ALPHA2:1.1.1.1
	netbsd-0-9-ALPHA:1.1.1.1
	netbsd-0-9:1.1.1.1.0.2
	netbsd-0-9-base:1.1.1.1
	netbsd-0-8:1.1.1.1
	netbsd-alpha-1:1.1.1.1
	patchkit-0-2-2:1.1.1.1
	WFJ-386bsd-01:1.1.1.1
	WFJ-920714:1.1.1;
locks; strict;
comment	@ * @;


1.8
date	98.08.22.05.33.20;	author tv;	state dead;
branches;
next	1.7;

1.7
date	97.10.18.11.53.09;	author lukem;	state Exp;
branches;
next	1.6;

1.6
date	97.04.24.06.22.16;	author mycroft;	state Exp;
branches;
next	1.5;

1.5
date	95.03.26.03.27.53;	author glass;	state Exp;
branches;
next	1.4;

1.4
date	95.03.25.06.39.47;	author glass;	state Exp;
branches;
next	1.3;

1.3
date	94.09.19.03.34.15;	author mycroft;	state Exp;
branches;
next	1.2;

1.2
date	93.08.01.18.18.33;	author mycroft;	state Exp;
branches;
next	1.1;

1.1
date	93.03.21.09.45.37;	author cgd;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	93.03.21.09.45.37;	author cgd;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	94.09.19.03.05.20;	author mycroft;	state Exp;
branches;
next	;


desc
@@


1.8
log
@Nuke the Berkeley tools (except strip).  The GNU binutils are now
standard.
@
text
@/*	$NetBSD: extract.c,v 1.7 1997/10/18 11:53:09 lukem Exp $	*/

/*-
 * Copyright (c) 1990, 1993, 1994
 *	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.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@@(#)extract.c	8.3 (Berkeley) 4/2/94";
#else 
__RCSID("$NetBSD: extract.c,v 1.7 1997/10/18 11:53:09 lukem Exp $");
#endif
#endif /* not lint */

#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>

#include <dirent.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "archive.h"
#include "extern.h"

/*
 * extract --
 *	Extract files from the named archive - if member names given only
 *	extract those members otherwise extract all members.  If 'o' option
 *	selected modify date of newly created file to be same as archive
 *	members date otherwise date is time of extraction.  Does not modify
 *	archive.
 */
int
extract(argv)
	char **argv;
{
	char *file;
	int afd, all, eval, tfd;
	struct timeval tv[2];
	struct stat sb;
	CF cf;

	eval = 0;
	tv[0].tv_usec = tv[1].tv_usec = 0;

	afd = open_archive(O_RDONLY);

	/* Read from an archive, write to disk; pad on read. */
	SETCF(afd, archive, 0, 0, RPAD);
	for (all = !*argv; get_arobj(afd);) {
		if (all)
			file = chdr.name;
		else if (!(file = files(argv))) {
			skip_arobj(afd);
			continue;
		}

		if (options & AR_U && !stat(file, &sb) &&
		    sb.st_mtime > chdr.date)
			continue;

		if ((tfd = open(file, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR)) < 0) {
			warn("%s", file);
			skip_arobj(afd);
			eval = 1;
			continue;
		}

		if (options & AR_V)
			(void)printf("x - %s\n", file);

		cf.wfd = tfd;
		cf.wname = file;
		copy_ar(&cf, chdr.size);

		if (fchmod(tfd, (short)chdr.mode)) {
			warn("chmod: %s", file);
			eval = 1;
		}
		if (options & AR_O) {
			tv[0].tv_sec = tv[1].tv_sec = chdr.date;
			if (futimes(tfd, tv)) {
				warn("utimes: %s", file);
				eval = 1;
			}
		}
		(void)close(tfd);
		if (!all && !*argv)
			break;
	}
	close_archive(afd);

	if (*argv) {
		orphans(argv);
		return (1);
	}
	return (0);
}	
@


1.7
log
@WARNSify, fix .Nm usage
@
text
@d1 1
a1 1
/*	$NetBSD: extract.c,v 1.6 1997/04/24 06:22:16 mycroft Exp $	*/
d44 1
a44 1
__RCSID("$NetBSD$");
@


1.6
log
@Use futimes(2), to prevent race conditions.
@
text
@d1 1
a1 1
/*	$NetBSD: extract.c,v 1.5 1995/03/26 03:27:53 glass Exp $	*/
d39 1
d44 1
a44 1
static char rcsid[] = "$NetBSD: extract.c,v 1.5 1995/03/26 03:27:53 glass Exp $";
@


1.5
log
@consistency..bleh
@
text
@d1 1
a1 1
/*	$NetBSD: extract.c,v 1.4 1995/03/25 06:39:47 glass Exp $	*/
d43 1
a43 1
static char rcsid[] = "$NetBSD: extract.c,v 1.4 1995/03/25 06:39:47 glass Exp $";
d118 1
a118 1
			if (utimes(file, tv)) {
@


1.4
log
@update rcsid format
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d43 1
a43 1
static char *rcsid = "$NetBSD: extract.c,v 1.3 1994/09/19 03:34:15 mycroft Exp $";
@


1.3
log
@Merge with 4.4-Lite.
@
text
@d1 2
d40 5
a44 2
/*static char sccsid[] = "from: @@(#)extract.c	8.3 (Berkeley) 4/2/94";*/
static char *rcsid = "$Id: $";
@


1.2
log
@Add RCS identifiers.
@
text
@d2 2
a3 2
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
d38 2
a39 2
/*static char sccsid[] = "from: @@(#)extract.c	5.5 (Berkeley) 3/12/91";*/
static char rcsid[] = "$Id: $";
d45 3
a48 3
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
d51 2
a55 3
extern CHDR chdr;			/* converted header */
extern char *archive;			/* archive name */

d64 1
d68 2
a69 1
	register int afd, all, tfd;
a72 2
	int eval;
	char *file;
d94 1
a94 2
			(void)fprintf(stderr, "ar: %s: %s.\n",
			    file, strerror(errno));
d108 1
a108 2
			(void)fprintf(stderr, "ar: %s: chmod: %s\n",
			    file, strerror(errno));
d114 1
a114 2
				(void)fprintf(stderr, "ar: %s: utimes: %s\n",
				    file, strerror(errno));
d126 1
a126 1
		return(1);
d128 1
a128 1
	return(0);
@


1.1
log
@Initial revision
@
text
@d38 2
a39 1
static char sccsid[] = "@@(#)extract.c	5.5 (Berkeley) 3/12/91";
@


1.1.1.1
log
@initial import of 386bsd-0.1 sources
@
text
@@


1.1.1.2
log
@Import original 4.4-Lite version.
@
text
@d2 2
a3 2
 * Copyright (c) 1990, 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
d38 1
a38 1
static char sccsid[] = "@@(#)extract.c	8.3 (Berkeley) 4/2/94";
d44 2
a45 1

d47 1
a47 2
#include <err.h>
#include <fcntl.h>
a49 2
#include <unistd.h>

d53 3
a63 1
int
d67 1
a67 2
	char *file;
	int afd, all, eval, tfd;
d71 2
d94 2
a95 1
			warn("%s", file);
d109 2
a110 1
			warn("chmod: %s", file);
d116 2
a117 1
				warn("utimes: %s", file);
d129 1
a129 1
		return (1);
d131 1
a131 1
	return (0);
@
