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