Commit 4ef3a778 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Introduce MG_NET_IF var, replaces MG_NET_IF_*

Possible values:
  MG_NET_IF_SOCKET (1) - traditional BSD socket API
  MG_NET_IF_SIMPLELINK (2) - TI's SimpleLink socket interface
  MG_NET_IF_LWIP_LOW_LEVEL - a net_if implementation that uses LWIP's
    low-level API, when LWIP_SOCKET is not available.

PUBLISHED_FROM=a5c0aebb7b6bdb1f1f4cb3210763d16f3ab5e133
parent 31c5ef1b
...@@ -15,7 +15,7 @@ signature: | ...@@ -15,7 +15,7 @@ signature: |
struct mbuf recv_mbuf; /* Received data */ struct mbuf recv_mbuf; /* Received data */
struct mbuf send_mbuf; /* Data scheduled for sending */ struct mbuf send_mbuf; /* Data scheduled for sending */
#if MG_ENABLE_SSL #if MG_ENABLE_SSL
#if !defined(MG_SOCKET_SIMPLELINK) #if MG_NET_IF != MG_NET_IF_SIMPLELINK
SSL *ssl; SSL *ssl;
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
#else #else
......
...@@ -1857,7 +1857,7 @@ static void mg_destroy_conn(struct mg_connection *conn, int destroy_if) { ...@@ -1857,7 +1857,7 @@ static void mg_destroy_conn(struct mg_connection *conn, int destroy_if) {
if (conn->proto_data != NULL && conn->proto_data_destructor != NULL) { if (conn->proto_data != NULL && conn->proto_data_destructor != NULL) {
conn->proto_data_destructor(conn->proto_data); conn->proto_data_destructor(conn->proto_data);
} }
#if MG_ENABLE_SSL && !defined(MG_SOCKET_SIMPLELINK) #if MG_ENABLE_SSL && MG_NET_IF == MG_NET_IF_SOCKET
if (conn->ssl != NULL) SSL_free(conn->ssl); if (conn->ssl != NULL) SSL_free(conn->ssl);
if (conn->ssl_ctx != NULL) SSL_CTX_free(conn->ssl_ctx); if (conn->ssl_ctx != NULL) SSL_CTX_free(conn->ssl_ctx);
#endif #endif
...@@ -1894,7 +1894,7 @@ void mg_mgr_init(struct mg_mgr *m, void *user_data) { ...@@ -1894,7 +1894,7 @@ void mg_mgr_init(struct mg_mgr *m, void *user_data) {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif #endif
#if MG_ENABLE_SSL && !defined(MG_SOCKET_SIMPLELINK) #if MG_ENABLE_SSL && MG_NET_IF == MG_NET_IF_SOCKET
{ {
static int init_done; static int init_done;
if (!init_done) { if (!init_done) {
...@@ -2145,7 +2145,7 @@ MG_INTERNAL int mg_parse_address(const char *str, union socket_address *sa, ...@@ -2145,7 +2145,7 @@ MG_INTERNAL int mg_parse_address(const char *str, union socket_address *sa,
#if MG_ENABLE_SSL #if MG_ENABLE_SSL
#ifndef MG_SOCKET_SIMPLELINK #if MG_NET_IF != MG_NET_IF_SIMPLELINK
/* /*
* Certificate generation script is at * Certificate generation script is at
* https://github.com/cesanta/mongoose/blob/master/scripts/generate_ssl_certificates.sh * https://github.com/cesanta/mongoose/blob/master/scripts/generate_ssl_certificates.sh
...@@ -2330,7 +2330,7 @@ const char *mg_set_ssl(struct mg_connection *nc, const char *cert, ...@@ -2330,7 +2330,7 @@ const char *mg_set_ssl(struct mg_connection *nc, const char *cert,
#else #else
const char *mg_set_ssl2(struct mg_connection *nc, const char *cert, const char *mg_set_ssl2(struct mg_connection *nc, const char *cert,
const char *key, const char *ca_cert); const char *key, const char *ca_cert);
#endif /* MG_SOCKET_SIMPLELINK */ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK */
#endif /* MG_ENABLE_SSL */ #endif /* MG_ENABLE_SSL */
...@@ -2542,7 +2542,7 @@ static void mg_set_ssl_server_name(struct mg_connection *nc, ...@@ -2542,7 +2542,7 @@ static void mg_set_ssl_server_name(struct mg_connection *nc,
DBG(("%p '%s'", nc, server_name)); DBG(("%p '%s'", nc, server_name));
#ifdef SSL_KRYPTON #ifdef SSL_KRYPTON
SSL_CTX_kr_set_verify_name(nc->ssl_ctx, server_name); SSL_CTX_kr_set_verify_name(nc->ssl_ctx, server_name);
#elif defined(MG_SOCKET_SIMPLELINK) #elif MG_NET_IF == MG_NET_IF_SIMPLELINK
nc->ssl_server_name = strdup(server_name); nc->ssl_server_name = strdup(server_name);
#else #else
/* TODO(rojer): Implement server name verification on OpenSSL. */ /* TODO(rojer): Implement server name verification on OpenSSL. */
...@@ -2823,7 +2823,7 @@ double mg_time(void) { ...@@ -2823,7 +2823,7 @@ double mg_time(void) {
* All rights reserved * All rights reserved
*/ */
#if !MG_DISABLE_SOCKET_IF && !defined(MG_SOCKET_SIMPLELINK) #if MG_NET_IF == MG_NET_IF_SOCKET
/* Amalgamated: #include "mongoose/src/internal.h" */ /* Amalgamated: #include "mongoose/src/internal.h" */
/* Amalgamated: #include "mongoose/src/util.h" */ /* Amalgamated: #include "mongoose/src/util.h" */
...@@ -3526,7 +3526,7 @@ void mg_if_get_conn_addr(struct mg_connection *nc, int remote, ...@@ -3526,7 +3526,7 @@ void mg_if_get_conn_addr(struct mg_connection *nc, int remote,
mg_sock_get_addr(nc->sock, remote, sa); mg_sock_get_addr(nc->sock, remote, sa);
} }
#endif /* !MG_DISABLE_SOCKET_IF && !defined(MG_SOCKET_SIMPLELINK) */ #endif /* MG_NET_IF == MG_NET_IF_SOCKET */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "mongoose/src/multithreading.c" #line 1 "mongoose/src/multithreading.c"
#endif #endif
...@@ -10264,7 +10264,7 @@ void fs_slfs_set_new_file_size(const char *name, size_t size) { ...@@ -10264,7 +10264,7 @@ void fs_slfs_set_new_file_size(const char *name, size_t size) {
* All rights reserved * All rights reserved
*/ */
#if defined(MG_SOCKET_SIMPLELINK) && \ #if MG_NET_IF == MG_NET_IF_SIMPLELINK && \
(defined(MG_FS_SLFS) || defined(MG_FS_SPIFFS)) (defined(MG_FS_SLFS) || defined(MG_FS_SPIFFS))
#include <errno.h> #include <errno.h>
...@@ -10650,7 +10650,7 @@ int sl_fs_init(void) { ...@@ -10650,7 +10650,7 @@ int sl_fs_init(void) {
return ret; return ret;
} }
#endif /* defined(MG_SOCKET_SIMPLELINK) && (defined(MG_FS_SLFS) || \ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK && (defined(MG_FS_SLFS) || \
defined(MG_FS_SPIFFS)) */ defined(MG_FS_SPIFFS)) */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/simplelink/sl_socket.c" #line 1 "common/platforms/simplelink/sl_socket.c"
...@@ -10660,7 +10660,7 @@ int sl_fs_init(void) { ...@@ -10660,7 +10660,7 @@ int sl_fs_init(void) {
* All rights reserved * All rights reserved
*/ */
#ifdef MG_SOCKET_SIMPLELINK #if MG_NET_IF == MG_NET_IF_SIMPLELINK
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
...@@ -10702,11 +10702,11 @@ int inet_pton(int af, const char *src, void *dst) { ...@@ -10702,11 +10702,11 @@ int inet_pton(int af, const char *src, void *dst) {
return 1; return 1;
} }
#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_SL_SOCKET_C_ */ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/simplelink/sl_mg_task.c" #line 1 "common/platforms/simplelink/sl_mg_task.c"
#endif #endif
#if defined(MG_SOCKET_SIMPLELINK) && !defined(MG_SIMPLELINK_NO_OSI) #if MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(MG_SIMPLELINK_NO_OSI)
/* Amalgamated: #include "mg_task.h" */ /* Amalgamated: #include "mg_task.h" */
...@@ -10756,7 +10756,7 @@ void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) { ...@@ -10756,7 +10756,7 @@ void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) {
osi_MsgQWrite(&s_mg_q, &msg, OSI_NO_WAIT); osi_MsgQWrite(&s_mg_q, &msg, OSI_NO_WAIT);
} }
#endif /* defined(MG_SOCKET_SIMPLELINK) */ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(MG_SIMPLELINK_NO_OSI) */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/simplelink/sl_net_if.c" #line 1 "common/platforms/simplelink/sl_net_if.c"
#endif #endif
...@@ -10765,7 +10765,7 @@ void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) { ...@@ -10765,7 +10765,7 @@ void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) {
* All rights reserved * All rights reserved
*/ */
#if !MG_DISABLE_SOCKET_IF && defined(MG_SOCKET_SIMPLELINK) #if MG_NET_IF == MG_NET_IF_SIMPLELINK
/* Amalgamated: #include "mongoose/src/internal.h" */ /* Amalgamated: #include "mongoose/src/internal.h" */
/* Amalgamated: #include "mongoose/src/util.h" */ /* Amalgamated: #include "mongoose/src/util.h" */
...@@ -11266,7 +11266,7 @@ void sl_restart_cb(struct mg_mgr *mgr) { ...@@ -11266,7 +11266,7 @@ void sl_restart_cb(struct mg_mgr *mgr) {
} }
} }
#endif /* !MG_DISABLE_SOCKET_IF && defined(MG_SOCKET_SIMPLELINK) */ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/lwip/mg_lwip_net_if.h" #line 1 "common/platforms/lwip/mg_lwip_net_if.h"
#endif #endif
...@@ -11278,7 +11278,7 @@ void sl_restart_cb(struct mg_mgr *mgr) { ...@@ -11278,7 +11278,7 @@ void sl_restart_cb(struct mg_mgr *mgr) {
#ifndef CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ #ifndef CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_
#define CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ #define CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_
#ifdef MG_NET_IF_LWIP #if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL
#include <inttypes.h> #include <inttypes.h>
...@@ -11307,7 +11307,7 @@ void mg_lwip_post_signal(enum mg_sig_type sig, struct mg_connection *nc); ...@@ -11307,7 +11307,7 @@ void mg_lwip_post_signal(enum mg_sig_type sig, struct mg_connection *nc);
/* To be implemented by the platform. */ /* To be implemented by the platform. */
void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr); void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr);
#endif /* MG_NET_IF_LWIP */ #endif /* MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL */
#endif /* CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ */ #endif /* CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -11318,7 +11318,7 @@ void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr); ...@@ -11318,7 +11318,7 @@ void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr);
* All rights reserved * All rights reserved
*/ */
#ifdef MG_NET_IF_LWIP #if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL
#include <lwip/pbuf.h> #include <lwip/pbuf.h>
#include <lwip/tcp.h> #include <lwip/tcp.h>
...@@ -11769,7 +11769,7 @@ void mg_sock_set(struct mg_connection *nc, sock_t sock) { ...@@ -11769,7 +11769,7 @@ void mg_sock_set(struct mg_connection *nc, sock_t sock) {
nc->sock = sock; nc->sock = sock;
} }
#endif /* MG_NET_IF_LWIP */ #endif /* MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/lwip/mg_lwip_ev_mgr.c" #line 1 "common/platforms/lwip/mg_lwip_ev_mgr.c"
#endif #endif
...@@ -11778,7 +11778,7 @@ void mg_sock_set(struct mg_connection *nc, sock_t sock) { ...@@ -11778,7 +11778,7 @@ void mg_sock_set(struct mg_connection *nc, sock_t sock) {
* All rights reserved * All rights reserved
*/ */
#ifdef MG_NET_IF_LWIP #if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL
#ifndef MG_SIG_QUEUE_LEN #ifndef MG_SIG_QUEUE_LEN
#define MG_SIG_QUEUE_LEN 16 #define MG_SIG_QUEUE_LEN 16
...@@ -11946,7 +11946,7 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) { ...@@ -11946,7 +11946,7 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
return timeout_ms; return timeout_ms;
} }
#endif /* MG_NET_IF_LWIP */ #endif /* MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/lwip/mg_lwip_ssl_krypton.c" #line 1 "common/platforms/lwip/mg_lwip_ssl_krypton.c"
#endif #endif
...@@ -11955,7 +11955,7 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) { ...@@ -11955,7 +11955,7 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
* All rights reserved * All rights reserved
*/ */
#if defined(MG_NET_IF_LWIP) && defined(SSL_KRYPTON) #if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL && defined(SSL_KRYPTON)
/* Amalgamated: #include "common/cs_dbg.h" */ /* Amalgamated: #include "common/cs_dbg.h" */
...@@ -12117,7 +12117,7 @@ ssize_t kr_recv(int fd, void *buf, size_t len, int flags) { ...@@ -12117,7 +12117,7 @@ ssize_t kr_recv(int fd, void *buf, size_t len, int flags) {
return len; return len;
} }
#endif /* defined(MG_NET_IF_LWIP) && defined(SSL_KRYPTON) */ #endif /* MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL && defined(SSL_KRYPTON) */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platforms/wince/wince_libc.c" #line 1 "common/platforms/wince/wince_libc.c"
#endif #endif
......
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
#endif /* !defined(CS_PLATFORM) */ #endif /* !defined(CS_PLATFORM) */
#define MG_NET_IF_SOCKET 1
#define MG_NET_IF_SIMPLELINK 2
#define MG_NET_IF_LWIP_LOW_LEVEL 3
/* Amalgamated: #include "common/platforms/platform_unix.h" */ /* Amalgamated: #include "common/platforms/platform_unix.h" */
/* Amalgamated: #include "common/platforms/platform_windows.h" */ /* Amalgamated: #include "common/platforms/platform_windows.h" */
/* Amalgamated: #include "common/platforms/platform_esp_lwip.h" */ /* Amalgamated: #include "common/platforms/platform_esp_lwip.h" */
...@@ -270,6 +274,10 @@ typedef struct _stati64 cs_stat_t; ...@@ -270,6 +274,10 @@ typedef struct _stati64 cs_stat_t;
#define MG_ENABLE_HTTP_CGI 1 #define MG_ENABLE_HTTP_CGI 1
#endif #endif
#ifndef MG_NET_IF
#define MG_NET_IF MG_NET_IF_SOCKET
#endif
#endif /* CS_PLATFORM == CS_P_WINDOWS */ #endif /* CS_PLATFORM == CS_P_WINDOWS */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_WINDOWS_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_WINDOWS_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -392,6 +400,10 @@ typedef struct stat cs_stat_t; ...@@ -392,6 +400,10 @@ typedef struct stat cs_stat_t;
#define MG_ENABLE_HTTP_CGI 1 #define MG_ENABLE_HTTP_CGI 1
#endif #endif
#ifndef MG_NET_IF
#define MG_NET_IF MG_NET_IF_SOCKET
#endif
#endif /* CS_PLATFORM == CS_P_UNIX */ #endif /* CS_PLATFORM == CS_P_UNIX */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_UNIX_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_UNIX_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -448,12 +460,14 @@ unsigned long os_random(void); ...@@ -448,12 +460,14 @@ unsigned long os_random(void);
#define random os_random #define random os_random
#ifndef RTOS_SDK #ifndef RTOS_SDK
#define MG_NET_IF_LWIP #define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL
struct mg_mgr; struct mg_mgr;
struct mg_connection; struct mg_connection;
uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr); uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr);
void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
int interval, int count); int interval, int count);
#else
#define MG_NET_IF MG_NET_IF_SOCKET
#endif #endif
#ifndef CS_ENABLE_STDIO #ifndef CS_ENABLE_STDIO
...@@ -482,7 +496,7 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, ...@@ -482,7 +496,7 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#define MG_SOCKET_SIMPLELINK 1 #define MG_NET_IF MG_NET_IF_SIMPLELINK
#define MG_DISABLE_SYNC_RESOLVER 1 #define MG_DISABLE_SYNC_RESOLVER 1
/* /*
...@@ -536,7 +550,7 @@ int inet_pton(int af, const char *src, void *dst); ...@@ -536,7 +550,7 @@ int inet_pton(int af, const char *src, void *dst);
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#define MG_SOCKET_SIMPLELINK 1 #define MG_NET_IF MG_NET_IF_SIMPLELINK
#define MG_DISABLE_SYNC_RESOLVER 1 #define MG_DISABLE_SYNC_RESOLVER 1
/* Only SPIFFS supports directories, SLFS does not. */ /* Only SPIFFS supports directories, SLFS does not. */
...@@ -671,7 +685,7 @@ struct dirent *readdir(DIR *dir); ...@@ -671,7 +685,7 @@ struct dirent *readdir(DIR *dir);
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#define MG_SOCKET_SIMPLELINK 1 #define MG_NET_IF MG_NET_IF_SIMPLELINK
#define MG_DISABLE_SYNC_RESOLVER 1 #define MG_DISABLE_SYNC_RESOLVER 1
/* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */ /* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */
...@@ -785,7 +799,7 @@ int _stat(const char *pathname, struct stat *st); ...@@ -785,7 +799,7 @@ int _stat(const char *pathname, struct stat *st);
#define CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ #define CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
/* If simplelink.h is already included, all bets are off. */ /* If simplelink.h is already included, all bets are off. */
#if defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__) #if MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(__SIMPLELINK_H__)
#include <stdbool.h> #include <stdbool.h>
...@@ -876,7 +890,7 @@ int sl_set_ssl_opts(struct mg_connection *nc); ...@@ -876,7 +890,7 @@ int sl_set_ssl_opts(struct mg_connection *nc);
} }
#endif #endif
#endif /* defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__) */ #endif /* MG_NET_IF == MG_NET_IF_SIMPLELINK && !defined(__SIMPLELINK_H__) */
#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */ #endif /* CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -1032,6 +1046,10 @@ typedef unsigned int* uintptr_t; ...@@ -1032,6 +1046,10 @@ typedef unsigned int* uintptr_t;
#define MG_ENABLE_FILESYSTEM 1 #define MG_ENABLE_FILESYSTEM 1
#endif #endif
#ifndef MG_NET_IF
#define MG_NET_IF MG_NET_IF_SOCKET
#endif
typedef struct _stati64 { typedef struct _stati64 {
uint32_t st_mtime; uint32_t st_mtime;
uint32_t st_size; uint32_t st_size;
...@@ -1423,10 +1441,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1423,10 +1441,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_RESOLVER 0 #define MG_DISABLE_RESOLVER 0
#endif #endif
#ifndef MG_DISABLE_SOCKET_IF
#define MG_DISABLE_SOCKET_IF 0
#endif
#ifndef MG_DISABLE_SYNC_RESOLVER #ifndef MG_DISABLE_SYNC_RESOLVER
#define MG_DISABLE_SYNC_RESOLVER 0 #define MG_DISABLE_SYNC_RESOLVER 0
#endif #endif
...@@ -1523,6 +1537,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1523,6 +1537,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_STDIO CS_ENABLE_STDIO #define MG_ENABLE_STDIO CS_ENABLE_STDIO
#endif #endif
#ifndef MG_NET_IF
#define MG_NET_IF MG_NET_IF_SOCKET
#endif
#ifndef MG_ENABLE_THREADS /* ifdef-ok */ #ifndef MG_ENABLE_THREADS /* ifdef-ok */
#ifdef _WIN32 #ifdef _WIN32
#define MG_ENABLE_THREADS 1 #define MG_ENABLE_THREADS 1
...@@ -1592,7 +1610,7 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1592,7 +1610,7 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#ifdef __APPLE__ #ifdef __APPLE__
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
#if !defined(MG_SOCKET_SIMPLELINK) #if MG_NET_IF != MG_NET_IF_SIMPLELINK
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
#endif /* MG_ENABLE_SSL */ #endif /* MG_ENABLE_SSL */
...@@ -1673,7 +1691,7 @@ struct mg_connection { ...@@ -1673,7 +1691,7 @@ struct mg_connection {
struct mbuf recv_mbuf; /* Received data */ struct mbuf recv_mbuf; /* Received data */
struct mbuf send_mbuf; /* Data scheduled for sending */ struct mbuf send_mbuf; /* Data scheduled for sending */
#if MG_ENABLE_SSL #if MG_ENABLE_SSL
#if !defined(MG_SOCKET_SIMPLELINK) #if MG_NET_IF != MG_NET_IF_SIMPLELINK
SSL *ssl; SSL *ssl;
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
#else #else
...@@ -1950,7 +1968,7 @@ struct mg_connection *mg_connect_opt(struct mg_mgr *mgr, const char *address, ...@@ -1950,7 +1968,7 @@ struct mg_connection *mg_connect_opt(struct mg_mgr *mgr, const char *address,
mg_event_handler_t handler, mg_event_handler_t handler,
struct mg_connect_opts opts); struct mg_connect_opts opts);
#if MG_ENABLE_SSL && !defined(MG_SOCKET_SIMPLELINK) #if MG_ENABLE_SSL && MG_NET_IF != MG_NET_IF_SIMPLELINK
/* /*
* Note: This function is deprecated. Please, use SSL options in * Note: This function is deprecated. Please, use SSL options in
* mg_connect_opt. * mg_connect_opt.
...@@ -2376,7 +2394,8 @@ void mg_set_close_on_exec(sock_t); ...@@ -2376,7 +2394,8 @@ void mg_set_close_on_exec(sock_t);
*/ */
void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len, void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len,
int flags); int flags);
#if !MG_DISABLE_SOCKET_IF /* Legacy interface. */ #if MG_NET_IF == MG_NET_IF_SOCKET
/* Legacy interface. */
void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags); void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment