summaryrefslogtreecommitdiff
path: root/lib/tar/internal.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-01 13:23:36 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-01 13:23:36 +0200
commit8aea2d1dc437b5b497170ef9c1b6854aee8f5dcf (patch)
tree0999ed4664c74cf90896d8b11f7f4a9dc06e8d48 /lib/tar/internal.h
parentf0d18050d832498c8e230c04084675455fef391f (diff)
cleanup: split tar code up, remove some duplications
This commit attempts to split some of the monolitic tar parsing code up into multiple functions in seperate files. Also, some code duplication (like reading a record into memory which was implemented twice) is removed. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/internal.h')
-rw-r--r--lib/tar/internal.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/tar/internal.h b/lib/tar/internal.h
new file mode 100644
index 0000000..6596987
--- /dev/null
+++ b/lib/tar/internal.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#ifndef INTERNAL_H
+#define INTERNAL_H
+
+#include "util.h"
+#include "tar.h"
+
+#include <sys/sysmacros.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdio.h>
+
+enum {
+ PAX_SIZE = 0x001,
+ PAX_UID = 0x002,
+ PAX_GID = 0x004,
+ PAX_DEV_MAJ = 0x008,
+ PAX_DEV_MIN = 0x010,
+ PAX_NAME = 0x020,
+ PAX_SLINK_TARGET = 0x040,
+ PAX_ATIME = 0x080,
+ PAX_MTIME = 0x100,
+ PAX_CTIME = 0x200,
+ PAX_SPARSE_SIZE = 0x400,
+};
+
+enum {
+ ETV_UNKNOWN = 0,
+ ETV_V7_UNIX,
+ ETV_PRE_POSIX,
+ ETV_POSIX,
+};
+
+int read_octal(const char *str, int digits, uint64_t *out);
+
+int read_binary(const char *str, int digits, uint64_t *out);
+
+int read_number(const char *str, int digits, uint64_t *out);
+
+void write_octal(char *dst, unsigned int value, int digits);
+
+int pax_read_decimal(const char *str, uint64_t *out);
+
+void update_checksum(tar_header_t *hdr);
+
+bool is_checksum_valid(const tar_header_t *hdr);
+
+sparse_map_t *read_sparse_map(const char *line);
+
+sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr);
+
+void free_sparse_list(sparse_map_t *sparse);
+
+#endif /* INTERNAL_H */