Add SHA1 support to "apt-ftparchive release"
[ntk/apt.git] / ftparchive / writer.h
index a5fb6f5..f347ca3 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: writer.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
+// $Id: writer.h,v 1.6 2003/12/26 20:50:01 mdz Exp $
 /* ######################################################################
 
    Writer 
 
 #include <string>
 #include <stdio.h>
+#include <iostream>
+#include <vector>
+#include <map>
 
 #include "cachedb.h"
 #include "override.h"
 #include "apt-ftparchive.h"
+
+using std::string;
+using std::cout;
+using std::endl;
+using std::vector;
+using std::map;
     
 class FTWScanner
 {
    protected:
-
-   char *TmpExt;
-   const char *Ext[10];
+   vector<string> Patterns;
    const char *OriginalPath;
    char *RealPath;
    bool ErrorPrinted;
@@ -60,10 +67,12 @@ class FTWScanner
    virtual bool DoPackage(string FileName) = 0;
    bool RecursiveScan(string Dir);
    bool LoadFileList(string BaseDir,string File);
+   bool ClearPatterns() { Patterns.clear(); };
+   bool AddPattern(string Pattern) { Patterns.push_back(Pattern); };
    bool SetExts(string Vals);
       
    FTWScanner();
-   virtual ~FTWScanner() {delete [] RealPath; delete [] TmpExt;};
+   virtual ~FTWScanner() {delete [] RealPath;};
 };
 
 class PackagesWriter : public FTWScanner
@@ -85,9 +94,11 @@ class PackagesWriter : public FTWScanner
    struct CacheDB::Stats &Stats;
    
    inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
+   inline bool ReadExtraOverride(string File) 
+      {return Over.ReadExtraOverride(File);};
    virtual bool DoPackage(string FileName);
 
-   PackagesWriter(string DB,string Overrides);
+   PackagesWriter(string DB,string Overrides,string ExtOverrides=string());
    virtual ~PackagesWriter() {};
 };
 
@@ -133,13 +144,34 @@ class SourcesWriter : public FTWScanner
    FILE *Output;
    struct CacheDB::Stats Stats;
 
-/*   inline bool ReadBinOverride(string File) {return BOver.ReadOverride(File);};
-   bool ReadSrcOverride(string File); // {return BOver.ReadOverride(File);};*/
    virtual bool DoPackage(string FileName);
 
-   SourcesWriter(string BOverrides,string SOverrides);
+   SourcesWriter(string BOverrides,string SOverrides,
+                string ExtOverrides=string());
    virtual ~SourcesWriter() {free(Buffer);};
 };
 
+class ReleaseWriter : public FTWScanner
+{
+public:
+   ReleaseWriter(string DB);
+   virtual bool DoPackage(string FileName);
+   void Finish();
+
+   FILE *Output;
+   // General options
+   string PathPrefix;
+   string DirStrip;
+
+protected:
+   struct CheckSum
+   {
+      string MD5;
+      string SHA1;
+      // Limited by FileFd::Size()
+      unsigned long size;
+   };
+   map<string,struct CheckSum> CheckSums;
+};
 
 #endif