blob: a78f9d5e96b2f4955ae03c36f8bae36f4349afab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
contents - Contents of archive things.
##################################################################### */
/*}}}*/
#ifndef CONTENTS_H
#define CONTENTS_H
#include <apt-pkg/dirstream.h>
#include <apt-pkg/strutl.h>
#include <cstddef>
#include <cstdio>
#include <set>
#include <string>
class debDebFile;
class FileFd;
class GenContents
{
/// \brief zero-terminated strings inside a BigBlock with minimal C++ accessor and comparison operator
struct StringInBlock
{
const char *data;
const char *c_str() const { return data; }
auto operator<=>(const StringInBlock &other) const noexcept { return strcmp(data, other.data); }
};
struct BigBlock
{
void *Block;
BigBlock *Next;
};
std::set<std::pair<StringInBlock, StringInBlock>> Entries;
// Big block allocation pools
BigBlock *BlockList;
char *StrPool;
unsigned long StrLeft;
void WriteSpace(std::string &out, size_t Current, size_t Target);
public:
StringInBlock Mystrdup(const char *From);
void Add(const char *Dir, StringInBlock Package);
void Print(FileFd &Out);
GenContents() : BlockList(0), StrPool(0), StrLeft(0) {};
~GenContents();
};
class ContentsExtract : public pkgDirStream
{
public:
// The Data Block
char *Data;
unsigned long long MaxSize;
unsigned long long CurSize;
void AddData(const char *Text);
bool Read(debDebFile &Deb);
bool DoItem(Item &Itm,int &Fd) override;
void Reset() {CurSize = 0;};
bool TakeContents(const void *Data,unsigned long long Length);
void Add(GenContents &Contents,std::string const &Package);
ContentsExtract();
virtual ~ContentsExtract();
};
#endif
|