2014-01-30 07:28:07 +04:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2014-02-01 17:28:30 +04:00
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include <boost/filesystem/fstream.hpp>
|
2014-01-30 07:28:07 +04:00
|
|
|
|
2014-02-01 07:09:55 +04:00
|
|
|
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
|
|
|
|
|
2014-01-30 07:28:07 +04:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
2014-02-01 07:09:55 +04:00
|
|
|
namespace config
|
|
|
|
{
|
|
|
|
extern std::map<std::string, std::string> mapArgs;
|
|
|
|
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
|
|
|
void OptionParser(int argc, const char* const argv[]);
|
|
|
|
int GetArg(const std::string& strArg, int nDefault);
|
|
|
|
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
|
|
|
const char* GetCharArg(const std::string& strArg, const std::string& nDefault);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace filesystem
|
|
|
|
{
|
2014-02-01 07:51:58 +04:00
|
|
|
const boost::filesystem::path &GetDataDir();
|
2014-03-13 22:22:32 +04:00
|
|
|
std::string GetFullPath (const std::string& filename);
|
2014-02-01 07:09:55 +04:00
|
|
|
boost::filesystem::path GetDefaultDataDir();
|
|
|
|
boost::filesystem::path GetConfigFile();
|
|
|
|
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
|
|
|
|
std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
|
|
|
}
|
|
|
|
|
2014-01-31 10:22:11 +04:00
|
|
|
namespace http
|
|
|
|
{
|
|
|
|
std::string httpRequest(const std::string& address);
|
|
|
|
struct url {
|
|
|
|
url(const std::string& url_s); // omitted copy, ==, accessors, ...
|
|
|
|
private:
|
|
|
|
void parse(const std::string& url_s);
|
|
|
|
public:
|
2014-04-07 00:18:55 +04:00
|
|
|
std::string protocol_, host_, path_, query_;
|
|
|
|
std::string portstr_ = "80";
|
|
|
|
unsigned int port_ = 80;
|
|
|
|
std::string user_ = "";
|
|
|
|
std::string pass_ = "";
|
2014-01-31 10:22:11 +04:00
|
|
|
};
|
|
|
|
}
|
2014-01-30 07:28:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|