summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/apt-ftparchive.cc39
-rw-r--r--ftparchive/cachedb.cc4
-rw-r--r--ftparchive/cachedb.h8
-rw-r--r--ftparchive/contents.cc7
-rw-r--r--ftparchive/contents.h8
-rw-r--r--ftparchive/multicompress.cc17
-rw-r--r--ftparchive/multicompress.h3
-rw-r--r--ftparchive/override.cc69
-rw-r--r--ftparchive/writer.cc31
-rw-r--r--ftparchive/writer.h4
10 files changed, 109 insertions, 81 deletions
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index 2639bc2f6..692f19e25 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -17,14 +17,23 @@
#include <apt-pkg/cmndline.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/init.h>
-#include <algorithm>
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
#include <climits>
#include <sys/time.h>
-#include <regex.h>
-
+#include <locale.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <functional>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cachedb.h"
+#include "override.h"
#include "apt-ftparchive.h"
-#include "contents.h"
#include "multicompress.h"
#include "writer.h"
@@ -438,7 +447,7 @@ bool PackageMap::GenContents(Configuration &Setup,
// ---------------------------------------------------------------------
/* This populates the PkgList with all the possible permutations of the
section/arch lists. */
-void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
+static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
{
// Load the defaults
string DDir = Setup.Find("TreeDefault::Directory",
@@ -484,7 +493,7 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
struct SubstVar const Vars[] = {{"$(DIST)",&Dist},
{"$(SECTION)",&Section},
{"$(ARCH)",&Arch},
- {}};
+ {NULL, NULL}};
mode_t const Perms = Block.FindI("FileMode", Permissions);
bool const LongDesc = Block.FindB("LongDescription", LongDescription);
TranslationWriter *TransWriter;
@@ -550,7 +559,7 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
// LoadBinDir - Load a 'bindirectory' section from the Generate Config /*{{{*/
// ---------------------------------------------------------------------
/* */
-void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup)
+static void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup)
{
mode_t const Permissions = Setup.FindI("Default::FileMode",0644);
@@ -586,7 +595,7 @@ void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup)
// ShowHelp - Show the help text /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -639,7 +648,7 @@ bool ShowHelp(CommandLine &CmdL)
// SimpleGenPackages - Generate a Packages file for a directory tree /*{{{*/
// ---------------------------------------------------------------------
/* This emulates dpkg-scanpackages's command line interface. 'mostly' */
-bool SimpleGenPackages(CommandLine &CmdL)
+static bool SimpleGenPackages(CommandLine &CmdL)
{
if (CmdL.FileSize() < 2)
return ShowHelp(CmdL);
@@ -667,7 +676,7 @@ bool SimpleGenPackages(CommandLine &CmdL)
// SimpleGenContents - Generate a Contents listing /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool SimpleGenContents(CommandLine &CmdL)
+static bool SimpleGenContents(CommandLine &CmdL)
{
if (CmdL.FileSize() < 2)
return ShowHelp(CmdL);
@@ -689,7 +698,7 @@ bool SimpleGenContents(CommandLine &CmdL)
// SimpleGenSources - Generate a Sources file for a directory tree /*{{{*/
// ---------------------------------------------------------------------
/* This emulates dpkg-scanpackages's command line interface. 'mostly' */
-bool SimpleGenSources(CommandLine &CmdL)
+static bool SimpleGenSources(CommandLine &CmdL)
{
if (CmdL.FileSize() < 2)
return ShowHelp(CmdL);
@@ -722,7 +731,7 @@ bool SimpleGenSources(CommandLine &CmdL)
/*}}}*/
// SimpleGenRelease - Generate a Release file for a directory tree /*{{{*/
// ---------------------------------------------------------------------
-bool SimpleGenRelease(CommandLine &CmdL)
+static bool SimpleGenRelease(CommandLine &CmdL)
{
if (CmdL.FileSize() < 2)
return ShowHelp(CmdL);
@@ -747,7 +756,7 @@ bool SimpleGenRelease(CommandLine &CmdL)
// Generate - Full generate, using a config file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Generate(CommandLine &CmdL)
+static bool Generate(CommandLine &CmdL)
{
struct CacheDB::Stats SrcStats;
if (CmdL.FileSize() < 2)
@@ -864,7 +873,7 @@ bool Generate(CommandLine &CmdL)
unsigned long MaxContentsChange = Setup.FindI("Default::MaxContentsChange",UINT_MAX)*1024;
for (vector<PackageMap>::iterator I = PkgList.begin(); I != PkgList.end(); ++I)
{
- // This record is not relevent
+ // This record is not relevant
if (I->ContentsDone == true ||
I->Contents.empty() == true)
continue;
@@ -911,7 +920,7 @@ bool Generate(CommandLine &CmdL)
// Clean - Clean out the databases /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Clean(CommandLine &CmdL)
+static bool Clean(CommandLine &CmdL)
{
if (CmdL.FileSize() != 2)
return ShowHelp(CmdL);
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index c2318bf53..523c6b5fa 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -19,8 +19,12 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/debfile.h>
#include <netinet/in.h> // htonl, etc
+#include <ctype.h>
+#include <stddef.h>
+#include <sys/stat.h>
#include "cachedb.h"
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h
index b9ced9418..49b9a0ef5 100644
--- a/ftparchive/cachedb.h
+++ b/ftparchive/cachedb.h
@@ -12,17 +12,19 @@
#ifndef CACHEDB_H
#define CACHEDB_H
-
#include <apt-pkg/debfile.h>
#include <db.h>
-#include <inttypes.h>
-#include <sys/stat.h>
#include <errno.h>
#include <string>
+#include <string.h>
+#include <stdint.h>
+#include <stdio.h>
#include "contents.h"
+class FileFd;
+
class CacheDB
{
protected:
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index 015c790e0..7a1fb779e 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -36,13 +36,12 @@
#include <config.h>
#include <apt-pkg/debfile.h>
-#include <apt-pkg/extracttar.h>
+#include <apt-pkg/dirstream.h>
#include <apt-pkg/error.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
#include "contents.h"
@@ -233,7 +232,7 @@ void GenContents::Add(const char *Dir,const char *Package)
// The final component if it does not have a trailing /
if (I - Start >= 1)
- Root = Grab(Root,Start,Package);
+ Grab(Root,Start,Package);
}
/*}}}*/
// GenContents::WriteSpace - Write a given number of white space chars /*{{{*/
@@ -316,7 +315,7 @@ bool ContentsExtract::Read(debDebFile &Deb)
// ContentsExtract::DoItem - Extract an item /*{{{*/
// ---------------------------------------------------------------------
/* This just tacks the name onto the end of our memory buffer */
-bool ContentsExtract::DoItem(Item &Itm,int &Fd)
+bool ContentsExtract::DoItem(Item &Itm, int &/*Fd*/)
{
unsigned long Len = strlen(Itm.Name);
diff --git a/ftparchive/contents.h b/ftparchive/contents.h
index 4af9db574..dbbb83350 100644
--- a/ftparchive/contents.h
+++ b/ftparchive/contents.h
@@ -9,11 +9,13 @@
/*}}}*/
#ifndef CONTENTS_H
#define CONTENTS_H
-
-#include <stdlib.h>
-#include <stdio.h>
+
#include <apt-pkg/dirstream.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string>
+
class debDebFile;
class GenContents
diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc
index 1fea589e2..f35d5304a 100644
--- a/ftparchive/multicompress.cc
+++ b/ftparchive/multicompress.cc
@@ -20,12 +20,15 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/hashsum_template.h>
+#include <ctype.h>
+#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
-#include <utime.h>
+#include <sys/time.h>
#include <unistd.h>
-#include <iostream>
#include "multicompress.h"
#include <apti18n.h>
@@ -234,14 +237,12 @@ bool MultiCompress::Finalize(unsigned long long &OutSize)
else
{
// Update the mtime if necessary
- if (UpdateMTime > 0 &&
+ if (UpdateMTime > 0 &&
(Now - St.st_mtime > (signed)UpdateMTime || St.st_mtime > Now))
{
- struct utimbuf Buf;
- Buf.actime = Buf.modtime = Now;
- utime(I->Output.c_str(),&Buf);
+ utimes(I->Output.c_str(), NULL);
Changed = true;
- }
+ }
}
// Force the file permissions
@@ -367,7 +368,7 @@ bool MultiCompress::Child(int const &FD)
for (Files *I = Outputs; I != 0; I = I->Next)
{
// Set the correct file modes
- fchmod(I->TmpFile.Fd(),Permissions);
+ chmod(I->TmpFile.Name().c_str(),Permissions);
if (rename(I->TmpFile.Name().c_str(),I->Output.c_str()) != 0)
_error->Errno("rename",_("Failed to rename %s to %s"),
diff --git a/ftparchive/multicompress.h b/ftparchive/multicompress.h
index 388fad22e..ddd1815a3 100644
--- a/ftparchive/multicompress.h
+++ b/ftparchive/multicompress.h
@@ -22,7 +22,8 @@
#include <string>
#include <stdio.h>
#include <sys/types.h>
-
+#include <time.h>
+
class MultiCompress
{
// An output file
diff --git a/ftparchive/override.cc b/ftparchive/override.cc
index 1288ff133..b4cd49b6c 100644
--- a/ftparchive/override.cc
+++ b/ftparchive/override.cc
@@ -16,6 +16,9 @@
#include <apt-pkg/error.h>
#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <utility>
#include "override.h"
@@ -52,45 +55,41 @@ bool Override::ReadOverride(string const &File,bool const &Source)
if (*Pkg == 0)
continue;
+#define APT_FIND_NEXT_FIELD \
+ for (End++; isspace(*End) != 0 && *End != 0; ++End) \
+ /* skip spaces */ ; \
+ Start = End; \
+ for (; isspace(*End) == 0 && *End != 0; ++End) \
+ /* find end of word */ ;
+
+#define APT_WARNING_MALFORMED_LINE(FIELD) \
+ if (*End == 0) \
+ { \
+ _error->Warning(_("Malformed override %s line %llu (%s)"),File.c_str(), \
+ Counter, FIELD ); \
+ continue; \
+ } \
+ *End = 0;
+
// Find the package and zero..
- char *Start = Pkg;
+ char *Start;
char *End = Pkg;
for (; isspace(*End) == 0 && *End != 0; End++);
- if (*End == 0)
- {
- _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(),
- Counter);
- continue;
- }
- *End = 0;
+ APT_WARNING_MALFORMED_LINE("pkgname");
+
+ APT_FIND_NEXT_FIELD;
// Find the priority
if (Source == false)
{
- for (End++; isspace(*End) != 0 && *End != 0; End++);
- Start = End;
- for (; isspace(*End) == 0 && *End != 0; End++);
- if (*End == 0)
- {
- _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(),
- Counter);
- continue;
- }
- *End = 0;
+ APT_WARNING_MALFORMED_LINE("priority");
Itm.Priority = Start;
+
+ APT_FIND_NEXT_FIELD;
}
-
+
// Find the Section
- for (End++; isspace(*End) != 0 && *End != 0; End++);
- Start = End;
- for (; isspace(*End) == 0 && *End != 0; End++);
- if (*End == 0)
- {
- _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(),
- Counter);
- continue;
- }
- *End = 0;
+ APT_WARNING_MALFORMED_LINE("section");
Itm.FieldOverride["Section"] = Start;
// Source override files only have the two columns
@@ -99,7 +98,7 @@ bool Override::ReadOverride(string const &File,bool const &Source)
Mapping[Pkg] = Itm;
continue;
}
-
+
// Find the =>
for (End++; isspace(*End) != 0 && *End != 0; End++);
if (*End != 0)
@@ -133,7 +132,7 @@ bool Override::ReadOverride(string const &File,bool const &Source)
// Override::ReadExtraOverride - Read the extra override file /*{{{*/
// ---------------------------------------------------------------------
/* This parses the extra override file and reads it into the map */
-bool Override::ReadExtraOverride(string const &File,bool const &Source)
+bool Override::ReadExtraOverride(string const &File,bool const &/*Source*/)
{
if (File.empty() == true)
return true;
@@ -205,7 +204,7 @@ bool Override::ReadExtraOverride(string const &File,bool const &Source)
}
/*}}}*/
-// Override::GetItem - Get a architecture specific item /*{{{*/
+// Override::GetItem - Get a architecture specific item /*{{{*/
// ---------------------------------------------------------------------
/* Returns a override item for the given package and the given architecture.
* Treats "all" special
@@ -236,10 +235,10 @@ Override::Item* Override::GetItem(string const &Package, string const &Architect
{
result->FieldOverride[foI->first] = foI->second;
}
- }
- }
+ }
+ }
return result;
-};
+}
// Override::Item::SwapMaint - Swap the maintainer field if necessary /*{{{*/
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 7ecfe78ed..153c4fb42 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -13,28 +13,37 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/md5.h>
-#include <apt-pkg/hashes.h>
#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/gpgv.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/debfile.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+#include <apt-pkg/tagfile.h>
+#include <ctype.h>
+#include <fnmatch.h>
+#include <ftw.h>
+#include <locale.h>
+#include <string.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctime>
-#include <ftw.h>
-#include <fnmatch.h>
#include <iostream>
#include <sstream>
#include <memory>
+#include <utility>
+#include "apt-ftparchive.h"
#include "writer.h"
#include "cachedb.h"
-#include "apt-ftparchive.h"
#include "multicompress.h"
#include <apti18n.h>
@@ -72,9 +81,9 @@ FTWScanner::FTWScanner(string const &Arch): Arch(Arch)
/*}}}*/
// FTWScanner::Scanner - FTW Scanner /*{{{*/
// ---------------------------------------------------------------------
-/* This is the FTW scanner, it processes each directory element in the
+/* This is the FTW scanner, it processes each directory element in the
directory tree. */
-int FTWScanner::ScannerFTW(const char *File,const struct stat *sb,int Flag)
+int FTWScanner::ScannerFTW(const char *File,const struct stat * /*sb*/,int Flag)
{
if (Flag == FTW_DNR)
{
@@ -951,7 +960,7 @@ bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompres
// ReleaseWriter::ReleaseWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-ReleaseWriter::ReleaseWriter(string const &DB)
+ReleaseWriter::ReleaseWriter(string const &/*DB*/)
{
if (_config->FindB("APT::FTPArchive::Release::Default-Patterns", true) == true)
{
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index 4932b0cc8..86884dcfc 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -13,14 +13,16 @@
#ifndef WRITER_H
#define WRITER_H
-
#include <string>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
+#include <stdlib.h>
+#include <sys/types.h>
+#include "contents.h"
#include "cachedb.h"
#include "override.h"
#include "apt-ftparchive.h"