From d436927cebd1ffbeb77b5359e2d50e6ef72bda83 Mon Sep 17 00:00:00 2001 From: obrien Date: Fri, 27 Jun 2003 03:59:46 +0000 Subject: Finish the deorbital burn of the i386-only a.out toolchain. --- usr.bin/ar/Makefile | 12 -- usr.bin/ar/append.c | 94 -------------- usr.bin/ar/ar.1 | 318 ---------------------------------------------- usr.bin/ar/ar.1aout | 318 ---------------------------------------------- usr.bin/ar/ar.5 | 147 ---------------------- usr.bin/ar/ar.c | 246 ------------------------------------ usr.bin/ar/archive.c | 333 ------------------------------------------------- usr.bin/ar/archive.h | 106 ---------------- usr.bin/ar/contents.c | 109 ---------------- usr.bin/ar/delete.c | 101 --------------- usr.bin/ar/extern.h | 54 -------- usr.bin/ar/extract.c | 133 -------------------- usr.bin/ar/misc.c | 144 --------------------- usr.bin/ar/move.c | 145 --------------------- usr.bin/ar/pathnames.h | 40 ------ usr.bin/ar/print.c | 95 -------------- usr.bin/ar/replace.c | 183 --------------------------- 17 files changed, 2578 deletions(-) delete mode 100644 usr.bin/ar/Makefile delete mode 100644 usr.bin/ar/append.c delete mode 100644 usr.bin/ar/ar.1 delete mode 100644 usr.bin/ar/ar.1aout delete mode 100644 usr.bin/ar/ar.5 delete mode 100644 usr.bin/ar/ar.c delete mode 100644 usr.bin/ar/archive.c delete mode 100644 usr.bin/ar/archive.h delete mode 100644 usr.bin/ar/contents.c delete mode 100644 usr.bin/ar/delete.c delete mode 100644 usr.bin/ar/extern.h delete mode 100644 usr.bin/ar/extract.c delete mode 100644 usr.bin/ar/misc.c delete mode 100644 usr.bin/ar/move.c delete mode 100644 usr.bin/ar/pathnames.h delete mode 100644 usr.bin/ar/print.c delete mode 100644 usr.bin/ar/replace.c (limited to 'usr.bin/ar') diff --git a/usr.bin/ar/Makefile b/usr.bin/ar/Makefile deleted file mode 100644 index 3046cde..0000000 --- a/usr.bin/ar/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $FreeBSD$ - -PROG= ar -SRCS= append.c ar.c archive.c contents.c delete.c extract.c misc.c \ - move.c print.c replace.c -CFLAGS+=-I${.CURDIR} -MAN= ar.1aout ar.5 -BINDIR= /usr/libexec/aout -WARNS?= 4 - -.include diff --git a/usr.bin/ar/append.c b/usr.bin/ar/append.c deleted file mode 100644 index b891b9e..0000000 --- a/usr.bin/ar/append.c +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)append.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -/* - * append -- - * Append files to the archive - modifies original archive or creates - * a new archive if named archive does not exist. - */ -int -append(argv) - char **argv; -{ - int afd, fd, eval; - char *file; - CF cf; - struct stat sb; - - afd = open_archive(O_CREAT|O_RDWR); - if (lseek(afd, (off_t)0, SEEK_END) == (off_t)-1) - error(archive); - - /* Read from disk, write to an archive; pad on write. */ - SETCF(0, 0, afd, archive, WPAD); - for (eval = 0; (file = *argv++); ) { - if ((fd = open(file, O_RDONLY)) < 0) { - warn("%s", file); - eval = 1; - continue; - } - if (options & AR_V) - (void)printf("q - %s\n", file); - cf.rfd = fd; - cf.rname = file; - put_arobj(&cf, &sb); - (void)close(fd); - } - close_archive(afd); - return (eval); -} diff --git a/usr.bin/ar/ar.1 b/usr.bin/ar/ar.1 deleted file mode 100644 index 3b537a2..0000000 --- a/usr.bin/ar/ar.1 +++ /dev/null @@ -1,318 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" 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. -.\" -.\" @(#)ar.1 8.1 (Berkeley) 6/29/93 -.\" $FreeBSD$ -.\" -.Dd June 29, 1993 -.Dt AR 1 -.Os -.Sh NAME -.Nm ar -.Nd create and maintain library archives -.Sh SYNOPSIS -.Nm -.Fl d -.Op Fl \&Tv -.Ar archive Ar -.Nm -.Fl m -.Op Fl \&Tv -.Ar archive Ar -.Nm -.Fl m -.Op Fl abiTv -.Ar position archive Ar -.Nm -.Fl p -.Op Fl \&Tv -.Ar archive Op Ar -.Nm -.Fl q -.Op Fl cTv -.Ar archive Ar -.Nm -.Fl r -.Op Fl cuTv -.Ar archive Ar -.Nm -.Fl r -.Op Fl abciuTv -.Ar position archive Ar -.Nm -.Fl t -.Op Fl \&Tv -.Ar archive Op Ar -.Nm -.Fl x -.Op Fl ouTv -.Ar archive Op Ar -.Sh DESCRIPTION -The -.Nm -utility creates and maintains groups of files combined into an archive. -Once an archive has been created, new files can be added and existing -files can be extracted, deleted, or replaced. -.Pp -Files are named in the archive by a single component, i.e., if a file -referenced by a path containing a slash (``/'') is archived it will be -named by the last component of that path. -When matching paths listed on the command line against file names stored -in the archive, only the last component of the path will be compared. -.Pp -All informational and error messages use the path listed on the command -line, if any was specified; otherwise the name in the archive is used. -If multiple files in the archive have the same name, and paths are listed -on the command line to ``select'' archive files for an operation, only the -.Em first -file with a matching name will be selected. -.Pp -The normal use of -.Nm -is for the creation and maintenance of libraries suitable for use with -the loader (see -.Xr ld 1 ) -although it is not restricted to this purpose. -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl a -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em after -the archive member -.Ar position , -which must be specified. -.It Fl b -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em before -the archive member -.Ar position , -which must be specified. -.It Fl c -Whenever an archive is created, an informational message to that effect -is written to standard error. -If the -.Fl c -option is specified, -.Nm -creates the archive silently. -.It Fl d -Delete the specified archive files. -.It Fl i -Identical to the -.Fl b -option. -.It Fl m -Move the specified archive files within the archive. -If one of the options -.Fl a , -.Fl b -or -.Fl i -is specified, the files are moved -before or after the -.Ar position -file in the archive. -If none of those options are specified, the files are moved -to the end of the archive. -.It Fl o -Set the access and modification times of extracted files to the -modification time of the file when it was entered into the archive. -This will fail if the user is not the owner of the extracted file -or the super-user. -.It Fl p -Write the contents of the specified archive files to the standard output. -If no files are specified, the contents of all the files in the archive -are written in the order they appear in the archive. -.It Fl q -(Quickly) append the specified files to the archive. -If the archive does not exist a new archive file is created. -Much faster than the -.Fl r -option, when creating a large archive -piece-by-piece, as no checking is done to see if the files already -exist in the archive. -.It Fl r -Replace or add the specified files to the archive. -If the archive does not exist a new archive file is created. -Files that replace existing files do not change the order of the files -within the archive. -New files are appended to the archive unless one of the options -.Fl a , -.Fl b -or -.Fl i -is specified. -.It Fl T -Select and/or name archive members using only the first fifteen characters -of the archive member or command line file name. -The historic archive format had sixteen bytes for the name, but some -historic archiver and loader implementations were unable to handle names -that used the entire space. -This means that file names that are not unique in their first fifteen -characters can subsequently be confused. -A warning message is printed to the standard error output if any file -names are truncated. -(See -.Xr ar 5 -for more information.) -.It Fl t -List the specified files in the order in which they appear in the archive, -each on a separate line. -If no files are specified, all files in the archive are listed. -.It Fl u -Update files. -When used with the -.Fl r -option, files in the archive will be replaced -only if the disk file has a newer modification time than the file in -the archive. -When used with the -.Fl x -option, files in the archive will be extracted -only if the archive file has a newer modification time than the file -on disk. -.It Fl v -Provide verbose output. -When used with the -.Fl d , -.Fl m , -.Fl q -or -.Fl x -options, -.Nm -gives a file-by-file description of the archive modification. -This description consists of three, white-space separated fields: the -option letter, a dash (``-'') and the file name. -When used with the -.Fl r -option, -.Nm -displays the description as above, but the initial letter is an ``a'' if -the file is added to the archive and an ``r'' if the file replaces a file -already in the archive. -.Pp -When used with the -.Fl p -option, -the name of each printed file, -enclosed in less-than (``<'') and greater-than (``>'') characters, -is written to the standard output before -the contents of the file; -it is preceded by a single newline character, and -followed by two newline characters. -.Pp -When used with the -.Fl t -option, -.Nm -displays an ``ls -l'' style listing of information about the members of -the archive. -This listing consists of eight, white-space separated fields: -the file permissions (see -.Xr strmode 3 ) , -the decimal user and group ID's, separated by a single slash (``/''), -the file size (in bytes), the file modification time (in the -.Xr date 1 -format ``%b %e %H:%M %Y''), and the name of the file. -.It Fl x -Extract the specified archive members into the files named by the command -line arguments. -If no members are specified, all the members of the archive are extracted into -the current directory. -.Pp -If the file does not exist, it is created; if it does exist, the owner -and group will be unchanged. -The file access and modification times are the time of the extraction -(but see the -.Fl o -option). -The file permissions will be set to those of the file when it was entered -into the archive; this will fail if the user is not the owner of the -extracted file or the super-user. -.El -.Sh DIAGNOSTICS -.Ex -std -.Sh ENVIRONMENT -.Bl -tag -width indent -compact -.It Ev TMPDIR -The pathname of the directory to use when creating temporary files. -.El -.Sh FILES -.Bl -tag -width indent -compact -.It Pa /tmp -default temporary file directory -.It Pa ar.XXXXXX -temporary file names -.El -.Sh COMPATIBILITY -By default, -.Nm -writes archives that may be incompatible with historic archives, as -the format used for storing archive members with names longer than -fifteen characters has changed. -This implementation of -.Nm -is backward compatible with previous versions of -.Nm -in that it can read and write (using the -.Fl T -option) historic archives. -The -.Fl T -option is provided for compatibility only, and will be deleted -in a future release. -See -.Xr ar 5 -for more information. -.Sh STANDARDS -The -.Nm -utility is expected to offer a superset of the -.St -p1003.2 -functionality. -.Sh SEE ALSO -.Xr ld 1 , -.Xr ranlib 1 , -.Xr strmode 3 , -.Xr ar 5 diff --git a/usr.bin/ar/ar.1aout b/usr.bin/ar/ar.1aout deleted file mode 100644 index 121d838..0000000 --- a/usr.bin/ar/ar.1aout +++ /dev/null @@ -1,318 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" 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. -.\" -.\" @(#)ar.1 8.1 (Berkeley) 6/29/93 -.\" $FreeBSD$ -.\" -.Dd June 29, 1993 -.Dt AR 1 -.Os -.Sh NAME -.Nm ar -.Nd create and maintain library archives -.Sh SYNOPSIS -.Nm -.Fl d -.Op Fl \&Tv -.Ar archive Ar -.Nm -.Fl m -.Op Fl \&Tv -.Ar archive Ar -.Nm -.Fl m -.Op Fl abiTv -.Ar position archive Ar -.Nm -.Fl p -.Op Fl \&Tv -.Ar archive Op Ar -.Nm -.Fl q -.Op Fl cTv -.Ar archive Ar -.Nm -.Fl r -.Op Fl cuTv -.Ar archive Ar -.Nm -.Fl r -.Op Fl abciuTv -.Ar position archive Ar -.Nm -.Fl t -.Op Fl \&Tv -.Ar archive Op Ar -.Nm -.Fl x -.Op Fl ouTv -.Ar archive Op Ar -.Sh DESCRIPTION -The -.Nm -utility creates and maintains groups of files combined into an archive. -Once an archive has been created, new files can be added and existing -files can be extracted, deleted, or replaced. -.Pp -Files are named in the archive by a single component, i.e., if a file -referenced by a path containing a slash (``/'') is archived it will be -named by the last component of that path. -When matching paths listed on the command line against file names stored -in the archive, only the last component of the path will be compared. -.Pp -All informational and error messages use the path listed on the command -line, if any was specified; otherwise the name in the archive is used. -If multiple files in the archive have the same name, and paths are listed -on the command line to ``select'' archive files for an operation, only the -.Em first -file with a matching name will be selected. -.Pp -The normal use of -.Nm -is for the creation and maintenance of libraries suitable for use with -the loader (see -.Xr ld 1 ) -although it is not restricted to this purpose. -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl a -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em after -the archive member -.Ar position , -which must be specified. -.It Fl b -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em before -the archive member -.Ar position , -which must be specified. -.It Fl c -Whenever an archive is created, an informational message to that effect -is written to standard error. -If the -.Fl c -option is specified, -.Nm -creates the archive silently. -.It Fl d -Delete the specified archive files. -.It Fl i -Identical to the -.Fl b -option. -.It Fl m -Move the specified archive files within the archive. -If one of the options -.Fl a , -.Fl b -or -.Fl i -is specified, the files are moved -before or after the -.Ar position -file in the archive. -If none of those options are specified, the files are moved -to the end of the archive. -.It Fl o -Set the access and modification times of extracted files to the -modification time of the file when it was entered into the archive. -This will fail if the user is not the owner of the extracted file -or the super-user. -.It Fl p -Write the contents of the specified archive files to the standard output. -If no files are specified, the contents of all the files in the archive -are written in the order they appear in the archive. -.It Fl q -(Quickly) append the specified files to the archive. -If the archive does not exist a new archive file is created. -Much faster than the -.Fl r -option, when creating a large archive -piece-by-piece, as no checking is done to see if the files already -exist in the archive. -.It Fl r -Replace or add the specified files to the archive. -If the archive does not exist a new archive file is created. -Files that replace existing files do not change the order of the files -within the archive. -New files are appended to the archive unless one of the options -.Fl a , -.Fl b -or -.Fl i -is specified. -.It Fl T -Select and/or name archive members using only the first fifteen characters -of the archive member or command line file name. -The historic archive format had sixteen bytes for the name, but some -historic archiver and loader implementations were unable to handle names -that used the entire space. -This means that file names that are not unique in their first fifteen -characters can subsequently be confused. -A warning message is printed to the standard error output if any file -names are truncated. -(See -.Xr ar 5 -for more information.) -.It Fl t -List the specified files in the order in which they appear in the archive, -each on a separate line. -If no files are specified, all files in the archive are listed. -.It Fl u -Update files. -When used with the -.Fl r -option, files in the archive will be replaced -only if the disk file has a newer modification time than the file in -the archive. -When used with the -.Fl x -option, files in the archive will be extracted -only if the archive file has a newer modification time than the file -on disk. -.It Fl v -Provide verbose output. -When used with the -.Fl d , -.Fl m , -.Fl q -or -.Fl x -options, -.Nm -gives a file-by-file description of the archive modification. -This description consists of three, white-space separated fields: the -option letter, a dash (``-'') and the file name. -When used with the -.Fl r -option, -.Nm -displays the description as above, but the initial letter is an ``a'' if -the file is added to the archive and an ``r'' if the file replaces a file -already in the archive. -.Pp -When used with the -.Fl p -option, -the name of each printed file, -enclosed in less-than (``<'') and greater-than (``>'') characters, -is written to the standard output before -the contents of the file; -it is preceded by a single newline character, and -followed by two newline characters. -.Pp -When used with the -.Fl t -option, -.Nm -displays an ``ls -l'' style listing of information about the members of -the archive. -This listing consists of eight, white-space separated fields: -the file permissions (see -.Xr strmode 3 ) , -the decimal user and group ID's, separated by a single slash (``/''), -the file size (in bytes), the file modification time (in the -.Xr date 1 -format ``%b %e %H:%M %Y''), and the name of the file. -.It Fl x -Extract the specified archive members into the files named by the command -line arguments. -If no members are specified, all the members of the archive are extracted into -the current directory. -.Pp -If the file does not exist, it is created; if it does exist, the owner -and group will be unchanged. -The file access and modification times are the time of the extraction -(but see the -.Fl o -option). -The file permissions will be set to those of the file when it was entered -into the archive; this will fail if the user is not the owner of the -extracted file or the super-user. -.El -.Sh DIAGNOSTICS -.Ex -std -.Sh ENVIRONMENT -.Bl -tag -width indent -compact -.It Ev TMPDIR -The pathname of the directory to use when creating temporary files. -.El -.Sh FILES -.Bl -tag -width indent -compact -.It Pa /tmp -default temporary file directory -.It Pa ar.XXXXXX -temporary file names -.El -.Sh COMPATIBILITY -By default, -.Nm -writes archives that may be incompatible with historic archives, as -the format used for storing archive members with names longer than -fifteen characters has changed. -This implementation of -.Nm -is backward compatible with previous versions of -.Nm -in that it can read and write (using the -.Fl T -option) historic archives. -The -.Fl T -option is provided for compatibility only, and will be deleted -in a future release. -See -.Xr ar 5 -for more information. -.Sh STANDARDS -The -.Nm -utility is expected to offer a superset of the -.St -p1003.2 -functionality. -.Sh SEE ALSO -.Xr ld 1 , -.Xr ranlib 1 , -.Xr strmode 3 , -.Xr ar 5 diff --git a/usr.bin/ar/ar.5 b/usr.bin/ar/ar.5 deleted file mode 100644 index a6274b8..0000000 --- a/usr.bin/ar/ar.5 +++ /dev/null @@ -1,147 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" 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. -.\" -.\" @(#)ar.5.5 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" -.Dd June 9, 1993 -.Dt AR 5 -.Os -.Sh NAME -.Nm ar -.Nd archive (library) file format -.Sh SYNOPSIS -.In ar.h -.Sh DESCRIPTION -The archive command -.Nm -combines several files into one. -Archives are mainly used as libraries of object files intended to be -loaded using the link-editor -.Xr ld 1 . -.Pp -A file created with -.Nm -begins with the ``magic'' string "!\en". -The rest of the archive is made up of objects, each of which is composed -of a header for a file, a possible file name, and the file contents. -The header is portable between machine architectures, and, if the file -contents are printable, the archive is itself printable. -.Pp -The header is made up of six variable length -.Tn ASCII -fields, followed by a -two character trailer. -The fields are the object name (16 characters), the file last modification -time (12 characters), the user and group id's (each 6 characters), the file -mode (8 characters) and the file size (10 characters). -All numeric fields are in decimal, except for the file mode which is in -octal. -.Pp -The modification time is the file -.Fa st_mtime -field, i.e., -.Dv CUT -seconds since -the epoch. -The user and group id's are the file -.Fa st_uid -and -.Fa st_gid -fields. -The file mode is the file -.Fa st_mode -field. -The file size is the file -.Fa st_size -field. -The two-byte trailer is the string "\`\en". -.Pp -Only the name field has any provision for overflow. -If any file name is more than 16 characters in length or contains an -embedded space, the string "#1/" followed by the -.Tn ASCII -length of the -name is written in the name field. -The file size (stored in the archive header) is incremented by the length -of the name. -The name is then written immediately following the archive header. -.Pp -Any unused characters in any of these fields are written as space -characters. -If any fields are their particular maximum number of characters in -length, there will be no separation between the fields. -.Pp -Objects in the archive are always an even number of bytes long; files -which are an odd number of bytes long are padded with a newline (``\en'') -character, although the size in the header does not reflect this. -.Sh SEE ALSO -.Xr ar 1 , -.Xr stat 2 -.Sh HISTORY -There have been at least four -.Nm -formats. -The first was denoted by the leading ``magic'' number 0177555 (stored as -type int). -These archives were almost certainly created on a 16-bit machine, and -contain headers made up of five fields. -The fields are the object name (8 characters), the file last modification -time (type long), the user id (type char), the file mode (type char) and -the file size (type unsigned int). -Files were padded to an even number of bytes. -.Pp -The second was denoted by the leading ``magic'' number 0177545 (stored as -type int). -These archives may have been created on either 16 or 32-bit machines, and -contain headers made up of six fields. -The fields are the object name (14 characters), the file last modification -time (type long), the user and group id's (each type char), the file mode -(type int) and the file size (type long). -Files were padded to an even number of bytes. -.\" For more information on converting from this format see -.\" .Xr arcv 8 . -.Pp -The current archive format (without support for long character names and -names with embedded spaces) was introduced in -.Bx 4.0 . -The headers were the same as the current format, with the exception that -names longer than 16 characters were truncated, and names with embedded -spaces (and often trailing spaces) were not supported. -It has been extended for these reasons, -as described above. -This format first appeared in -.Bx 4.4 . -.Sh COMPATIBILITY -No archive format is currently specified by any standard. -.At V -has historically distributed archives in a different format from -all of the above. diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c deleted file mode 100644 index c39d1b7..0000000 --- a/usr.bin/ar/ar.c +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * 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. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1990, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)ar.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -CHDR chdr; -u_int options; -char *archive, *posarg, *posname; -const char *envtmp; -static void badoptions(const char *); -static void usage(void); - -/* - * main -- - * main basically uses getopt to parse options and calls the appropriate - * functions. Some hacks that let us be backward compatible with 4.3 ar - * option parsing and sanity checking. - */ -int -main(int argc, char **argv) -{ - int c; - char *p; - int (*fcall)(char **) = NULL; - - (void) setlocale(LC_TIME, "");; - - if (argc < 3) - usage(); - - /* - * Historic versions didn't require a '-' in front of the options. - * Fix it, if necessary. - */ - if (*argv[1] != '-') { - if (!(p = malloc((u_int)(strlen(argv[1]) + 2)))) - err(1, NULL); - *p = '-'; - (void)strcpy(p + 1, argv[1]); - argv[1] = p; - } - - while ((c = getopt(argc, argv, "abcdilmopqrTtuvx")) != -1) { - switch(c) { - case 'a': - options |= AR_A; - break; - case 'b': - case 'i': - options |= AR_B; - break; - case 'c': - options |= AR_C; - break; - case 'd': - options |= AR_D; - fcall = delete; - break; - case 'l': /* not documented, compatibility only */ - envtmp = "."; - break; - case 'm': - options |= AR_M; - fcall = move; - break; - case 'o': - options |= AR_O; - break; - case 'p': - options |= AR_P; - fcall = print; - break; - case 'q': - options |= AR_Q; - fcall = append; - break; - case 'r': - options |= AR_R; - fcall = replace; - break; - case 'T': - options |= AR_TR; - break; - case 't': - options |= AR_T; - fcall = contents; - break; - case 'u': - options |= AR_U; - break; - case 'v': - options |= AR_V; - break; - case 'x': - options |= AR_X; - fcall = extract; - break; - default: - usage(); - } - } - - argv += optind; - argc -= optind; - - /* One of -dmpqrtx required. */ - if (!(options & (AR_D|AR_M|AR_P|AR_Q|AR_R|AR_T|AR_X))) { - warnx("one of options -dmpqrtx is required"); - usage(); - } - /* Only one of -a and -bi allowed. */ - if (options & AR_A && options & AR_B) { - warnx("only one of -a and -[bi] options allowed"); - usage(); - } - /* -ab require a position argument. */ - if (options & (AR_A|AR_B)) { - if (!(posarg = *argv++)) { - warnx("no position operand specified"); - usage(); - } - posname = basename(posarg); - } - /* -d only valid with -Tv. */ - if (options & AR_D && options & ~(AR_D|AR_TR|AR_V)) - badoptions("-d"); - /* -m only valid with -abiTv. */ - if (options & AR_M && options & ~(AR_A|AR_B|AR_M|AR_TR|AR_V)) - badoptions("-m"); - /* -p only valid with -Tv. */ - if (options & AR_P && options & ~(AR_P|AR_TR|AR_V)) - badoptions("-p"); - /* -q only valid with -cTv. */ - if (options & AR_Q && options & ~(AR_C|AR_Q|AR_TR|AR_V)) - badoptions("-q"); - /* -r only valid with -abcuTv. */ - if (options & AR_R && options & ~(AR_A|AR_B|AR_C|AR_R|AR_U|AR_TR|AR_V)) - badoptions("-r"); - /* -t only valid with -Tv. */ - if (options & AR_T && options & ~(AR_T|AR_TR|AR_V)) - badoptions("-t"); - /* -x only valid with -ouTv. */ - if (options & AR_X && options & ~(AR_O|AR_U|AR_TR|AR_V|AR_X)) - badoptions("-x"); - - if (!(archive = *argv++)) { - warnx("no archive specified"); - usage(); - } - - /* -dmr require a list of archive elements. */ - if (options & (AR_D|AR_M|AR_R) && !*argv) { - warnx("no archive members specified"); - usage(); - } - - exit((*fcall)(argv)); -} - -static void -badoptions(arg) - const char *arg; -{ - - warnx("illegal option combination for %s", arg); - usage(); -} - -static void -usage() -{ - - (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", - "usage: ar -d [-Tv] archive file ...", - " ar -m [-Tv] archive file ...", - " ar -m [-abiTv] position archive file ...", - " ar -p [-Tv] archive [file ...]", - " ar -q [-cTv] archive file ...", - " ar -r [-cuTv] archive file ...", - " ar -r [-abciuTv] position archive file ...", - " ar -t [-Tv] archive [file ...]", - " ar -x [-ouTv] archive [file ...]"); - exit(1); -} diff --git a/usr.bin/ar/archive.c b/usr.bin/ar/archive.c deleted file mode 100644 index b347fb7..0000000 --- a/usr.bin/ar/archive.c +++ /dev/null @@ -1,333 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)archive.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -typedef struct ar_hdr HDR; -static char hb[sizeof(HDR) + 1]; /* real header */ - -int -open_archive(mode) - int mode; -{ - int created, fd, nr; - char buf[SARMAG]; - - created = 0; - if (mode & O_CREAT) { - mode |= O_EXCL; - if ((fd = open(archive, mode, DEFFILEMODE)) >= 0) { - /* POSIX.2 puts create message on stderr. */ - if (!(options & AR_C)) - warnx("creating archive %s", archive); - created = 1; - goto opened; - } - if (errno != EEXIST) - error(archive); - mode &= ~O_EXCL; - } - if ((fd = open(archive, mode, DEFFILEMODE)) < 0) - error(archive); - - /* - * Attempt to place a lock on the opened file - if we get an - * error then someone is already working on this library (or - * it's going across NFS). - */ -opened: if (flock(fd, LOCK_EX|LOCK_NB) && errno != EOPNOTSUPP) - error(archive); - - /* - * If not created, O_RDONLY|O_RDWR indicates that it has to be - * in archive format. - */ - if (!created && - ((mode & O_ACCMODE) == O_RDONLY || (mode & O_ACCMODE) == O_RDWR)) { - if ((nr = read(fd, buf, SARMAG) != SARMAG)) { - if (nr >= 0) - badfmt(); - error(archive); - } else if (bcmp(buf, ARMAG, SARMAG)) - badfmt(); - } else if (write(fd, ARMAG, SARMAG) != SARMAG) - error(archive); - return (fd); -} - -void -close_archive(fd) - int fd; -{ - - (void)close(fd); /* Implicit unlock. */ -} - -/* Convert ar header field to an integer. */ -#define AR_ATOI(from, to, len, base) { \ - memmove(buf, from, len); \ - buf[len] = '\0'; \ - to = strtol(buf, (char **)NULL, base); \ -} - -/* - * get_arobj -- - * read the archive header for this member - */ -int -get_arobj(fd) - int fd; -{ - struct ar_hdr *hdr; - int len, nr; - char *p, buf[20]; - - nr = read(fd, hb, sizeof(HDR)); - if (nr != sizeof(HDR)) { - if (!nr) - return (0); - if (nr < 0) - error(archive); - badfmt(); - } - - hdr = (struct ar_hdr *)hb; - if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1)) - badfmt(); - - /* Convert the header into the internal format. */ -#define DECIMAL 10 -#define OCTAL 8 - - AR_ATOI(hdr->ar_date, chdr.date, sizeof(hdr->ar_date), DECIMAL); - AR_ATOI(hdr->ar_uid, chdr.uid, sizeof(hdr->ar_uid), DECIMAL); - AR_ATOI(hdr->ar_gid, chdr.gid, sizeof(hdr->ar_gid), DECIMAL); - AR_ATOI(hdr->ar_mode, chdr.mode, sizeof(hdr->ar_mode), OCTAL); - AR_ATOI(hdr->ar_size, chdr.size, sizeof(hdr->ar_size), DECIMAL); - - /* Leading spaces should never happen. */ - if (hdr->ar_name[0] == ' ') - badfmt(); - - /* - * Long name support. Set the "real" size of the file, and the - * long name flag/size. - */ - if (!bcmp(hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) { - chdr.lname = len = atoi(hdr->ar_name + sizeof(AR_EFMT1) - 1); - if (len <= 0 || len > MAXNAMLEN) - badfmt(); - nr = read(fd, chdr.name, len); - if (nr != len) { - if (nr < 0) - error(archive); - badfmt(); - } - chdr.name[len] = 0; - chdr.size -= len; - } else { - chdr.lname = 0; - memmove(chdr.name, hdr->ar_name, sizeof(hdr->ar_name)); - - /* Strip trailing spaces, null terminate. */ - for (p = chdr.name + sizeof(hdr->ar_name) - 1; *p == ' '; --p); - *++p = '\0'; - } - return (1); -} - -static int already_written; - -/* - * put_arobj -- - * Write an archive member to a file. - */ -void -put_arobj(cfp, sb) - CF *cfp; - struct stat *sb; -{ - size_t lname; - char *name; - struct ar_hdr *hdr; - off_t size; - - /* - * If passed an sb structure, reading a file from disk. Get stat(2) - * information, build a name and construct a header. (Files are named - * by their last component in the archive.) If not, then just write - * the last header read. - */ - if (sb) { - name = basename(cfp->rname); - (void)fstat(cfp->rfd, sb); - - /* - * If not truncating names and the name is too long or contains - * a space, use extended format 1. - */ - lname = strlen(name); - if (options & AR_TR) { - if (lname > OLDARMAXNAME) { - (void)fflush(stdout); - warnx("warning: %s truncated to %.*s", - name, OLDARMAXNAME, name); - (void)fflush(stderr); - } - (void)sprintf(hb, HDR3, name, - (long)sb->st_mtimespec.tv_sec, sb->st_uid, - sb->st_gid, sb->st_mode, sb->st_size, ARFMAG); - lname = 0; - } else if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) - (void)sprintf(hb, HDR1, AR_EFMT1, lname, - (long)sb->st_mtimespec.tv_sec, sb->st_uid, - sb->st_gid, sb->st_mode, sb->st_size + lname, - ARFMAG); - else { - lname = 0; - (void)sprintf(hb, HDR2, name, - (long)sb->st_mtimespec.tv_sec, sb->st_uid, - sb->st_gid, sb->st_mode, sb->st_size, ARFMAG); - } - size = sb->st_size; - } else { - lname = chdr.lname; - name = chdr.name; - size = chdr.size; - } - - if (write(cfp->wfd, hb, sizeof(HDR)) != sizeof(HDR)) - error(cfp->wname); - if (lname) { - if ((size_t)write(cfp->wfd, name, lname) != lname) - error(cfp->wname); - already_written = lname; - } - copy_ar(cfp, size); - already_written = 0; -} - -/* - * copy_ar -- - * Copy size bytes from one file to another - taking care to handle the - * extra byte (for odd size files) when reading archives and writing an - * extra byte if necessary when adding files to archive. The length of - * the object is the long name plus the object itself; the variable - * already_written gets set if a long name was written. - * - * The padding is really unnecessary, and is almost certainly a remnant - * of early archive formats where the header included binary data which - * a PDP-11 required to start on an even byte boundary. (Or, perhaps, - * because 16-bit word addressed copies were faster?) Anyhow, it should - * have been ripped out long ago. - */ -void -copy_ar(cfp, size) - CF *cfp; - off_t size; -{ - static char pad = '\n'; - off_t sz; - int from, nr = 0, nw, off, to; - char buf[8*1024]; - - if (!(sz = size)) - return; - - from = cfp->rfd; - to = cfp->wfd; - sz = size; - while (sz && (nr = read(from, buf, MIN(sz, sizeof(buf)))) > 0) { - sz -= nr; - for (off = 0; off < nr; nr -= off, off += nw) - if ((nw = write(to, buf + off, nr)) < 0) - error(cfp->wname); - } - if (sz) { - if (nr == 0) - badfmt(); - error(cfp->rname); - } - - if (cfp->flags & RPAD && (size + chdr.lname) & 1 && - (nr = read(from, buf, 1)) != 1) { - if (nr == 0) - badfmt(); - error(cfp->rname); - } - if (cfp->flags & WPAD && (size + already_written) & 1 && - write(to, &pad, 1) != 1) - error(cfp->wname); -} - -/* - * skip_arobj - - * Skip over an object -- taking care to skip the pad bytes. - */ -void -skip_arobj(fd) - int fd; -{ - off_t len; - - len = chdr.size + ( (chdr.size + chdr.lname) & 1); - if (lseek(fd, len, SEEK_CUR) == (off_t)-1) - error(archive); -} diff --git a/usr.bin/ar/archive.h b/usr.bin/ar/archive.h deleted file mode 100644 index 7bbf6b9..0000000 --- a/usr.bin/ar/archive.h +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 1991, 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. - * - * @(#)archive.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ - */ - -/* Ar(1) options. */ -#define AR_A 0x0001 -#define AR_B 0x0002 -#define AR_C 0x0004 -#define AR_D 0x0008 -#define AR_M 0x0010 -#define AR_O 0x0020 -#define AR_P 0x0040 -#define AR_Q 0x0080 -#define AR_R 0x0100 -#define AR_T 0x0200 -#define AR_TR 0x0400 -#define AR_U 0x0800 -#define AR_V 0x1000 -#define AR_X 0x2000 -extern u_int options; - -/* Set up file copy. */ -#define SETCF(from, fromname, to, toname, pad) { \ - cf.rfd = from; \ - cf.rname = fromname; \ - cf.wfd = to; \ - cf.wname = toname; \ - cf.flags = pad; \ -} - -/* File copy structure. */ -typedef struct { - int rfd; /* read file descriptor */ - const char *rname; /* read name */ - int wfd; /* write file descriptor */ - const char *wname; /* write name */ -#define NOPAD 0x00 /* don't pad */ -#define RPAD 0x01 /* pad on reads */ -#define WPAD 0x02 /* pad on writes */ - u_int flags; /* pad flags */ -} CF; - -/* Header structure internal format. */ -typedef struct { - off_t size; /* size of the object in bytes */ - time_t date; /* date */ - int lname; /* size of the long name in bytes */ - int gid; /* group */ - int uid; /* owner */ - u_short mode; /* permissions */ - char name[MAXNAMLEN + 1]; /* name */ -} CHDR; - -/* Header format strings. */ -#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10qd%2s" -#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10qd%2s" - -#define OLDARMAXNAME 15 -#define HDR3 "%-16.15s%-12ld%-6u%-6u%-8o%-10qd%2s" - - -#include - -struct stat; - -void close_archive(int); -void copy_ar(CF *, off_t); -int get_arobj(int); -int open_archive(int); -void put_arobj(CF *, struct stat *); -void skip_arobj(int); diff --git a/usr.bin/ar/contents.c b/usr.bin/ar/contents.c deleted file mode 100644 index c53c323..0000000 --- a/usr.bin/ar/contents.c +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)contents.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -/* - * contents -- - * Handles t[v] option - opens the archive and then reads headers, - * skipping member contents. - */ -int -contents(argv) - char **argv; -{ - int afd, all; - struct tm *tp; - char *file, buf[80]; - - afd = open_archive(O_RDONLY); - - for (all = !*argv; get_arobj(afd);) { - if (all) - file = chdr.name; - else if (!(file = files(argv))) - goto next; - if (options & AR_V) { - static int d_first = -1; - - (void)strmode(chdr.mode, buf); - (void)printf("%s %6d/%-6d %8qd ", - buf + 1, chdr.uid, chdr.gid, chdr.size); - - if (d_first < 0) - d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); - tp = localtime(&chdr.date); - (void)strftime(buf, sizeof(buf), - d_first ? "%e %b %R %Y" : - "%b %e %R %Y", - tp); - (void)printf("%s %s\n", buf, file); - } else - (void)printf("%s\n", file); - if (!all && !*argv) - break; -next: skip_arobj(afd); - } - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/delete.c b/usr.bin/ar/delete.c deleted file mode 100644 index 53e7f92..0000000 --- a/usr.bin/ar/delete.c +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)delete.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -/*- - * delete -- - * Deletes named members from the archive. - */ -int -delete(argv) - char **argv; -{ - CF cf; - off_t size; - int afd, tfd; - char *file; - - afd = open_archive(O_RDWR); - tfd = tmp(); - - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, tfd, tname, RPAD|WPAD); - while (get_arobj(afd)) { - if (*argv && (file = files(argv))) { - if (options & AR_V) - (void)printf("d - %s\n", file); - skip_arobj(afd); - continue; - } - put_arobj(&cf, (struct stat *)NULL); - } - - size = lseek(tfd, (off_t)0, SEEK_CUR); - (void)lseek(tfd, (off_t)0, SEEK_SET); - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - SETCF(tfd, tname, afd, archive, NOPAD); - copy_ar(&cf, size); - (void)close(tfd); - (void)ftruncate(afd, size + SARMAG); - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/extern.h b/usr.bin/ar/extern.h deleted file mode 100644 index 68e0c47..0000000 --- a/usr.bin/ar/extern.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)extern.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ - */ - -int append(char **); -void badfmt(void); -int compare(char *); -int contents(char **); -int delete(char **); -void error(const char *); -int extract(char **); -char *files(char **argv); -int move(char **); -void orphans(char **argv); -int print(char **); -int replace(char **); -int tmp(void); - -extern char *archive; -extern char *posarg, *posname; /* positioning file name */ -extern const char *tname; /* temporary file "name" */ -extern CHDR chdr; /* converted header */ diff --git a/usr.bin/ar/extract.c b/usr.bin/ar/extract.c deleted file mode 100644 index 9d53f97..0000000 --- a/usr.bin/ar/extract.c +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)extract.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#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 (utimes(file, 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); -} diff --git a/usr.bin/ar/misc.c b/usr.bin/ar/misc.c deleted file mode 100644 index d3c3ba2..0000000 --- a/usr.bin/ar/misc.c +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -const char *tname = "temporary file"; /* temporary file "name" */ - -int -tmp() -{ - extern char *envtmp; - sigset_t set, oset; - static int first; - int fd; - char path[MAXPATHLEN]; - - if (!first && !envtmp) { - envtmp = getenv("TMPDIR"); - first = 1; - } - - if (envtmp) - (void)snprintf(path, sizeof(path), "%s/%s", envtmp, - _NAME_ARTMP); - else - strlcpy(path, _PATH_ARTMP, sizeof(path)); - - sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) == -1) - error(tname); - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return (fd); -} - -/* - * files -- - * See if the current file matches any file in the argument list; if it - * does, remove it from the argument list. - */ -char * -files(argv) - char **argv; -{ - char **list, *p; - - for (list = argv; *list; ++list) - if (compare(*list)) { - p = *list; - for (; (list[0] = list[1]); ++list) - continue; - return (p); - } - return (NULL); -} - -void -orphans(argv) - char **argv; -{ - - for (; *argv; ++argv) - warnx("%s: not found in archive", *argv); -} - -int -compare(dest) - char *dest; -{ - int maxname = (options & AR_TR) ? OLDARMAXNAME : MAXNAMLEN; - return (!strncmp(chdr.name, basename(dest), maxname)); -} - -void -badfmt() -{ - - errx(1, "%s: %s", archive, strerror(EFTYPE)); -} - -void -error(name) - const char *name; -{ - - err(1, "%s", name); -} diff --git a/usr.bin/ar/move.c b/usr.bin/ar/move.c deleted file mode 100644 index 8240b5c..0000000 --- a/usr.bin/ar/move.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)move.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -/* - * move -- - * Change location of named members in archive - if 'b' or 'i' option - * selected then named members are placed before 'posname'. If 'a' - * option selected members go after 'posname'. If no options, members - * are moved to end of archive. - */ -int -move(argv) - char **argv; -{ - CF cf; - off_t size, tsize; - int afd, curfd, mods, tfd1, tfd2, tfd3; - char *file; - - afd = open_archive(O_RDWR); - mods = options & (AR_A|AR_B); - - tfd1 = tmp(); /* Files before key file. */ - tfd2 = tmp(); /* Files selected by user. */ - tfd3 = tmp(); /* Files after key file. */ - - /* - * Break archive into three parts -- selected entries and entries - * before and after the key entry. If positioning before the key, - * place the key at the beginning of the after key entries and if - * positioning after the key, place the key at the end of the before - * key entries. Put it all back together at the end. - */ - - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, 0, tname, RPAD|WPAD); - for (curfd = tfd1; get_arobj(afd);) { - if (*argv && (file = files(argv))) { - if (options & AR_V) - (void)printf("m - %s\n", file); - cf.wfd = tfd2; - put_arobj(&cf, (struct stat *)NULL); - continue; - } - if (mods && compare(posname)) { - mods = 0; - if (options & AR_B) - curfd = tfd3; - cf.wfd = curfd; - put_arobj(&cf, (struct stat *)NULL); - if (options & AR_A) - curfd = tfd3; - } else { - cf.wfd = curfd; - put_arobj(&cf, (struct stat *)NULL); - } - } - - if (mods) { - warnx("%s: archive member not found", posarg); - close_archive(afd); - return (1); - } - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - - SETCF(tfd1, tname, afd, archive, NOPAD); - tsize = size = lseek(tfd1, (off_t)0, SEEK_CUR); - (void)lseek(tfd1, (off_t)0, SEEK_SET); - copy_ar(&cf, size); - - tsize += size = lseek(tfd2, (off_t)0, SEEK_CUR); - (void)lseek(tfd2, (off_t)0, SEEK_SET); - cf.rfd = tfd2; - copy_ar(&cf, size); - - tsize += size = lseek(tfd3, (off_t)0, SEEK_CUR); - (void)lseek(tfd3, (off_t)0, SEEK_SET); - cf.rfd = tfd3; - copy_ar(&cf, size); - - (void)ftruncate(afd, tsize + SARMAG); - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/pathnames.h b/usr.bin/ar/pathnames.h deleted file mode 100644 index ed92db6..0000000 --- a/usr.bin/ar/pathnames.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#define _NAME_ARTMP "ar.XXXXXX" -#define _PATH_ARTMP "/tmp/ar.XXXXXX" diff --git a/usr.bin/ar/print.c b/usr.bin/ar/print.c deleted file mode 100644 index 19ef47e..0000000 --- a/usr.bin/ar/print.c +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)print.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -/* - * print -- - * Prints archive members on stdout - if member names given only - * print those members, otherwise print all members. - */ -int -print(argv) - char **argv; -{ - CF cf; - int afd, all; - char *file; - - afd = open_archive(O_RDONLY); - - /* Read from an archive, write to stdout; pad on read. */ - SETCF(afd, archive, STDOUT_FILENO, "stdout", RPAD); - for (all = !*argv; get_arobj(afd);) { - if (all) - file = chdr.name; - else if (!(file = files(argv))) { - skip_arobj(afd); - continue; - } - if (options & AR_V) { - (void)printf("\n<%s>\n\n", file); - (void)fflush(stdout); - } - copy_ar(&cf, chdr.size); - if (!all && !*argv) - break; - } - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/replace.c b/usr.bin/ar/replace.c deleted file mode 100644 index 3dffd04..0000000 --- a/usr.bin/ar/replace.c +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)replace.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "archive.h" -#include "extern.h" - -/* - * replace -- - * Replace or add named members to archive. Entries already in the - * archive are swapped in place. Others are added before or after - * the key entry, based on the a, b and i options. If the u option - * is specified, modification dates select for replacement. - */ -int -replace(argv) - char **argv; -{ - char *file; - int afd, curfd, errflg, exists, mods, sfd, tfd1, tfd2; - struct stat sb; - CF cf; - off_t size, tsize; - - errflg = 0; - /* - * If doesn't exist, simply append to the archive. There's - * a race here, but it's pretty short, and not worth fixing. - */ - exists = !stat(archive, &sb); - afd = open_archive(O_CREAT|O_RDWR); - - if (!exists) { - tfd1 = -1; - tfd2 = tmp(); - goto append; - } - - tfd1 = tmp(); /* Files before key file. */ - tfd2 = tmp(); /* Files after key file. */ - - /* - * Break archive into two parts -- entries before and after the key - * entry. If positioning before the key, place the key at the - * beginning of the after key entries and if positioning after the - * key, place the key at the end of the before key entries. Put it - * all back together at the end. - */ - mods = (options & (AR_A|AR_B)); - for (curfd = tfd1; get_arobj(afd);) { - if (*argv && (file = files(argv))) { - if ((sfd = open(file, O_RDONLY)) < 0) { - errflg = 1; - warn("%s", file); - goto useold; - } - (void)fstat(sfd, &sb); - if (options & AR_U && sb.st_mtime <= chdr.date) { - (void) close(sfd); - goto useold; - } - - if (options & AR_V) - (void)printf("r - %s\n", file); - - /* Read from disk, write to an archive; pad on write */ - SETCF(sfd, file, curfd, tname, WPAD); - put_arobj(&cf, &sb); - (void)close(sfd); - skip_arobj(afd); - continue; - } - - if (mods && compare(posname)) { - mods = 0; - if (options & AR_B) - curfd = tfd2; - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_arobj(&cf, (struct stat *)NULL); - if (options & AR_A) - curfd = tfd2; - } else { - /* Read and write to an archive; pad on both. */ -useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_arobj(&cf, (struct stat *)NULL); - } - } - - if (mods) { - warnx("%s: archive member not found", posarg); - close_archive(afd); - return (1); - } - - /* Append any left-over arguments to the end of the after file. */ -append: while ( (file = *argv++) ) { - if (options & AR_V) - (void)printf("a - %s\n", file); - if ((sfd = open(file, O_RDONLY)) < 0) { - errflg = 1; - warn("%s", file); - continue; - } - (void)fstat(sfd, &sb); - /* Read from disk, write to an archive; pad on write. */ - SETCF(sfd, file, - options & (AR_A|AR_B) ? tfd1 : tfd2, tname, WPAD); - put_arobj(&cf, &sb); - (void)close(sfd); - } - - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - - SETCF(tfd1, tname, afd, archive, NOPAD); - if (tfd1 != -1) { - tsize = size = lseek(tfd1, (off_t)0, SEEK_CUR); - (void)lseek(tfd1, (off_t)0, SEEK_SET); - copy_ar(&cf, size); - } else - tsize = 0; - - tsize += size = lseek(tfd2, (off_t)0, SEEK_CUR); - (void)lseek(tfd2, (off_t)0, SEEK_SET); - cf.rfd = tfd2; - copy_ar(&cf, size); - - (void)ftruncate(afd, tsize + SARMAG); - close_archive(afd); - return (errflg); -} -- cgit v1.1