mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-07-08 01:30:39 +08:00
Update
This commit is contained in:
@@ -93,6 +93,9 @@ if (NOT MSVC)
|
|||||||
check_symbol_exists(timezone "time.h" HAVE_TIMEZONE)
|
check_symbol_exists(timezone "time.h" HAVE_TIMEZONE)
|
||||||
check_symbol_exists(tzset "time.h" HAVE_TZSET)
|
check_symbol_exists(tzset "time.h" HAVE_TZSET)
|
||||||
endif()
|
endif()
|
||||||
|
if (NOT WIN32)
|
||||||
|
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
|
||||||
|
endif()
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utils_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/utils_config.h")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utils_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/utils_config.h")
|
||||||
|
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
|
||||||
|
|||||||
@@ -1028,3 +1028,18 @@ std::string dumpCookie(std::map<std::string, std::string> cookie) {
|
|||||||
}
|
}
|
||||||
return re;
|
return re;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Request::toUri() {
|
||||||
|
std::string re;
|
||||||
|
if (this->https) {
|
||||||
|
re += "https://";
|
||||||
|
} else {
|
||||||
|
re += "http://";
|
||||||
|
}
|
||||||
|
re += this->host;
|
||||||
|
if (this->port != (this->https ? "https" : "http")) {
|
||||||
|
re += ":" + this->port;
|
||||||
|
}
|
||||||
|
re += this->path;
|
||||||
|
return re;
|
||||||
|
}
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ public:
|
|||||||
std::string path;
|
std::string path;
|
||||||
std::string method;
|
std::string method;
|
||||||
CookiesBase* cookies = nullptr;
|
CookiesBase* cookies = nullptr;
|
||||||
|
std::string toUri();
|
||||||
private:
|
private:
|
||||||
HttpBody* body = nullptr;
|
HttpBody* body = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,3 +63,18 @@ time_t time_util::timegm(struct tm* tm) {
|
|||||||
return now + get_timezone();
|
return now + get_timezone();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t time_util::time_ns() {
|
||||||
|
#if _WIN32
|
||||||
|
FILETIME ft;
|
||||||
|
GetSystemTimeAsFileTime(&ft);
|
||||||
|
time_t t = ((size_t)ft.dwHighDateTime << 32) | (size_t)ft.dwLowDateTime;
|
||||||
|
return t;
|
||||||
|
#elif HAVE_CLOCK_GETTIME
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
return ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||||
|
#else
|
||||||
|
return time(NULL) * 1000000000LL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ namespace time_util {
|
|||||||
char* strptime(const char* s, const char* format, struct tm* tm);
|
char* strptime(const char* s, const char* format, struct tm* tm);
|
||||||
long get_timezone();
|
long get_timezone();
|
||||||
time_t timegm(struct tm* tm);
|
time_t timegm(struct tm* tm);
|
||||||
|
time_t time_ns();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,3 +26,4 @@
|
|||||||
#cmakedefine HAVE_TIMEZONE @HAVE_TIMEZONE@
|
#cmakedefine HAVE_TIMEZONE @HAVE_TIMEZONE@
|
||||||
#cmakedefine HAVE_TZSET @HAVE_TZSET@
|
#cmakedefine HAVE_TZSET @HAVE_TZSET@
|
||||||
#cmakedefine HAVE_FPRINTF_S @HAVE_FPRINTF_S@
|
#cmakedefine HAVE_FPRINTF_S @HAVE_FPRINTF_S@
|
||||||
|
#cmakedefine HAVE_CLOCK_GETTIME @HAVE_CLOCK_GETTIME@
|
||||||
|
|||||||
Reference in New Issue
Block a user