]> git.saurik.com Git - apt.git/blame - ftparchive/contents.h
fix -Wmissing-field-initializers warnings
[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
12
13#include <stdlib.h>
14#include <stdio.h>
b2e465d6
AL
15#include <apt-pkg/dirstream.h>
16
472ff00e
DK
17class debDebFile;
18
b2e465d6
AL
19class 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
69class ContentsExtract : public pkgDirStream
70{
71 public:
72
73 // The Data Block
74 char *Data;
650faab0
DK
75 unsigned long long MaxSize;
76 unsigned long long CurSize;
b2e465d6
AL
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;};
650faab0 83 bool TakeContents(const void *Data,unsigned long long Length);
8f3ba4e8 84 void Add(GenContents &Contents,std::string const &Package);
b2e465d6
AL
85
86 ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
87 virtual ~ContentsExtract() {delete [] Data;};
88};
89
90#endif