]> git.saurik.com Git - ldid.git/blame - arid.cpp
Checkpointing work on -n and -w before adding MH_DYLDLINK.
[ldid.git] / arid.cpp
CommitLineData
756bdb9f 1#include <iostream>
e067acdc 2#include <string.h>
756bdb9f
JF
3#include "minimal/mapping.h"
4
5struct ar_hdr {
6 char ar_name[16];
7 char ar_date[12];
8 char ar_uid[6];
9 char ar_gid[6];
10 char ar_mode[8];
11 char ar_size[10];
12#define ARFMAG "`\n"
13 char ar_fmag[2];
14};
15
16int main(int argc, char *argv[]) {
17 size_t size;
18 _assert(argc == 2);
19 uint8_t *data = reinterpret_cast<uint8_t *>(map(argv[1], 0, _not(size_t), &size, false));
20 data += 8;
21 uint8_t *end = data + size;
22 while (end - data >= sizeof(struct ar_hdr)) {
23 struct ar_hdr *head = reinterpret_cast<struct ar_hdr *>(data);
24 memset(head->ar_date + 1, ' ', sizeof(head->ar_date) - 1);
25 head->ar_date[0] = '0';
26 size_t length = strtoul(head->ar_size, NULL, 10);
27 data += length + sizeof(struct ar_hdr);
28 }
29 return 0;
30}