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