4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
27 * Copyright (c) 1988 AT&T
46 #include <sys/types.h>
47 #include <sys/param.h>
58 #define ROUNDUP(x) (((x) + 1) & ~1)
60 #define DATESIZE 60 /* sizeof (struct ar_hdr) */
62 typedef struct arfile ARFILE
;
63 typedef ARFILE
*ARFILEP
;
66 * Per-member state, help on listhead/listend list.
69 char ar_name
[SNAME
]; /* info from archive member header */
73 unsigned long ar_mode
;
77 Elf
*ar_elf
; /* My elf descriptor */
80 size_t ar_offset
; /* The member offset */
81 unsigned char ar_flag
;
82 unsigned char ar_padding
; /* # padding bytes following data */
83 ARFILE
*ar_next
; /* Next member in linked list or NULL */
87 * Command function. There is one of these for each operation
88 * ar can perform (r, x, etc).
91 typedef void Cmd_func(struct cmd_info
*);
93 /* Command information block */
94 typedef struct cmd_info
{
95 char *arnam
; /* Archive file name */
96 int afd
; /* fd for the archive file */
97 Elf
*arf
; /* Elf descriptor for the archive */
98 char *ponam
; /* Position Name (-a, -b/-i) */
99 char **namv
; /* Member names from command line */
100 int namc
; /* # of member names in namv */
101 int opt_flgs
; /* options */
102 Cmd_func
*comfun
; /* function to carry out command */
103 int modified
; /* Set if need to write archive */
107 * options (Cmd_info opt_flgs)
109 #define a_FLAG 0x00000001
110 #define b_FLAG 0x00000002
111 #define c_FLAG 0x00000004
112 #define C_FLAG 0x00000008
113 #define d_FLAG 0x00000010
114 #define m_FLAG 0x00000020
115 #define p_FLAG 0x00000040
116 #define q_FLAG 0x00000080
117 #define r_FLAG 0x00000100
118 #define s_FLAG 0x00000200
119 #define S_FLAG 0x00000400
120 #define t_FLAG 0x00000800
121 #define T_FLAG 0x00001000
122 #define u_FLAG 0x00002000
123 #define v_FLAG 0x00004000
124 #define x_FLAG 0x00008000
125 #define z_FLAG 0x00010000
128 * Member flags (ARFILE ar_flag)
130 #define F_ELFRAW 0x01 /* ar_contents data via elf_rawfile */
131 #define F_CLASS32 0x02 /* ELFCLASS32 */
132 #define F_CLASS64 0x04 /* ELFCLASS64 */
135 * Function prototypes
145 extern ARFILE
*listhead
, *listend
;
147 extern void establish_sighandler(void (*)());
148 extern int getaf(Cmd_info
*);
149 extern ARFILE
*getfile(Cmd_info
*);
150 extern ARFILE
*newfile(void);
151 extern char *trim(char *);
152 extern void writefile(Cmd_info
*cmd_info
);