-/* $OpenBSD: pax.h,v 1.9 1997/07/23 19:15:58 kstailey Exp $ */
+/* $OpenBSD: pax.h,v 1.17 2005/11/09 19:59:06 otto Exp $ */
/* $NetBSD: pax.h,v 1.3 1995/03/21 09:07:41 cgd Exp $ */
/*-
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
/* Don't even think of changing this */
#define DEVBLK 8192 /* default read blksize for devices */
#define FILEBLK 10240 /* default read blksize for files */
-#define PAXPATHLEN 3072 /* maximium path length for pax. MUST be */
+#define PAXPATHLEN 3072 /* maximum path length for pax. MUST be */
/* longer than the system MAXPATHLEN */
/*
#define DEFOP LIST /* if no flags default is to LIST */
/*
- * Device type of the current archive volume
+ * Device type of the current archive volume
*/
#define ISREG 0 /* regular file */
#define ISCHR 1 /* character device */
#define ISTAPE 3 /* tape drive */
#define ISPIPE 4 /* pipe/socket */
+/*
+ * Pattern matching structure
+ *
+ * Used to store command line patterns
+ */
+typedef struct pattern {
+ char *pstr; /* pattern to match, user supplied */
+ char *pend; /* end of a prefix match */
+ char *chdname; /* the dir to change to if not NULL. */
+ int plen; /* length of pstr */
+ int flgs; /* processing/state flags */
+#define MTCH 0x1 /* pattern has been matched */
+#define DIR_MTCH 0x2 /* pattern matched a directory */
+ struct pattern *fow; /* next pattern */
+} PATTERN;
+
+/*
+ * General Archive Structure (used internal to pax)
+ *
+ * This structure is used to pass information about archive members between
+ * the format independent routines and the format specific routines. When
+ * new archive formats are added, they must accept requests and supply info
+ * encoded in a structure of this type. The name fields are declared statically
+ * here, as there is only ONE of these floating around, size is not a major
+ * consideration. Eventually converting the name fields to a dynamic length
+ * may be required if and when the supporting operating system removes all
+ * restrictions on the length of pathnames it will resolve.
+ */
+typedef struct {
+ int nlen; /* file name length */
+ char name[PAXPATHLEN+1]; /* file name */
+ int ln_nlen; /* link name length */
+ char ln_name[PAXPATHLEN+1]; /* name to link to (if any) */
+ char *org_name; /* orig name in file system */
+ PATTERN *pat; /* ptr to pattern match (if any) */
+ struct stat sb; /* stat buffer see stat(2) */
+ off_t pad; /* bytes of padding after file xfer */
+ off_t skip; /* bytes of real data after header */
+ /* IMPORTANT. The st_size field does */
+ /* not always indicate the amount of */
+ /* data following the header. */
+ u_int32_t crc; /* file crc */
+ int type; /* type of file node */
+#define PAX_DIR 1 /* directory */
+#define PAX_CHR 2 /* character device */
+#define PAX_BLK 3 /* block device */
+#define PAX_REG 4 /* regular file */
+#define PAX_SLK 5 /* symbolic link */
+#define PAX_SCK 6 /* socket */
+#define PAX_FIF 7 /* fifo */
+#define PAX_HLK 8 /* hard link */
+#define PAX_HRG 9 /* hard link to a regular file */
+#define PAX_CTG 10 /* high performance file */
+#define PAX_GLL 11 /* GNU long symlink */
+#define PAX_GLF 12 /* GNU long file */
+} ARCHD;
+
/*
* Format Specific Routine Table
*
* The format specific routine table allows new archive formats to be quickly
* added. Overall pax operation is independent of the actual format used to
- * form the archive. Only those routines which deal directly with the archive
- * are tailored to the oddities of the specifc format. All other routines are
+ * form the archive. Only those routines which deal directly with the archive
+ * are tailored to the oddities of the specific format. All other routines are
* independent of the archive format. Data flow in and out of the format
* dependent routines pass pointers to ARCHD structure (described below).
*/
int hlk; /* does archive store hard links info? if */
/* not, we do not bother to look for them */
/* during archive write operations */
- int blkalgn; /* writes must be aligned to blkalgn boundry */
+ int blkalgn; /* writes must be aligned to blkalgn boundary */
int inhead; /* is the trailer encoded in a valid header? */
/* if not, trailers are assumed to be found */
/* in invalid headers (i.e like tar) */
- int (*id)(); /* checks if a buffer is a valid header */
- /* returns 1 if it is, o.w. returns a 0 */
- int (*st_rd)(); /* initialize routine for read. so format */
+ int (*id)(char *, /* checks if a buffer is a valid header */
+ int); /* returns 1 if it is, o.w. returns a 0 */
+ int (*st_rd)(void); /* initialize routine for read. so format */
/* can set up tables etc before it starts */
/* reading an archive */
- int (*rd)(); /* read header routine. passed a pointer to */
- /* ARCHD. It must extract the info from the */
+ int (*rd)(ARCHD *, /* read header routine. passed a pointer to */
+ char *); /* ARCHD. It must extract the info from the */
/* format and store it in the ARCHD struct. */
/* This routine is expected to fill all the */
/* fields in the ARCHD (including stat buf) */
/* padding and the number of bytes of data */
/* which follow the header. This info is */
/* used skip to the next file header */
- off_t (*end_rd)(); /* read cleanup. Allows format to clean up */
+ off_t (*end_rd)(void); /* read cleanup. Allows format to clean up */
/* and MUST RETURN THE LENGTH OF THE TRAILER */
/* RECORD (so append knows how many bytes */
/* to move back to rewrite the trailer) */
- int (*st_wr)(); /* initialize routine for write operations */
- int (*wr)(); /* write archive header. Passed an ARCHD */
+ int (*st_wr)(void); /* initialize routine for write operations */
+ int (*wr)(ARCHD *); /* write archive header. Passed an ARCHD */
/* filled with the specs on the next file to */
/* archived. Returns a 1 if no file data is */
/* is to be stored; 0 if file data is to be */
/* the proper padding can be added after */
/* file data. This routine must NEVER write */
/* a flawed archive header. */
- int (*end_wr)(); /* end write. write the trailer and do any */
+ int (*end_wr)(void); /* end write. write the trailer and do any */
/* other format specific functions needed */
- /* at the ecnd of a archive write */
- int (*trail)(); /* returns 0 if a valid trailer, -1 if not */
- /* For formats which encode the trailer */
- /* outside of a valid header, a return value */
+ /* at the end of an archive write */
+ int (*trail)(ARCHD *, /* returns 0 if a valid trailer, -1 if not */
+ char *, int, /* For formats which encode the trailer */
+ int *); /* outside of a valid header, a return value */
/* of 1 indicates that the block passed to */
/* it can never contain a valid header (skip */
/* this block, no point in looking at it) */
/* CAUTION: parameters to this function are */
/* different for trailers inside or outside */
/* of headers. See get_head() for details */
- int (*rd_data)(); /* read/process file data from the archive */
- int (*wr_data)(); /* write/process file data to the archive */
- int (*options)(); /* process format specific options (-o) */
+ int (*rd_data)(ARCHD *, /* read/process file data from the archive */
+ int, off_t *);
+ int (*wr_data)(ARCHD *, /* write/process file data to the archive */
+ int, off_t *);
+ int (*options)(void); /* process format specific options (-o) */
} FSUB;
-/*
- * Pattern matching structure
- *
- * Used to store command line patterns
- */
-typedef struct pattern {
- char *pstr; /* pattern to match, user supplied */
- char *pend; /* end of a prefix match */
- char *chdname; /* the dir to change to if not NULL. */
- int plen; /* length of pstr */
- int flgs; /* processing/state flags */
-#define MTCH 0x1 /* pattern has been matched */
-#define DIR_MTCH 0x2 /* pattern matched a directory */
- struct pattern *fow; /* next pattern */
-} PATTERN;
-
-/*
- * General Archive Structure (used internal to pax)
- *
- * This structure is used to pass information about archive members between
- * the format independent routines and the format specific routines. When
- * new archive formats are added, they must accept requests and supply info
- * encoded in a structure of this type. The name fields are declared statically
- * here, as there is only ONE of these floating around, size is not a major
- * consideration. Eventually converting the name fields to a dynamic length
- * may be required if and when the supporting operating system removes all
- * restrictions on the length of pathnames it will resolve.
- */
-typedef struct {
- int nlen; /* file name length */
- char name[PAXPATHLEN+1]; /* file name */
- int ln_nlen; /* link name length */
- char ln_name[PAXPATHLEN+1]; /* name to link to (if any) */
- char *org_name; /* orig name in file system */
- PATTERN *pat; /* ptr to pattern match (if any) */
- struct stat sb; /* stat buffer see stat(2) */
- off_t pad; /* bytes of padding after file xfer */
- off_t skip; /* bytes of real data after header */
- /* IMPORTANT. The st_size field does */
- /* not always indicate the amount of */
- /* data following the header. */
- u_long crc; /* file crc */
- int type; /* type of file node */
-#define PAX_DIR 1 /* directory */
-#define PAX_CHR 2 /* character device */
-#define PAX_BLK 3 /* block device */
-#define PAX_REG 4 /* regular file */
-#define PAX_SLK 5 /* symbolic link */
-#define PAX_SCK 6 /* socket */
-#define PAX_FIF 7 /* fifo */
-#define PAX_HLK 8 /* hard link */
-#define PAX_HRG 9 /* hard link to a regular file */
-#define PAX_CTG 10 /* high performance file */
-} ARCHD;
-
/*
* Format Specific Options List
*
* General Macros
*/
#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define MAJOR(x) major(x)
#define MINOR(x) minor(x)
/*
* General Defines
*/
-#define HEX 16
-#define OCT 8
-#define _PAX_ 1
+#define HEX 16
+#define OCT 8
+#define _PAX_ 1
+#define _TFILE_BASE "paxXXXXXXXXXX"
+
+/* hack since we're pulling routines in from OpenBSD library to this dir */
+size_t strlcpy(char *, const char *, size_t);
+char * vis(char *, int, int, int);
+