* as/asranlib/Makefile.in, as/asranlib/asranlib.dsp,
[fw/sdcc] / as / link / lkar.h
1 /* lkar.h - ar library format handling
2
3    Copyright (C) 2008-2009 Borut Razem, borut dot razem at siol dot net
4
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 2, or (at your option) any
8 later version.
9
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.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19 #ifndef __LKAR_H
20 #define __LKAR_H
21
22 #include <sys/types.h>
23 #include <string.h>
24
25
26 #ifdef _WIN32
27 typedef unsigned short mode_t;
28 typedef short uid_t;
29 typedef short gid_t;
30 typedef _off_t off_t;
31 #endif
32
33 #ifdef WORDS_BIGENDIAN
34 #define sgetl(buf)  (((((((unsigned char)(buf)[3] << 8) + (unsigned char)(buf)[2]) << 8) + (unsigned char)(buf)[1]) << 8) + (unsigned char)(buf)[0])
35 #define sputl(value, buf)  ((buf)[3] = ((value) >> 24, (buf)[2] = (value) >> 16, (buf)[1] = (value) >> 8, (buf)[0] = (value))
36 #else
37 #define sgetl(buf)  (((((((unsigned char)(buf)[0] << 8) + (unsigned char)(buf)[1]) << 8) + (unsigned char)(buf)[2]) << 8) + (unsigned char)(buf)[3])
38 #define sputl(value, buf)  ((buf)[0] = (value) >> 24, (buf)[1] = (value) >> 16, (buf)[2] = (value) >> 8, (buf)[3] = (value))
39 #endif
40
41 #define ARMAG   "!<arch>\n"           /* magic string */
42 #define SARMAG  (sizeof (ARMAG) - 1)  /* length of magic string */
43
44 #define ARFMAG  "`\n"                 /* header trailer string */
45
46 #define AR_NAME_OFFSET  0
47 #define AR_NAME_LEN     16
48
49 #define AR_DATE_OFFSET  16
50 #define AR_DATE_LEN     12
51
52 #define AR_UID_OFFSET   28
53 #define AR_UID_LEN      6
54
55 #define AR_GID_OFFSET   34
56 #define AR_GID_LEN      6
57
58 #define AR_MODE_OFFSET  40
59 #define AR_MODE_LEN     8
60
61 #define AR_SIZE_OFFSET  48
62 #define AR_SIZE_LEN     10
63
64 #define AR_FMAG_OFFSET  58
65 #define AR_FMAG_LEN     (sizeof (ARFMAG) - 1)
66
67 #define ARHDR_LEN (AR_NAME_LEN + AR_DATE_LEN + AR_UID_LEN + AR_GID_LEN + AR_MODE_LEN + AR_SIZE_LEN + AR_FMAG_LEN)
68
69 #define AR_SYMBOL_TABLE_NAME "/               "
70 #define AR_STRING_TABLE_NAME "//              "
71
72 #define AR_IS_SYMBOL_TABLE(hdr) (0 == strcmp((hdr).ar_name, AR_SYMBOL_TABLE_NAME))
73 #define AR_IS_STRING_TABLE(hdr) (0 == strcmp((hdr).ar_name, AR_STRING_TABLE_NAME))
74
75
76 struct ar_hdr                     /* archive member header */
77 {
78   char ar_name[AR_NAME_LEN + 1];  /* archive member name */
79   time_t ar_date;                 /* archive member date */
80   uid_t ar_uid;                   /* archive member user identification */
81   gid_t ar_gid;                   /* archive member group identification */
82   mode_t ar_mode;                 /* archive member mode (octal) */
83   off_t ar_size;                  /* archive member size */
84 };
85
86 #endif /* __LKAR_H */