|
|
1.1 ! root 1: /* $Source: /src386/usr/bin/pax/pax.h,v $ ! 2: * ! 3: * $Revision: 1.1 $ ! 4: * ! 5: * pax.h - defnitions for entire program ! 6: * ! 7: * DESCRIPTION ! 8: * ! 9: * This file contains most all of the definitions required by the PAX ! 10: * software. This header is included in every source file. ! 11: * ! 12: * AUTHOR ! 13: * ! 14: * Mark H. Colburn, NAPS International ([email protected]) ! 15: * ! 16: * Sponsored by The USENIX Association for public distribution. ! 17: * ! 18: * Copyright (c) 1989 Mark H. Colburn. ! 19: * All rights reserved. ! 20: * ! 21: * Redistribution and use in source and binary forms are permitted ! 22: * provided that the above copyright notice and this paragraph are ! 23: * duplicated in all such forms and that any documentation, ! 24: * advertising materials, and other materials related to such ! 25: * distribution and use acknowledge that the software was developed ! 26: * by Mark H. Colburn and sponsored by The USENIX Association. ! 27: * ! 28: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 29: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 30: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 31: */ ! 32: ! 33: #ifndef _PAX_H ! 34: #define _PAX_H ! 35: ! 36: /* Headers */ ! 37: ! 38: #include "config.h" ! 39: #include "limits.h" ! 40: #include <stdio.h> ! 41: #include <errno.h> ! 42: #include <signal.h> ! 43: #include <ctype.h> ! 44: #include <sys/types.h> ! 45: /*#include <sys/ioctl.h>*/ ! 46: #include <sys/stat.h> ! 47: #include "regexp.h" ! 48: ! 49: #if defined(DIRENT) || defined(_POSIX_SOURCE) ! 50: # ifdef PAXDIR ! 51: # include "paxdir.h" ! 52: # else ! 53: # include <dirent.h> ! 54: # endif ! 55: #else ! 56: # ifdef hpux ! 57: # include <ndir.h> ! 58: # else ! 59: # ifdef XENIX_286 ! 60: # include <sys/ndir.h> ! 61: # else XENIX_286 ! 62: # include <sys/dir.h> ! 63: # endif XENIX_286 ! 64: # endif /* hpux */ ! 65: # define dirent direct ! 66: #endif ! 67: ! 68: #ifndef major ! 69: # include <sys/sysmacros.h> ! 70: #endif /* major */ ! 71: ! 72: #ifdef SYSTIME ! 73: # include <sys/time.h> ! 74: #else /* SYSTIME */ ! 75: # include <time.h> ! 76: #endif /* SYSTIME */ ! 77: ! 78: #ifndef V7 ! 79: # include <fcntl.h> ! 80: #endif ! 81: ! 82: #ifdef XENIX ! 83: # include <sys/inode.h> ! 84: #endif ! 85: #ifdef XENIX_286 ! 86: #include <sys/param.h> ! 87: #endif XENIX_286 ! 88: ! 89: #include <pwd.h> ! 90: #include <grp.h> ! 91: #ifndef XENIX_286 ! 92: /*#include <sys/file.h>*/ ! 93: #endif XENIX_286 ! 94: ! 95: /* Defines */ ! 96: ! 97: #define STDIN 0 /* Standard input file descriptor */ ! 98: #define STDOUT 1 /* Standard output file descriptor */ ! 99: ! 100: /* ! 101: * Open modes; there is no <fcntl.h> with v7 UNIX and other versions of ! 102: * UNIX may not have all of these defined... ! 103: */ ! 104: ! 105: #ifndef O_RDONLY ! 106: # define O_RDONLY 0 ! 107: #endif ! 108: ! 109: #ifndef O_WRONLY ! 110: # define O_WRONLY 1 ! 111: #endif ! 112: ! 113: #ifndef O_RDWR ! 114: # define O_WRONLY 2 ! 115: #endif ! 116: ! 117: #ifndef O_BINARY ! 118: # define O_BINARY 0 ! 119: #endif ! 120: ! 121: #ifndef NULL ! 122: # define NULL 0 ! 123: #endif ! 124: ! 125: #define TMAGIC "ustar" /* ustar and a null */ ! 126: #define TMAGLEN 6 ! 127: #define TVERSION "00" /* 00 and no null */ ! 128: #define TVERSLEN 2 ! 129: ! 130: /* Values used in typeflag field */ ! 131: #define REGTYPE '0' /* Regular File */ ! 132: #define AREGTYPE '\0' /* Regular File */ ! 133: #define LNKTYPE '1' /* Link */ ! 134: #define SYMTYPE '2' /* Reserved */ ! 135: #define CHRTYPE '3' /* Character Special File */ ! 136: #define BLKTYPE '4' /* Block Special File */ ! 137: #define DIRTYPE '5' /* Directory */ ! 138: #define FIFOTYPE '6' /* FIFO */ ! 139: #define CONTTYPE '7' /* Reserved */ ! 140: ! 141: #define BLOCKSIZE 512 /* all output is padded to 512 bytes */ ! 142: #define uint unsigned int /* Not always in types.h */ ! 143: #define ushort unsigned short /* Not always in types.h */ ! 144: #define BLOCK 5120 /* Default archive block size */ ! 145: #define H_COUNT 10 /* Number of items in ASCII header */ ! 146: #define H_PRINT "%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo" ! 147: #define H_SCAN "%6ho%6ho%6ho%6ho%6ho%6ho%6ho%11lo%6o%11lo" ! 148: #define H_STRLEN 70 /* ASCII header string length */ ! 149: #define M_ASCII "070707" /* ASCII magic number */ ! 150: #define M_BINARY 070707 /* Binary magic number */ ! 151: #define M_STRLEN 6 /* ASCII magic number length */ ! 152: #define PATHELEM 256 /* Pathname element count limit */ ! 153: #define S_IFSHF 12 /* File type shift (shb in stat.h) */ ! 154: #define S_IPERM 07777 /* File permission bits (shb in stat.h) */ ! 155: #define S_IPEXE 07000 /* Special execution bits (shb in stat.h) */ ! 156: #define S_IPOPN 0777 /* Open access bits (shb in stat.h) */ ! 157: ! 158: /* ! 159: * Trailer pathnames. All must be of the same length. ! 160: */ ! 161: #define TRAILER "TRAILER!!!" /* Archive trailer (cpio compatible) */ ! 162: #define TRAILZ 11 /* Trailer pathname length (including null) */ ! 163: ! 164: #include "port.h" ! 165: ! 166: ! 167: #define TAR 1 ! 168: #define CPIO 2 ! 169: #define PAX 3 ! 170: ! 171: #define AR_READ 0 ! 172: #define AR_WRITE 1 ! 173: #define AR_EXTRACT 2 ! 174: #define AR_APPEND 4 ! 175: ! 176: /* ! 177: * Header block on tape. ! 178: */ ! 179: #define NAMSIZ 100 ! 180: #define PFIXSIZ 155 ! 181: #define TUNMLEN 32 ! 182: #define TGNMLEN 32 ! 183: ! 184: /* The checksum field is filled with this while the checksum is computed. */ ! 185: #define CHKBLANKS " " /* 8 blanks, no null */ ! 186: ! 187: /* ! 188: * Exit codes from the "tar" program ! 189: */ ! 190: #define EX_SUCCESS 0 /* success! */ ! 191: #define EX_ARGSBAD 1 /* invalid args */ ! 192: #define EX_BADFILE 2 /* invalid filename */ ! 193: #define EX_BADARCH 3 /* bad archive */ ! 194: #define EX_SYSTEM 4 /* system gave unexpected error */ ! 195: ! 196: #define ROUNDUP(a,b) (((a) % (b)) == 0 ? (a) : ((a) + ((b) - ((a) % (b))))) ! 197: ! 198: /* ! 199: * Mininum value. ! 200: */ ! 201: #define MIN(a, b) (((a) < (b)) ? (a) : (b)) ! 202: ! 203: /* ! 204: * Remove a file or directory. ! 205: */ ! 206: #define REMOVE(name, asb) \ ! 207: (((asb)->sb_mode & S_IFMT) == S_IFDIR ? rmdir(name) : unlink(name)) ! 208: ! 209: /* ! 210: * Cast and reduce to unsigned short. ! 211: */ ! 212: #define USH(n) (((ushort) (n)) & 0177777) ! 213: ! 214: ! 215: /* Type Definitions */ ! 216: ! 217: /* ! 218: * Binary archive header (obsolete). ! 219: */ ! 220: typedef struct { ! 221: short b_dev; /* Device code */ ! 222: ushort b_ino; /* Inode number */ ! 223: ushort b_mode; /* Type and permissions */ ! 224: ushort b_uid; /* Owner */ ! 225: ushort b_gid; /* Group */ ! 226: short b_nlink; /* Number of links */ ! 227: short b_rdev; /* Real device */ ! 228: ushort b_mtime[2]; /* Modification time (hi/lo) */ ! 229: ushort b_name; /* Length of pathname (with null) */ ! 230: ushort b_size[2]; /* Length of data */ ! 231: } Binary; ! 232: ! 233: /* ! 234: * File status with symbolic links. Kludged to hold symbolic link pathname ! 235: * within structure. ! 236: */ ! 237: typedef struct { ! 238: struct stat sb_stat; ! 239: char sb_link[PATH_MAX + 1]; ! 240: } Stat; ! 241: ! 242: #define STAT(name, asb) stat(name, &(asb)->sb_stat) ! 243: #define FSTAT(fd, asb) fstat(fd, &(asb)->sb_stat) ! 244: ! 245: #define sb_dev sb_stat.st_dev ! 246: #define sb_ino sb_stat.st_ino ! 247: #define sb_mode sb_stat.st_mode ! 248: #define sb_nlink sb_stat.st_nlink ! 249: #define sb_uid sb_stat.st_uid ! 250: #define sb_gid sb_stat.st_gid ! 251: #define sb_rdev sb_stat.st_rdev ! 252: #define sb_size sb_stat.st_size ! 253: #define sb_atime sb_stat.st_atime ! 254: #define sb_mtime sb_stat.st_mtime ! 255: #define sb_ctime sb_stat.st_ctime ! 256: ! 257: #ifdef S_IFLNK ! 258: # define LSTAT(name, asb) lstat(name, &(asb)->sb_stat) ! 259: # define sb_blksize sb_stat.st_blksize ! 260: # define sb_blocks sb_stat.st_blocks ! 261: #else /* S_IFLNK */ ! 262: /* ! 263: * File status without symbolic links. ! 264: */ ! 265: # define LSTAT(name, asb) stat(name, &(asb)->sb_stat) ! 266: #endif /* S_IFLNK */ ! 267: ! 268: /* ! 269: * Hard link sources. One or more are chained from each link structure. ! 270: */ ! 271: typedef struct name { ! 272: struct name *p_forw; /* Forward chain (terminated) */ ! 273: struct name *p_back; /* Backward chain (circular) */ ! 274: char *p_name; /* Pathname to link from */ ! 275: } Path; ! 276: ! 277: /* ! 278: * File linking information. One entry exists for each unique file with with ! 279: * outstanding hard links. ! 280: */ ! 281: typedef struct link { ! 282: struct link *l_forw; /* Forward chain (terminated) */ ! 283: struct link *l_back; /* Backward chain (terminated) */ ! 284: dev_t l_dev; /* Device */ ! 285: ino_t l_ino; /* Inode */ ! 286: ushort l_nlink; /* Unresolved link count */ ! 287: OFFSET l_size; /* Length */ ! 288: char *l_name; /* pathname to link from */ ! 289: Path *l_path; /* Pathname which link to l_name */ ! 290: } Link; ! 291: ! 292: /* ! 293: * Structure for ed-style replacement strings (-s option). ! 294: */ ! 295: typedef struct replstr { ! 296: regexp *comp; /* compiled regular expression */ ! 297: char *replace; /* replacement string */ ! 298: char print; /* >0 if we are to print replacement */ ! 299: char global; /* >0 if we are to replace globally */ ! 300: struct replstr *next; /* pointer to next record */ ! 301: } Replstr; ! 302: ! 303: ! 304: /* ! 305: * This has to be included here to insure that all of the type ! 306: * delcarations are declared for the prototypes. ! 307: */ ! 308: #include "func.h" ! 309: ! 310: ! 311: #ifndef NO_EXTERN ! 312: /* Globally Available Identifiers */ ! 313: ! 314: extern char *ar_file; ! 315: extern char *bufend; ! 316: extern char *bufstart; ! 317: extern char *bufidx; ! 318: extern char *myname; ! 319: extern int archivefd; ! 320: extern int blocking; ! 321: extern uint blocksize; ! 322: extern int gid; ! 323: extern int head_standard; ! 324: extern int ar_interface; ! 325: extern int ar_format; ! 326: extern int mask; ! 327: extern int ttyf; ! 328: extern int uid; ! 329: extern OFFSET total; ! 330: extern short areof; ! 331: extern short f_append; ! 332: extern short f_create; ! 333: extern short f_extract; ! 334: extern short f_follow_links; ! 335: extern short f_interactive; ! 336: extern short f_linksleft; ! 337: extern short f_list; ! 338: extern short f_modified; ! 339: extern short f_verbose; ! 340: extern short f_link; ! 341: extern short f_owner; ! 342: extern short f_access_time; ! 343: extern short f_pass; ! 344: extern short f_pass; ! 345: extern short f_disposition; ! 346: extern short f_reverse_match; ! 347: extern short f_mtime; ! 348: extern short f_dir_create; ! 349: extern short f_unconditional; ! 350: extern short f_newer; ! 351: extern time_t now; ! 352: extern uint arvolume; ! 353: extern int names_from_stdin; ! 354: extern Replstr *rplhead; ! 355: extern Replstr *rpltail; ! 356: extern char **n_argv; ! 357: extern int n_argc; ! 358: extern FILE *msgfile; ! 359: #endif /* NO_EXTERN */ ! 360: ! 361: extern char *optarg; ! 362: extern int optind; ! 363: extern int sys_nerr; ! 364: extern char *sys_errlist[]; ! 365: extern int errno; ! 366: ! 367: #endif /* _PAX_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.