mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 12:47:48 +02:00
Cleanup util, add documentation.
This commit is contained in:
parent
66754aac5a
commit
79e3f669f0
2 changed files with 374 additions and 329 deletions
93
util.h
93
util.h
|
@ -18,23 +18,73 @@ namespace util
|
|||
{
|
||||
extern std::map<std::string, std::string> mapArgs;
|
||||
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
|
||||
|
||||
/**
|
||||
* Parses command line arguments, i.e. stores them in config::mapArgs.
|
||||
*/
|
||||
void OptionParser(int argc, const char* const argv[]);
|
||||
|
||||
/**
|
||||
* @return a command line argument from config::mapArgs as an int
|
||||
* @param nDefault the default value to be returned
|
||||
*/
|
||||
int GetArg(const std::string& strArg, int nDefault);
|
||||
|
||||
/**
|
||||
* @return a command line argument from config::mapArgs as a std::string
|
||||
* @param strDefault the default value to be returned
|
||||
*/
|
||||
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
||||
|
||||
/**
|
||||
* @return a command line argument from config::mapArgs as a C-style string
|
||||
* @param nDefault the default value to be returned
|
||||
*/
|
||||
const char* GetCharArg(const std::string& strArg, const std::string& nDefault);
|
||||
}
|
||||
|
||||
namespace filesystem
|
||||
{
|
||||
void SetAppName (const std::string& name);
|
||||
std::string GetAppName ();
|
||||
/**
|
||||
* Change the application name.
|
||||
*/
|
||||
void SetAppName(const std::string& name);
|
||||
|
||||
const boost::filesystem::path &GetDataDir();
|
||||
std::string GetFullPath (const std::string& filename);
|
||||
boost::filesystem::path GetDefaultDataDir();
|
||||
/**
|
||||
* @return the application name.
|
||||
*/
|
||||
std::string GetAppName();
|
||||
|
||||
/**
|
||||
* @return the path of the i2pd directory
|
||||
*/
|
||||
const boost::filesystem::path& GetDataDir();
|
||||
|
||||
/**
|
||||
* @return the full path of a file within the i2pd directory
|
||||
*/
|
||||
std::string GetFullPath(const std::string& filename);
|
||||
|
||||
/**
|
||||
* @return the path of the configuration file
|
||||
*/
|
||||
boost::filesystem::path GetConfigFile();
|
||||
|
||||
/**
|
||||
* @return the default directory for i2pd data
|
||||
*/
|
||||
boost::filesystem::path GetDefaultDataDir();
|
||||
|
||||
|
||||
/**
|
||||
* Read a configuration file and store its contents in the given maps.
|
||||
*/
|
||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
|
||||
std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
||||
|
||||
/**
|
||||
* @return the path of the certificates directory
|
||||
*/
|
||||
boost::filesystem::path GetCertificatesDir();
|
||||
}
|
||||
|
||||
|
@ -46,10 +96,32 @@ namespace util
|
|||
const char LAST_MODIFIED[] = "Last-Modified";
|
||||
const char TRANSFER_ENCODING[] = "Transfer-Encoding";
|
||||
|
||||
/**
|
||||
* Perform an HTTP request.
|
||||
* @return the result of the request, or an empty string if it fails
|
||||
*/
|
||||
std::string httpRequest(const std::string& address);
|
||||
std::string GetHttpContent (std::istream& response);
|
||||
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
||||
int httpRequestViaI2pProxy(const std::string& address, std::string &content); // return http code
|
||||
|
||||
/**
|
||||
* @return the content of the given HTTP stream without headers
|
||||
*/
|
||||
std::string GetHttpContent(std::istream& response);
|
||||
|
||||
/**
|
||||
* Merge chunks of a HTTP response into the gien std:ostream object.
|
||||
*/
|
||||
void MergeChunkedResponse(std::istream& response, std::ostream& merged);
|
||||
|
||||
/**
|
||||
* Send an HTTP request through the i2p proxy.
|
||||
* @return the HTTP status code
|
||||
*/
|
||||
int httpRequestViaI2pProxy(const std::string& address, std::string &content);
|
||||
|
||||
|
||||
/**
|
||||
* @return the decoded url
|
||||
*/
|
||||
std::string urlDecode(const std::string& data);
|
||||
|
||||
/**
|
||||
|
@ -73,7 +145,10 @@ namespace util
|
|||
|
||||
namespace net
|
||||
{
|
||||
int GetMTU (const boost::asio::ip::address& localAddress);
|
||||
/**
|
||||
* @return the maximum transmission unit, or 576 on failure
|
||||
*/
|
||||
int GetMTU(const boost::asio::ip::address& localAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue