summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/debfile.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/deb/debfile.h
parent7f0508ecc442705ac9fcbc3c2b5ac74ead18fff8 (diff)
parent6089a4b17c61ef30b2efc00e270b0907f51f352a (diff)
Merge branch 'pu/merge-libraries'
Diffstat (limited to 'apt-pkg/deb/debfile.h')
-rw-r--r--apt-pkg/deb/debfile.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/apt-pkg/deb/debfile.h b/apt-pkg/deb/debfile.h
new file mode 100644
index 000000000..21c59a567
--- /dev/null
+++ b/apt-pkg/deb/debfile.h
@@ -0,0 +1,95 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Debian Archive File (.deb)
+
+ This Class handles all the operations performed directly on .deb
+ files. It makes use of the AR and TAR classes to give the necessary
+ external interface.
+
+ There are only two things that can be done with a raw package,
+ extract it's control information and extract the contents itself.
+
+ This should probably subclass an as-yet unwritten super class to
+ produce a generic archive mechanism.
+
+ The memory control file extractor is useful to extract a single file
+ into memory from the control.tar.gz
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef PKGLIB_DEBFILE_H
+#define PKGLIB_DEBFILE_H
+
+#include <apt-pkg/arfile.h>
+#include <apt-pkg/dirstream.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/tagfile.h>
+
+#include <string>
+
+#ifndef APT_8_CLEANER_HEADERS
+#include <apt-pkg/md5.h>
+#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/pkgcache.h>
+#endif
+
+class FileFd;
+
+class debDebFile
+{
+ protected:
+
+ FileFd &File;
+ ARArchive AR;
+
+ bool CheckMember(const char *Name);
+
+ public:
+ class ControlExtract;
+ class MemControlExtract;
+
+ bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
+ bool ExtractArchive(pkgDirStream &Stream);
+ const ARArchive::Member *GotoMember(const char *Name);
+ inline FileFd &GetFile() {return File;};
+
+ explicit debDebFile(FileFd &File);
+};
+
+class debDebFile::ControlExtract : public pkgDirStream
+{
+ public:
+
+ virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
+};
+
+class debDebFile::MemControlExtract : public pkgDirStream
+{
+ bool IsControl;
+
+ public:
+
+ char *Control;
+ pkgTagSection Section;
+ unsigned long Length;
+ std::string Member;
+
+ // Members from DirStream
+ virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
+ virtual bool Process(Item &Itm,const unsigned char *Data,
+ unsigned long long Size,unsigned long long Pos) APT_OVERRIDE;
+
+ // Helpers
+ bool Read(debDebFile &Deb);
+ bool TakeControl(const void *Data,unsigned long long Size);
+
+ MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
+ explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
+ ~MemControlExtract() {delete [] Control;};
+};
+ /*}}}*/
+
+#endif