1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26 /* 27 * Copyright (c) 1988 AT&T 28 * All Rights Reserved 29 * 30 */ 31 32 #ifndef _INC_H 33 #define _INC_H 34 35 #include <stdio.h> 36 #include <stdarg.h> 37 #include <stdlib.h> 38 #include <errno.h> 39 #include <ctype.h> 40 #include <unistd.h> 41 #include <signal.h> 42 #include <sys/stat.h> 43 #include <errno.h> 44 #include <string.h> 45 #include <fcntl.h> 46 #include <sys/types.h> 47 #include <sys/param.h> 48 #include <time.h> 49 #include <locale.h> 50 #include <ar.h> 51 #include <libelf.h> 52 #include "sgs.h" 53 #include "msg.h" 54 55 #define CHUNK 500 56 #define SYMCHUNK 1000 57 #define SNAME 16 58 #define ROUNDUP(x) (((x) + 1) & ~1) 59 60 #define DATESIZE 60 /* sizeof (struct ar_hdr) */ 61 62 typedef struct arfile ARFILE; 63 typedef ARFILE *ARFILEP; 64 65 /* 66 * Per-member state, help on listhead/listend list. 67 */ 68 struct arfile { 69 char ar_name[SNAME]; /* info from archive member header */ 70 time_t ar_date; 71 int ar_uid; 72 int ar_gid; 73 unsigned long ar_mode; 74 size_t ar_size; 75 char *ar_longname; 76 char *ar_rawname; 77 Elf *ar_elf; /* My elf descriptor */ 78 char *ar_pathname; 79 char *ar_contents; 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 */ 84 }; 85 86 /* 87 * Command function. There is one of these for each operation 88 * ar can perform (r, x, etc). 89 */ 90 struct cmd_info; 91 typedef void Cmd_func(struct cmd_info *); 92 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 */ 104 } Cmd_info; 105 106 /* 107 * options (Cmd_info opt_flgs) 108 */ 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 126 127 /* 128 * Member flags (ARFILE ar_flag) 129 */ 130 #define F_ELFRAW 0x01 /* ar_contents data via elf_rawfile */ 131 #define F_CLASS32 0x02 /* ELFCLASS32 */ 132 #define F_CLASS64 0x04 /* ELFCLASS64 */ 133 134 /* 135 * Function prototypes 136 */ 137 Cmd_func qcmd; 138 Cmd_func rcmd; 139 Cmd_func dcmd; 140 Cmd_func xcmd; 141 Cmd_func pcmd; 142 Cmd_func mcmd; 143 Cmd_func tcmd; 144 145 extern ARFILE *listhead, *listend; 146 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); 153 154 155 #endif /* _INC_H */ 156