]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
Updated French manpage. Closes: #291020
[apt.git] / cmdline / apt-cache.cc
index bcf4e1c0f606b00a6fff3565442e0c6f3bb0915d..4e16b8c1180e310a1616c0b54092d0a8738a7aaa 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-cache.cc,v 1.66 2003/08/01 20:27:13 mdz Exp $
+// $Id: apt-cache.cc,v 1.72 2004/04/30 04:34:03 mdz Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -37,6 +37,8 @@
 #include <errno.h>
 #include <regex.h>
 #include <stdio.h>
+
+#include <iomanip>
                                                                        /*}}}*/
 
 using namespace std;
@@ -1195,7 +1197,7 @@ bool DisplayRecord(pkgCache::VerIterator V)
    Buffer[V.FileList()->Size] = '\n';
    if (PkgF.Seek(V.FileList()->Offset) == false ||
        PkgF.Read(Buffer,V.FileList()->Size) == false ||
-       write(STDOUT_FILENO,Buffer,V.FileList()->Size+1) != V.FileList()->Size+1)
+       fwrite(Buffer,1,V.FileList()->Size+1,stdout) < (size_t)(V.FileList()->Size+1))
    {
       delete [] Buffer;
       return false;
@@ -1559,6 +1561,74 @@ bool Policy(CommandLine &CmdL)
    
    return true;
 }
+                                                                       /*}}}*/
+// Madison - Look a bit like katie's madison                           /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool Madison(CommandLine &CmdL)
+{
+   if (SrcList == 0)
+      return _error->Error("Generate must be enabled for this function");
+
+   SrcList->ReadMainList();
+
+   pkgCache &Cache = *GCache;
+
+   // Create the text record parsers
+   pkgSrcRecords SrcRecs(*SrcList);
+   if (_error->PendingError() == true)
+      return false;
+
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   {
+      pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
+
+      if (Pkg.end() == false)
+      {
+         for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; V++)
+         {
+            for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+            {
+// This might be nice, but wouldn't uniquely identify the source -mdz
+//                if (VF.File().Archive() != 0)
+//                {
+//                   cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+//                        << VF.File().Archive() << endl;
+//                }
+
+               // Locate the associated index files so we can derive a description
+               for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++)
+               {
+                    vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
+                    for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
+                         IF != Indexes->end(); IF++)
+                    {
+                         if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File())
+                         {
+                                   cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | "
+                                        << (*IF)->Describe(true) << endl;
+                         }
+                    }
+               }
+            }
+         }
+      }
+
+      
+      SrcRecs.Restart();
+      pkgSrcRecords::Parser *SrcParser;
+      while ((SrcParser = SrcRecs.Find(*I,false)) != 0)
+      {
+         // Maybe support Release info here too eventually
+         cout << setw(10) << SrcParser->Package() << " | "
+              << setw(10) << SrcParser->Version() << " | "
+              << SrcParser->Index().Describe(true) << endl;
+      }
+   }
+
+   return true;
+}
+
                                                                        /*}}}*/
 // GenCaches - Call the main cache generator                           /*{{{*/
 // ---------------------------------------------------------------------
@@ -1618,7 +1688,7 @@ bool ShowHelp(CommandLine &Cmd)
       "  -q   Disable progress indicator.\n"
       "  -i   Show only important deps for the unmet command.\n"
       "  -c=? Read this configuration file\n"
-      "  -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp\n"
+      "  -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"
       "See the apt-cache(8) and apt.conf(5) manual pages for more information.\n");
    return true;
 }
@@ -1645,12 +1715,12 @@ int main(int argc,const char *argv[])
       {'f',"full","APT::Cache::ShowFull",0},
       {'g',"generate","APT::Cache::Generate",0},
       {'a',"all-versions","APT::Cache::AllVersions",0},
-      {0,"names-only","APT::Cache::NamesOnly",0},
-      {'n',"all-names","APT::Cache::AllNames",0},
+      {'n',"names-only","APT::Cache::NamesOnly",0},
+      {0,"all-names","APT::Cache::AllNames",0},
       {0,"recurse","APT::Cache::RecurseDepends",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
-      {'n',"installed","APT::Cache::Installed",0},
+      {0,"installed","APT::Cache::Installed",0},
       {0,0,0,0}};
    CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
                                     {"add",&DoAdd},
@@ -1670,6 +1740,7 @@ int main(int argc,const char *argv[])
                                     {"show",&ShowPackage},
                                     {"pkgnames",&ShowPkgNames},
                                     {"policy",&Policy},
+                                    {"madison",&Madison},
                                     {0,0}};
 
    CacheInitialize();
@@ -1697,7 +1768,7 @@ int main(int argc,const char *argv[])
    }
    
    // Deal with stdout not being a tty
-   if (ttyname(STDOUT_FILENO) == 0 && _config->FindI("quiet",0) < 1)
+   if (isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
       _config->Set("quiet","1");
 
    if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)