summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/arid.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/util/arid.cpp b/util/arid.cpp
new file mode 100644
index 000000000..ab2bccb60
--- /dev/null
+++ b/util/arid.cpp
@@ -0,0 +1,29 @@
+#include <iostream>
+#include "minimal/mapping.h"
+
+struct ar_hdr {
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6];
+ char ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+#define ARFMAG "`\n"
+ char ar_fmag[2];
+};
+
+int main(int argc, char *argv[]) {
+ size_t size;
+ _assert(argc == 2);
+ uint8_t *data = reinterpret_cast<uint8_t *>(map(argv[1], 0, _not(size_t), &size, false));
+ data += 8;
+ uint8_t *end = data + size;
+ while (end - data >= sizeof(struct ar_hdr)) {
+ struct ar_hdr *head = reinterpret_cast<struct ar_hdr *>(data);
+ memset(head->ar_date + 1, ' ', sizeof(head->ar_date) - 1);
+ head->ar_date[0] = '0';
+ size_t length = strtoul(head->ar_size, NULL, 10);
+ data += length + sizeof(struct ar_hdr);
+ }
+ return 0;
+}