summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/cdrom.cc6
-rw-r--r--methods/connect.cc2
-rw-r--r--methods/copy.cc3
-rw-r--r--methods/file.cc3
-rw-r--r--methods/ftp.cc11
-rw-r--r--methods/ftp.h4
-rw-r--r--methods/gpgv.cc16
-rw-r--r--methods/gzip.cc43
-rw-r--r--methods/http.cc32
-rw-r--r--methods/http.h4
-rw-r--r--methods/http_main.cc5
-rw-r--r--methods/https.cc19
-rw-r--r--methods/https.h23
-rw-r--r--methods/mirror.cc40
-rw-r--r--methods/mirror.h2
-rw-r--r--methods/rred.cc17
-rw-r--r--methods/rsh.cc10
-rw-r--r--methods/rsh.h4
-rw-r--r--methods/server.cc47
-rw-r--r--methods/server.h9
20 files changed, 162 insertions, 138 deletions
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index 22d4b9164..74e2ecc6b 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -19,9 +19,9 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
+#include <string>
+#include <vector>
#include <sys/stat.h>
-#include <unistd.h>
-#include <dlfcn.h>
#include <iostream>
#include <apti18n.h>
@@ -62,7 +62,7 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
MountedByApt(false)
{
UdevCdroms.Dlopen();
-};
+}
/*}}}*/
// CDROMMethod::Exit - Unmount the disc if necessary /*{{{*/
// ---------------------------------------------------------------------
diff --git a/methods/connect.cc b/methods/connect.cc
index d9c9a1dd4..e2cbf4f5c 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -23,7 +23,7 @@
#include <errno.h>
#include <unistd.h>
#include <sstream>
-
+#include <string.h>
#include<set>
#include<string>
diff --git a/methods/copy.cc b/methods/copy.cc
index f2a8f9ed8..d59f032ff 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -17,9 +17,10 @@
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <string>
#include <sys/stat.h>
#include <sys/time.h>
-#include <unistd.h>
+
#include <apti18n.h>
/*}}}*/
diff --git a/methods/file.cc b/methods/file.cc
index 3d0687c5b..12db62203 100644
--- a/methods/file.cc
+++ b/methods/file.cc
@@ -21,8 +21,9 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
+#include <string>
#include <sys/stat.h>
-#include <unistd.h>
+
#include <apti18n.h>
/*}}}*/
diff --git a/methods/ftp.cc b/methods/ftp.cc
index 621f48476..66787a7be 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -23,7 +23,11 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/strutl.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
@@ -42,6 +46,7 @@
#include "rfc2553emu.h"
#include "connect.h"
#include "ftp.h"
+
#include <apti18n.h>
/*}}}*/
@@ -56,9 +61,9 @@ struct AFMap
};
#ifndef AF_INET6
-struct AFMap AFMap[] = {{AF_INET,1},{}};
+struct AFMap AFMap[] = {{AF_INET,1},{0, 0}};
#else
-struct AFMap AFMap[] = {{AF_INET,1},{AF_INET6,2},{}};
+struct AFMap AFMap[] = {{AF_INET,1},{AF_INET6,2},{0, 0}};
#endif
unsigned long TimeOut = 120;
@@ -1098,7 +1103,7 @@ bool FtpMethod::Fetch(FetchItem *Itm)
}
/*}}}*/
-int main(int argc,const char *argv[])
+int main(int, const char *argv[])
{
setlocale(LC_ALL, "");
diff --git a/methods/ftp.h b/methods/ftp.h
index 8055c389f..dd92f0086 100644
--- a/methods/ftp.h
+++ b/methods/ftp.h
@@ -12,6 +12,8 @@
#include <apt-pkg/strutl.h>
+#include <sys/types.h>
+#include <time.h>
#include <string>
class FTPConn
@@ -76,7 +78,7 @@ class FtpMethod : public pkgAcqMethod
static std::string FailFile;
static int FailFd;
static time_t FailTime;
- static void SigTerm(int);
+ static APT_NORETURN void SigTerm(int);
public:
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index 25bf64ddd..ae521a2ed 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -1,19 +1,21 @@
#include <config.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/indexcopy.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/gpgv.h>
+#include <apt-pkg/strutl.h>
-#include <stdio.h>
-#include <fcntl.h>
+#include <ctype.h>
#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <iostream>
-#include <sstream>
+#include <string>
#include <vector>
#include <apti18n.h>
diff --git a/methods/gzip.cc b/methods/gzip.cc
index a2844e969..df3f8828f 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -11,17 +11,20 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/acquire-method.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
+#include <string>
+#include <vector>
+
#include <apti18n.h>
/*}}}*/
@@ -58,17 +61,25 @@ bool GzipMethod::Fetch(FetchItem *Itm)
return _error->Error("Extraction of file %s requires unknown compressor %s", Path.c_str(), Prog);
// Open the source and destination files
- FileFd From;
- From.Open(Path, FileFd::ReadOnly, *compressor);
-
- if(From.FileSize() == 0)
- return _error->Error(_("Empty files can't be valid archives"));
-
- FileFd To(Itm->DestFile,FileFd::WriteAtomic);
+ FileFd From, To;
+ if (_config->FindB("Method::Compress", false) == false)
+ {
+ From.Open(Path, FileFd::ReadOnly, *compressor);
+ if(From.FileSize() == 0)
+ return _error->Error(_("Empty files can't be valid archives"));
+ To.Open(Itm->DestFile, FileFd::WriteAtomic);
+ }
+ else
+ {
+ From.Open(Path, FileFd::ReadOnly);
+ To.Open(Itm->DestFile, FileFd::WriteOnly | FileFd::Create | FileFd::Empty, *compressor);
+ }
To.EraseOnFailure();
- if (_error->PendingError() == true)
+
+ if (From.IsOpen() == false || From.Failed() == true ||
+ To.IsOpen() == false || To.Failed() == true)
return false;
-
+
// Read data from source, generate checksums and write
Hashes Hash;
bool Failed = false;
@@ -120,7 +131,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
}
/*}}}*/
-int main(int argc, char *argv[])
+int main(int, char *argv[])
{
setlocale(LC_ALL, "");
diff --git a/methods/http.cc b/methods/http.cc
index 42b31beeb..ed6e3517d 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -33,24 +33,21 @@
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
+#include <apt-pkg/strutl.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/select.h>
+#include <cstring>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
-#include <signal.h>
#include <stdio.h>
#include <errno.h>
-#include <string.h>
-#include <climits>
#include <iostream>
-#include <map>
-
-// Internet stuff
-#include <netdb.h>
#include "config.h"
#include "connect.h"
-#include "rfc2553emu.h"
#include "http.h"
#include <apti18n.h>
@@ -61,7 +58,7 @@ unsigned long long CircleBuf::BwReadLimit=0;
unsigned long long CircleBuf::BwTickReadData=0;
struct timeval CircleBuf::BwReadTick={0,0};
const unsigned int CircleBuf::BW_HZ=10;
-
+
// CircleBuf::CircleBuf - Circular input buffer /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -87,8 +84,8 @@ void CircleBuf::Reset()
{
delete Hash;
Hash = new Hashes;
- }
-};
+ }
+}
/*}}}*/
// CircleBuf::Read - Read from a FD into the circular buffer /*{{{*/
// ---------------------------------------------------------------------
@@ -473,7 +470,7 @@ bool HttpServerState::WriteResponse(const std::string &Data) /*{{{*/
return Out.Read(Data);
}
/*}}}*/
-bool HttpServerState::IsOpen() /*{{{*/
+APT_PURE bool HttpServerState::IsOpen() /*{{{*/
{
return (ServerFd != -1);
}
@@ -484,16 +481,11 @@ bool HttpServerState::InitHashes(FileFd &File) /*{{{*/
In.Hash = new Hashes;
// Set the expected size and read file for the hashes
- if (StartPos >= 0)
- {
- File.Truncate(StartPos);
-
- return In.Hash->AddFD(File, StartPos);
- }
- return true;
+ File.Truncate(StartPos);
+ return In.Hash->AddFD(File, StartPos);
}
/*}}}*/
-Hashes * HttpServerState::GetHashes() /*{{{*/
+APT_PURE Hashes * HttpServerState::GetHashes() /*{{{*/
{
return In.Hash;
}
diff --git a/methods/http.h b/methods/http.h
index 450a42eed..5406ce4a7 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -12,14 +12,18 @@
#define APT_HTTP_H
#include <apt-pkg/strutl.h>
+#include <apt-pkg/acquire-method.h>
#include <string>
+#include <sys/time.h>
+#include <iostream>
#include "server.h"
using std::cout;
using std::endl;
+class FileFd;
class HttpMethod;
class Hashes;
diff --git a/methods/http_main.cc b/methods/http_main.cc
index 2ca91bfc9..3b346a514 100644
--- a/methods/http_main.cc
+++ b/methods/http_main.cc
@@ -1,14 +1,9 @@
#include <config.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <signal.h>
-#include "connect.h"
-#include "rfc2553emu.h"
#include "http.h"
-
int main()
{
setlocale(LC_ALL, "");
diff --git a/methods/https.cc b/methods/https.cc
index febe6a0f0..c4aff8f38 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -18,19 +18,20 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/strutl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
-#include <signal.h>
#include <stdio.h>
-#include <errno.h>
-#include <string.h>
#include <iostream>
#include <sstream>
+#include <ctype.h>
+#include <stdlib.h>
-#include "config.h"
#include "https.h"
+
#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -83,9 +84,9 @@ HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
return size*nmemb;
}
-int
-HttpsMethod::progress_callback(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+int
+HttpsMethod::progress_callback(void *clientp, double dltotal, double /*dlnow*/,
+ double /*ultotal*/, double /*ulnow*/)
{
HttpsMethod *me = (HttpsMethod *)clientp;
if(dltotal > 0 && me->Res.Size == 0) {
@@ -95,7 +96,7 @@ HttpsMethod::progress_callback(void *clientp, double dltotal, double dlnow,
}
// HttpsServerState::HttpsServerState - Constructor /*{{{*/
-HttpsServerState::HttpsServerState(URI Srv,HttpsMethod *Owner) : ServerState(Srv, NULL)
+HttpsServerState::HttpsServerState(URI Srv,HttpsMethod * /*Owner*/) : ServerState(Srv, NULL)
{
TimeOut = _config->FindI("Acquire::https::Timeout",TimeOut);
Reset();
@@ -432,7 +433,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
delete File;
return true;
-};
+}
int main()
{
diff --git a/methods/https.h b/methods/https.h
index ab0dd3407..faac8a3cd 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -11,37 +11,42 @@
#ifndef APT_HTTPS_H
#define APT_HTTPS_H
-#include <iostream>
+#include <apt-pkg/acquire-method.h>
+
#include <curl/curl.h>
+#include <iostream>
+#include <stddef.h>
+#include <string>
#include "server.h"
using std::cout;
using std::endl;
+class Hashes;
class HttpsMethod;
class FileFd;
class HttpsServerState : public ServerState
{
protected:
- virtual bool ReadHeaderLines(std::string &Data) { return false; }
- virtual bool LoadNextResponse(bool const ToFile, FileFd * const File) { return false; }
+ virtual bool ReadHeaderLines(std::string &/*Data*/) { return false; }
+ virtual bool LoadNextResponse(bool const /*ToFile*/, FileFd * const /*File*/) { return false; }
public:
- virtual bool WriteResponse(std::string const &Data) { return false; }
+ virtual bool WriteResponse(std::string const &/*Data*/) { return false; }
/** \brief Transfer the data from the socket */
- virtual bool RunData(FileFd * const File) { return false; }
+ virtual bool RunData(FileFd * const /*File*/) { return false; }
virtual bool Open() { return false; }
virtual bool IsOpen() { return false; }
virtual bool Close() { return false; }
- virtual bool InitHashes(FileFd &File) { return false; }
+ virtual bool InitHashes(FileFd &/*File*/) { return false; }
virtual Hashes * GetHashes() { return NULL; }
- virtual bool Die(FileFd &File) { return false; }
- virtual bool Flush(FileFd * const File) { return false; }
- virtual bool Go(bool ToFile, FileFd * const File) { return false; }
+ virtual bool Die(FileFd &/*File*/) { return false; }
+ virtual bool Flush(FileFd * const /*File*/) { return false; }
+ virtual bool Go(bool /*ToFile*/, FileFd * const /*File*/) { return false; }
HttpsServerState(URI Srv, HttpsMethod *Owner);
virtual ~HttpsServerState() {Close();};
diff --git a/methods/mirror.cc b/methods/mirror.cc
index 085f3717b..d3aef91bc 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -16,18 +16,18 @@
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/hashes.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/metaindex.h>
+#include <apt-pkg/strutl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <algorithm>
-#include <fstream>
#include <iostream>
-
-#include <stdarg.h>
+#include <fstream>
#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/utsname.h>
#include <dirent.h>
@@ -60,7 +60,7 @@ using namespace std;
MirrorMethod::MirrorMethod()
: HttpMethod(), DownloadedMirrorFile(false), Debug(false)
{
-};
+}
// HttpMethod::Configuration - Handle a configuration message /*{{{*/
// ---------------------------------------------------------------------
@@ -90,17 +90,17 @@ bool MirrorMethod::Clean(string Dir)
pkgSourceList list;
list.ReadMainList();
- DIR *D = opendir(Dir.c_str());
+ DIR *D = opendir(Dir.c_str());
if (D == 0)
return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
-
+
string StartDir = SafeGetCWD();
if (chdir(Dir.c_str()) != 0)
{
closedir(D);
return _error->Errno("chdir",_("Unable to change to %s"),Dir.c_str());
}
-
+
for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
{
// Skip some files..
@@ -123,23 +123,23 @@ bool MirrorMethod::Clean(string Dir)
// nothing found, nuke it
if (I == list.end())
unlink(Dir->d_name);
- };
+ }
closedir(D);
if (chdir(StartDir.c_str()) != 0)
return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
- return true;
+ return true;
}
-bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str)
+bool MirrorMethod::DownloadMirrorFile(string /*mirror_uri_str*/)
{
- // not that great to use pkgAcquire here, but we do not have
+ // not that great to use pkgAcquire here, but we do not have
// any other way right now
string fetch = BaseUri;
fetch.replace(0,strlen("mirror://"),"http://");
-#if 0 // no need for this, the getArchitectures() will also include the main
+#if 0 // no need for this, the getArchitectures() will also include the main
// arch
// append main architecture
fetch += "?arch=" + _config->Find("Apt::Architecture");
@@ -173,7 +173,7 @@ bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str)
if(Debug)
clog << "MirrorMethod::DownloadMirrorFile() success: " << res << endl;
-
+
return res;
}
@@ -187,13 +187,13 @@ bool MirrorMethod::RandomizeMirrorFile(string mirror_file)
if (!FileExists(mirror_file))
return false;
- // read
+ // read
ifstream in(mirror_file.c_str());
while ( !in.eof() ) {
getline(in, line);
content.push_back(line);
}
-
+
// we want the file to be random for each different machine, but also
// "stable" on the same machine. this is to avoid running into out-of-sync
// issues (i.e. Release/Release.gpg different on each mirror)
@@ -422,10 +422,10 @@ bool MirrorMethod::Fetch(FetchItem *Itm)
if(Debug)
clog << "Fetch: " << Itm->Uri << endl << endl;
-
+
// now run the real fetcher
return HttpMethod::Fetch(Itm);
-};
+}
void MirrorMethod::Fail(string Err,bool Transient)
{
@@ -437,7 +437,7 @@ void MirrorMethod::Fail(string Err,bool Transient)
// try the next mirror on fail (if its not a expected failure,
// e.g. translations are ok to ignore)
- if (!Queue->FailIgnore && TryNextMirror())
+ if (!Queue->FailIgnore && TryNextMirror())
return;
// all mirrors failed, so bail out
diff --git a/methods/mirror.h b/methods/mirror.h
index 1dd9f2ec6..6c0ce370e 100644
--- a/methods/mirror.h
+++ b/methods/mirror.h
@@ -11,6 +11,8 @@
#ifndef APT_MIRROR_H
#define APT_MIRROR_H
+#include <apt-pkg/acquire-method.h>
+
#include <iostream>
#include <string>
#include <vector>
diff --git a/methods/rred.cc b/methods/rred.cc
index fe7ef7322..cabb3c456 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -8,19 +8,18 @@
#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
+#include <stddef.h>
+#include <iostream>
#include <string>
#include <list>
#include <vector>
-#include <iterator>
-#include <fcntl.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -469,7 +468,7 @@ class Patch {
void write_diff(FILE *f)
{
- size_t line = 0;
+ unsigned long long line = 0;
std::list<struct Change>::reverse_iterator ch;
for (ch = filechanges.rbegin(); ch != filechanges.rend(); ++ch) {
line += ch->offset + ch->del_cnt;
@@ -482,11 +481,11 @@ class Patch {
line -= ch->del_cnt;
if (ch->add_cnt > 0) {
if (ch->del_cnt == 0) {
- fprintf(f, "%lua\n", line);
+ fprintf(f, "%llua\n", line);
} else if (ch->del_cnt == 1) {
- fprintf(f, "%luc\n", line+1);
+ fprintf(f, "%lluc\n", line+1);
} else {
- fprintf(f, "%lu,%luc\n", line+1, line+ch->del_cnt);
+ fprintf(f, "%llu,%lluc\n", line+1, line+ch->del_cnt);
}
mg_i = ch;
@@ -496,9 +495,9 @@ class Patch {
fprintf(f, ".\n");
} else if (ch->del_cnt == 1) {
- fprintf(f, "%lud\n", line+1);
+ fprintf(f, "%llud\n", line+1);
} else if (ch->del_cnt > 1) {
- fprintf(f, "%lu,%lud\n", line+1, line+ch->del_cnt);
+ fprintf(f, "%llu,%llud\n", line+1, line+ch->del_cnt);
}
line -= ch->offset;
}
diff --git a/methods/rsh.cc b/methods/rsh.cc
index 550f77eca..bd46d2515 100644
--- a/methods/rsh.cc
+++ b/methods/rsh.cc
@@ -17,7 +17,11 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/strutl.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
@@ -368,7 +372,7 @@ RSHMethod::RSHMethod() : pkgAcqMethod("1.0",SendConfig)
signal(SIGINT,SigTerm);
Server = 0;
FailFd = -1;
-};
+}
/*}}}*/
// RSHMethod::Configuration - Handle a configuration message /*{{{*/
// ---------------------------------------------------------------------
@@ -390,7 +394,7 @@ bool RSHMethod::Configuration(std::string Message)
// RSHMethod::SigTerm - Clean up and timestamp the files on exit /*{{{*/
// ---------------------------------------------------------------------
/* */
-void RSHMethod::SigTerm(int sig)
+void RSHMethod::SigTerm(int)
{
if (FailFd == -1)
_exit(100);
@@ -519,7 +523,7 @@ bool RSHMethod::Fetch(FetchItem *Itm)
}
/*}}}*/
-int main(int argc, const char *argv[])
+int main(int, const char *argv[])
{
setlocale(LC_ALL, "");
diff --git a/methods/rsh.h b/methods/rsh.h
index d7efa3f06..dd259e744 100644
--- a/methods/rsh.h
+++ b/methods/rsh.h
@@ -11,6 +11,8 @@
#define APT_RSH_H
#include <string>
+#include <time.h>
+
#include <apt-pkg/strutl.h>
class Hashes;
@@ -62,7 +64,7 @@ class RSHMethod : public pkgAcqMethod
static std::string FailFile;
static int FailFd;
static time_t FailTime;
- static void SigTerm(int);
+ static APT_NORETURN void SigTerm(int);
public:
diff --git a/methods/server.cc b/methods/server.cc
index ef90c809c..5a13f18a7 100644
--- a/methods/server.cc
+++ b/methods/server.cc
@@ -10,32 +10,27 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/hashes.h>
-#include <apt-pkg/netrc.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
-#include <fcntl.h>
+#include <ctype.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <time.h>
#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <climits>
#include <iostream>
+#include <limits>
#include <map>
+#include <string>
+#include <vector>
-// Internet stuff
-#include <netdb.h>
-
-#include "config.h"
-#include "connect.h"
-#include "rfc2553emu.h"
-#include "http.h"
+#include "server.h"
#include <apti18n.h>
/*}}}*/
@@ -119,10 +114,10 @@ bool ServerState::HeaderLine(string Line)
string::size_type Pos2 = Pos;
while (Pos2 < Line.length() && isspace(Line[Pos2]) != 0)
Pos2++;
-
+
string Tag = string(Line,0,Pos);
string Val = string(Line,Pos2);
-
+
if (stringcasecmp(Tag.c_str(),Tag.c_str()+4,"HTTP") == 0)
{
// Evil servers return no version
@@ -159,14 +154,14 @@ bool ServerState::HeaderLine(string Line)
}
return true;
- }
-
+ }
+
if (stringcasecmp(Tag,"Content-Length:") == 0)
{
if (Encoding == Closes)
Encoding = Stream;
HaveContent = true;
-
+
// The length is already set from the Content-Range header
if (StartPos != 0)
return true;
@@ -184,7 +179,7 @@ bool ServerState::HeaderLine(string Line)
HaveContent = true;
return true;
}
-
+
if (stringcasecmp(Tag,"Content-Range:") == 0)
{
HaveContent = true;
@@ -201,12 +196,12 @@ bool ServerState::HeaderLine(string Line)
return _error->Error(_("This HTTP server has broken range support"));
return true;
}
-
+
if (stringcasecmp(Tag,"Transfer-Encoding:") == 0)
{
HaveContent = true;
if (stringcasecmp(Val,"chunked") == 0)
- Encoding = Chunked;
+ Encoding = Chunked;
return true;
}
@@ -218,7 +213,7 @@ bool ServerState::HeaderLine(string Line)
Persistent = true;
return true;
}
-
+
if (stringcasecmp(Tag,"Last-Modified:") == 0)
{
if (RFC1123StrToTime(Val.c_str(), Date) == false)
@@ -413,7 +408,7 @@ bool ServerMethod::Fetch(FetchItem *)
}
return true;
-};
+}
/*}}}*/
// ServerMethod::Loop - Main loop /*{{{*/
int ServerMethod::Loop()
diff --git a/methods/server.h b/methods/server.h
index 2b81e6173..0f45ab994 100644
--- a/methods/server.h
+++ b/methods/server.h
@@ -12,7 +12,10 @@
#define APT_SERVER_H
#include <apt-pkg/strutl.h>
+#include <apt-pkg/acquire-method.h>
+#include <time.h>
+#include <iostream>
#include <string>
using std::cout;
@@ -32,7 +35,7 @@ struct ServerState
// These are some statistics from the last parsed header lines
unsigned long long Size;
- signed long long StartPos;
+ unsigned long long StartPos;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
@@ -62,7 +65,7 @@ struct ServerState
/** \brief IO error while retrieving */
RUN_HEADERS_IO_ERROR,
/** \brief Parse error after retrieving */
- RUN_HEADERS_PARSE_ERROR,
+ RUN_HEADERS_PARSE_ERROR
};
/** \brief Get the headers before the data */
RunHeadersResult RunHeaders(FileFd * const File);
@@ -126,7 +129,7 @@ class ServerMethod : public pkgAcqMethod
static std::string FailFile;
static int FailFd;
static time_t FailTime;
- static void SigTerm(int);
+ static APT_NORETURN void SigTerm(int);
virtual bool Configuration(std::string Message);
virtual bool Flush() { return Server->Flush(File); };