summaryrefslogtreecommitdiff
path: root/util/ldid-xerub/arid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'util/ldid-xerub/arid.cpp')
-rw-r--r--util/ldid-xerub/arid.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/util/ldid-xerub/arid.cpp b/util/ldid-xerub/arid.cpp
new file mode 100644
index 000000000..99b4ae85b
--- /dev/null
+++ b/util/ldid-xerub/arid.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+#include <string.h>
+#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;
+}