]> git.saurik.com Git - apt.git/blame - ftparchive/contents.h
get pdiff files from the same mirror as the index
[apt.git] / ftparchive / contents.h
CommitLineData
b2e465d6
AL
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
453b82a3 12
b2e465d6
AL
13#include <apt-pkg/dirstream.h>
14
453b82a3
DK
15#include <stddef.h>
16#include <stdio.h>
17#include <string>
18
472ff00e 19class debDebFile;
88593886 20class FileFd;
472ff00e 21
b2e465d6
AL
22class 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);
88593886
DK
58 void WriteSpace(std::string &out, size_t Current, size_t Target);
59 void DoPrint(FileFd &Out,Node *Top, char *Buf);
b2e465d6
AL
60
61 public:
62
63 char *Mystrdup(const char *From);
64 void Add(const char *Dir,const char *Package);
88593886 65 void Print(FileFd &Out);
b2e465d6
AL
66
67 GenContents() : BlockList(0), StrPool(0), StrLeft(0),
68 NodePool(0), NodeLeft(0) {};
69 ~GenContents();
70};
71
72class ContentsExtract : public pkgDirStream
73{
74 public:
75
76 // The Data Block
77 char *Data;
650faab0
DK
78 unsigned long long MaxSize;
79 unsigned long long CurSize;
b2e465d6
AL
80 void AddData(const char *Text);
81
82 bool Read(debDebFile &Deb);
83
3b302846 84 virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
b2e465d6 85 void Reset() {CurSize = 0;};
650faab0 86 bool TakeContents(const void *Data,unsigned long long Length);
8f3ba4e8 87 void Add(GenContents &Contents,std::string const &Package);
b2e465d6 88
21ea1dbb
MV
89 ContentsExtract();
90 virtual ~ContentsExtract();
b2e465d6
AL
91};
92
93#endif