cleanup headers and especially #includes everywhere
[ntk/apt.git] / apt-inst / deb / debfile.h
CommitLineData
b2e465d6
AL
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
b2e465d6
AL
26
27#include <apt-pkg/arfile.h>
b2e465d6
AL
28#include <apt-pkg/dirstream.h>
29#include <apt-pkg/tagfile.h>
453b82a3
DK
30
31#include <string>
472ff00e 32
4e1c86a6
DK
33#ifndef APT_8_CLEANER_HEADERS
34#include <apt-pkg/md5.h>
35#endif
453b82a3
DK
36#ifndef APT_10_CLEANER_HEADERS
37#include <apt-pkg/pkgcache.h>
38#endif
4e1c86a6 39
472ff00e 40class FileFd;
b2e465d6
AL
41
42class debDebFile
43{
44 protected:
45
46 FileFd &File;
47 ARArchive AR;
48
49 bool CheckMember(const char *Name);
50
51 public:
b2e465d6
AL
52 class ControlExtract;
53 class MemControlExtract;
9c257550 54
50b942e9 55 bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
b2e465d6 56 bool ExtractArchive(pkgDirStream &Stream);
b2e465d6
AL
57 const ARArchive::Member *GotoMember(const char *Name);
58 inline FileFd &GetFile() {return File;};
59
60 debDebFile(FileFd &File);
61};
62
63class debDebFile::ControlExtract : public pkgDirStream
64{
65 public:
66
67 virtual bool DoItem(Item &Itm,int &Fd);
68};
69
70class debDebFile::MemControlExtract : public pkgDirStream
71{
72 bool IsControl;
73
74 public:
75
76 char *Control;
77 pkgTagSection Section;
78 unsigned long Length;
8f3ba4e8 79 std::string Member;
b2e465d6
AL
80
81 // Members from DirStream
82 virtual bool DoItem(Item &Itm,int &Fd);
83 virtual bool Process(Item &Itm,const unsigned char *Data,
84 unsigned long Size,unsigned long Pos);
85
86
87 // Helpers
88 bool Read(debDebFile &Deb);
89 bool TakeControl(const void *Data,unsigned long Size);
90
91 MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
8f3ba4e8 92 MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
b2e465d6
AL
93 ~MemControlExtract() {delete [] Control;};
94};
95 /*}}}*/
96
97#endif