home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume17 / pax / part01 next >
Text File  |  1989-02-02  |  61KB  |  2,186 lines

  1. Subject:  v17i074:  Usenix/IEEE POSIX replacement for TAR and CPIO, Part01/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Mark H. Colburn <mark@jhereg.jhereg.mn.org>
  6. Posting-number: Volume 17, Issue 74
  7. Archive-name: pax/part01
  8.  
  9. [  The name is Latin for "peace."  --r$  ]
  10.  
  11.     This is version 1.1 of Pax, a public domain archiving utility.  
  12.     
  13.     Pax is an archiving utility that reads and writes tar and cpio formats, 
  14.     both the traditional ones and the extended formats specified in IEEE 
  15.     1003.1.  It handles multi-volume archives and automatically determines 
  16.     the format of an archive while reading it.  Three user interfaces are 
  17.     supported: tar, cpio, and pax.  The pax interface was designed by IEEE 
  18.     1003.2 as a compromise in the chronic controversy over which of tar or 
  19.     cpio is best.
  20.  
  21.     The USENIX Association provided some support for this implementation 
  22.     project.  As a result, the Pax utility is being distributed free of 
  23.     charge and may be redistributed by others in either source or binary 
  24.     form.  (See the liscensing section for restrictions)
  25.  
  26.     The source for Pax is being posted to comp.sources.unix on USENET and 
  27.     will also be available by anonymous FTP on the Internet from uunet.uu.net,
  28.     moon.honeywell.com and from one of the Berkeley machines.  The source
  29.     to Pax will be available via anonymous UUCP from jhereg.mn.org, the 
  30.     author's home machine and possibly other sites.
  31.  
  32.     The source for Pax will continue to change as long as the definition of 
  33.     the utility is modified by the 1003.2 working group.  (For example, 
  34.     there are a number of changes in Draft 8 which will be incorporated as 
  35.     soon as Draft 8 is available).  Additional modifications will be made 
  36.     based on user input, such as request for support of additional archive 
  37.     formats, etc.  Patches and new releases will be made as new functionality 
  38.     is added or problems are diagnosed and fixed.
  39.  
  40.     Please report any bug or problems to:
  41.  
  42.     Mark Colburn
  43.     NAPS International
  44.     117 Mackubin St., Suite 1
  45.     St. Paul MN   55102
  46.     (612) 224-9108
  47.     mark@jhereg.MN.ORG
  48.  
  49. -----------------------------------------------------------------------------
  50. #! /bin/sh
  51. # This is a shell archive.  Remove anything before this line, then unpack
  52. # it by saving it into a file and typing "sh file".  To overwrite existing
  53. # files, type "sh file -c".  You can also feed this as standard input via
  54. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  55. # will see the following message at the end:
  56. #        "End of archive 1 (of 6)."
  57. # Contents:  PATCHLEVEL README append.c config.h cpio.c limits.h mem.c
  58. #   pass.c pathname.c paxdir.h port.c port.h regexp.h tar.1 wildmat.c
  59. # Wrapped by mark@jhereg on Tue Dec 27 19:37:30 1988
  60. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  61. if test -f PATCHLEVEL -a "${1}" != "-c" ; then 
  62.   echo shar: Will not over-write existing file \"PATCHLEVEL\"
  63. else
  64. echo shar: Extracting \"PATCHLEVEL\" \(64 characters\)
  65. sed "s/^X//" >PATCHLEVEL <<'END_OF_PATCHLEVEL'
  66. XPatchlevel 0
  67. X$Id: PATCHLEVEL,v 1.1 88/12/23 18:02:43 mark Rel $
  68. END_OF_PATCHLEVEL
  69. if test 64 -ne `wc -c <PATCHLEVEL`; then
  70.     echo shar: \"PATCHLEVEL\" unpacked with wrong size!
  71. fi
  72. # end of overwriting check
  73. fi
  74. if test -f README -a "${1}" != "-c" ; then 
  75.   echo shar: Will not over-write existing file \"README\"
  76. else
  77. echo shar: Extracting \"README\" \(4822 characters\)
  78. sed "s/^X//" >README <<'END_OF_README'
  79. XPAX - Portable Archive Interchange
  80. X
  81. XCopyright (C) 1989 Mark H. Colburn
  82. XAll Rights Reserved.
  83. X
  84. X
  85. XIntroduction
  86. X
  87. X    This is version 1.1 of Pax, a public domain archiving utility.  
  88. X    
  89. X    Pax is an archiving utility that reads and writes tar and cpio formats, 
  90. X    both the traditional ones and the extended formats specified in IEEE 
  91. X    1003.1.  It handles multi-volume archives and automatically determines 
  92. X    the format of an archive while reading it.  Three user interfaces are 
  93. X    supported: tar, cpio, and pax.  The pax interface was designed by IEEE 
  94. X    1003.2 as a compromise in the chronic controversy over which of tar or 
  95. X    cpio is best.
  96. X
  97. X    The USENIX Association provided some support for this implementation 
  98. X    project.  As a result, the Pax utility is being distributed free of 
  99. X    charge and may be redistributed by others in either source or binary 
  100. X    form.  (See the liscensing section for restrictions)
  101. X
  102. X    The source for Pax is being posted to comp.sources.unix on USENET and 
  103. X    will also be available by anonymous FTP on the Internet from uunet.uu.net,
  104. X    moon.honeywell.com and from one of the Berkeley machines.  The source
  105. X    to Pax will be available via anonymous UUCP from jhereg.mn.org, the 
  106. X    author's home machine and possibly other sites.
  107. X
  108. X    The source for Pax will continue to change as long as the definition of 
  109. X    the utility is modified by the 1003.2 working group.  (For example, 
  110. X    there are a number of changes in Draft 8 which will be incorporated as 
  111. X    soon as Draft 8 is available).  Additional modifications will be made 
  112. X    based on user input, such as request for support of additional archive 
  113. X    formats, etc.  Patches and new releases will be made as new functionality 
  114. X    is added or problems are diagnosed and fixed.
  115. X
  116. X
  117. XInstallation
  118. X
  119. X    In order to install Pax, you must first edit the Makefile and the 
  120. X    config.h file according to the directions in each of the files.  
  121. X    These two files provide the configuration information for most 
  122. X    commonly available machines.  Please be sure to read through all 
  123. X    the directions in each of these files before attempting to compile
  124. X    Pax.
  125. X
  126. X
  127. XPortability
  128. X
  129. X    Pax is intended to run on as many systems as possible.  If you have
  130. X    problems getting Pax to compile or run on your system, please let me 
  131. X    know so that the source or the installation procedure can be modified.
  132. X
  133. X    Pax has been tested and appears to run correctly on the following 
  134. X    machines:
  135. X
  136. X        Machine                 Operating System/Release
  137. X    -------------------------------------------------------
  138. X    Altos 586        System III (2.3)
  139. X    AT&T UNIX PC        System V.2 (Release 3.51)
  140. X    Cray 2            UNICOS
  141. X    HP 9000            HP/UX 6.0.1
  142. X    Mac II             A/UX 1.0
  143. X    NCR Tower        System V.2
  144. X    Pyramid            AT&T and Berkeley universe
  145. X    Sequent Symetry        Dynix 3.0
  146. X    SGI Iris 4D/60G        UNIX 3.0
  147. X    SGI Iris 4D/70G        UNIX 3.0
  148. X    Sun 2            SunOS 3.4
  149. X    Sun 2            SunOS 3.5
  150. X    Sun 3            SunOS 3.4
  151. X    Sun 3            SunOS 3.5
  152. X    Sun 3            SunOS 4.0
  153. X    Sun 4            SunOS 4.0
  154. X    VAX 8750        BSD 4.3 (Mt. Xinu)
  155. X    VAX 8650        BSD 4.3 (Mt. Xinu)
  156. X    VAX 780            BSD 4.3 (Berkeley)
  157. X    -------------------------------------------------------
  158. X
  159. X    In future releases, the source will be moving toward ANSI C and POSIX 
  160. X    compatibility.  This should allow for portability over any system 
  161. X    supporting both ANSI and POSIX.  In addition, POSIX/ANSI portability 
  162. X    library routines will be developed which will allow the code to run on 
  163. X    the standard machines available now.
  164. X
  165. X
  166. XCredit Where Credit is Due
  167. X
  168. X    Parts of the code which makes up Pax were gleaned from a number of 
  169. X    different sources: the directory access routines in paxdir.h are 
  170. X    modified copies of Doug Gwyn's dirent library; the regular expression 
  171. X    matching routines in regexp.c are from Henry Spencer, some of the tar 
  172. X    archive routines were initially written by John Gilmore for his PDTAR; 
  173. X    and finally afio, written by Mark Brukhartz at Lachman Associates, was 
  174. X    the basis for the buffering schemes used in pax.
  175. X
  176. X
  177. XLicensing
  178. X
  179. X    Copyright (c) 1989 Mark H. Colburn.  
  180. X    All rights reserved.
  181. X
  182. X    Redistribution and use in source and binary forms are permitted
  183. X    provided that the above copyright notice is duplicated in all such 
  184. X    forms and that any documentation, advertising materials, and other 
  185. X    materials related to such distribution and use acknowledge that the 
  186. X    software was developed by Mark H. Colburn and sponsored by The 
  187. X    USENIX Association. 
  188. X
  189. X    THE SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  190. X    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  191. X    WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  192. X
  193. XPlease report any bug or problems to:
  194. X
  195. XMark Colburn
  196. XNAPS International
  197. X117 Mackubin St., Suite 1
  198. XSt. Paul MN   55102
  199. X(612) 224-9108
  200. Xmark@jhereg.MN.ORG
  201. END_OF_README
  202. if test 4822 -ne `wc -c <README`; then
  203.     echo shar: \"README\" unpacked with wrong size!
  204. fi
  205. # end of overwriting check
  206. fi
  207. if test -f append.c -a "${1}" != "-c" ; then 
  208.   echo shar: Will not over-write existing file \"append.c\"
  209. else
  210. echo shar: Extracting \"append.c\" \(2298 characters\)
  211. sed "s/^X//" >append.c <<'END_OF_append.c'
  212. X/* $Source: /u/mark/src/pax/RCS/append.c,v $
  213. X *
  214. X * $Revision: 1.1 $
  215. X *
  216. X * append.c - append to a tape archive. 
  217. X *
  218. X * DESCRIPTION
  219. X *
  220. X *    Routines to allow appending of archives
  221. X *
  222. X * AUTHORS
  223. X *
  224. X *         Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  225. X *
  226. X *
  227. X * Sponsored by The USENIX Association for public distribution. 
  228. X *
  229. X * Copyright (c) 1989 Mark H. Colburn.
  230. X * All rights reserved.
  231. X *
  232. X * Redistribution and use in source and binary forms are permitted
  233. X * provided that the above copyright notice is duplicated in all such 
  234. X * forms and that any documentation, advertising materials, and other 
  235. X * materials related to such distribution and use acknowledge that the 
  236. X * software was developed * by Mark H. Colburn and sponsored by The 
  237. X * USENIX Association. 
  238. X *
  239. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  240. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  241. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  242. X *
  243. X * $Log:    append.c,v $
  244. X * Revision 1.1  88/12/23  18:02:00  mark
  245. X * Initial revision
  246. X * 
  247. X */
  248. X
  249. X#ifndef lint
  250. Xstatic char *ident = "$Id: append.c,v 1.1 88/12/23 18:02:00 mark Rel $";
  251. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  252. X#endif /* ! lint */
  253. X
  254. X
  255. X/* Headers */
  256. X
  257. X#include "pax.h"
  258. X
  259. X
  260. X/* append_archive - main loop for appending to a tar archive
  261. X *
  262. X * DESCRIPTION
  263. X *
  264. X *    Append_archive reads an archive until the end of the archive is
  265. X *    reached once the archive is reached, the buffers are reset and the
  266. X *    create_archive function is called to handle the actual writing of
  267. X *    the appended archive data.  This is quite similar to the
  268. X *    read_archive function, however, it does not do all the processing.
  269. X */
  270. X
  271. X#ifdef __STDC__
  272. X
  273. Xvoid append_archive(void)
  274. X
  275. X#else
  276. X
  277. Xvoid append_archive()
  278. X
  279. X#endif
  280. X{
  281. X    Stat            sb;
  282. X    char            name[PATH_MAX + 1];
  283. X
  284. X    name[0] = '\0';
  285. X    while (get_header(name, &sb) == 0) {
  286. X    if (((ar_format == TAR)
  287. X         ? buf_skip(ROUNDUP((OFFSET) sb.sb_size, BLOCKSIZE))
  288. X         : buf_skip((OFFSET) sb.sb_size)) < 0) {
  289. X        warn(name, "File data is corrupt");
  290. X    }
  291. X    }
  292. X    /* we have now gotten to the end of the archive... */
  293. X
  294. X    /* reset the buffer now that we have read the entire archive */
  295. X    bufend = bufidx = bufstart;
  296. X    create_archive();
  297. X}
  298. END_OF_append.c
  299. if test 2298 -ne `wc -c <append.c`; then
  300.     echo shar: \"append.c\" unpacked with wrong size!
  301. fi
  302. # end of overwriting check
  303. fi
  304. if test -f config.h -a "${1}" != "-c" ; then 
  305.   echo shar: Will not over-write existing file \"config.h\"
  306. else
  307. echo shar: Extracting \"config.h\" \(4505 characters\)
  308. sed "s/^X//" >config.h <<'END_OF_config.h'
  309. X/* $Source: /u/mark/src/pax/RCS/config.h,v $
  310. X *
  311. X * $Revision: 1.1 $
  312. X *
  313. X * config.h - configuration options for PAX
  314. X *
  315. X * DESCRIPTION
  316. X *
  317. X *    This file contains a number of configurable parameters for the
  318. X *    PAX software.  This files should be edited prior to makeing the
  319. X *    package.
  320. X *
  321. X * AUTHOR
  322. X *
  323. X *    Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  324. X *
  325. X * Sponsored by The USENIX Association for public distribution. 
  326. X *
  327. X * Copyright (c) 1989 Mark H. Colburn.
  328. X * All rights reserved.
  329. X *
  330. X * Redistribution and use in source and binary forms are permitted
  331. X * provided that the above copyright notice and this paragraph are
  332. X * duplicated in all such forms and that any documentation,
  333. X * advertising materials, and other materials related to such
  334. X * distribution and use acknowledge that the software was developed
  335. X * by Mark H. Colburn and sponsored by The USENIX Association. 
  336. X *
  337. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  338. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  339. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  340. X */
  341. X
  342. X#ifndef _PAX_CONFIG_H
  343. X#define _PAX_CONFIG_H
  344. X
  345. X/* Defines */
  346. X
  347. X/*
  348. X * USG - USG (Unix System V) specific modifications
  349. X *
  350. X * Define USG if you are running Unix System V or some similar variant
  351. X */
  352. X#define USG     /* Running on a USG System */
  353. X
  354. X/*
  355. X * BSD - BSD (Berkely) specific modifications
  356. X *
  357. X * Define BSD if you are running some version of BSD Unix
  358. X */
  359. X#define BSD     /* Running on a BSD System */
  360. X
  361. X/*
  362. X * DEF_AR_FILE - tar only (required)
  363. X *
  364. X * DEF_AR_FILE should contain the full pathname of your favorite archive
  365. X * device.  Normally this would be a tape drive, but it may be a disk drive
  366. X * on those systems that don't have tape drives.
  367. X */
  368. X#define DEF_AR_FILE    "-"    /* The default archive on your system */
  369. X
  370. X/*
  371. X * TTY - device which interactive queries should be directed to (required)
  372. X *
  373. X * This is the device to which interactive queries will be sent to and
  374. X * received from.  On most unix systems, this should be /dev/tty, however, on
  375. X * some systems, such as MS-DOS, it my need to be different (e.g. "con:").
  376. X */
  377. X#define    TTY    "/dev/tty"    /* for most versions of UNIX */
  378. X/* #define    TTY    "con:"        /* For MS-DOS */
  379. X
  380. X/*
  381. X * PAXDIR - if you do not have directory access routines
  382. X *
  383. X * Define PAXDIR if you do not have Doug Gwyn's dirent package installed
  384. X * as a system library or you wish to use the version supplied with PAX.  
  385. X *
  386. X * NOTE: DO NOT DEFINE THIS IF YOU HAVE BERKELEY DIRECTORY ACCESS ROUTINES.
  387. X */
  388. X/* #define PAXDIR        /* use paxdir.h paxdir.c */
  389. X
  390. X/*
  391. X * DIRENT - directory access routines (required)
  392. X *
  393. X * If you have Doug Gwyn's dirent package installed, either as a system
  394. X * library, or are using the paxdir.c and paxdir.h routines which come with 
  395. X * PAX, then define dirent. 
  396. X *
  397. X * NOTE: DO NOT DEFINE THIS IF YOU HAVE BERKELEY DIRECTORY ACCESS ROUTINES.
  398. X */
  399. X/* #define DIRENT        /* use POSIX compatible directory routines */
  400. X
  401. X/*
  402. X * OFFSET - compiler dependent offset type
  403. X * 
  404. X * OFFSET is the type which is returned by lseek().  It is different on
  405. X * some systems.  Most define it to be off_t, but some define it to be long.
  406. X */
  407. X#define OFFSET    off_t    /* for most BSD, USG and other systems */
  408. X/* #define OFFSET    long    /* for most of the rest of them... */
  409. X
  410. X/*
  411. X * VOID - compiler support for VOID types
  412. X *
  413. X * If your system does not support void, then this should be defined to
  414. X * int, otherwise, it should be left undefined.
  415. X *
  416. X * For ANSI Systems this should always be blank.
  417. X */
  418. X#ifndef __STDC__
  419. X/* #define void    int    /* for system which do support void */
  420. X#endif
  421. X
  422. X/*
  423. X * SIG_T - return type for the signal routine
  424. X *
  425. X * Some systems have signal defines to return an int *, other return a
  426. X * void *.  Please choose the correct value for your system.
  427. X */
  428. X/* #define SIG_T    void    /* signal defined as "void (*signal)()" */
  429. X#define SIG_T    int    /* signal defined as "int (*signal)()" */
  430. X
  431. X/*
  432. X * STRCSPN - use the strcspn function included with pax
  433. X *
  434. X * Some systems do not have the strcspn() function in their C libraries.
  435. X * For those system define STRCSPN and the one provided in regexp.c will 
  436. X * be used.
  437. X */
  438. X/* #define STRCSPN    /* implementation does not have strcspn() */
  439. X
  440. X/*
  441. X * END OF CONFIGURATION SECTION
  442. X *
  443. X * Nothing beyond this point should need to be changed
  444. X */
  445. X
  446. X#ifdef BSD
  447. X#ifdef USG
  448. X#include "You must first edit config.h and Makefile to configure pax."
  449. X#endif
  450. X#endif
  451. X/*
  452. X * Do a little sanity checking
  453. X */
  454. X#ifdef PAXDIR
  455. X#  ifndef DIRENT
  456. X#    define DIRENT
  457. X#  endif
  458. X#endif
  459. X
  460. X#endif /* _PAX_CONFIG_H */
  461. END_OF_config.h
  462. if test 4505 -ne `wc -c <config.h`; then
  463.     echo shar: \"config.h\" unpacked with wrong size!
  464. fi
  465. # end of overwriting check
  466. fi
  467. if test -f cpio.c -a "${1}" != "-c" ; then 
  468.   echo shar: Will not over-write existing file \"cpio.c\"
  469. else
  470. echo shar: Extracting \"cpio.c\" \(4492 characters\)
  471. sed "s/^X//" >cpio.c <<'END_OF_cpio.c'
  472. X/* $Source: /u/mark/src/pax/RCS/cpio.c,v $
  473. X *
  474. X * $Revision: 1.1 $
  475. X *
  476. X * cpio.c - Cpio specific functions for archive handling
  477. X *
  478. X * DESCRIPTION
  479. X *
  480. X *    These function provide a cpio conformant interface to the pax
  481. X *    program.
  482. X *
  483. X * AUTHOR
  484. X *
  485. X *     Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  486. X *
  487. X * Sponsored by The USENIX Association for public distribution. 
  488. X *
  489. X * Copyright (c) 1989 Mark H. Colburn.
  490. X * All rights reserved.
  491. X *
  492. X * Redistribution and use in source and binary forms are permitted
  493. X * provided that the above copyright notice is duplicated in all such 
  494. X * forms and that any documentation, advertising materials, and other 
  495. X * materials related to such distribution and use acknowledge that the 
  496. X * software was developed * by Mark H. Colburn and sponsored by The 
  497. X * USENIX Association. 
  498. X *
  499. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  500. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  501. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  502. X *
  503. X * $Log:    cpio.c,v $
  504. X * Revision 1.1  88/12/23  18:02:05  mark
  505. X * Initial revision
  506. X * 
  507. X */
  508. X
  509. X#ifndef lint
  510. Xstatic char *ident = "$Id: cpio.c,v 1.1 88/12/23 18:02:05 mark Rel $";
  511. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  512. X#endif /* ! lint */
  513. X
  514. X
  515. X/* Headers */
  516. X
  517. X#include "pax.h"
  518. X
  519. X
  520. X/* Function Prototypes */
  521. X
  522. X#ifdef __STDC__
  523. Xstatic void     usage(void);
  524. X#else /* !__STDC__ */
  525. Xstatic void     usage();
  526. X#endif /* __STDC__ */
  527. X
  528. X
  529. X/* do_cpio - handle cpio format archives
  530. X *
  531. X * DESCRIPTION
  532. X *
  533. X *    Do_cpio provides a standard CPIO interface to the PAX program.  All
  534. X *    of the standard cpio flags are available, and the behavior of the
  535. X *    program mimics traditonal cpio.
  536. X *
  537. X * PARAMETERS
  538. X *
  539. X *    int    argc    - command line argument count
  540. X *    char    **argv    - pointer to command line arguments
  541. X *
  542. X * RETURNS
  543. X *
  544. X *    Nothing.
  545. X */
  546. X
  547. X#ifdef __STDC__
  548. X
  549. Xint do_cpio(int argc, char **argv)
  550. X
  551. X#else
  552. X
  553. Xint do_cpio(argc, argv)
  554. Xint             argc;
  555. Xchar          **argv;
  556. X
  557. X#endif
  558. X{
  559. X    int             c;
  560. X    char           *dirname;
  561. X    Stat            st;
  562. X
  563. X    /* default input/output file for CPIO is STDIN/STDOUT */
  564. X    ar_file = "-";
  565. X    names_from_stdin = 1;
  566. X
  567. X    /* set up the flags to reflect the default CPIO inteface. */
  568. X    blocksize = BLOCKSIZE;
  569. X    ar_interface = CPIO;
  570. X    ar_format = CPIO;
  571. X    msgfile=stderr;
  572. X
  573. X    while ((c = getopt(argc, argv, "D:Bacdfilmoprtuv")) != EOF) {
  574. X    switch (c) {
  575. X    case 'i':
  576. X        f_extract = 1;
  577. X        break;
  578. X    case 'o':
  579. X        f_create = 1;
  580. X        break;
  581. X    case 'p':
  582. X        f_pass = 1;
  583. X        dirname = argv[--argc];
  584. X
  585. X        /* check to make sure that the argument is a directory */
  586. X        if (LSTAT(dirname, &st) < 0) {
  587. X        fatal(syserr());
  588. X        }
  589. X        if ((st.sb_mode & S_IFMT) != S_IFDIR) {
  590. X        fatal("Not a directory");
  591. X        }
  592. X        break;
  593. X    case 'B':
  594. X        blocksize = BLOCK;
  595. X        break;
  596. X    case 'a':
  597. X        f_access_time = 1;
  598. X        break;
  599. X    case 'c':
  600. X        break;
  601. X    case 'D':
  602. X        ar_file = optarg;
  603. X        break;
  604. X    case 'd':
  605. X        f_create_dirs = 1;
  606. X        break;
  607. X    case 'f':
  608. X        f_reverse_match = 1;
  609. X        break;
  610. X    case 'l':
  611. X        f_link = 1;
  612. X        break;
  613. X    case 'm':
  614. X        f_modification_time = 1;
  615. X        break;
  616. X    case 'r':
  617. X        f_interactive = 1;
  618. X        break;
  619. X    case 't':
  620. X        f_list = 1;
  621. X        break;
  622. X    case 'u':
  623. X        f_unconditional = 1;
  624. X        break;
  625. X    case 'v':
  626. X        f_verbose = 1;
  627. X        break;
  628. X    default:
  629. X        usage();
  630. X    }
  631. X    }
  632. X
  633. X    if (f_create + f_pass + f_extract != 1) {
  634. X    usage();
  635. X    }
  636. X    if (!f_pass) {
  637. X    buf_allocate((OFFSET) blocksize);
  638. X    }
  639. X    if (f_extract) {
  640. X    open_archive(AR_READ);    /* Open for reading */
  641. X    read_archive();
  642. X    } else if (f_create) {
  643. X    open_archive(AR_WRITE);
  644. X    create_archive();
  645. X    } else if (f_pass) {
  646. X    pass(dirname);
  647. X    }
  648. X
  649. X    /* print out the total block count transfered */
  650. X    fprintf(stderr, "%d Blocks\n", ROUNDUP(total, BLOCKSIZE) / BLOCKSIZE);
  651. X    
  652. X    exit(0);
  653. X    /* NOTREACHED */
  654. X}
  655. X
  656. X
  657. X/* usage - print a helpful message and exit
  658. X *
  659. X * DESCRIPTION
  660. X *
  661. X *    Usage prints out the usage message for the CPIO interface and then
  662. X *    exits with a non-zero termination status.  This is used when a user
  663. X *    has provided non-existant or incompatible command line arguments.
  664. X *
  665. X * RETURNS
  666. X *
  667. X *    Returns an exit status of 1 to the parent process.
  668. X *
  669. X */
  670. X
  671. X#ifdef __STDC__
  672. X
  673. Xstatic void usage(void)
  674. X
  675. X#else
  676. X
  677. Xstatic void usage()
  678. X
  679. X#endif
  680. X{
  681. X    fprintf(stderr, "\
  682. XUsage: %s -o[Bacv]\n", myname);
  683. X    fprintf(stderr, "\
  684. X       %s -i[Bcdmrtuvf] [pattern...]\n", myname);
  685. X    fprintf(stderr, "\
  686. X       %s -p[adlmruv] directory\n", myname);
  687. X    exit(1);
  688. X}
  689. END_OF_cpio.c
  690. if test 4492 -ne `wc -c <cpio.c`; then
  691.     echo shar: \"cpio.c\" unpacked with wrong size!
  692. fi
  693. # end of overwriting check
  694. fi
  695. if test -f limits.h -a "${1}" != "-c" ; then 
  696.   echo shar: Will not over-write existing file \"limits.h\"
  697. else
  698. echo shar: Extracting \"limits.h\" \(2765 characters\)
  699. sed "s/^X//" >limits.h <<'END_OF_limits.h'
  700. X/* $Source: /u/mark/src/pax/RCS/limits.h,v $
  701. X *
  702. X * $Revision: 1.1 $
  703. X *
  704. X *     limits.h - POSIX compatible defnitions for some of <limits.h>
  705. X *
  706. X * DESCRIPTION
  707. X *
  708. X *     We need to include <limits.h> if this system is being compiled with an 
  709. X *     ANSI standard C compiler, or if we are running on a POSIX confomrming 
  710. X *     system.  If the manifest constant _POSIX_SOURCE is not defined when 
  711. X *     <limits.h> is included, then none of the POSIX constants are defined 
  712. X *    and we need to define them here.  It's a bit wierd, but it works.
  713. X *
  714. X *     These values where taken from the IEEE P1003.1 standard, draft 12.
  715. X *     All of the values below are the MINIMUM values allowed by the standard.
  716. X *     Not all values are used by the PAX program, but they are included for
  717. X *     completeness, and for support of future enhancements.  Please see
  718. X *     section 2.9 of the draft standard for more information on the following
  719. X *     constants.
  720. X *
  721. X * AUTHOR
  722. X *
  723. X *     Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  724. X *
  725. X * Sponsored by The USENIX Association for public distribution. 
  726. X *
  727. X * Copyright (c) 1989 Mark H. Colburn.
  728. X * All rights reserved.
  729. X *
  730. X * Redistribution and use in source and binary forms are permitted
  731. X * provided that the above copyright notice and this paragraph are
  732. X * duplicated in all such forms and that any documentation,
  733. X * advertising materials, and other materials related to such
  734. X * distribution and use acknowledge that the software was developed
  735. X * by Mark H. Colburn and sponsored by The USENIX Association. 
  736. X *
  737. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  738. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  739. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  740. X */
  741. X
  742. X#ifndef _PAX_LIMITS_H
  743. X#define _PAX_LIMITS_H
  744. X
  745. X/* Headers */
  746. X
  747. X#if defined(__STDC__) || defined(_POSIX_SOURCE)
  748. X#   include <limits.h>
  749. X#endif
  750. X
  751. X
  752. X/* Defines */
  753. X
  754. X#ifndef _POSIX_SOURCE
  755. X
  756. X#define MAX_INPUT    256    /* Max numbef of bytes in terminal input */
  757. X#define NGROUPS_MAX    1    /* Max number of suplemental group id's */
  758. X#define PASS_MAX    8    /* Max number of bytes in a password */
  759. X#define PID_MAX        30000    /* Max value for a process ID */
  760. X#define UID_MAX        32000    /* Max value for a user or group ID */
  761. X#define ARG_MAX        4096    /* Nax number of bytes passed to exec */
  762. X#define CHILD_MAX    6    /* Max number of simultaneous processes */
  763. X#define MAX_CANON    256    /* Max numbef of bytes in a cononical queue */
  764. X#define OPEN_MAX    16    /* Nax number of open files per process */
  765. X#define NAME_MAX    14    /* Max number of bytes in a file name */
  766. X#define PATH_MAX    255    /* Max number of bytes in pathname */
  767. X#define LINK_MAX    8    /* Max value of a file's link count */
  768. X#define PIPE_BUF    512    /* Max number of bytes for pipe reads */
  769. X
  770. X#endif /* _POSIX_SOURCE */
  771. X#endif /* _PAX_LIMITS_H */
  772. END_OF_limits.h
  773. if test 2765 -ne `wc -c <limits.h`; then
  774.     echo shar: \"limits.h\" unpacked with wrong size!
  775. fi
  776. # end of overwriting check
  777. fi
  778. if test -f mem.c -a "${1}" != "-c" ; then 
  779.   echo shar: Will not over-write existing file \"mem.c\"
  780. else
  781. echo shar: Extracting \"mem.c\" \(3204 characters\)
  782. sed "s/^X//" >mem.c <<'END_OF_mem.c'
  783. X/* $Source: /u/mark/src/pax/RCS/mem.c,v $
  784. X *
  785. X * $Revision: 1.1 $
  786. X *
  787. X * mem.c - memory allocation and manipulation functions
  788. X *
  789. X * DESCRIPTION
  790. X *
  791. X *    These routines are provided for higher level handling of the UNIX
  792. X *    memory allocation functions.
  793. X *
  794. X * AUTHOR
  795. X *
  796. X *     Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  797. X *
  798. X *
  799. X * Sponsored by The USENIX Association for public distribution. 
  800. X *
  801. X * Copyright (c) 1989 Mark H. Colburn.
  802. X * All rights reserved.
  803. X *
  804. X * Redistribution and use in source and binary forms are permitted
  805. X * provided that the above copyright notice is duplicated in all such 
  806. X * forms and that any documentation, advertising materials, and other 
  807. X * materials related to such distribution and use acknowledge that the 
  808. X * software was developed * by Mark H. Colburn and sponsored by The 
  809. X * USENIX Association. 
  810. X *
  811. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  812. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  813. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  814. X *
  815. X * $Log:    mem.c,v $
  816. X * Revision 1.1  88/12/23  18:02:17  mark
  817. X * Initial revision
  818. X * 
  819. X */
  820. X
  821. X#ifndef lint
  822. Xstatic char *ident = "$Id: mem.c,v 1.1 88/12/23 18:02:17 mark Rel $";
  823. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  824. X#endif /* ! lint */
  825. X
  826. X
  827. X/* Headers */
  828. X
  829. X#include "pax.h"
  830. X
  831. X
  832. X/* mem_get - allocate memory
  833. X *
  834. X * DESCRIPTION
  835. X *
  836. X *    Mem_get attempts to allocate a block of memory using the malloc
  837. X *    function call.  In the event that the memory is not available, 
  838. X *    mem_get will display an "Out of memory" message for the user
  839. X *    the first time it encounters the an out of memory situation.
  840. X *    Subsequent calls to mem_get may fail, but no message will be
  841. X *    printed.
  842. X *
  843. X * PARAMETERS
  844. X *
  845. X *    uint len    - The amount of memory to allocate
  846. X *
  847. X * RETURNS
  848. X *
  849. X *    Normally returns the pointer to the newly allocated memory.  If
  850. X *    an error occurss, NULL is returned, and an error message is
  851. X *    printed.
  852. X *
  853. X * ERRORS
  854. X *
  855. X *    ENOMEM    No memory is available 
  856. X */
  857. X
  858. X#ifdef __STDC__
  859. X
  860. Xchar *mem_get(uint len)
  861. X
  862. X#else
  863. X
  864. Xchar *mem_get(len)
  865. Xuint            len;        /* amount of memory to get */
  866. X
  867. X#endif
  868. X{
  869. X    char           *mem;
  870. X    static short    outofmem = 0;
  871. X
  872. X    if ((mem = (char *)malloc(len)) == NULL && !outofmem) {
  873. X    outofmem++;
  874. X    warn("mem_get()", "Out of memory");
  875. X    }
  876. X    return (mem);
  877. X}
  878. X
  879. X
  880. X/* mem_str - duplicate a string into dynamic memory
  881. X *
  882. X * DESCRIPTION
  883. X *
  884. X *    Mem_str attempts to make a copy of string.  It allocates space for
  885. X *    the string, and if the allocation was successfull, copies the old
  886. X *    string into the newly allocated space.
  887. X *
  888. X * PARAMETERS
  889. X *
  890. X *    char *str     - string to make a copy of 
  891. X *
  892. X * RETURNS
  893. X *
  894. X *    Normally returns a pointer to a new string at least as large
  895. X *    as strlen(str) + 1, which contains a copy of the the data 
  896. X *    passed in str, plus a null terminator.  Returns (char *)NULL 
  897. X *    if enough memory to make a copy of str is not available.
  898. X */
  899. X
  900. X#ifdef __STDC__
  901. X
  902. Xchar *mem_str(char *str)
  903. X
  904. X#else
  905. X
  906. Xchar *mem_str(str)
  907. Xchar           *str;        /* string to make a copy of */
  908. X
  909. X#endif
  910. X{
  911. X    char           *mem;
  912. X
  913. X    if (mem = mem_get((uint) strlen(str) + 1)) {
  914. X    strcpy(mem, str);
  915. X    }
  916. X    return (mem);
  917. X}
  918. END_OF_mem.c
  919. if test 3204 -ne `wc -c <mem.c`; then
  920.     echo shar: \"mem.c\" unpacked with wrong size!
  921. fi
  922. # end of overwriting check
  923. fi
  924. if test -f pass.c -a "${1}" != "-c" ; then 
  925.   echo shar: Will not over-write existing file \"pass.c\"
  926. else
  927. echo shar: Extracting \"pass.c\" \(3492 characters\)
  928. sed "s/^X//" >pass.c <<'END_OF_pass.c'
  929. X/* $Source: /u/mark/src/pax/RCS/pass.c,v $
  930. X *
  931. X * $Revision: 1.1 $
  932. X *
  933. X * pass.c - handle the pass option of cpio
  934. X *
  935. X * DESCRIPTION
  936. X *
  937. X *    These functions implement the pass options in PAX.  The pass option
  938. X *    copies files from one directory hierarchy to another.
  939. X * 
  940. X * AUTHOR
  941. X *
  942. X *    Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  943. X *
  944. X * Sponsored by The USENIX Association for public distribution. 
  945. X *
  946. X * Copyright (c) 1989 Mark H. Colburn.
  947. X * All rights reserved.
  948. X *
  949. X * Redistribution and use in source and binary forms are permitted
  950. X * provided that the above copyright notice is duplicated in all such 
  951. X * forms and that any documentation, advertising materials, and other 
  952. X * materials related to such distribution and use acknowledge that the 
  953. X * software was developed * by Mark H. Colburn and sponsored by The 
  954. X * USENIX Association. 
  955. X *
  956. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  957. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  958. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  959. X *
  960. X * $Log:    pass.c,v $
  961. X * Revision 1.1  88/12/23  18:02:20  mark
  962. X * Initial revision
  963. X * 
  964. X */
  965. X
  966. X#ifndef lint
  967. Xstatic char *ident = "$Id: pass.c,v 1.1 88/12/23 18:02:20 mark Rel $";
  968. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  969. X#endif /* ! lint */
  970. X
  971. X
  972. X/* Headers */
  973. X
  974. X#include "pax.h"
  975. X
  976. X
  977. X/* pass - copy within the filesystem
  978. X *
  979. X * DESCRIPTION
  980. X *
  981. X *    Pass copies the named files from the current directory hierarchy to
  982. X *    the directory pointed to by dirname.
  983. X *
  984. X * PARAMETERS
  985. X *
  986. X *    char    *dirname    - name of directory to copy named files to.
  987. X *
  988. X */
  989. X
  990. X#ifdef __STDC__
  991. X    
  992. Xint pass(char *dirname)
  993. X
  994. X#else
  995. X    
  996. Xint pass(dirname)
  997. Xchar    *dirname;
  998. X
  999. X#endif
  1000. X{
  1001. X    char            name[PATH_MAX + 1];
  1002. X    int             fd;
  1003. X    Stat            sb;
  1004. X
  1005. X    while (name_next(name, &sb) >= 0 && (fd = openi(name, &sb)) >= 0) {
  1006. X
  1007. X    if (rplhead != NULL) {
  1008. X        rpl_name(name);
  1009. X    }
  1010. X    if (get_disposition("pass", name) || get_newname(name, sizeof(name))) {
  1011. X        /* skip file... */
  1012. X        if (fd) {
  1013. X        close(fd);
  1014. X        }
  1015. X        continue;
  1016. X    } 
  1017. X
  1018. X    if (passitem(name, &sb, fd, dirname)) {
  1019. X        close(fd);
  1020. X    }
  1021. X    if (f_verbose) {
  1022. X        fprintf(stderr, "%s/%s\n", dirname, name);
  1023. X    }
  1024. X    }
  1025. X}
  1026. X
  1027. X
  1028. X/* passitem - copy one file
  1029. X *
  1030. X * DESCRIPTION
  1031. X *
  1032. X *    Passitem copies a specific file to the named directory
  1033. X *
  1034. X * PARAMETERS
  1035. X *
  1036. X *    char   *from    - the name of the file to open
  1037. X *    Stat   *asb    - the stat block associated with the file to copy
  1038. X *    int    ifd    - the input file descriptor for the file to copy
  1039. X *    char   *dir    - the directory to copy it to
  1040. X *
  1041. X * RETURNS
  1042. X *
  1043. X *     Returns given input file descriptor or -1 if an error occurs.
  1044. X *
  1045. X * ERRORS
  1046. X */
  1047. X
  1048. X#ifdef __STDC__
  1049. X
  1050. Xint passitem(char *from, Stat *asb, int ifd, char *dir)
  1051. X
  1052. X#else
  1053. X    
  1054. Xint passitem(from, asb, ifd, dir)
  1055. Xchar           *from;
  1056. XStat           *asb;
  1057. Xint             ifd;
  1058. Xchar           *dir;
  1059. X
  1060. X#endif
  1061. X{
  1062. X    int             ofd;
  1063. X    time_t          tstamp[2];
  1064. X    char            to[PATH_MAX + 1];
  1065. X
  1066. X    if (nameopt(strcat(strcat(strcpy(to, dir), "/"), from)) < 0) {
  1067. X    return (-1);
  1068. X    }
  1069. X    if (asb->sb_nlink > 1) {
  1070. X    if (f_link && islink(from, asb) == (Link *) NULL) {
  1071. X        linkto(from, asb);
  1072. X    }
  1073. X    linkto(to, asb);
  1074. X    }
  1075. X    if ((ofd = openo(to, asb, islink(to, asb), 1)) < 0) {
  1076. X    return (-1);
  1077. X    }
  1078. X    if (ofd > 0) {
  1079. X    passdata(from, ifd, to, ofd);
  1080. X    }
  1081. X    tstamp[0] = asb->sb_atime;
  1082. X    tstamp[1] = f_modification_time ? asb->sb_mtime : time((time_t *) 0);
  1083. X    utime(to, tstamp);
  1084. X    return (ifd);
  1085. X}
  1086. END_OF_pass.c
  1087. if test 3492 -ne `wc -c <pass.c`; then
  1088.     echo shar: \"pass.c\" unpacked with wrong size!
  1089. fi
  1090. # end of overwriting check
  1091. fi
  1092. if test -f pathname.c -a "${1}" != "-c" ; then 
  1093.   echo shar: Will not over-write existing file \"pathname.c\"
  1094. else
  1095. echo shar: Extracting \"pathname.c\" \(4973 characters\)
  1096. sed "s/^X//" >pathname.c <<'END_OF_pathname.c'
  1097. X/* $Source: /u/mark/src/pax/RCS/pathname.c,v $
  1098. X *
  1099. X * $Revision: 1.1 $
  1100. X *
  1101. X * pathname.c - directory/pathname support functions 
  1102. X *
  1103. X * DESCRIPTION
  1104. X *
  1105. X *    These functions provide directory/pathname support for PAX
  1106. X *
  1107. X * AUTHOR
  1108. X *
  1109. X *    Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  1110. X *
  1111. X * Sponsored by The USENIX Association for public distribution. 
  1112. X *
  1113. X * Copyright (c) 1989 Mark H. Colburn.
  1114. X * All rights reserved.
  1115. X *
  1116. X * Redistribution and use in source and binary forms are permitted
  1117. X * provided that the above copyright notice is duplicated in all such 
  1118. X * forms and that any documentation, advertising materials, and other 
  1119. X * materials related to such distribution and use acknowledge that the 
  1120. X * software was developed * by Mark H. Colburn and sponsored by The 
  1121. X * USENIX Association. 
  1122. X *
  1123. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1124. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1125. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1126. X *
  1127. X * $Log:    pathname.c,v $
  1128. X * Revision 1.1  88/12/23  18:02:21  mark
  1129. X * Initial revision
  1130. X * 
  1131. X */
  1132. X
  1133. X#ifndef lint
  1134. Xstatic char *ident = "$Id: pathname.c,v 1.1 88/12/23 18:02:21 mark Rel $";
  1135. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  1136. X#endif /* ! lint */
  1137. X
  1138. X
  1139. X/* Headers */
  1140. X
  1141. X#include "pax.h"
  1142. X
  1143. X
  1144. X/* dirneed  - checks for the existance of directories and possibly create
  1145. X *
  1146. X * DESCRIPTION
  1147. X *
  1148. X *    Dirneed checks to see if a directory of the name pointed to by name
  1149. X *    exists.  If the directory does exist, then dirneed returns 0.  If
  1150. X *    the directory does not exist and the f_create_dirs flag is set,
  1151. X *    then dirneed will create the needed directory, recursively creating
  1152. X *    any needed intermediate directory.
  1153. X *
  1154. X *    If f_create_dirs is not set, then no directories will be created
  1155. X *    and a value of -1 will be returned if the directory does not
  1156. X *    exist.
  1157. X *
  1158. X * PARAMETERS
  1159. X *
  1160. X *    name        - name of the directory to create
  1161. X *
  1162. X * RETURNS
  1163. X *
  1164. X *    Returns a 0 if the creation of the directory succeeded or if the
  1165. X *    directory already existed.  If the f_create_dirs flag was not set
  1166. X *    and the named directory does not exist, or the directory creation 
  1167. X *    failed, a -1 will be returned to the calling routine.
  1168. X */
  1169. X
  1170. X#ifdef __STDC__
  1171. X
  1172. Xint dirneed(char *name)
  1173. X
  1174. X#else
  1175. X
  1176. Xint dirneed(name)
  1177. Xchar           *name;
  1178. X
  1179. X#endif
  1180. X{
  1181. X    char           *cp;
  1182. X    char           *last;
  1183. X    int             ok;
  1184. X    static Stat     sb;
  1185. X
  1186. X    last = NULL;
  1187. X    for (cp = name; *cp;) {
  1188. X    if (*cp++ == '/') {
  1189. X        last = cp;
  1190. X    }
  1191. X    }
  1192. X    if (last == NULL) {
  1193. X    return (STAT(".", &sb));
  1194. X    }
  1195. X    *--last = '\0';
  1196. X    ok = STAT(*name ? name : ".", &sb) == 0
  1197. X    ? ((sb.sb_mode & S_IFMT) == S_IFDIR)
  1198. X    : (f_create_dirs && dirneed(name) == 0 && dirmake(name, &sb) == 0);
  1199. X    *last = '/';
  1200. X    return (ok ? 0 : -1);
  1201. X}
  1202. X
  1203. X
  1204. X/* nameopt - optimize a pathname
  1205. X *
  1206. X * DESCRIPTION
  1207. X *
  1208. X *     Confused by "<symlink>/.." twistiness. Returns the number of final 
  1209. X *     pathname elements (zero for "/" or ".") or -1 if unsuccessful. 
  1210. X *
  1211. X * PARAMETERS
  1212. X *
  1213. X *    char    *begin    - name of the path to optimize
  1214. X *
  1215. X * RETURNS
  1216. X *
  1217. X *    Returns 0 if successful, non-zero otherwise.
  1218. X *
  1219. X */
  1220. X
  1221. X#ifdef __STDC__
  1222. X
  1223. Xint nameopt(char *begin)
  1224. X
  1225. X#else
  1226. X
  1227. Xint nameopt(begin)
  1228. Xchar           *begin;
  1229. X
  1230. X#endif
  1231. X{
  1232. X    char           *name;
  1233. X    char           *item;
  1234. X    int             idx;
  1235. X    int             absolute;
  1236. X    char           *element[PATHELEM];
  1237. X
  1238. X    absolute = (*(name = begin) == '/');
  1239. X    idx = 0;
  1240. X    for (;;) {
  1241. X    if (idx == PATHELEM) {
  1242. X        warn(begin, "Too many elements");
  1243. X        return (-1);
  1244. X    }
  1245. X    while (*name == '/') {
  1246. X        ++name;
  1247. X    }
  1248. X    if (*name == '\0') {
  1249. X        break;
  1250. X    }
  1251. X    element[idx] = item = name;
  1252. X    while (*name && *name != '/') {
  1253. X        ++name;
  1254. X    }
  1255. X    if (*name) {
  1256. X        *name++ = '\0';
  1257. X    }
  1258. X    if (strcmp(item, "..") == 0) {
  1259. X        if (idx == 0) {
  1260. X        if (!absolute) {
  1261. X            ++idx;
  1262. X        }
  1263. X        } else if (strcmp(element[idx - 1], "..") == 0) {
  1264. X        ++idx;
  1265. X        } else {
  1266. X        --idx;
  1267. X        }
  1268. X    } else if (strcmp(item, ".") != 0) {
  1269. X        ++idx;
  1270. X    }
  1271. X    }
  1272. X    if (idx == 0) {
  1273. X    element[idx++] = absolute ? "" : "."; 
  1274. X    }
  1275. X    element[idx] = NULL;
  1276. X    name = begin;
  1277. X    if (absolute) {
  1278. X    *name++ = '/';
  1279. X    }
  1280. X    for (idx = 0; item = element[idx]; ++idx, *name++ = '/') {
  1281. X    while (*item) {
  1282. X        *name++ = *item++;
  1283. X    }
  1284. X    }
  1285. X    *--name = '\0';
  1286. X    return (idx);
  1287. X}
  1288. X
  1289. X
  1290. X/* dirmake - make a directory  
  1291. X *
  1292. X * DESCRIPTION
  1293. X *
  1294. X *    Dirmake makes a directory with the appropritate permissions.
  1295. X *
  1296. X * PARAMETERS
  1297. X *
  1298. X *    char     *name    - Name of directory make
  1299. X *    Stat    *asb    - Stat structure of directory to make
  1300. X *
  1301. X * RETURNS
  1302. X *
  1303. X *     Returns zero if successful, -1 otherwise. 
  1304. X *
  1305. X */
  1306. X
  1307. X#ifdef __STDC__
  1308. X
  1309. Xint dirmake(char *name, Stat *asb)
  1310. X
  1311. X#else
  1312. X
  1313. Xint dirmake(name, asb)
  1314. Xchar           *name;
  1315. XStat           *asb;
  1316. X
  1317. X#endif
  1318. X{
  1319. X    if (mkdir(name, (int) (asb->sb_mode & S_IPOPN)) < 0) {
  1320. X    return (-1);
  1321. X    }
  1322. X    if (asb->sb_mode & S_IPEXE) {
  1323. X    chmod(name, (int) (asb->sb_mode & S_IPERM));
  1324. X    }
  1325. X    if (f_owner) {
  1326. X    chown(name, (int) asb->sb_uid, (int) asb->sb_gid);
  1327. X    }
  1328. X    return (0);
  1329. X}
  1330. END_OF_pathname.c
  1331. if test 4973 -ne `wc -c <pathname.c`; then
  1332.     echo shar: \"pathname.c\" unpacked with wrong size!
  1333. fi
  1334. # end of overwriting check
  1335. fi
  1336. if test -f paxdir.h -a "${1}" != "-c" ; then 
  1337.   echo shar: Will not over-write existing file \"paxdir.h\"
  1338. else
  1339. echo shar: Extracting \"paxdir.h\" \(1562 characters\)
  1340. sed "s/^X//" >paxdir.h <<'END_OF_paxdir.h'
  1341. X/*
  1342. X    <dirent.h> -- definitions for SVR3 directory access routines
  1343. X
  1344. X    last edit:    25-Apr-1987    D A Gwyn
  1345. X
  1346. X    Prerequisite:    <sys/types.h>
  1347. X*/
  1348. X
  1349. X#ifndef _PAX_DIRENT_H
  1350. X#define _PAX_DIRENT_H
  1351. X
  1352. X#include "config.h"
  1353. X#ifdef USG
  1354. X#define UFS
  1355. X#else
  1356. X#ifdef BSD
  1357. X#define BFS
  1358. X#endif
  1359. X#endif
  1360. X
  1361. Xstruct dirent {             /* data from getdents()/readdir() */
  1362. X    long        d_ino;        /* inode number of entry */
  1363. X    off_t        d_off;        /* offset of disk directory entry */
  1364. X    unsigned short    d_reclen;    /* length of this record */
  1365. X    char        d_name[1];    /* name of file (non-POSIX) */
  1366. X};
  1367. X
  1368. Xtypedef struct {
  1369. X    int        dd_fd;            /* file descriptor */
  1370. X    int        dd_loc;            /* offset in block */
  1371. X    int        dd_size;        /* amount of valid data */
  1372. X    char    *dd_buf;        /* -> directory block */
  1373. X} DIR;                    /* stream data from opendir() */
  1374. X
  1375. X
  1376. X/* 
  1377. X * The following nonportable ugliness could have been avoided by defining
  1378. X * DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments. 
  1379. X */
  1380. X#define    DIRENTBASESIZ        (((struct dirent *)0)->d_name \
  1381. X                - (char *)&((struct dirent *)0)->d_ino)
  1382. X#define    DIRENTSIZ( namlen )    ((DIRENTBASESIZ + sizeof(long) + (namlen)) \
  1383. X                / sizeof(long) * sizeof(long))
  1384. X
  1385. X#define    MAXNAMLEN 512            /* maximum filename length */
  1386. X
  1387. X#ifndef NAME_MAX
  1388. X#define    NAME_MAX (MAXNAMLEN - 1)    /* DAG -- added for POSIX */
  1389. X#endif
  1390. X
  1391. X#define    DIRBUF     8192            /* buffer size for fs-indep. dirs */
  1392. X        /* must in general be larger than the filesystem buffer size */
  1393. X
  1394. Xextern DIR        *opendir();
  1395. Xextern struct dirent    *readdir();
  1396. Xextern OFFSET        telldir();
  1397. Xextern void        seekdir();
  1398. Xextern int        closedir();
  1399. X
  1400. X#endif /* _PAX_DIRENT_H */
  1401. END_OF_paxdir.h
  1402. if test 1562 -ne `wc -c <paxdir.h`; then
  1403.     echo shar: \"paxdir.h\" unpacked with wrong size!
  1404. fi
  1405. # end of overwriting check
  1406. fi
  1407. if test -f port.c -a "${1}" != "-c" ; then 
  1408.   echo shar: Will not over-write existing file \"port.c\"
  1409. else
  1410. echo shar: Extracting \"port.c\" \(4782 characters\)
  1411. sed "s/^X//" >port.c <<'END_OF_port.c'
  1412. X/* $Source: /u/mark/src/pax/RCS/port.c,v $
  1413. X *
  1414. X * $Revision: 1.1 $
  1415. X *
  1416. X * port.c - These are routines not available in all environments. 
  1417. X *
  1418. X * DESCRIPTION
  1419. X *
  1420. X *    The routines contained in this file are provided for portability to
  1421. X *    other versions of UNIX or other operating systems (e.g. MSDOS).
  1422. X *    Not all systems have the same functions or the same semantics,
  1423. X *    these routines attempt to bridge the gap as much as possible.
  1424. X *
  1425. X * AUTHOR
  1426. X *
  1427. X *    Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  1428. X *    John Gilmore (gnu@hoptoad)
  1429. X *
  1430. X * Sponsored by The USENIX Association for public distribution. 
  1431. X *
  1432. X * Copyright (c) 1989 Mark H. Colburn.
  1433. X * All rights reserved.
  1434. X *
  1435. X * Redistribution and use in source and binary forms are permitted
  1436. X * provided that the above copyright notice is duplicated in all such 
  1437. X * forms and that any documentation, advertising materials, and other 
  1438. X * materials related to such distribution and use acknowledge that the 
  1439. X * software was developed * by Mark H. Colburn and sponsored by The 
  1440. X * USENIX Association. 
  1441. X *
  1442. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1443. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1444. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1445. X *
  1446. X * $Log:    port.c,v $
  1447. X * Revision 1.1  88/12/23  18:02:29  mark
  1448. X * Initial revision
  1449. X * 
  1450. X */
  1451. X
  1452. X#ifndef lint
  1453. Xstatic char *ident = "$Id: port.c,v 1.1 88/12/23 18:02:29 mark Rel $";
  1454. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  1455. X#endif /* ! lint */
  1456. X
  1457. X
  1458. X/* Headers */
  1459. X
  1460. X#include "pax.h"
  1461. X
  1462. X
  1463. X/*
  1464. X * Some computers are not so crass as to align themselves into the BSD or USG
  1465. X * camps.  If a system supplies all of the routines we fake here, add it to
  1466. X * the list in the #if !defined()'s below and it'll all be skipped. 
  1467. X */
  1468. X
  1469. X#if !defined(mc300) && !defined(mc500) && !defined(mc700) && \
  1470. X    !defined(BSD)
  1471. X
  1472. X/* mkdir - make a directory
  1473. X *
  1474. X * DESCRIPTION
  1475. X *
  1476. X *     Mkdir will make a directory of the name "dpath" with a mode of
  1477. X *    "dmode".  This is consistent with the BSD mkdir() function and the
  1478. X *    P1003.1 definitions of MKDIR.
  1479. X *
  1480. X * PARAMETERS
  1481. X *
  1482. X *    dpath        - name of directory to create
  1483. X *    dmode        - mode of the directory
  1484. X *
  1485. X * RETURNS
  1486. X *
  1487. X *    Returns 0 if the directory was successfully created, otherwise a
  1488. X *    non-zero return value will be passed back to the calling function
  1489. X *    and the value of errno should reflect the error.
  1490. X */
  1491. X
  1492. X#ifdef __STDC__
  1493. X
  1494. Xint mkdir(char *dpath, int dmode)
  1495. X
  1496. X#else
  1497. X    
  1498. Xint mkdir(dpath, dmode)
  1499. Xchar           *dpath;
  1500. Xint             dmode;
  1501. X
  1502. X#endif
  1503. X{
  1504. X    int             cpid, status;
  1505. X    Stat            statbuf;
  1506. X    extern int      errno;
  1507. X
  1508. X    if (STAT(dpath, &statbuf) == 0) {
  1509. X    errno = EEXIST;        /* Stat worked, so it already exists */
  1510. X    return (-1);
  1511. X    }
  1512. X    /* If stat fails for a reason other than non-existence, return error */
  1513. X    if (errno != ENOENT)
  1514. X    return (-1);
  1515. X
  1516. X    switch (cpid = fork()) {
  1517. X
  1518. X    case -1:            /* Error in fork() */
  1519. X    return (-1);        /* Errno is set already */
  1520. X
  1521. X    case 0:            /* Child process */
  1522. X
  1523. X    status = umask(0);    /* Get current umask */
  1524. X    status = umask(status | (0777 & ~dmode));    /* Set for mkdir */
  1525. X    execl("/bin/mkdir", "mkdir", dpath, (char *) 0);
  1526. X    _exit(-1);        /* Can't exec /bin/mkdir */
  1527. X
  1528. X    default:            /* Parent process */
  1529. X    while (cpid != wait(&status)) {
  1530. X        /* Wait for child to finish */
  1531. X    }
  1532. X    }
  1533. X
  1534. X    if (TERM_SIGNAL(status) != 0 || TERM_VALUE(status) != 0) {
  1535. X    errno = EIO;        /* We don't know why, but */
  1536. X    return (-1);        /* /bin/mkdir failed */
  1537. X    }
  1538. X    return (0);
  1539. X}
  1540. X
  1541. X
  1542. X/* rmdir - remove a directory
  1543. X *
  1544. X * DESCRIPTION
  1545. X *
  1546. X *    Rmdir will remove the directory specified by "dpath".  It is
  1547. X *    consistent with the BSD and POSIX rmdir functions.
  1548. X *
  1549. X * PARAMETERS
  1550. X *
  1551. X *    dpath        - name of directory to remove
  1552. X *
  1553. X * RETURNS
  1554. X *
  1555. X *    Returns 0 if the directory was successfully deleted, otherwise a
  1556. X *    non-zero return value will be passed back to the calling function
  1557. X *    and the value of errno should reflect the error.
  1558. X */
  1559. X
  1560. X#ifdef __STDC__
  1561. X
  1562. Xint rmdir(char *dpath)
  1563. X
  1564. X#else
  1565. X    
  1566. Xint rmdir(dpath)
  1567. Xchar           *dpath;
  1568. X
  1569. X#endif
  1570. X{
  1571. X    int             cpid, status;
  1572. X    Stat            statbuf;
  1573. X    extern int      errno;
  1574. X
  1575. X    /* check to see if it exists */
  1576. X    if (STAT(dpath, &statbuf) == -1) {
  1577. X    return (-1);
  1578. X    }
  1579. X    switch (cpid = fork()) {
  1580. X
  1581. X    case -1:            /* Error in fork() */
  1582. X    return (-1);        /* Errno is set already */
  1583. X
  1584. X    case 0:            /* Child process */
  1585. X    execl("/bin/rmdir", "rmdir", dpath, (char *) 0);
  1586. X    _exit(-1);        /* Can't exec /bin/rmdir */
  1587. X
  1588. X    default:            /* Parent process */
  1589. X    while (cpid != wait(&status)) {
  1590. X        /* Wait for child to finish */
  1591. X    }
  1592. X    }
  1593. X
  1594. X    if (TERM_SIGNAL(status) != 0 || TERM_VALUE(status) != 0) {
  1595. X    errno = EIO;        /* We don't know why, but */
  1596. X    return (-1);        /* /bin/rmdir failed */
  1597. X    }
  1598. X    return (0);
  1599. X}
  1600. X
  1601. X#endif /* MASSCOMP, BSD */
  1602. END_OF_port.c
  1603. if test 4782 -ne `wc -c <port.c`; then
  1604.     echo shar: \"port.c\" unpacked with wrong size!
  1605. fi
  1606. # end of overwriting check
  1607. fi
  1608. if test -f port.h -a "${1}" != "-c" ; then 
  1609.   echo shar: Will not over-write existing file \"port.h\"
  1610. else
  1611. echo shar: Extracting \"port.h\" \(2833 characters\)
  1612. sed "s/^X//" >port.h <<'END_OF_port.h'
  1613. X/* $Source: /u/mark/src/pax/RCS/port.h,v $
  1614. X *
  1615. X * $Revision: 1.1 $
  1616. X *
  1617. X * port.h - defnitions for portability library
  1618. X *
  1619. X * DESCRIPTION
  1620. X *
  1621. X *    Header for maintaing portablilty across operating system and
  1622. X *    version boundries.  For the most part, this file contains
  1623. X *    definitions which map functions which have the same functionality
  1624. X *    but different names on different systems, to have the same name.
  1625. X *
  1626. X * AUTHORS
  1627. X *
  1628. X *    Mark H. Colburn, NAPS International (mark@jhereg.mn.org)
  1629. X *    John Gilmore (gnu@hoptoad)
  1630. X *
  1631. X * Sponsored by The USENIX Association for public distribution. 
  1632. X *
  1633. X * Copyright (c) 1989 Mark H. Colburn.
  1634. X * All rights reserved.
  1635. X *
  1636. X * Redistribution and use in source and binary forms are permitted
  1637. X * provided that the above copyright notice and this paragraph are
  1638. X * duplicated in all such forms and that any documentation,
  1639. X * advertising materials, and other materials related to such
  1640. X * distribution and use acknowledge that the software was developed
  1641. X * by Mark H. Colburn and sponsored by The USENIX Association. 
  1642. X *
  1643. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1644. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1645. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1646. X */
  1647. X
  1648. X#ifndef _PAX_PORT_H
  1649. X#define _PAX_PORT_H
  1650. X
  1651. X/*
  1652. X * Everybody does wait() differently.  There seem to be no definitions for
  1653. X * this in V7 (e.g. you are supposed to shift and mask things out using
  1654. X * constant shifts and masks.)  In order to provide the functionality, here
  1655. X * are some non standard but portable macros.  Don't change to a "union wait" 
  1656. X * based approach -- the ordering of the elements of the struct depends on the 
  1657. X * byte-sex of the machine. 
  1658. X */
  1659. X
  1660. X#define    TERM_SIGNAL(status)    ((status) & 0x7F)
  1661. X#define TERM_COREDUMP(status)    (((status) & 0x80) != 0)
  1662. X#define TERM_VALUE(status)    ((status) >> 8)
  1663. X
  1664. X/*
  1665. X * String library emulation definitions for the different variants of UNIX
  1666. X */
  1667. X
  1668. X#if defined(USG) 
  1669. X
  1670. X#   include <string.h>
  1671. X#   include <memory.h>
  1672. X
  1673. X#else /* USG */
  1674. X
  1675. X/*
  1676. X * The following functions are defined here since func.h has no idea which
  1677. X * of the functions will actually be used.
  1678. X */
  1679. X#  ifdef __STDC__
  1680. Xextern char *rindex(char *, char);
  1681. Xextern char *index(char *, char);
  1682. Xextern char *bcopy(char *, char *, unsigned int);
  1683. Xextern char *bzero(char *, unsigned int);
  1684. Xextern char *strcat(char *, char *);
  1685. Xextern char *strcpy(char *, char *);
  1686. X#  else /* !__STDC__ */
  1687. Xextern char *rindex();
  1688. Xextern char *index();
  1689. Xextern char *bcopy();
  1690. Xextern char *bzero();
  1691. Xextern char *strcat();
  1692. Xextern char *strcpy();
  1693. X#  endif /* __STDC__ */
  1694. X
  1695. X/*
  1696. X * Map ANSI C compatible functions to V7 functions
  1697. X */
  1698. X
  1699. X#   define memcpy(a,b,n)    bcopy((b),(a),(n))
  1700. X#   define memset(a,b,n)    bzero((a),(n))
  1701. X#   define strrchr(s,c)        rindex(s,c)
  1702. X#   define strchr(s,c)        index(s,c)
  1703. X
  1704. X#endif /* USG */
  1705. X#endif /* _PAX_PORT_H */
  1706. END_OF_port.h
  1707. if test 2833 -ne `wc -c <port.h`; then
  1708.     echo shar: \"port.h\" unpacked with wrong size!
  1709. fi
  1710. # end of overwriting check
  1711. fi
  1712. if test -f regexp.h -a "${1}" != "-c" ; then 
  1713.   echo shar: Will not over-write existing file \"regexp.h\"
  1714. else
  1715. echo shar: Extracting \"regexp.h\" \(803 characters\)
  1716. sed "s/^X//" >regexp.h <<'END_OF_regexp.h'
  1717. X/*
  1718. X * Definitions etc. for regexp(3) routines.
  1719. X *
  1720. X * Caveat:  this is V8 regexp(3) [actually, a reimplementation thereof],
  1721. X * not the System V one.
  1722. X */
  1723. X
  1724. X#ifndef _PAX_REGEXP_H
  1725. X#define _PAX_REGEXP_H
  1726. X
  1727. X#define NSUBEXP  10
  1728. Xtypedef struct regexp {
  1729. X    char *startp[NSUBEXP];
  1730. X    char *endp[NSUBEXP];
  1731. X    char regstart;        /* Internal use only. */
  1732. X    char reganch;        /* Internal use only. */
  1733. X    char *regmust;        /* Internal use only. */
  1734. X    int regmlen;        /* Internal use only. */
  1735. X    char program[1];    /* Unwarranted chumminess with compiler. */
  1736. X} regexp;
  1737. X
  1738. X
  1739. X/*
  1740. X * The first byte of the regexp internal "program" is actually this magic
  1741. X * number; the start node begins in the second byte.
  1742. X */
  1743. X#define    MAGIC    0234
  1744. X
  1745. Xextern regexp *regcomp();
  1746. Xextern int regexec();
  1747. Xextern void regsub();
  1748. Xextern void regerror();
  1749. X
  1750. X#endif /* _PAX_REGEXP_H */
  1751. END_OF_regexp.h
  1752. if test 803 -ne `wc -c <regexp.h`; then
  1753.     echo shar: \"regexp.h\" unpacked with wrong size!
  1754. fi
  1755. # end of overwriting check
  1756. fi
  1757. if test -f tar.1 -a "${1}" != "-c" ; then 
  1758.   echo shar: Will not over-write existing file \"tar.1\"
  1759. else
  1760. echo shar: Extracting \"tar.1\" \(4671 characters\)
  1761. sed "s/^X//" >tar.1 <<'END_OF_tar.1'
  1762. X.\" $Id: tar.1,v 1.1 88/12/23 18:02:37 mark Rel $
  1763. X.TH TAR 1 "USENIX Association" ""
  1764. X.SH NAME
  1765. Xtar \- process tape archives
  1766. X.SH SYNOPSIS
  1767. X.B tar
  1768. X.BR \-c [ bfvw ]
  1769. X.I device
  1770. X.I block
  1771. X.I filename...
  1772. X.br
  1773. X.B tar
  1774. X.BR \-r [ bvw ]
  1775. X.I device
  1776. X.I block
  1777. X.RI [ filename... ]
  1778. X.br
  1779. X.B tar
  1780. X.BR \-t [ fv ]
  1781. X.I device
  1782. X.br
  1783. X.B tar
  1784. X.BR \-u [ bvw ]
  1785. X.I device
  1786. X.I block
  1787. X.br
  1788. X.B tar
  1789. X.BR \-x [ flmovw ]
  1790. X.I device
  1791. X.RI [ filename... ]
  1792. X.SH DESCRIPTION
  1793. X.I Tar
  1794. Xreads and writes archive files which conform to the
  1795. X.B "Archive/Interchange File Format"
  1796. Xspecified in
  1797. X.IR "IEEE Std. 1003.1-1988" .
  1798. X.SS Options
  1799. XThe following options are available:
  1800. X.TP 1i
  1801. X.B \-c
  1802. XCreates a new archive; writing begins at the beginning of the archive,
  1803. Xinstead of after the last file.
  1804. X.TP 1i
  1805. X.B \-r
  1806. XWrites names files to the end of the archive.
  1807. X.TP 1i
  1808. X.B \-t
  1809. XLists the names of all of the files in the archive.
  1810. X.TP 1i
  1811. X.B \-u
  1812. XCauses named files to be
  1813. Xadded to the archive if they are not already there, or have been
  1814. Xmodified since last written into the archive.
  1815. XThis implies the
  1816. X.B \-r
  1817. Xoption.
  1818. X.TP 1i
  1819. X.B \-x
  1820. XExtracts named files
  1821. Xfrom the archive.
  1822. XIf a named file matches a directory whose contents had been written onto
  1823. Xthe archive, that directory is recursively extracted.
  1824. XIf a named file in the archive does not exist on the system, the file is
  1825. Xcreate with the same mode as the one in the archive, except that the
  1826. Xset-user-id and get-group-id modes are not set unless the user has
  1827. Xappropriate privileges.
  1828. X.PP
  1829. XIf the files exist, their modes are not changed except as described above.
  1830. XThe owner, group and modification time are restored if possible.
  1831. XIf no
  1832. X.I filename
  1833. Xargument is given, the entire contents of the archive is extracted.
  1834. XNote that if several files with the same name are in the archive,
  1835. Xthe last one will overwrite all earlier ones.
  1836. X.TP 1i
  1837. X.B \-b
  1838. XCauses
  1839. X.I tar
  1840. Xto use the next argument on the command line as the blocking factor for
  1841. Xtape records.
  1842. XThe default is 1; the maximum is 20.
  1843. XThis option should only be used with raw magnetic tape archives.
  1844. XNormally, the block size is determined automatically when reading tapes.
  1845. X.TP 1i
  1846. X.B \-f
  1847. XCauses
  1848. X.I tar
  1849. Xto use the next argument on the command line as the name of the archive
  1850. Xinstead of the default, which is usually a tape drive.
  1851. XIf
  1852. X.B -
  1853. Xis specified as a filename
  1854. X.I tar
  1855. Xwrites to the standard output or reads from the standard input, whichever
  1856. Xis appropriate for the options given.
  1857. XThus,
  1858. X.I tar
  1859. Xcan be used as the head or tail of a pipeline.
  1860. X.TP 1i
  1861. X.B \-l
  1862. XTells
  1863. X.I tar
  1864. Xto report if it cannot resolve all of the links to the files being
  1865. Xarchived.
  1866. XIf
  1867. X.B \-l
  1868. Xis not specified, no error messages are written to the standard output.
  1869. XThis modifier is only valid with the
  1870. X.BR \-c ,
  1871. X.B \-r
  1872. Xand
  1873. X.BR \-u
  1874. Xoptions.
  1875. X.TP 1i
  1876. X.B \-m
  1877. XTells
  1878. X.I tar
  1879. Xnot to restore the modification times.
  1880. XThe modification time of the file will be the time of extraction.
  1881. XThis modifier is invalid with th
  1882. X.B \-t
  1883. Xoption.
  1884. X.TP 1i
  1885. X.B \-o
  1886. XCauses extracted files to take on the user and group identifier of the user
  1887. Xrunning the program rather than those on the archive.
  1888. XThis modifier is only valid with the
  1889. X.B \-x
  1890. Xoption.
  1891. X.TP 1i
  1892. X.B \-v
  1893. XCauses
  1894. X.I tar
  1895. Xto operate verbosely.  Usually,
  1896. X.I tar
  1897. Xdoes its work silently, but
  1898. Xthe
  1899. X.B v
  1900. Xmodifier causes it to print the name of each file it processes,
  1901. Xpreceded by the option letter.
  1902. XWith the
  1903. X.B \-t
  1904. Xoption,
  1905. X.B v
  1906. Xgives more information about the archive entries than just the name.
  1907. X.TP 1i
  1908. X.B \-w
  1909. XCauses
  1910. X.I tar
  1911. Xto print the action to be taken, followed by the name of the file, and then
  1912. Xwait for the user's confirmation.
  1913. XIf a word beginning with
  1914. X.B y
  1915. Xis given, the action is performed.
  1916. XAny other input means "no".
  1917. XThis modifier is invalid with the
  1918. X.B \-t
  1919. Xoption.
  1920. X.SH FILES
  1921. X.TP 1i
  1922. X/dev/tty
  1923. Xused to prompt the user for information when the
  1924. X.BR \-i " or " \-y
  1925. Xoptions are specified.
  1926. X.SH "SEE ALSO"
  1927. Xcpio(1), dd(1), find(1), pax(1), cpio(5), tar(5)
  1928. X.SH COPYRIGHT
  1929. XCopyright (c) 1989 Mark H. Colburn.  
  1930. X.br
  1931. XAll rights reserved.
  1932. X.PP
  1933. XRedistribution and use in source and binary forms are permitted
  1934. Xprovided that the above copyright notice is duplicated in all such 
  1935. Xforms and that any documentation, advertising materials, and other 
  1936. Xmaterials related to such distribution and use acknowledge that the 
  1937. Xsoftware was developed by Mark H. Colburn and sponsored by The 
  1938. XUSENIX Association. 
  1939. X.PP
  1940. XTHE SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1941. XIMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1942. XWARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1943. X.SH AUTHOR
  1944. XMark H. Colburn
  1945. X.br
  1946. XNAPS International
  1947. X.br
  1948. X117 Mackubin Street, Suite 1
  1949. X.br
  1950. XSt. Paul, MN 55102
  1951. X.br
  1952. Xmark@jhereg.MN.ORG
  1953. X.sp 2
  1954. XSponsored by
  1955. X.B "The USENIX Association"
  1956. Xfor public distribution.
  1957. END_OF_tar.1
  1958. if test 4671 -ne `wc -c <tar.1`; then
  1959.     echo shar: \"tar.1\" unpacked with wrong size!
  1960. fi
  1961. # end of overwriting check
  1962. fi
  1963. if test -f wildmat.c -a "${1}" != "-c" ; then 
  1964.   echo shar: Will not over-write existing file \"wildmat.c\"
  1965. else
  1966. echo shar: Extracting \"wildmat.c\" \(4958 characters\)
  1967. sed "s/^X//" >wildmat.c <<'END_OF_wildmat.c'
  1968. X/* $Source: /u/mark/src/pax/RCS/wildmat.c,v $
  1969. X *
  1970. X * $Revision: 1.1 $
  1971. X *
  1972. X * wildmat.c - simple regular expression pattern matching routines 
  1973. X *
  1974. X * DESCRIPTION 
  1975. X *
  1976. X *     These routines provide simple UNIX style regular expression matching.  
  1977. X *    They were originally written by Rich Salz, the comp.sources.unix 
  1978. X *    moderator for inclusion in some of his software.  These routines 
  1979. X *    were released into the public domain and used by John Gilmore in 
  1980. X *    USTAR. 
  1981. X *
  1982. X * AUTHORS 
  1983. X *
  1984. X *     Mark H. Colburn, NAPS International (mark@jhereg.mn.org) 
  1985. X *     John Gilmore (gnu@hoptoad) 
  1986. X *     Rich Salz (rs@uunet.uu.net) 
  1987. X *
  1988. X *
  1989. X * Sponsored by The USENIX Association for public distribution. 
  1990. X *
  1991. X * Copyright (c) 1989 Mark H. Colburn.
  1992. X * All rights reserved.
  1993. X *
  1994. X * Redistribution and use in source and binary forms are permitted
  1995. X * provided that the above copyright notice is duplicated in all such 
  1996. X * forms and that any documentation, advertising materials, and other 
  1997. X * materials related to such distribution and use acknowledge that the 
  1998. X * software was developed * by Mark H. Colburn and sponsored by The 
  1999. X * USENIX Association. 
  2000. X *
  2001. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  2002. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  2003. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  2004. X *
  2005. X * $Log:    wildmat.c,v $
  2006. X * Revision 1.1  88/12/23  18:02:41  mark
  2007. X * Initial revision
  2008. X * 
  2009. X */
  2010. X
  2011. X#ifndef lint
  2012. Xstatic char *ident = "$Id: wildmat.c,v 1.1 88/12/23 18:02:41 mark Rel $";
  2013. Xstatic char *copyright = "Copyright (c) 1989 Mark H. Colburn.\nAll rights reserved.\n";
  2014. X#endif /* ! lint */
  2015. X
  2016. X
  2017. X/* Headers */
  2018. X
  2019. X#include "pax.h"
  2020. X
  2021. X
  2022. X/* Function Prototypes */
  2023. X
  2024. X#ifdef __STDC__
  2025. Xstatic int star(char *, char *);
  2026. X#else  /* !__STDC__ */
  2027. Xstatic int      star();
  2028. X#endif /* __STDC__ */
  2029. X
  2030. X
  2031. X/*
  2032. X * star - handle trailing * in a regular expression 
  2033. X *
  2034. X * DESCRIPTION
  2035. X *
  2036. X *    Star is used to match filename expansions containing a trailing
  2037. X *    asterisk ('*').  Star call wildmat() to determine if the substring
  2038. X *    passed to it is matches the regular expression.
  2039. X *
  2040. X * PARAMETERS 
  2041. X *
  2042. X *     char *source     - The source string which is to be compared to the 
  2043. X *              regular expression pattern. 
  2044. X *     char *pattern     - The regular expression which we are supposed to 
  2045. X *              match to. 
  2046. X *
  2047. X * RETURNS 
  2048. X *
  2049. X *     Returns non-zero if the entire source string is completely matched by 
  2050. X *    the regular expression pattern, returns 0 otherwise. This is used to 
  2051. X *    see if *'s in a pattern matched the entire source string. 
  2052. X *
  2053. X */
  2054. X
  2055. X#ifdef __STDC__
  2056. X
  2057. Xstatic int star(char *source, char *pattern)
  2058. X
  2059. X#else
  2060. X
  2061. Xstatic int star(source, pattern)
  2062. Xchar           *source;        /* source operand */
  2063. Xchar           *pattern;    /* regular expression to match */
  2064. X
  2065. X#endif
  2066. X{
  2067. X    while (!wildmat(source, pattern)) {
  2068. X    if (*++source == '\0') {
  2069. X        return (0);
  2070. X    }
  2071. X    }
  2072. X    return (1);
  2073. X}
  2074. X
  2075. X
  2076. X/*
  2077. X * wildmat - match a regular expression 
  2078. X *
  2079. X * DESCRIPTION
  2080. X *
  2081. X *    Wildmat attempts to match the string pointed to by source to the 
  2082. X *    regular expression pointed to by pattern.  The subset of regular 
  2083. X *    expression syntax which is supported is defined by POSIX P1003.2 
  2084. X *    FILENAME EXPANSION rules.
  2085. X *
  2086. X * PARAMETERS 
  2087. X *
  2088. X *     char *source     - The source string which is to be compared to the 
  2089. X *              regular expression pattern. 
  2090. X *     char *pattern     - The regular expression which we are supposed to 
  2091. X *              match to. 
  2092. X *
  2093. X * RETURNS 
  2094. X *
  2095. X *     Returns non-zero if the source string matches the regular expression 
  2096. X *    pattern specified, returns 0 otherwise. 
  2097. X *
  2098. X */
  2099. X
  2100. X#ifdef __STDC__
  2101. X
  2102. Xint wildmat(char *pattern, char *source)
  2103. X
  2104. X#else
  2105. X
  2106. Xint wildmat(pattern, source)
  2107. Xchar           *pattern;    /* regular expression to match */
  2108. Xchar           *source;        /* source operand */
  2109. X
  2110. X#endif
  2111. X{
  2112. X    int             last;    /* last character matched */
  2113. X    int             matched;    /* !0 if a match occurred */
  2114. X    int             reverse;    /* !0 if sense of match is reversed */
  2115. X
  2116. X    for (; *pattern; source++, pattern++) {
  2117. X    switch (*pattern) {
  2118. X    case '\\':
  2119. X        /* Literal match with following character */
  2120. X        pattern++;
  2121. X        /* FALLTHRU */
  2122. X    default:
  2123. X        if (*source != *pattern) {
  2124. X        return (0);
  2125. X        }
  2126. X        continue;
  2127. X    case '?':
  2128. X        /* Match anything. */
  2129. X        if (*source == '\0') {
  2130. X        return (0);
  2131. X        }
  2132. X        continue;
  2133. X    case '*':
  2134. X        /* Trailing star matches everything. */
  2135. X        return (*++pattern ? star(source, pattern) : 1);
  2136. X    case '[':
  2137. X        /* [^....] means inverse character class. */
  2138. X        if (reverse = pattern[1] == '^') {
  2139. X        pattern++;
  2140. X        }
  2141. X        for (last = 0400, matched = 0;
  2142. X         *++pattern && *pattern != ']'; last = *pattern) {
  2143. X        /* This next line requires a good C compiler. */
  2144. X        if (*pattern == '-'
  2145. X            ? *source <= *++pattern && *source >= last
  2146. X            : *source == *pattern) {
  2147. X            matched = 1;
  2148. X        }
  2149. X        }
  2150. X        if (matched == reverse) {
  2151. X        return (0);
  2152. X        }
  2153. X        continue;
  2154. X    }
  2155. X    }
  2156. X
  2157. X    /*
  2158. X     * For "tar" use, matches that end at a slash also work. --hoptoad!gnu 
  2159. X     */
  2160. X    return (*source == '\0' || *source == '/');
  2161. X}
  2162. END_OF_wildmat.c
  2163. if test 4958 -ne `wc -c <wildmat.c`; then
  2164.     echo shar: \"wildmat.c\" unpacked with wrong size!
  2165. fi
  2166. # end of overwriting check
  2167. fi
  2168. echo shar: End of archive 1 \(of 6\).
  2169. cp /dev/null ark1isdone
  2170. MISSING=""
  2171. for I in 1 2 3 4 5 6 ; do
  2172.     if test ! -f ark${I}isdone ; then
  2173.     MISSING="${MISSING} ${I}"
  2174.     fi
  2175. done
  2176. if test "${MISSING}" = "" ; then
  2177.     echo You have unpacked all 6 archives.
  2178.     rm -f ark[1-9]isdone
  2179. else
  2180.     echo You still need to unpack the following archives:
  2181.     echo "        " ${MISSING}
  2182. fi
  2183. ##  End of shell archive.
  2184. exit 0
  2185.  
  2186.