Skip to content
Snippets Groups Projects
Commit 48b60acb authored by alexey.stratulat's avatar alexey.stratulat Committed by dmitriy.gerasimov
Browse files

[+] Added function dap_ctime_r. This function does the same as ctime_r, but if...

[+] Added function dap_ctime_r. This function does the same as ctime_r, but if it returns (null), a line break is added.
parent fe619958
No related branches found
No related tags found
1 merge request!263Master
......@@ -33,6 +33,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifndef __cplusplus
# include <stdatomic.h>
......@@ -50,6 +51,7 @@
#define pipe(pfds) _pipe(pfds, 4096, _O_BINARY)
#define strerror_r(arg1, arg2, arg3) strerror_s(arg2, arg3, arg1)
#define ctime_r(arg1, arg2) ctime_s(arg2, sizeof(arg2), arg1)
#define asctime_r(arg1, arg2) asctime_s(arg2, sizeof(arg2), arg1)
#endif
#ifdef __MACH__
#include <dispatch/dispatch.h>
......@@ -453,6 +455,14 @@ void dap_lendian_put64(uint8_t *a_buf, uint64_t a_val);
#define DAP_USEC_PER_SEC 1000000
void dap_usleep(time_t a_microseconds);
/**
* @brief dap_ctime_r This function does the same as ctime_r, but if it returns (null), a line break is added.
* @param a_time
* @param a_buf The minimum buffer size is 26 elements.
* @return
*/
char* dap_ctime_r(time_t *a_time, char* a_buf);
#ifdef __MINGW32__
......
......@@ -1066,3 +1066,13 @@ void dap_usleep(time_t a_microseconds)
#endif
}
char* dap_ctime_r(time_t *a_time, char* a_buf){
struct tm *l_time = localtime(a_time);
char *l_str_time = asctime_r(l_time, a_buf);
if (l_str_time)
return l_str_time;
else
return "(null)\n";
// localtime_r()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment