2 * Header file for public domain tar (tape archive) program.
4 * @(#)tar.h 1.20 86/10/29 Public Domain.
6 * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
8 * $FreeBSD$ # checkin only
12 * Kludge for handling systems that can't cope with multiple
13 * external definitions of a variable. In ONE routine (tar.c),
14 * we #define TAR_EXTERN to null; here, we set it to "extern" if
15 * it is not already set.
18 #define TAR_EXTERN extern
22 * Header block on tape.
24 * I'm going to use traditional DP naming conventions here.
25 * A "block" is a big chunk of stuff that we do I/O on.
26 * A "record" is a piece of info that we care about.
27 * Typically many "record"s fit into a "block".
29 #define RECORDSIZE 512
35 char charptr[RECORDSIZE];
45 char linkname[NAMSIZ];
54 /* The checksum field is filled with this while the checksum is computed. */
55 #define CHKBLANKS " " /* 8 blanks, no null */
57 /* The magic field is filled with this if uname and gname are valid. */
58 #define TMAGIC "ustar " /* 7 chars and a null */
60 /* The linkflag defines the type of file */
61 #define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */
62 #define LF_NORMAL '0' /* Normal disk file */
63 #define LF_LINK '1' /* Link to previously dumped file */
64 #define LF_SYMLINK '2' /* Symbolic link */
65 #define LF_CHR '3' /* Character special file */
66 #define LF_BLK '4' /* Block special file */
67 #define LF_DIR '5' /* Directory */
68 #define LF_FIFO '6' /* FIFO special file */
69 #define LF_CONTIG '7' /* Contiguous file */
70 /* Further link types may be defined later. */
73 * Exit codes from the "tar" program
75 #define EX_SUCCESS 0 /* success! */
76 #define EX_ARGSBAD 1 /* invalid args */
77 #define EX_BADFILE 2 /* invalid filename */
78 #define EX_BADARCH 3 /* bad archive */
79 #define EX_SYSTEM 4 /* system gave unexpected error */
85 TAR_EXTERN union record *ar_block; /* Start of block of archive */
86 TAR_EXTERN union record *ar_record; /* Current record of archive */
87 TAR_EXTERN union record *ar_last; /* Last+1 record of archive block */
88 TAR_EXTERN char ar_reading; /* 0 writing, !0 reading archive */
89 TAR_EXTERN int blocking; /* Size of each block, in records */
90 TAR_EXTERN int blocksize; /* Size of each block, in bytes */
91 TAR_EXTERN char *ar_file; /* File containing archive */
92 TAR_EXTERN char *name_file; /* File containing names to work on */
93 TAR_EXTERN char *tar; /* Name of this program */
96 * Flags from the command line
98 TAR_EXTERN char f_reblock; /* -B */
99 TAR_EXTERN char f_create; /* -c */
100 TAR_EXTERN char f_debug; /* -d */
101 TAR_EXTERN char f_sayblock; /* -D */
102 TAR_EXTERN char f_follow_links; /* -h */
103 TAR_EXTERN char f_ignorez; /* -i */
104 TAR_EXTERN char f_keep; /* -k */
105 TAR_EXTERN char f_modified; /* -m */
106 TAR_EXTERN char f_oldarch; /* -o */
107 TAR_EXTERN char f_use_protection; /* -p */
108 TAR_EXTERN char f_sorted_names; /* -s */
109 TAR_EXTERN char f_list; /* -t */
110 TAR_EXTERN char f_namefile; /* -T */
111 TAR_EXTERN char f_verbose; /* -v */
112 TAR_EXTERN char f_extract; /* -x */
113 TAR_EXTERN char f_compress; /* -z */
116 * We now default to Unix Standard format rather than 4.2BSD tar format.
117 * The code can actually produce all three:
118 * f_standard ANSI standard
121 * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
122 * The only advantage to the "neither" option is that we can cmp(1) our
123 * output to the output of 4.2BSD tar, for debugging.
125 #define f_standard (!f_oldarch)
128 * Structure for keeping track of filenames and lists thereof.
137 TAR_EXTERN struct name *namelist; /* Points to first name in list */
138 TAR_EXTERN struct name *namelast; /* Points to last name in list */
140 TAR_EXTERN int archive; /* File descriptor for archive file */
141 TAR_EXTERN int errors; /* # of files in error */
145 * Due to the next struct declaration, each routine that includes
146 * "tar.h" must also include <sys/types.h>. I tried to make it automatic,
147 * but System V has no defines in <sys/types.h>, so there is no way of
148 * knowing when it has been included. In addition, it cannot be included
149 * twice, but must be included exactly once. Argghh!
151 * Thanks, typedef. Thanks, USG.
161 TAR_EXTERN struct link *linklist; /* Points to first link in list */
165 * Error recovery stuff
167 TAR_EXTERN char read_error_flag;
171 * Declarations of functions available to the world.
174 union record *findrec();
176 union record *endofrecs();
178 #define annorec(stream, msg) anno(stream, msg, 0) /* Cur rec */
179 #define annofile(stream, msg) anno(stream, msg, 1) /* Saved rec */