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