summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/arfile.h
blob: cf454941e002fc1033a1daf7f95c40b304ca3b46 (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
// -*- mode: cpp; mode: fold -*-
// Description								/*{{{*/
/* ######################################################################

   AR File - Handle an 'AR' archive
   
   This is a reader for the usual 4.4 BSD AR format. It allows raw
   stream access to a single member at a time. Basically all this class
   provides is header parsing and verification. It is up to the client
   to correctly make use of the stream start/stop points.
   
   ##################################################################### */
									/*}}}*/
#ifndef PKGLIB_ARFILE_H
#define PKGLIB_ARFILE_H

#include <apt-pkg/macros.h>
#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/fileutl.h>
#endif

class FileFd;

class ARArchive
{
   struct MemberHeader;
   public:
   struct Member;
   
   protected:

   // Linked list of members
   Member *List;
   
   bool LoadHeaders();

   public:
   
   // The stream file
   FileFd &File;

   // Locate a member by name
   const Member *FindMember(const char *Name) const;
   inline Member *Members() { return List; }
   
   explicit ARArchive(FileFd &File);
   ~ARArchive();
};

// A member of the archive
struct ARArchive::Member
{
   // Fields from the header
   std::string Name;
   unsigned long MTime;
   unsigned long UID;
   unsigned long GID;
   unsigned long Mode;
   unsigned long long Size;
   
   // Location of the data.
   unsigned long long Start;
   Member *Next;
   
   Member() : Start(0), Next(0) {};
};

#endif