diff --git a/mongoose.c b/mongoose.c index 472a114da320398a9efa2084ca56e03ef706abdb..75ee3ac70e99fdea14f7962fdab4910c23e902a2 100644 --- a/mongoose.c +++ b/mongoose.c @@ -165,6 +165,10 @@ MG_INTERNAL int mg_sntp_parse_reply(const char *buf, int len, #ifndef CS_COMMON_MG_MEM_H_ #define CS_COMMON_MG_MEM_H_ +#ifdef __cplusplus +extern "C" { +#endif + #ifndef MG_MALLOC #define MG_MALLOC malloc #endif @@ -181,6 +185,10 @@ MG_INTERNAL int mg_sntp_parse_reply(const char *buf, int len, #define MG_FREE free #endif +#ifdef __cplusplus +} +#endif + #endif /* CS_COMMON_MG_MEM_H_ */ #ifdef MG_MODULE_LINES #line 1 "common/cs_dbg.h" @@ -782,6 +790,10 @@ double cs_time(void) { #ifndef CS_COMMON_CS_ENDIAN_H_ #define CS_COMMON_CS_ENDIAN_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * clang with std=-c99 uses __LITTLE_ENDIAN, by default * while for ex, RTOS gcc - LITTLE_ENDIAN, by default @@ -797,6 +809,10 @@ double cs_time(void) { #endif /* BIG_ENDIAN */ #endif /* BYTE_ORDER */ +#ifdef __cplusplus +} +#endif + #endif /* CS_COMMON_CS_ENDIAN_H_ */ #ifdef MG_MODULE_LINES #line 1 "common/cs_md5.c" diff --git a/mongoose.h b/mongoose.h index 66fbe857ee3aaf00e71aff3a94cdfdbc856ff090..819dd80b41c9e023ccbd36e2ac4f4033c4498a6b 100644 --- a/mongoose.h +++ b/mongoose.h @@ -560,9 +560,9 @@ typedef struct stat cs_stat_t; #ifndef MG_NET_IF #include <lwip/opt.h> #if LWIP_SOCKET /* RTOS SDK has LWIP sockets */ -# define MG_NET_IF MG_NET_IF_SOCKET +#define MG_NET_IF MG_NET_IF_SOCKET #else -# define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL +#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL #endif #endif @@ -603,7 +603,7 @@ typedef struct stat cs_stat_t; #include <simplelink.h> #include <netapp.h> -#undef timeval +#undef timeval typedef int sock_t; #define INVALID_SOCKET (-1) @@ -840,7 +840,8 @@ int _stat(const char *pathname, struct stat *st); #define CS_ENABLE_STDIO 1 #endif -#if (defined(CC3200_FS_SPIFFS) || defined(CC3200_FS_SLFS)) && !defined(MG_ENABLE_FILESYSTEM) +#if (defined(CC3200_FS_SPIFFS) || defined(CC3200_FS_SLFS)) && \ + !defined(MG_ENABLE_FILESYSTEM) #define MG_ENABLE_FILESYSTEM 1 #endif @@ -884,15 +885,15 @@ typedef struct stat cs_stat_t; #define __cdecl #ifndef MG_NET_IF -# include <lwip/opt.h> -# if LWIP_SOCKET -# define MG_NET_IF MG_NET_IF_SOCKET -# else -# define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL -# endif -# define MG_LWIP 1 +#include <lwip/opt.h> +#if LWIP_SOCKET +#define MG_NET_IF MG_NET_IF_SOCKET +#else +#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL +#endif +#define MG_LWIP 1 #elif MG_NET_IF == MG_NET_IF_SIMPLELINK -# include "common/platforms/simplelink/cs_simplelink.h" +/* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */ #endif #ifndef CS_ENABLE_STDIO @@ -1014,16 +1015,16 @@ in_addr_t inet_addr(const char *cp); #define to64(x) strtoll(x, NULL, 10) -#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL -#define MG_LWIP 1 -#define MG_ENABLE_IPV6 1 +#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL +#define MG_LWIP 1 +#define MG_ENABLE_IPV6 1 /* * For ARM C Compiler, make lwip to export `struct timeval`; for other * compilers, suppress it. */ #if !defined(__ARMCC_VERSION) -# define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_TIMEVAL_PRIVATE 0 #else struct timeval; int gettimeofday(struct timeval *tp, void *tzp); @@ -1060,12 +1061,12 @@ int gettimeofday(struct timeval *tp, void *tzp); #define to64(x) strtoll(x, NULL, 10) -#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL -#define MG_LWIP 1 -#define MG_ENABLE_IPV6 1 +#define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL +#define MG_LWIP 1 +#define MG_ENABLE_IPV6 1 #if !defined(ENOSPC) -# define ENOSPC 28 /* No space left on device */ +#define ENOSPC 28 /* No space left on device */ #endif /* @@ -1073,7 +1074,7 @@ int gettimeofday(struct timeval *tp, void *tzp); * compilers, suppress it. */ #if !defined(__ARMCC_VERSION) -# define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_TIMEVAL_PRIVATE 0 #endif #define INT64_FMT PRId64 @@ -1377,18 +1378,18 @@ typedef struct _stati64 { #endif #ifndef _UINTPTR_T_DEFINED -typedef unsigned int* uintptr_t; +typedef unsigned int *uintptr_t; #endif #define _S_IFREG 2 #define _S_IFDIR 4 #ifndef S_ISDIR -#define S_ISDIR(x) (((x) & _S_IFDIR) != 0) +#define S_ISDIR(x) (((x) &_S_IFDIR) != 0) #endif #ifndef S_ISREG -#define S_ISREG(x) (((x) & _S_IFREG) != 0) +#define S_ISREG(x) (((x) &_S_IFREG) != 0) #endif int open(const char *filename, int oflag, int pmode); @@ -1425,7 +1426,8 @@ typedef struct stat cs_stat_t; #define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL /* - * LPCXpress comes with 3 C library implementations: Newlib, NewlibNano and Redlib. + * LPCXpress comes with 3 C library implementations: Newlib, NewlibNano and + *Redlib. * See https://community.nxp.com/message/630860 for more details. * * Redlib is the default and lacks certain things, so we provide them. @@ -1521,7 +1523,7 @@ typedef TCP_SOCKET sock_t; #define CS_ENABLE_STDIO 1 #endif -char* inet_ntoa(struct in_addr in); +char *inet_ntoa(struct in_addr in); #endif /* CS_PLATFORM == CS_P_PIC32 */ @@ -1759,7 +1761,7 @@ double cs_time(void); #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* Describes chunk of memory */ struct mg_str { @@ -1813,7 +1815,7 @@ const char *mg_strstr(const struct mg_str haystack, const struct mg_str needle); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif #endif /* CS_COMMON_MG_STR_H_ */ #ifdef MG_MODULE_LINES