]> git.saurik.com Git - apt.git/blob - ftparchive/contents.h
Added code to allow SmartConfigure to be called mutiple times on the same package...
[apt.git] / ftparchive / contents.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: contents.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
4 /* ######################################################################
5
6 contents - Contents of archive things.
7
8 ##################################################################### */
9 /*}}}*/
10 #ifndef CONTENTS_H
11 #define CONTENTS_H
12
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <apt-pkg/debfile.h>
16 #include <apt-pkg/dirstream.h>
17
18 class GenContents
19 {
20 struct Node
21 {
22 // Binary Tree links
23 Node *BTreeLeft;
24 Node *BTreeRight;
25 Node *DirDown;
26 Node *Dups;
27 const char *Path;
28 const char *Package;
29
30 void *operator new(size_t Amount,GenContents *Owner);
31 void operator delete(void *) {};
32
33 Node() : BTreeLeft(0), BTreeRight(0), DirDown(0), Dups(0),
34 Path(0), Package(0) {};
35 };
36 friend struct Node;
37
38 struct BigBlock
39 {
40 void *Block;
41 BigBlock *Next;
42 };
43
44 Node Root;
45
46 // Big block allocation pools
47 BigBlock *BlockList;
48 char *StrPool;
49 unsigned long StrLeft;
50 Node *NodePool;
51 unsigned long NodeLeft;
52
53 Node *Grab(Node *Top,const char *Name,const char *Package);
54 void WriteSpace(FILE *Out,unsigned int Current,unsigned int Target);
55 void DoPrint(FILE *Out,Node *Top, char *Buf);
56
57 public:
58
59 char *Mystrdup(const char *From);
60 void Add(const char *Dir,const char *Package);
61 void Print(FILE *Out);
62
63 GenContents() : BlockList(0), StrPool(0), StrLeft(0),
64 NodePool(0), NodeLeft(0) {};
65 ~GenContents();
66 };
67
68 class ContentsExtract : public pkgDirStream
69 {
70 public:
71
72 // The Data Block
73 char *Data;
74 unsigned long MaxSize;
75 unsigned long CurSize;
76 void AddData(const char *Text);
77
78 bool Read(debDebFile &Deb);
79
80 virtual bool DoItem(Item &Itm,int &Fd);
81 void Reset() {CurSize = 0;};
82 bool TakeContents(const void *Data,unsigned long Length);
83 void Add(GenContents &Contents,string const &Package);
84
85 ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
86 virtual ~ContentsExtract() {delete [] Data;};
87 };
88
89 #endif