1 /* lkar.h - ar library format handling
3 Copyright (C) 2008-2012 Borut Razem, borut dot razem at siol dot net
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include <sys/types.h>
26 typedef unsigned short mode_t
;
32 #define sgetl(buf) (((((((unsigned char)(buf)[0] << 8) + (unsigned char)(buf)[1]) << 8) + (unsigned char)(buf)[2]) << 8) + (unsigned char)(buf)[3])
33 #define sputl(value, buf) ((buf)[0] = (value) >> 24, (buf)[1] = (value) >> 16, (buf)[2] = (value) >> 8, (buf)[3] = (value))
35 /* Note that the usual '\n' in magic strings may translate to different
36 characters, as allowed by ANSI. '\012' has a fixed value, and remains
37 compatible with existing BSDish archives. */
39 #define ARMAG "!<arch>\012" /* magic string */
40 #define SARMAG (sizeof (ARMAG) - 1) /* length of magic string */
42 #define ARFMAG "`\012" /* header trailer string */
44 #define AR_NAME_OFFSET 0
45 #define AR_NAME_LEN 16
47 #define AR_DATE_OFFSET 16
48 #define AR_DATE_LEN 12
50 #define AR_UID_OFFSET 28
53 #define AR_GID_OFFSET 34
56 #define AR_MODE_OFFSET 40
59 #define AR_SIZE_OFFSET 48
60 #define AR_SIZE_LEN 10
62 #define AR_FMAG_OFFSET 58
63 #define AR_FMAG_LEN (sizeof (ARFMAG) - 1)
65 #define ARHDR_LEN (AR_NAME_LEN + AR_DATE_LEN + AR_UID_LEN + AR_GID_LEN + AR_MODE_LEN + AR_SIZE_LEN + AR_FMAG_LEN)
67 #define AR_SYMBOL_TABLE_NAME "/ "
68 #define AR_STRING_TABLE_NAME "// "
70 #define AR_BSD_SYMBOL_TABLE_NAME "__.SYMDEF "
71 #define AR_BSD_SORTED_SYMBOL_TABLE_NAME "__.SYMDEF SORTED"
73 #define AR_IS_SYMBOL_TABLE(name) (0 == strcmp((name), AR_SYMBOL_TABLE_NAME))
74 #define AR_IS_STRING_TABLE(name) (0 == strcmp((name), AR_STRING_TABLE_NAME))
76 #define AR_IS_BSD_SYMBOL_TABLE(name) (0 == strcmp((name), AR_BSD_SYMBOL_TABLE_NAME) || 0 == strcmp((name), AR_BSD_SORTED_SYMBOL_TABLE_NAME))
79 struct ar_hdr
/* archive member header */
81 char ar_name
[AR_NAME_LEN
+ 1]; /* archive member name */
82 time_t ar_date
; /* archive member date */
83 uid_t ar_uid
; /* archive member user identification */
84 gid_t ar_gid
; /* archive member group identification */
85 mode_t ar_mode
; /* archive member mode (octal) */
86 size_t ar_size
; /* archive member size */