]> git.saurik.com Git - apt.git/blob - ftparchive/writer.h
G++3 fixes from Randolph
[apt.git] / ftparchive / writer.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: writer.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
4 /* ######################################################################
5
6 Writer
7
8 The file writer classes. These write various types of output, sources,
9 packages and contents.
10
11 ##################################################################### */
12 /*}}}*/
13 #ifndef WRITER_H
14 #define WRITER_H
15
16 #ifdef __GNUG__
17 #pragma interface "writer.h"
18 #endif
19
20 #include <string>
21 #include <stdio.h>
22
23 #include "cachedb.h"
24 #include "override.h"
25 #include "apt-ftparchive.h"
26
27 class FTWScanner
28 {
29 protected:
30
31 char *TmpExt;
32 const char *Ext[10];
33 const char *OriginalPath;
34 char *RealPath;
35 bool ErrorPrinted;
36
37 // Stuff for the delinker
38 bool NoLinkAct;
39
40 static FTWScanner *Owner;
41 static int Scanner(const char *File,const struct stat *sb,int Flag);
42
43 bool Delink(string &FileName,const char *OriginalPath,
44 unsigned long &Bytes,struct stat &St);
45
46 inline void NewLine(unsigned Priority)
47 {
48 if (ErrorPrinted == false && Quiet <= Priority)
49 {
50 cout << endl;
51 ErrorPrinted = true;
52 }
53 }
54
55 public:
56
57 unsigned long DeLinkLimit;
58 string InternalPrefix;
59
60 virtual bool DoPackage(string FileName) = 0;
61 bool RecursiveScan(string Dir);
62 bool LoadFileList(string BaseDir,string File);
63 bool SetExts(string Vals);
64
65 FTWScanner();
66 virtual ~FTWScanner() {delete [] RealPath; delete [] TmpExt;};
67 };
68
69 class PackagesWriter : public FTWScanner
70 {
71 Override Over;
72 CacheDB Db;
73
74 public:
75
76 // Some flags
77 bool DoMD5;
78 bool NoOverride;
79 bool DoContents;
80
81 // General options
82 string PathPrefix;
83 string DirStrip;
84 FILE *Output;
85 struct CacheDB::Stats &Stats;
86
87 inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
88 virtual bool DoPackage(string FileName);
89
90 PackagesWriter(string DB,string Overrides);
91 virtual ~PackagesWriter() {};
92 };
93
94 class ContentsWriter : public FTWScanner
95 {
96 CacheDB Db;
97
98 GenContents Gen;
99
100 public:
101
102 // General options
103 FILE *Output;
104 struct CacheDB::Stats &Stats;
105 string Prefix;
106
107 bool DoPackage(string FileName,string Package);
108 virtual bool DoPackage(string FileName)
109 {return DoPackage(FileName,string());};
110 bool ReadFromPkgs(string PkgFile,string PkgCompress);
111
112 void Finish() {Gen.Print(Output);};
113 inline bool ReadyDB(string DB) {return Db.ReadyDB(DB);};
114
115 ContentsWriter(string DB);
116 virtual ~ContentsWriter() {};
117 };
118
119 class SourcesWriter : public FTWScanner
120 {
121 Override BOver;
122 Override SOver;
123 char *Buffer;
124 unsigned long BufSize;
125
126 public:
127
128 bool NoOverride;
129
130 // General options
131 string PathPrefix;
132 string DirStrip;
133 FILE *Output;
134 struct CacheDB::Stats Stats;
135
136 /* inline bool ReadBinOverride(string File) {return BOver.ReadOverride(File);};
137 bool ReadSrcOverride(string File); // {return BOver.ReadOverride(File);};*/
138 virtual bool DoPackage(string FileName);
139
140 SourcesWriter(string BOverrides,string SOverrides);
141 virtual ~SourcesWriter() {free(Buffer);};
142 };
143
144
145 #endif