@@ -99,14 +99,6 @@ extern "C" {
9999
100100#define socklen_t int
101101#define closesocket (x ) soc_close(x)
102- #define gmtime_r (a, b ) gmtime(a)
103- #define MG_INT64_FMT " %lld"
104-
105- static __inline struct tm *localtime_r (const time_t *t, struct tm *tm) {
106- struct tm *x = localtime (t);
107- *tm = *x;
108- return tm;
109- }
110102
111103#undef FOPEN_MAX
112104
@@ -192,16 +184,6 @@ struct timeval {
192184#error Set LWIP_SOCKET variable to 1 (in lwipopts.h)
193185#endif
194186
195- #if LWIP_POSIX_SOCKETS_IO_NAMES != 0
196- // LWIP_POSIX_SOCKETS_IO_NAMES must be disabled in posix-compatible OS
197- // enviroment (freertos mimics to one) otherwise names like `read` and `write`
198- // conflict
199- #error LWIP_POSIX_SOCKETS_IO_NAMES must be set to 0 (in lwipopts.h) for FreeRTOS
200- #endif
201-
202- #define MG_INT64_FMT " %lld"
203- #define MG_DIRSEP ' /'
204-
205187// Re-route calloc/free to the FreeRTOS's functions, don't use stdlib
206188static inline void *mg_calloc (int cnt, size_t size) {
207189 void *p = pvPortMalloc (cnt * size);
@@ -211,7 +193,6 @@ static inline void *mg_calloc(int cnt, size_t size) {
211193#define calloc (a, b ) mg_calloc((a), (b))
212194#define free (a ) vPortFree(a)
213195#define malloc (a ) pvPortMalloc(a)
214- #define gmtime_r (a, b ) gmtime(a)
215196#define mkdir (a, b ) (-1 )
216197
217198#endif // MG_ARCH == MG_ARCH_FREERTOS_LWIP
@@ -275,8 +256,6 @@ static inline void *mg_calloc(int cnt, size_t size) {
275256#define malloc (a ) pvPortMalloc(a)
276257#define mkdir (a, b ) (-1 )
277258
278- #define gmtime_r (a, b ) gmtime(a)
279-
280259#if !defined(__GNUC__)
281260// copied from GCC on ARM; for some reason useconds are signed
282261struct timeval {
@@ -331,8 +310,6 @@ struct timeval {
331310#include < time.h>
332311#include < unistd.h>
333312
334- #define MG_INT64_FMT " %" PRId64
335-
336313#ifndef MG_ENABLE_DIRLIST
337314#define MG_ENABLE_DIRLIST 1
338315#endif
@@ -430,19 +407,6 @@ typedef int socklen_t;
430407#define MG_ENABLE_DIRLIST 1
431408#endif
432409
433- // https://lgtm.com/rules/2154840805/ -gmtime, localtime, ctime and asctime
434- static __inline struct tm *gmtime_r (const time_t *t, struct tm *tm) {
435- struct tm *x = gmtime (t);
436- *tm = *x;
437- return tm;
438- }
439-
440- static __inline struct tm *localtime_r (const time_t *t, struct tm *tm) {
441- struct tm *x = localtime (t);
442- *tm = *x;
443- return tm;
444- }
445-
446410#endif
447411
448412
@@ -584,6 +548,17 @@ const char *mg_strstr(const struct mg_str haystack, const struct mg_str needle);
584548bool mg_match (struct mg_str str, struct mg_str pattern, struct mg_str *caps);
585549bool mg_globmatch (const char *pattern, size_t plen, const char *s, size_t n);
586550bool mg_commalist (struct mg_str *s, struct mg_str *k, struct mg_str *v);
551+ bool mg_commalist (struct mg_str *s, struct mg_str *k, struct mg_str *v);
552+ size_t mg_vsnprintf (char *buf, size_t len, const char *fmt, va_list ap);
553+ size_t mg_snprintf (char *buf, size_t len, const char *fmt, ...);
554+ char *mg_hexdump (const void *buf, size_t len);
555+ char *mg_hex (const void *buf, size_t len, char *dst);
556+ void mg_unhex (const char *buf, size_t len, unsigned char *to);
557+ unsigned long mg_unhexn (const char *s, size_t len);
558+ int mg_asprintf (char **buf, size_t size, const char *fmt, ...);
559+ int mg_vasprintf (char **buf, size_t size, const char *fmt, va_list ap);
560+ int mg_check_ip_acl (struct mg_str acl, uint32_t remote_ip);
561+ int64_t mg_to64 (struct mg_str str);
587562
588563
589564
@@ -687,14 +662,6 @@ void mg_random(void *buf, size_t len);
687662uint16_t mg_ntohs (uint16_t net);
688663uint32_t mg_ntohl (uint32_t net);
689664uint32_t mg_crc32 (uint32_t crc, const char *buf, size_t len);
690- char *mg_hexdump (const void *buf, size_t len);
691- char *mg_hex (const void *buf, size_t len, char *dst);
692- void mg_unhex (const char *buf, size_t len, unsigned char *to);
693- unsigned long mg_unhexn (const char *s, size_t len);
694- int mg_asprintf (char **buf, size_t size, const char *fmt, ...);
695- int mg_vasprintf (char **buf, size_t size, const char *fmt, va_list ap);
696- int mg_check_ip_acl (struct mg_str acl, uint32_t remote_ip);
697- int64_t mg_to64 (struct mg_str str);
698665int64_t mg_millis (void );
699666
700667#define mg_htons (x ) mg_ntohs(x)
0 commit comments