]> git.saurik.com Git - apt.git/blob - apt-inst/deb/debfile.h
Merge branch 'debian/sid' of ssh://git.debian.org/git/apt/apt into debian/sid
[apt.git] / apt-inst / deb / debfile.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: debfile.h,v 1.2 2001/02/20 07:03:17 jgg Exp $
4 /* ######################################################################
5
6 Debian Archive File (.deb)
7
8 This Class handles all the operations performed directly on .deb
9 files. It makes use of the AR and TAR classes to give the necessary
10 external interface.
11
12 There are only two things that can be done with a raw package,
13 extract it's control information and extract the contents itself.
14
15 This should probably subclass an as-yet unwritten super class to
16 produce a generic archive mechanism.
17
18 The memory control file extractor is useful to extract a single file
19 into memory from the control.tar.gz
20
21 ##################################################################### */
22 /*}}}*/
23 #ifndef PKGLIB_DEBFILE_H
24 #define PKGLIB_DEBFILE_H
25
26
27 #include <apt-pkg/arfile.h>
28 #include <apt-pkg/dirstream.h>
29 #include <apt-pkg/tagfile.h>
30 #include <apt-pkg/pkgcache.h>
31
32 #ifndef APT_8_CLEANER_HEADERS
33 #include <apt-pkg/md5.h>
34 #endif
35
36 class FileFd;
37
38 class debDebFile
39 {
40 protected:
41
42 FileFd &File;
43 ARArchive AR;
44
45 bool CheckMember(const char *Name);
46
47 public:
48 class ControlExtract;
49 class MemControlExtract;
50
51 bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
52 bool ExtractArchive(pkgDirStream &Stream);
53 const ARArchive::Member *GotoMember(const char *Name);
54 inline FileFd &GetFile() {return File;};
55
56 debDebFile(FileFd &File);
57 };
58
59 class debDebFile::ControlExtract : public pkgDirStream
60 {
61 public:
62
63 virtual bool DoItem(Item &Itm,int &Fd);
64 };
65
66 class debDebFile::MemControlExtract : public pkgDirStream
67 {
68 bool IsControl;
69
70 public:
71
72 char *Control;
73 pkgTagSection Section;
74 unsigned long Length;
75 std::string Member;
76
77 // Members from DirStream
78 virtual bool DoItem(Item &Itm,int &Fd);
79 virtual bool Process(Item &Itm,const unsigned char *Data,
80 unsigned long Size,unsigned long Pos);
81
82
83 // Helpers
84 bool Read(debDebFile &Deb);
85 bool TakeControl(const void *Data,unsigned long Size);
86
87 MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
88 MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
89 ~MemControlExtract() {delete [] Control;};
90 };
91 /*}}}*/
92
93 #endif