10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 58324SAli.Bahrami@Sun.COM * Common Development and Distribution License (the "License"). 68324SAli.Bahrami@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*12792SAli.Bahrami@Oracle.COM 220Sstevel@tonic-gate /* 23*12792SAli.Bahrami@Oracle.COM * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * Copyright (c) 1988 AT&T 280Sstevel@tonic-gate * All Rights Reserved 290Sstevel@tonic-gate * 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 328324SAli.Bahrami@Sun.COM #ifndef _INC_H 338324SAli.Bahrami@Sun.COM #define _INC_H 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <stdio.h> 36*12792SAli.Bahrami@Oracle.COM #include <stdarg.h> 37*12792SAli.Bahrami@Oracle.COM #include <stdlib.h> 380Sstevel@tonic-gate #include <errno.h> 390Sstevel@tonic-gate #include <ctype.h> 400Sstevel@tonic-gate #include <unistd.h> 410Sstevel@tonic-gate #include <signal.h> 420Sstevel@tonic-gate #include <sys/stat.h> 430Sstevel@tonic-gate #include <errno.h> 440Sstevel@tonic-gate #include <string.h> 450Sstevel@tonic-gate #include <fcntl.h> 46*12792SAli.Bahrami@Oracle.COM #include <sys/types.h> 47*12792SAli.Bahrami@Oracle.COM #include <sys/param.h> 480Sstevel@tonic-gate #include <time.h> 490Sstevel@tonic-gate #include <locale.h> 50*12792SAli.Bahrami@Oracle.COM #include <ar.h> 51*12792SAli.Bahrami@Oracle.COM #include <libelf.h> 52*12792SAli.Bahrami@Oracle.COM #include "sgs.h" 53*12792SAli.Bahrami@Oracle.COM #include "msg.h" 540Sstevel@tonic-gate 550Sstevel@tonic-gate #define CHUNK 500 560Sstevel@tonic-gate #define SYMCHUNK 1000 570Sstevel@tonic-gate #define SNAME 16 580Sstevel@tonic-gate #define ROUNDUP(x) (((x) + 1) & ~1) 590Sstevel@tonic-gate 600Sstevel@tonic-gate #define DATESIZE 60 /* sizeof (struct ar_hdr) */ 610Sstevel@tonic-gate 620Sstevel@tonic-gate typedef struct arfile ARFILE; 63*12792SAli.Bahrami@Oracle.COM typedef ARFILE *ARFILEP; 640Sstevel@tonic-gate 65*12792SAli.Bahrami@Oracle.COM /* 66*12792SAli.Bahrami@Oracle.COM * Per-member state, help on listhead/listend list. 67*12792SAli.Bahrami@Oracle.COM */ 68*12792SAli.Bahrami@Oracle.COM struct arfile { 69*12792SAli.Bahrami@Oracle.COM char ar_name[SNAME]; /* info from archive member header */ 70*12792SAli.Bahrami@Oracle.COM time_t ar_date; 71*12792SAli.Bahrami@Oracle.COM int ar_uid; 72*12792SAli.Bahrami@Oracle.COM int ar_gid; 730Sstevel@tonic-gate unsigned long ar_mode; 74*12792SAli.Bahrami@Oracle.COM size_t ar_size; 75*12792SAli.Bahrami@Oracle.COM char *ar_longname; 76*12792SAli.Bahrami@Oracle.COM char *ar_rawname; 77*12792SAli.Bahrami@Oracle.COM Elf *ar_elf; /* My elf descriptor */ 78*12792SAli.Bahrami@Oracle.COM char *ar_pathname; 79*12792SAli.Bahrami@Oracle.COM char *ar_contents; 80*12792SAli.Bahrami@Oracle.COM size_t ar_offset; /* The member offset */ 81*12792SAli.Bahrami@Oracle.COM unsigned char ar_flag; 82*12792SAli.Bahrami@Oracle.COM unsigned char ar_padding; /* # padding bytes following data */ 83*12792SAli.Bahrami@Oracle.COM ARFILE *ar_next; /* Next member in linked list or NULL */ 840Sstevel@tonic-gate }; 850Sstevel@tonic-gate 86*12792SAli.Bahrami@Oracle.COM /* 87*12792SAli.Bahrami@Oracle.COM * Command function. There is one of these for each operation 88*12792SAli.Bahrami@Oracle.COM * ar can perform (r, x, etc). 89*12792SAli.Bahrami@Oracle.COM */ 90*12792SAli.Bahrami@Oracle.COM struct cmd_info; 91*12792SAli.Bahrami@Oracle.COM typedef void Cmd_func(struct cmd_info *); 92*12792SAli.Bahrami@Oracle.COM 93*12792SAli.Bahrami@Oracle.COM /* Command information block */ 940Sstevel@tonic-gate typedef struct cmd_info { 95*12792SAli.Bahrami@Oracle.COM char *arnam; /* Archive file name */ 96*12792SAli.Bahrami@Oracle.COM int afd; /* fd for the archive file */ 97*12792SAli.Bahrami@Oracle.COM Elf *arf; /* Elf descriptor for the archive */ 98*12792SAli.Bahrami@Oracle.COM char *ponam; /* Position Name (-a, -b/-i) */ 99*12792SAli.Bahrami@Oracle.COM char **namv; /* Member names from command line */ 100*12792SAli.Bahrami@Oracle.COM int namc; /* # of member names in namv */ 101*12792SAli.Bahrami@Oracle.COM int opt_flgs; /* options */ 102*12792SAli.Bahrami@Oracle.COM Cmd_func *comfun; /* function to carry out command */ 103*12792SAli.Bahrami@Oracle.COM int modified; /* Set if need to write archive */ 1040Sstevel@tonic-gate } Cmd_info; 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate /* 107*12792SAli.Bahrami@Oracle.COM * options (Cmd_info opt_flgs) 1080Sstevel@tonic-gate */ 109*12792SAli.Bahrami@Oracle.COM #define a_FLAG 0x00000001 110*12792SAli.Bahrami@Oracle.COM #define b_FLAG 0x00000002 111*12792SAli.Bahrami@Oracle.COM #define c_FLAG 0x00000004 112*12792SAli.Bahrami@Oracle.COM #define C_FLAG 0x00000008 113*12792SAli.Bahrami@Oracle.COM #define d_FLAG 0x00000010 114*12792SAli.Bahrami@Oracle.COM #define m_FLAG 0x00000020 115*12792SAli.Bahrami@Oracle.COM #define p_FLAG 0x00000040 116*12792SAli.Bahrami@Oracle.COM #define q_FLAG 0x00000080 117*12792SAli.Bahrami@Oracle.COM #define r_FLAG 0x00000100 118*12792SAli.Bahrami@Oracle.COM #define s_FLAG 0x00000200 119*12792SAli.Bahrami@Oracle.COM #define S_FLAG 0x00000400 120*12792SAli.Bahrami@Oracle.COM #define t_FLAG 0x00000800 121*12792SAli.Bahrami@Oracle.COM #define T_FLAG 0x00001000 122*12792SAli.Bahrami@Oracle.COM #define u_FLAG 0x00002000 123*12792SAli.Bahrami@Oracle.COM #define v_FLAG 0x00004000 124*12792SAli.Bahrami@Oracle.COM #define x_FLAG 0x00008000 125*12792SAli.Bahrami@Oracle.COM #define z_FLAG 0x00010000 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 128*12792SAli.Bahrami@Oracle.COM * Member flags (ARFILE ar_flag) 1290Sstevel@tonic-gate */ 130*12792SAli.Bahrami@Oracle.COM #define F_ELFRAW 0x01 /* ar_contents data via elf_rawfile */ 131*12792SAli.Bahrami@Oracle.COM #define F_CLASS32 0x02 /* ELFCLASS32 */ 132*12792SAli.Bahrami@Oracle.COM #define F_CLASS64 0x04 /* ELFCLASS64 */ 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * Function prototypes 1360Sstevel@tonic-gate */ 137*12792SAli.Bahrami@Oracle.COM Cmd_func qcmd; 138*12792SAli.Bahrami@Oracle.COM Cmd_func rcmd; 139*12792SAli.Bahrami@Oracle.COM Cmd_func dcmd; 140*12792SAli.Bahrami@Oracle.COM Cmd_func xcmd; 141*12792SAli.Bahrami@Oracle.COM Cmd_func pcmd; 142*12792SAli.Bahrami@Oracle.COM Cmd_func mcmd; 143*12792SAli.Bahrami@Oracle.COM Cmd_func tcmd; 1440Sstevel@tonic-gate 145*12792SAli.Bahrami@Oracle.COM extern ARFILE *listhead, *listend; 146*12792SAli.Bahrami@Oracle.COM 147*12792SAli.Bahrami@Oracle.COM extern void establish_sighandler(void (*)()); 148*12792SAli.Bahrami@Oracle.COM extern int getaf(Cmd_info *); 149*12792SAli.Bahrami@Oracle.COM extern ARFILE *getfile(Cmd_info *); 150*12792SAli.Bahrami@Oracle.COM extern ARFILE *newfile(void); 151*12792SAli.Bahrami@Oracle.COM extern char *trim(char *); 152*12792SAli.Bahrami@Oracle.COM extern void writefile(Cmd_info *cmd_info); 153*12792SAli.Bahrami@Oracle.COM 1548324SAli.Bahrami@Sun.COM 1558324SAli.Bahrami@Sun.COM #endif /* _INC_H */ 156