cleanup, get padding and archive creation right
[unix-history] / usr / src / usr.bin / ar / archive.h
CommitLineData
ada13728
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Hugh Smith at The University of Guelph.
7 *
8 * @(#)archive.h 5.1 (Berkeley) %G%
9 */
10
11/* Ar(1) options. */
12#define AR_A 0x0001
13#define AR_B 0x0002
14#define AR_C 0x0004
15#define AR_D 0x0008
16#define AR_M 0x0010
17#define AR_O 0x0020
18#define AR_P 0x0040
19#define AR_Q 0x0080
20#define AR_R 0x0100
21#define AR_T 0x0200
22#define AR_U 0x0400
23#define AR_V 0x0800
24#define AR_X 0x1000
25extern u_int options;
26
27/* Set up file copy. */
28#define SETCF(from, fromname, to, toname, pad) { \
29 cf.rfd = from; \
30 cf.rname = fromname; \
31 cf.wfd = to; \
32 cf.wname = toname; \
33 cf.flags = pad; \
34}
35
36/* File copy structure. */
37typedef struct {
38 int rfd; /* read file descriptor */
39 char *rname; /* read name */
40 int wfd; /* write file descriptor */
41 char *wname; /* write name */
42#define RPAD 0x01 /* pad on reads */
43#define WPAD 0x02 /* pad on writes */
44 u_int flags; /* pad flags */
45} CF;
46
47/* Header structure internal format. */
48typedef struct {
49 long date; /* date */
50 long size; /* size in bytes */
51 int gid; /* group */
52 int lname; /* if long name */
53 int uid; /* owner */
54 u_short mode; /* permissions */
55 char name[MAXNAMLEN + 1]; /* name */
56} CHDR;
57
58/* Seek over the module contents; always rounds. */
59#define SKIP(fd, size, name) { \
60 if (lseek((fd), ((size) + ((size) & 1)), SEEK_CUR) == (off_t)-1) \
61 error(name); \
62}
63
64/* Print out any files that weren't in the archive. */
65#define ORPHANS { \
66 if (*argv) { \
67 eval = 1; \
68 do { \
69 (void)fprintf(stderr, \
70 "ar: %s: not found in archive.\n", *argv); \
71 } while (*++argv); \
72 } \
73}
74
75/* Header format strings. */
76#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10ld%2s"
77#define HDR2 "%-16s%-12ld%-6u%-6u%-8o%-10ld%2s"
78
79#include <stdlib.h>
80#include <string.h>