]>
Commit | Line | Data |
---|---|---|
756bdb9f JF |
1 | #include <iostream> |
2 | #include "minimal/mapping.h" | |
3 | ||
4 | struct ar_hdr { | |
5 | char ar_name[16]; | |
6 | char ar_date[12]; | |
7 | char ar_uid[6]; | |
8 | char ar_gid[6]; | |
9 | char ar_mode[8]; | |
10 | char ar_size[10]; | |
11 | #define ARFMAG "`\n" | |
12 | char ar_fmag[2]; | |
13 | }; | |
14 | ||
15 | int main(int argc, char *argv[]) { | |
16 | size_t size; | |
17 | _assert(argc == 2); | |
18 | uint8_t *data = reinterpret_cast<uint8_t *>(map(argv[1], 0, _not(size_t), &size, false)); | |
19 | data += 8; | |
20 | uint8_t *end = data + size; | |
21 | while (end - data >= sizeof(struct ar_hdr)) { | |
22 | struct ar_hdr *head = reinterpret_cast<struct ar_hdr *>(data); | |
23 | memset(head->ar_date + 1, ' ', sizeof(head->ar_date) - 1); | |
24 | head->ar_date[0] = '0'; | |
25 | size_t length = strtoul(head->ar_size, NULL, 10); | |
26 | data += length + sizeof(struct ar_hdr); | |
27 | } | |
28 | return 0; | |
29 | } |