summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/arfile.h
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-05-06 13:42:03 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2019-05-06 13:42:03 +0200
commitdb36c35a351a76825ae00628b74c160bc418683c (patch)
treeb0f31e19e45775f9a0880c0d4801e87077696036 /apt-pkg/contrib/arfile.h
parent7f0508ecc442705ac9fcbc3c2b5ac74ead18fff8 (diff)
parent6089a4b17c61ef30b2efc00e270b0907f51f352a (diff)
Merge branch 'pu/merge-libraries'
Diffstat (limited to 'apt-pkg/contrib/arfile.h')
-rw-r--r--apt-pkg/contrib/arfile.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/apt-pkg/contrib/arfile.h b/apt-pkg/contrib/arfile.h
new file mode 100644
index 000000000..cf454941e
--- /dev/null
+++ b/apt-pkg/contrib/arfile.h
@@ -0,0 +1,69 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ AR File - Handle an 'AR' archive
+
+ This is a reader for the usual 4.4 BSD AR format. It allows raw
+ stream access to a single member at a time. Basically all this class
+ provides is header parsing and verification. It is up to the client
+ to correctly make use of the stream start/stop points.
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef PKGLIB_ARFILE_H
+#define PKGLIB_ARFILE_H
+
+#include <apt-pkg/macros.h>
+#include <string>
+#ifndef APT_8_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#endif
+
+class FileFd;
+
+class ARArchive
+{
+ struct MemberHeader;
+ public:
+ struct Member;
+
+ protected:
+
+ // Linked list of members
+ Member *List;
+
+ bool LoadHeaders();
+
+ public:
+
+ // The stream file
+ FileFd &File;
+
+ // Locate a member by name
+ const Member *FindMember(const char *Name) const;
+ inline Member *Members() { return List; }
+
+ explicit ARArchive(FileFd &File);
+ ~ARArchive();
+};
+
+// A member of the archive
+struct ARArchive::Member
+{
+ // Fields from the header
+ std::string Name;
+ unsigned long MTime;
+ unsigned long UID;
+ unsigned long GID;
+ unsigned long Mode;
+ unsigned long long Size;
+
+ // Location of the data.
+ unsigned long long Start;
+ Member *Next;
+
+ Member() : Start(0), Next(0) {};
+};
+
+#endif