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