Преглед изворни кода

apt-cache showsrc
Author: jgg
Date: 1999-10-18 03:44:39 GMT
apt-cache showsrc

Arch Librarian пре 22 година
родитељ
комит
f8f410f57e
4 измењених фајлова са 37 додато и 4 уклоњено
  1. 8 1
      apt-pkg/deb/debsrcrecords.h
  2. 2 1
      apt-pkg/srcrecords.h
  3. 26 2
      cmdline/apt-cache.cc
  4. 1 0
      debian/changelog

+ 8 - 1
apt-pkg/deb/debsrcrecords.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: debsrcrecords.h,v 1.3 1999/04/07 05:51:01 jgg Exp $
+// $Id: debsrcrecords.h,v 1.4 1999/10/18 03:44:39 jgg Exp $
 /* ######################################################################
    
    Debian Source Package Records - Parser implementation for Debian style
@@ -38,6 +38,13 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    virtual string Section() {return Sect.FindS("Section");};
    virtual const char **Binaries();
    virtual unsigned long Offset() {return iOffset;};
+   virtual unsigned long Length() {return Sec.size();};
+   virtual string AsStr() 
+   {
+      const char *Start,Stop;
+      Sect.GetSection(Start,Stop);
+      return string(Start,Stop);
+   };
    virtual bool Files(vector<pkgSrcRecords::File> &F);
    
    debSrcRecordParser(FileFd *File,pkgSourceList::const_iterator SrcItem) : 

+ 2 - 1
apt-pkg/srcrecords.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: srcrecords.h,v 1.4 1999/07/20 05:53:33 jgg Exp $
+// $Id: srcrecords.h,v 1.5 1999/10/18 03:44:39 jgg Exp $
 /* ######################################################################
    
    Source Package Records - Allows access to source package records
@@ -46,6 +46,7 @@ class pkgSrcRecords
       virtual bool Step() = 0;
       virtual bool Jump(unsigned long Off) = 0;
       virtual unsigned long Offset() = 0;
+      virtual string AsStr() = 0;
       
       virtual string Package() = 0;
       virtual string Version() = 0;

+ 26 - 2
cmdline/apt-cache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: apt-cache.cc,v 1.38 1999/10/02 04:14:54 jgg Exp $
+// $Id: apt-cache.cc,v 1.39 1999/10/18 03:44:39 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -24,6 +24,7 @@
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/srcrecords.h>
 #include <config.h>
 
 #include <iostream.h>
@@ -597,6 +598,28 @@ bool ShowPackage(CommandLine &CmdL)
    return true;
 }
 									/*}}}*/
+// ShowSrcPackage - Show source package records				/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool ShowSrcPackage(CommandLine &CmdL)
+{
+   pkgSourceList List;
+   List.ReadMainList();
+   
+   // Create the text record parsers
+   pkgSrcRecords SrcRecs(List);
+   if (_error->PendingError() == true)
+      return false;
+
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   {
+      pkgSrcRecords::Parser *Parse;
+      while ((Parse = SrcRecs.Find(*I,false)) != 0)
+	 cout << Parse->AsStr();
+   }      
+   return true;
+}
+									/*}}}*/
 // GenCaches - Call the main cache generator				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -680,6 +703,7 @@ int main(int argc,const char *argv[])
    CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
                                     {"add",&DoAdd},
                                     {"gencaches",&GenCaches},
+                                    {"showsrc",&ShowSrcPackage},
                                     {0,0}};
    CommandLine::Dispatch CmdsB[] = {{"showpkg",&DumpPackage},
                                     {"stats",&Stats},
@@ -725,7 +749,7 @@ int main(int argc,const char *argv[])
 	 // Open the cache file
 	 pkgSourceList List;
 	 List.ReadMainList();
-	 
+
 	 // Generate it and map it
 	 OpProgress Prog;
 	 Map = pkgMakeStatusCacheMem(List,Prog);

+ 1 - 0
debian/changelog

@@ -19,6 +19,7 @@ apt (0.3.13.1) unstable; urgency=low
   * Unmounts CDROMs iff it mounted them Closes: #45299
   * Checks for the partial directories before doing downloads Closes: #47392
   * no_proxy environment variable (http only!) Closes: #43476
+  * apt-cache showsrc Closes: #45799
   
  -- Jason Gunthorpe <jgg@debian.org>  Fri,  3 Sep 1999 09:04:28 -0700