2 Commits

Author SHA1 Message Date
3f9171737c Rename some functions and classes to make more sense 2021-04-15 11:53:35 -07:00
fb14afe8d9 Fix soname 2021-04-11 19:24:01 -07:00
7 changed files with 43 additions and 42 deletions

View File

@@ -18,7 +18,7 @@ mark_as_advanced(ENABLE_PROFILING)
set(SOURCE_LIST "src/async.cpp" "src/curl_easy_handle.cpp" "src/curl_header_list.cpp" "src/httpint.cpp" "src/read_write_cback.cpp" "src/response.cpp" "src/sync.cpp" "src/types.cpp")
if(ENABLE_SHARED)
add_library(rcw SHARED ${SOURCE_LIST})
set_target_properties(rcw PROPERTIES SOVERSION "${librcw_VERSION_MAJOR}.${librcw_VERSION_MINOR}.${librcw_VERSION_REVISION}")
set_target_properties(rcw PROPERTIES SOVERSION "${librcw_VERSION_MAJOR}.${librcw_VERSION_MINOR}")
set(LIBRCW_LIBFLAGS "-lrcw")
target_link_libraries(rcw "-lcurl -lrexy -lpthread")
else()
@@ -26,6 +26,7 @@ else()
set(LIBRCW_LIBFLAGS "-lrcw -lcurl -lrexy -lpthread")
target_link_libraries(rcw "-lcurl -lrexy -lpthread")
endif()
set_target_properties(rcw PROPERTIES VERSION "${librcw_VERSION_MAJOR}.${librcw_VERSION_MINOR}.${librcw_VERSION_REVISION}")
if(ENABLE_PROFILING)
target_compile_options(rcw PRIVATE -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)

View File

