]> git.saurik.com Git - apt.git/blob - apt-inst/deb/debfile.h
merged from 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/database.h>
29 #include <apt-pkg/dirstream.h>
30 #include <apt-pkg/tagfile.h>
31
32 class debDebFile
33 {
34 protected:
35
36 FileFd &File;
37 ARArchive AR;
38
39 bool CheckMember(const char *Name);
40
41 public:
42
43 class ControlExtract;
44 class MemControlExtract;
45
46 bool ExtractControl(pkgDataBase &DB);
47 bool ExtractArchive(pkgDirStream &Stream);
48 pkgCache::VerIterator MergeControl(pkgDataBase &DB);
49 const ARArchive::Member *GotoMember(const char *Name);
50 inline FileFd &GetFile() {return File;};
51
52 debDebFile(FileFd &File);
53 };
54
55 class debDebFile::ControlExtract : public pkgDirStream
56 {
57 public:
58
59 virtual bool DoItem(Item &Itm,int &Fd);
60 };
61
62 class debDebFile::MemControlExtract : public pkgDirStream
63 {
64 bool IsControl;
65
66 public:
67
68 char *Control;
69 pkgTagSection Section;
70 unsigned long Length;
71 string Member;
72
73 // Members from DirStream
74 virtual bool DoItem(Item &Itm,int &Fd);
75 virtual bool Process(Item &Itm,const unsigned char *Data,
76 unsigned long Size,unsigned long Pos);
77
78
79 // Helpers
80 bool Read(debDebFile &Deb);
81 bool TakeControl(const void *Data,unsigned long Size);
82
83 MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
84 MemControlExtract(string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
85 ~MemControlExtract() {delete [] Control;};
86 };
87 /*}}}*/
88
89 #endif