1 | //! Archive definitions. |
2 | //! |
3 | //! These definitions are independent of read/write support, although we do implement |
4 | //! some traits useful for those. |
5 | |
6 | use crate::pod::Pod; |
7 | |
8 | /// File identification bytes stored at the beginning of the file. |
9 | pub const MAGIC: [u8; 8] = *b"!<arch> \n" ; |
10 | |
11 | /// File identification bytes at the beginning of AIX big archive. |
12 | pub const AIX_BIG_MAGIC: [u8; 8] = *b"<bigaf> \n" ; |
13 | |
14 | /// File identification bytes stored at the beginning of a thin archive. |
15 | /// |
16 | /// A thin archive only contains a symbol table and file names. |
17 | pub const THIN_MAGIC: [u8; 8] = *b"!<thin> \n" ; |
18 | |
19 | /// The terminator for each archive member header. |
20 | pub const TERMINATOR: [u8; 2] = *b"` \n" ; |
21 | |
22 | /// The header at the start of an archive member. |
23 | #[derive (Debug, Clone, Copy)] |
24 | #[repr (C)] |
25 | pub struct Header { |
26 | /// The file name. |
27 | pub name: [u8; 16], |
28 | /// File modification timestamp in decimal. |
29 | pub date: [u8; 12], |
30 | /// User ID in decimal. |
31 | pub uid: [u8; 6], |
32 | /// Group ID in decimal. |
33 | pub gid: [u8; 6], |
34 | /// File mode in octal. |
35 | pub mode: [u8; 8], |
36 | /// File size in decimal. |
37 | pub size: [u8; 10], |
38 | /// Must be equal to `TERMINATOR`. |
39 | pub terminator: [u8; 2], |
40 | } |
41 | |
42 | /// The header at the start of an AIX big archive member, without name. |
43 | #[derive (Debug, Clone, Copy)] |
44 | #[repr (C)] |
45 | pub struct AixHeader { |
46 | /// File member size in decimal. |
47 | pub size: [u8; 20], |
48 | /// Next member offset in decimal. |
49 | pub nxtmem: [u8; 20], |
50 | /// Previous member offset in decimal. |
51 | pub prvmem: [u8; 20], |
52 | /// File member date in decimal. |
53 | pub date: [u8; 12], |
54 | /// File member user id in decimal. |
55 | pub uid: [u8; 12], |
56 | /// File member group id in decimal. |
57 | pub gid: [u8; 12], |
58 | /// File member mode in octal. |
59 | pub mode: [u8; 12], |
60 | /// File member name length in decimal. |
61 | pub namlen: [u8; 4], |
62 | } |
63 | |
64 | /// The AIX big archive's fixed length header at file beginning. |
65 | #[derive (Debug, Clone, Copy)] |
66 | #[repr (C)] |
67 | pub struct AixFileHeader { |
68 | /// Archive magic string. |
69 | pub magic: [u8; 8], |
70 | /// Offset of member table. |
71 | pub memoff: [u8; 20], |
72 | /// Offset of global symbol table. |
73 | pub gstoff: [u8; 20], |
74 | /// Offset of global symbol table for 64-bit objects. |
75 | pub gst64off: [u8; 20], |
76 | /// Offset of first member. |
77 | pub fstmoff: [u8; 20], |
78 | /// Offset of last member. |
79 | pub lstmoff: [u8; 20], |
80 | /// Offset of first member on free list. |
81 | pub freeoff: [u8; 20], |
82 | } |
83 | |
84 | /// Offset of a member in an AIX big archive. |
85 | /// |
86 | /// This is used in the member index. |
87 | #[derive (Debug, Clone, Copy)] |
88 | #[repr (C)] |
89 | pub struct AixMemberOffset(pub [u8; 20]); |
90 | |
91 | unsafe_impl_pod!(Header, AixHeader, AixFileHeader, AixMemberOffset,); |
92 | |