@@ -78,19 +78,19 @@ namespace rcw{
void reset(void);
response perform(void);
string escape_to_str(const char* data, int len = 0);
string escape_to_str(const rexy::string_base<char>& data);
string escape(const char* data, int len = 0);
string escape(const rexy::string_base<char>& data);
std::string escape_to_std(const char* data, int len = 0);
std::string escape_to_std(const rexy::string_base<char>& data);
char* escape_to_cstr(const char* data, int* outlen, int len = 0);
char* escape_to_cstr(const rexy::string_base<char>& data, int* outlen);
std::string decode_to_std(const char* data, int len = 0);
std::string decode_to_std(const rexy::string_base<char>& data);
string decode_to_str(const char* data, int len = 0);
string decode_to_str(const rexy::string_base<char>& data);
char* decode_to_cstr(const char* data, int* outlen, int len = 0);
char* decode_to_cstr(const rexy::string_base<char>& data, int* outlen);
std::string unescape_to_std(const char* data, int len = 0);
std::string unescape_to_std(const rexy::string_base<char>& data);
string unescape(const char* data, int len = 0);
string unescape(const rexy::string_base<char>& data);
char* unescape_to_cstr(const char* data, int* outlen, int len = 0);
char* unescape_to_cstr(const rexy::string_base<char>& data, int* outlen);
long get_last_status(void)const;
CURL* get(void);

View File

@@ -22,17 +22,17 @@
namespace rcw{
//class representing http status codes where 200-299 is valid and 300+ is invalid
class http_status
class httpint
{
private:
long m_code = 200;
public:
http_status(void) = default;
http_status(long x);
http_status(const http_status&) = default;
http_status& operator=(const http_status&) = default;
http_status& operator=(long x);
httpint(void) = default;
httpint(long x);
httpint(const httpint&) = default;
httpint& operator=(const httpint&) = default;
httpint& operator=(long x);
bool ok(void)const;
operator long(void)const;

View File

@@ -21,13 +21,13 @@
#define RCW_VERSION @librcw_VERSION_STRING@
#include <sync.hpp>
#include <async.hpp>
#include <response.hpp>
#include <curl_easy_handle.hpp>
#include <curl_header_list.hpp>
#include <httpint.hpp>
#include <string.hpp>
#include <types.hpp>
#include <rcw/sync.hpp>
#include <rcw/async.hpp>
#include <rcw/response.hpp>
#include <rcw/curl_easy_handle.hpp>
#include <rcw/curl_header_list.hpp>
#include <rcw/httpint.hpp>
#include <rcw/string.hpp>
#include <rcw/types.hpp>
#endif

View File

@@ -27,7 +27,7 @@ namespace rcw{
class response
{
public:
http_status status;
httpint status;
size_t elapsed_time_us; //CURLINFO_TOTAL_TIME_T
size_t uploaded_bytes; //CURLINFO_SIZE_UPLOAD_T
size_t downloaded_bytes; //CURLINFO_SIZE_DOWNLOAD_T

View File

@@ -162,25 +162,25 @@ namespace rcw{
return tmp;
}
std::string curl_easy_handle::decode_to_std(const char* data, int len){
char* tmp = decode_to_cstr(data, &len, len);
std::string curl_easy_handle::unescape_to_std(const char* data, int len){
char* tmp = unescape_to_cstr(data, &len, len);
std::string ret(tmp, len);
curl_free(tmp);
return ret;
}
char* curl_easy_handle::decode_to_cstr(const char* data, int* outlen, int len){
char* curl_easy_handle::unescape_to_cstr(const char* data, int* outlen, int len){
if(!len)
len = strlen(data);
char* tmp = curl_easy_unescape(m_curl, data, len, outlen);
return tmp;
}
string curl_easy_handle::escape_to_str(const char* data, int len){
string curl_easy_handle::escape(const char* data, int len){
char* tmp = escape_to_cstr(data, &len, len);
return string(rexy::steal(tmp), len, len);
}
string curl_easy_handle::escape_to_str(const rexy::string_base<char>& data){
return escape_to_str(data.get(), data.length());
string curl_easy_handle::escape(const rexy::string_base<char>& data){
return escape(data.get(), data.length());
}
std::string curl_easy_handle::escape_to_std(const rexy::string_base<char>& data){
return escape_to_std(data.get(), data.length());
@@ -189,17 +189,17 @@ namespace rcw{
return escape_to_cstr(data.get(), outlen, data.length());
}
string curl_easy_handle::decode_to_str(const char* data, int len){
char* tmp = decode_to_cstr(data, &len, len);
string curl_easy_handle::unescape(const char* data, int len){
char* tmp = unescape_to_cstr(data, &len, len);
return string(rexy::steal(tmp), len, len);
}
string curl_easy_handle::decode_to_str(const rexy::string_base<char>& data){
return decode_to_str(data.get(), data.length());
string curl_easy_handle::unescape(const rexy::string_base<char>& data){
return unescape(data.get(), data.length());
}
std::string curl_easy_handle::decode_to_std(const rexy::string_base<char>& data){
return decode_to_std(data.get(), data.length());
std::string curl_easy_handle::unescape_to_std(const rexy::string_base<char>& data){
return unescape_to_std(data.get(), data.length());
}
char* curl_easy_handle::decode_to_cstr(const rexy::string_base<char>& data, int* outlen){
char* curl_easy_handle::unescape_to_cstr(const rexy::string_base<char>& data, int* outlen){
return escape_to_cstr(data.get(), outlen, data.length());
}

View File

@@ -20,20 +20,20 @@
namespace rcw{
http_status::http_status(long x):
httpint::httpint(long x):
m_code(x){}
http_status& http_status::operator=(long x){
httpint& httpint::operator=(long x){
m_code = x;
return *this;
}
bool http_status::ok(void)const{
bool httpint::ok(void)const{
return (m_code >= 200 && m_code < 300);
}
http_status::operator long(void)const{
httpint::operator long(void)const{
return m_code;
}
long http_status::get(void)const{
long httpint::get(void)const{
return m_code;
}