diff options
author | Michael Vogt <mvo@debian.org> | 2014-03-14 09:02:44 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-03-14 09:02:44 +0100 |
commit | 83b880c6505a20247239d897b7387bba37942993 (patch) | |
tree | 11a23275548175e301f6fefda20a6a8bb6fe6de8 /test/interactive-helper/aptwebserver.cc | |
parent | f98d9bd2adf4f24a72d973f5752b47987843984c (diff) | |
parent | 40f8a8ba8c2e7ff9ce80781250c863c07ac130dd (diff) |
fix test/integration/test-apt-helper
Diffstat (limited to 'test/interactive-helper/aptwebserver.cc')
-rw-r--r-- | test/interactive-helper/aptwebserver.cc | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 992f802a6..34476e1af 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -1,29 +1,31 @@ #include <config.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/fileutl.h> -#include <apt-pkg/error.h> #include <apt-pkg/cmndline.h> #include <apt-pkg/configuration.h> -#include <apt-pkg/init.h> - -#include <vector> -#include <string> -#include <list> -#include <sstream> +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/strutl.h> +#include <dirent.h> +#include <errno.h> +#include <netinet/in.h> +#include <pthread.h> +#include <regex.h> +#include <signal.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> #include <sys/socket.h> -#include <sys/types.h> #include <sys/stat.h> -#include <netinet/in.h> -#include <unistd.h> -#include <errno.h> #include <time.h> -#include <stdlib.h> -#include <dirent.h> -#include <signal.h> +#include <unistd.h> +#include <iostream> +#include <sstream> +#include <list> +#include <string> +#include <vector> -char const * const httpcodeToStr(int const httpcode) /*{{{*/ +static char const * httpcodeToStr(int const httpcode) /*{{{*/ { switch (httpcode) { @@ -77,7 +79,7 @@ char const * const httpcodeToStr(int const httpcode) /*{{{*/ return NULL; } /*}}}*/ -void addFileHeaders(std::list<std::string> &headers, FileFd &data) /*{{{*/ +static void addFileHeaders(std::list<std::string> &headers, FileFd &data)/*{{{*/ { std::ostringstream contentlength; contentlength << "Content-Length: " << data.FileSize(); @@ -88,14 +90,14 @@ void addFileHeaders(std::list<std::string> &headers, FileFd &data) /*{{{*/ headers.push_back(lastmodified); } /*}}}*/ -void addDataHeaders(std::list<std::string> &headers, std::string &data) /*{{{*/ +static void addDataHeaders(std::list<std::string> &headers, std::string &data)/*{{{*/ { std::ostringstream contentlength; contentlength << "Content-Length: " << data.size(); headers.push_back(contentlength.str()); } /*}}}*/ -bool sendHead(int const client, int const httpcode, std::list<std::string> &headers)/*{{{*/ +static bool sendHead(int const client, int const httpcode, std::list<std::string> &headers)/*{{{*/ { std::string response("HTTP/1.1 "); response.append(httpcodeToStr(httpcode)); @@ -128,7 +130,7 @@ bool sendHead(int const client, int const httpcode, std::list<std::string> &head return Success; } /*}}}*/ -bool sendFile(int const client, FileFd &data) /*{{{*/ +static bool sendFile(int const client, FileFd &data) /*{{{*/ { bool Success = true; char buffer[500]; @@ -144,7 +146,7 @@ bool sendFile(int const client, FileFd &data) /*{{{*/ return Success; } /*}}}*/ -bool sendData(int const client, std::string const &data) /*{{{*/ +static bool sendData(int const client, std::string const &data) /*{{{*/ { if (FileFd::Write(client, data.c_str(), data.size()) == false) { @@ -154,7 +156,7 @@ bool sendData(int const client, std::string const &data) /*{{{*/ return true; } /*}}}*/ -void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/ +static void sendError(int const client, int const httpcode, std::string const &request,/*{{{*/ bool content, std::string const &error = "") { std::list<std::string> headers; @@ -179,13 +181,13 @@ void sendError(int const client, int const httpcode, std::string const &request, if (content == true) sendData(client, response); } -void sendSuccess(int const client, std::string const &request, +static void sendSuccess(int const client, std::string const &request, bool content, std::string const &error = "") { sendError(client, 200, request, content, error); } /*}}}*/ -void sendRedirect(int const client, int const httpcode, std::string const &uri,/*{{{*/ +static void sendRedirect(int const client, int const httpcode, std::string const &uri,/*{{{*/ std::string const &request, bool content) { std::list<std::string> headers; @@ -222,7 +224,7 @@ void sendRedirect(int const client, int const httpcode, std::string const &uri,/ sendData(client, response); } /*}}}*/ -int filter_hidden_files(const struct dirent *a) /*{{{*/ +static int filter_hidden_files(const struct dirent *a) /*{{{*/ { if (a->d_name[0] == '.') return 0; @@ -236,7 +238,7 @@ int filter_hidden_files(const struct dirent *a) /*{{{*/ #endif return 1; } -int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { +static int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { #ifdef _DIRENT_HAVE_D_TYPE if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_DIR); else if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_REG) @@ -260,7 +262,7 @@ int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { return strcasecmp((*a)->d_name, (*b)->d_name); } /*}}}*/ -void sendDirectoryListing(int const client, std::string const &dir, /*{{{*/ +static void sendDirectoryListing(int const client, std::string const &dir,/*{{{*/ std::string const &request, bool content) { std::list<std::string> headers; @@ -312,7 +314,7 @@ void sendDirectoryListing(int const client, std::string const &dir, /*{{{*/ sendData(client, response); } /*}}}*/ -bool parseFirstLine(int const client, std::string const &request, /*{{{*/ +static bool parseFirstLine(int const client, std::string const &request,/*{{{*/ std::string &filename, std::string ¶ms, bool &sendContent, bool &closeConnection) { @@ -432,7 +434,7 @@ bool parseFirstLine(int const client, std::string const &request, /*{{{*/ return true; } /*}}}*/ -bool handleOnTheFlyReconfiguration(int const client, std::string const &request, std::vector<std::string> const &parts)/*{{{*/ +static bool handleOnTheFlyReconfiguration(int const client, std::string const &request, std::vector<std::string> const &parts)/*{{{*/ { size_t const pcount = parts.size(); if (pcount == 4 && parts[1] == "set") @@ -475,7 +477,7 @@ bool handleOnTheFlyReconfiguration(int const client, std::string const &request, return false; } /*}}}*/ -void * handleClient(void * voidclient) /*{{{*/ +static void * handleClient(void * voidclient) /*{{{*/ { int client = *((int*)(voidclient)); std::clog << "ACCEPT client " << client << std::endl; |