"Fossies" - the Fresh Open Source Software Archive

Member "apt-1.9.4/apt-pkg/deb/debfile.h" (19 Sep 2019, 2363 Bytes) of package /linux/misc/apt-1.9.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "debfile.h" see the Fossies "Dox" file reference documentation.

    1 // -*- mode: cpp; mode: fold -*-
    2 // Description                              /*{{{*/
    3 /* ######################################################################
    4 
    5    Debian Archive File (.deb)
    6 
    7    This Class handles all the operations performed directly on .deb 
    8    files. It makes use of the AR and TAR classes to give the necessary
    9    external interface.
   10    
   11    There are only two things that can be done with a raw package, 
   12    extract it's control information and extract the contents itself. 
   13 
   14    This should probably subclass an as-yet unwritten super class to
   15    produce a generic archive mechanism.
   16   
   17    The memory control file extractor is useful to extract a single file
   18    into memory from the control.tar.gz
   19    
   20    ##################################################################### */
   21                                     /*}}}*/
   22 #ifndef PKGLIB_DEBFILE_H
   23 #define PKGLIB_DEBFILE_H
   24 
   25 #include <apt-pkg/arfile.h>
   26 #include <apt-pkg/dirstream.h>
   27 #include <apt-pkg/macros.h>
   28 #include <apt-pkg/tagfile.h>
   29 
   30 #include <string>
   31 
   32 
   33 class FileFd;
   34 
   35 class debDebFile
   36 {
   37    protected:
   38    
   39    FileFd &File;
   40    ARArchive AR;
   41    
   42    bool CheckMember(const char *Name);
   43    
   44    public:
   45    class ControlExtract;
   46    class MemControlExtract;
   47 
   48    bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
   49    bool ExtractArchive(pkgDirStream &Stream);
   50    const ARArchive::Member *GotoMember(const char *Name);
   51    inline FileFd &GetFile() {return File;};
   52    
   53    explicit debDebFile(FileFd &File);
   54 };
   55 
   56 class debDebFile::ControlExtract : public pkgDirStream
   57 {
   58    public:
   59    
   60    virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
   61 };
   62 
   63 class debDebFile::MemControlExtract : public pkgDirStream
   64 {
   65    bool IsControl;
   66    
   67    public:
   68    
   69    char *Control;
   70    pkgTagSection Section;
   71    unsigned long Length;
   72    std::string Member;
   73    
   74    // Members from DirStream
   75    virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
   76    virtual bool Process(Item &Itm,const unsigned char *Data,
   77             unsigned long long Size,unsigned long long Pos) APT_OVERRIDE;
   78 
   79    // Helpers
   80    bool Read(debDebFile &Deb);
   81    bool TakeControl(const void *Data,unsigned long long Size);
   82 
   83    MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
   84    explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
   85    ~MemControlExtract() {delete [] Control;};   
   86 };
   87                                     /*}}}*/
   88 
   89 #endif