mirror of
https://github.com/nmap/nmap.git
synced 2026-01-04 13:49:03 +00:00
Add thread-safe gmtime equivalent to nbase
This commit is contained in:
@@ -165,6 +165,10 @@ int n_localtime(const time_t *timer, struct tm *result) {
|
||||
return localtime_s(result, timer);
|
||||
}
|
||||
|
||||
int n_gmtime(const time_t *timer, struct tm *result) {
|
||||
return gmtime_s(result, timer);
|
||||
}
|
||||
|
||||
int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
|
||||
return ctime_s(buffer, bufsz, timer);
|
||||
}
|
||||
@@ -184,6 +188,14 @@ int n_localtime(const time_t *timer, struct tm *result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_gmtime(const time_t *timer, struct tm *result) {
|
||||
struct tm *tmp = gmtime_s(timer, result);
|
||||
if (!tmp) {
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
|
||||
return ctime_s(buffer, bufsz, timer);
|
||||
}
|
||||
@@ -200,6 +212,14 @@ int n_localtime(const time_t *timer, struct tm *result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_gmtime(const time_t *timer, struct tm *result) {
|
||||
struct tm *tmp = gmtime_r(timer, result);
|
||||
if (!tmp) {
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
|
||||
char *tmp = ctime_r(timer, buffer);
|
||||
if (!tmp) {
|
||||
@@ -223,6 +243,15 @@ int n_localtime(const time_t *timer, struct tm *result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_gmtime(const time_t *timer, struct tm *result) {
|
||||
struct tm *tmp = gmtime(timer); // lgtm[cpp/potentially-dangerous-function]
|
||||
if (tmp)
|
||||
*result = *tmp;
|
||||
else
|
||||
return errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
|
||||
char *tmp = ctime(timer); // lgtm[cpp/potentially-dangerous-function]
|
||||
if (tmp)
|
||||
|
||||
Reference in New Issue
Block a user