]> git.saurik.com Git - apt.git/blob - ftparchive/contents.h
cleanup the hash iteration. unfortunately there is no 1:1 mapping from Hashes::Suppor...
[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/dirstream.h>
16
17 class debDebFile;
18
19 class GenContents
20 {
21 struct Node
22 {
23 // Binary Tree links
24 Node *BTreeLeft;
25 Node *BTreeRight;
26 Node *DirDown;
27 Node *Dups;
28 const char *Path;
29 const char *Package;
30
31 void *operator new(size_t Amount,GenContents *Owner);
32 void operator delete(void *) {};
33
34 Node() : BTreeLeft(0), BTreeRight(0), DirDown(0), Dups(0),
35 Path(0), Package(0) {};
36 };
37 friend struct Node;
38
39 struct BigBlock
40 {
41 void *Block;
42 BigBlock *Next;
43 };
44
45 Node Root;
46
47 // Big block allocation pools
48 BigBlock *BlockList;
49 char *StrPool;
50 unsigned long StrLeft;
51 Node *NodePool;
52 unsigned long NodeLeft;
53
54 Node *Grab(Node *Top,const char *Name,const char *Package);
55 void WriteSpace(FILE *Out,unsigned int Current,unsigned int Target);
56 void DoPrint(FILE *Out,Node *Top, char *Buf);
57
58 public:
59
60 char *Mystrdup(const char *From);
61 void Add(const char *Dir,const char *Package);
62 void Print(FILE *Out);
63
64 GenContents() : BlockList(0), StrPool(0), StrLeft(0),
65 NodePool(0), NodeLeft(0) {};
66 ~GenContents();
67 };
68
69 class ContentsExtract : public pkgDirStream
70 {
71 public:
72
73 // The Data Block
74 char *Data;
75 unsigned long long MaxSize;
76 unsigned long long CurSize;
77 void AddData(const char *Text);
78
79 bool Read(debDebFile &Deb);
80
81 virtual bool DoItem(Item &Itm,int &Fd);
82 void Reset() {CurSize = 0;};
83 bool TakeContents(const void *Data,unsigned long long Length);
84 void Add(GenContents &Contents,std::string const &Package);
85
86 ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
87 virtual ~ContentsExtract() {delete [] Data;};
88 };
89
90 #endif