Commit 241090a8 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

CS_DISABLE_(STDIO|HEXDUMP) -> CS_ENABLE_$1

PUBLISHED_FROM=9fd0cebfa8df53b5d9574a8d013305ddda5e7a18
parent 618bef0e
...@@ -5,7 +5,9 @@ symbol_kind: "struct" ...@@ -5,7 +5,9 @@ symbol_kind: "struct"
signature: | signature: |
struct mg_mgr { struct mg_mgr {
struct mg_connection *active_connections; struct mg_connection *active_connections;
#if MG_ENABLE_HEXDUMP
const char *hexdump_file; /* Debug hexdump file path */ const char *hexdump_file; /* Debug hexdump file path */
#endif
#if !MG_DISABLE_SOCKETPAIR #if !MG_DISABLE_SOCKETPAIR
sock_t ctl[2]; /* Socketpair for mg_broadcast() */ sock_t ctl[2]; /* Socketpair for mg_broadcast() */
#endif #endif
......
...@@ -6,10 +6,18 @@ ...@@ -6,10 +6,18 @@
#ifndef CS_COMMON_CS_DBG_H_ #ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_ #define CS_COMMON_CS_DBG_H_
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifndef CS_ENABLE_DEBUG
#define CS_ENABLE_DEBUG 0
#endif
#ifndef CS_LOG_TS_DIFF
#define CS_LOG_TS_DIFF 0
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -28,7 +36,7 @@ enum cs_log_level { ...@@ -28,7 +36,7 @@ enum cs_log_level {
void cs_log_set_level(enum cs_log_level level); void cs_log_set_level(enum cs_log_level level);
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
void cs_log_set_file(FILE *file); void cs_log_set_file(FILE *file);
...@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...); ...@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
#endif #endif
#else /* CS_DISABLE_STDIO */ #else /* CS_ENABLE_STDIO */
#define LOG(l, x) #define LOG(l, x)
#define DBG(x) #define DBG(x)
......
#!/bin/bash
docker run \
--rm -i -v $(realpath ${PWD}/../..):/src \
--entrypoint=/bin/bash $(cat sdk.version) -l -c -x '
export SDK_PATH=/opt/Espressif/ESP8266_SDK;
export BIN_PATH=./bin;
cd /src/examples/ESP8266_RTOS &&
mkdir -p ./bin && make clean &&
make BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=qio SPI_SIZE_MAP=0'
docker.cesanta.com/esp8266-build-rtos:1.4.0-r2
./../../../../common/cs_dbg.h
\ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "esp_common.h" #include "esp_common.h"
#include "mongoose.h" #include "mongoose.h"
#include "cs_dbg.h"
#define AP_SSID "Mongoose" #define AP_SSID "Mongoose"
#define AP_PASS "Mongoose" #define AP_PASS "Mongoose"
...@@ -25,14 +24,13 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) { ...@@ -25,14 +24,13 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
"Content-Type: text/plain\r\n" "Content-Type: text/plain\r\n"
"\r\n" "\r\n"
"Hello %s\n"; "Hello %s\n";
LOG(LL_DEBUG, ("conn %p ev %d", nc, ev));
switch (ev) { switch (ev) {
case MG_EV_ACCEPT: { case MG_EV_ACCEPT: {
char addr[32]; char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
LOG(LL_INFO, ("Connection %p from %s", nc, addr)); printf("Connection %p from %s\n", nc, addr);
break; break;
} }
case MG_EV_HTTP_REQUEST: { case MG_EV_HTTP_REQUEST: {
...@@ -40,15 +38,14 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) { ...@@ -40,15 +38,14 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
struct http_message *hm = (struct http_message *) p; struct http_message *hm = (struct http_message *) p;
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
LOG(LL_INFO, printf("HTTP request from %s: %.*s %.*s\n", addr, (int) hm->method.len,
("HTTP request from %s: %.*s %.*s", addr, (int) hm->method.len, hm->method.p, (int) hm->uri.len, hm->uri.p);
hm->method.p, (int) hm->uri.len, hm->uri.p));
mg_printf(nc, reply_fmt, addr); mg_printf(nc, reply_fmt, addr);
nc->flags |= MG_F_SEND_AND_CLOSE; nc->flags |= MG_F_SEND_AND_CLOSE;
break; break;
} }
case MG_EV_CLOSE: { case MG_EV_CLOSE: {
LOG(LL_INFO, ("Connection %p closed", nc)); printf("Connection %p closed\n", nc);
break; break;
} }
} }
...@@ -71,30 +68,28 @@ void setup_ap(void) { ...@@ -71,30 +68,28 @@ void setup_ap(void) {
cfg.max_connection = 10; cfg.max_connection = 10;
cfg.beacon_interval = 100; /* ms */ cfg.beacon_interval = 100; /* ms */
LOG(LL_INFO, ("Setting up AP '%s' on channel %d", cfg.ssid, cfg.channel)); printf("Setting up AP '%s' on channel %d\n", cfg.ssid, cfg.channel);
wifi_softap_set_config_current(&cfg); wifi_softap_set_config_current(&cfg);
wifi_softap_dhcps_stop(); wifi_softap_dhcps_stop();
wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &off); wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &off);
wifi_softap_dhcps_start(); wifi_softap_dhcps_start();
wifi_get_ip_info(SOFTAP_IF, &info); wifi_get_ip_info(SOFTAP_IF, &info);
LOG(LL_INFO, ("WiFi AP: SSID %s, channel %d, IP " IPSTR "", cfg.ssid, printf("WiFi AP: SSID %s, channel %d, IP " IPSTR "\n", cfg.ssid, cfg.channel,
cfg.channel, IP2STR(&info.ip))); IP2STR(&info.ip));
} }
static void mg_task(void *arg) { static void mg_task(void *arg) {
struct mg_mgr mgr; struct mg_mgr mgr;
struct mg_connection *nc; struct mg_connection *nc;
cs_log_set_level(LL_INFO); printf("SDK version: %s\n", system_get_sdk_version());
LOG(LL_INFO, ("SDK version: %s", system_get_sdk_version()));
setup_ap(); setup_ap();
mg_mgr_init(&mgr, NULL); mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, MG_LISTEN_ADDR, ev_handler); nc = mg_bind(&mgr, MG_LISTEN_ADDR, ev_handler);
if (nc == NULL) { if (nc == NULL) {
LOG(LL_ERROR, ("Error setting up listener!")); printf("Error setting up listener!\n");
return; return;
} }
mg_set_protocol_http_websocket(nc); mg_set_protocol_http_websocket(nc);
......
...@@ -6,10 +6,18 @@ ...@@ -6,10 +6,18 @@
#ifndef CS_COMMON_CS_DBG_H_ #ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_ #define CS_COMMON_CS_DBG_H_
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifndef CS_ENABLE_DEBUG
#define CS_ENABLE_DEBUG 0
#endif
#ifndef CS_LOG_TS_DIFF
#define CS_LOG_TS_DIFF 0
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -28,7 +36,7 @@ enum cs_log_level { ...@@ -28,7 +36,7 @@ enum cs_log_level {
void cs_log_set_level(enum cs_log_level level); void cs_log_set_level(enum cs_log_level level);
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
void cs_log_set_file(FILE *file); void cs_log_set_file(FILE *file);
...@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...); ...@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
#endif #endif
#else /* CS_DISABLE_STDIO */ #else /* CS_ENABLE_STDIO */
#define LOG(l, x) #define LOG(l, x)
#define DBG(x) #define DBG(x)
......
...@@ -160,8 +160,10 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path, ...@@ -160,8 +160,10 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
#ifndef CS_COMMON_CS_DBG_H_ #ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_ #define CS_COMMON_CS_DBG_H_
#ifndef CS_DISABLE_STDIO /* Amalgamated: #include "common/platform.h" */
#define CS_DISABLE_STDIO 0
#if CS_ENABLE_STDIO
#include <stdio.h>
#endif #endif
#ifndef CS_ENABLE_DEBUG #ifndef CS_ENABLE_DEBUG
...@@ -172,10 +174,6 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path, ...@@ -172,10 +174,6 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
#define CS_LOG_TS_DIFF 0 #define CS_LOG_TS_DIFF 0
#endif #endif
#if !CS_DISABLE_STDIO
#include <stdio.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -194,7 +192,7 @@ enum cs_log_level { ...@@ -194,7 +192,7 @@ enum cs_log_level {
void cs_log_set_level(enum cs_log_level level); void cs_log_set_level(enum cs_log_level level);
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
void cs_log_set_file(FILE *file); void cs_log_set_file(FILE *file);
...@@ -222,7 +220,7 @@ void cs_log_printf(const char *fmt, ...); ...@@ -222,7 +220,7 @@ void cs_log_printf(const char *fmt, ...);
#endif #endif
#else /* CS_DISABLE_STDIO */ #else /* CS_ENABLE_STDIO */
#define LOG(l, x) #define LOG(l, x)
#define DBG(x) #define DBG(x)
...@@ -256,7 +254,7 @@ enum cs_log_level cs_log_level = ...@@ -256,7 +254,7 @@ enum cs_log_level cs_log_level =
LL_ERROR; LL_ERROR;
#endif #endif
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
FILE *cs_log_file = NULL; FILE *cs_log_file = NULL;
...@@ -289,11 +287,11 @@ void cs_log_set_file(FILE *file) { ...@@ -289,11 +287,11 @@ void cs_log_set_file(FILE *file) {
cs_log_file = file; cs_log_file = file;
} }
#endif /* !CS_DISABLE_STDIO */ #endif /* CS_ENABLE_STDIO */
void cs_log_set_level(enum cs_log_level level) { void cs_log_set_level(enum cs_log_level level) {
cs_log_level = level; cs_log_level = level;
#if CS_LOG_TS_DIFF && !CS_DISABLE_STDIO #if CS_LOG_TS_DIFF && CS_ENABLE_STDIO
cs_log_ts = cs_time(); cs_log_ts = cs_time();
#endif #endif
} }
...@@ -426,7 +424,7 @@ void cs_base64_encode(const unsigned char *src, int src_len, char *dst) { ...@@ -426,7 +424,7 @@ void cs_base64_encode(const unsigned char *src, int src_len, char *dst) {
#undef BASE64_OUT #undef BASE64_OUT
#undef BASE64_FLUSH #undef BASE64_FLUSH
#if !CS_DISABLE_STDIO #if CS_ENABLE_STDIO
#define BASE64_OUT(ch) \ #define BASE64_OUT(ch) \
do { \ do { \
fprintf(f, "%c", (ch)); \ fprintf(f, "%c", (ch)); \
...@@ -441,7 +439,7 @@ void cs_fprint_base64(FILE *f, const unsigned char *src, int src_len) { ...@@ -441,7 +439,7 @@ void cs_fprint_base64(FILE *f, const unsigned char *src, int src_len) {
#undef BASE64_OUT #undef BASE64_OUT
#undef BASE64_FLUSH #undef BASE64_FLUSH
#endif /* !CS_DISABLE_STDIO */ #endif /* CS_ENABLE_STDIO */
/* Convert one byte of encoded base64 input stream to 6-bit chunk */ /* Convert one byte of encoded base64 input stream to 6-bit chunk */
static unsigned char from_b64(unsigned char ch) { static unsigned char from_b64(unsigned char ch) {
...@@ -1779,7 +1777,7 @@ MG_INTERNAL void mg_call(struct mg_connection *nc, ...@@ -1779,7 +1777,7 @@ MG_INTERNAL void mg_call(struct mg_connection *nc,
ev_handler == nc->handler ? "user" : "proto", ev, ev_data, nc->flags, ev_handler == nc->handler ? "user" : "proto", ev, ev_data, nc->flags,
(int) nc->recv_mbuf.len, (int) nc->send_mbuf.len)); (int) nc->recv_mbuf.len, (int) nc->send_mbuf.len));
#if !defined(NO_LIBC) && !MG_DISABLE_HEXDUMP #if !defined(NO_LIBC) && MG_ENABLE_HEXDUMP
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
if (nc->mgr->hexdump_file != NULL && ev != MG_EV_POLL && if (nc->mgr->hexdump_file != NULL && ev != MG_EV_POLL &&
ev != MG_EV_SEND /* handled separately */) { ev != MG_EV_SEND /* handled separately */) {
...@@ -2343,7 +2341,7 @@ void mg_send(struct mg_connection *nc, const void *buf, int len) { ...@@ -2343,7 +2341,7 @@ void mg_send(struct mg_connection *nc, const void *buf, int len) {
} else { } else {
mg_if_tcp_send(nc, buf, len); mg_if_tcp_send(nc, buf, len);
} }
#if !defined(NO_LIBC) && !MG_DISABLE_HEXDUMP #if !defined(NO_LIBC) && MG_ENABLE_HEXDUMP
if (nc->mgr && nc->mgr->hexdump_file != NULL) { if (nc->mgr && nc->mgr->hexdump_file != NULL) {
mg_hexdump_connection(nc, nc->mgr->hexdump_file, buf, len, MG_EV_SEND); mg_hexdump_connection(nc, nc->mgr->hexdump_file, buf, len, MG_EV_SEND);
} }
...@@ -7799,7 +7797,7 @@ void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len, ...@@ -7799,7 +7797,7 @@ void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len,
mg_sock_addr_to_str(&sa, buf, len, flags); mg_sock_addr_to_str(&sa, buf, len, flags);
} }
#if !MG_DISABLE_HEXDUMP #if MG_ENABLE_HEXDUMP
int mg_hexdump(const void *buf, int len, char *dst, int dst_len) { int mg_hexdump(const void *buf, int len, char *dst, int dst_len) {
const unsigned char *p = (const unsigned char *) buf; const unsigned char *p = (const unsigned char *) buf;
char ascii[17] = ""; char ascii[17] = "";
...@@ -7821,6 +7819,44 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len) { ...@@ -7821,6 +7819,44 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len) {
return n; return n;
} }
void mg_hexdump_connection(struct mg_connection *nc, const char *path,
const void *buf, int num_bytes, int ev) {
FILE *fp = NULL;
char *hexbuf, src[60], dst[60];
int buf_size = num_bytes * 5 + 100;
if (strcmp(path, "-") == 0) {
fp = stdout;
} else if (strcmp(path, "--") == 0) {
fp = stderr;
#if !MG_DISABLE_FILESYSTEM
} else {
fp = fopen(path, "a");
#endif
}
if (fp == NULL) return;
mg_conn_addr_to_str(nc, src, sizeof(src),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
mg_conn_addr_to_str(nc, dst, sizeof(dst), MG_SOCK_STRINGIFY_IP |
MG_SOCK_STRINGIFY_PORT |
MG_SOCK_STRINGIFY_REMOTE);
fprintf(
fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL), (void *) nc, src,
ev == MG_EV_RECV ? "<-" : ev == MG_EV_SEND
? "->"
: ev == MG_EV_ACCEPT
? "<A"
: ev == MG_EV_CONNECT ? "C>" : "XX",
dst, num_bytes);
if (num_bytes > 0 && (hexbuf = (char *) MG_MALLOC(buf_size)) != NULL) {
mg_hexdump(buf, num_bytes, hexbuf, buf_size);
fprintf(fp, "%s", hexbuf);
MG_FREE(hexbuf);
}
if (fp != stdin && fp != stdout) fclose(fp);
}
#endif #endif
int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap) { int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap) {
...@@ -7868,48 +7904,6 @@ int mg_asprintf(char **buf, size_t size, const char *fmt, ...) { ...@@ -7868,48 +7904,6 @@ int mg_asprintf(char **buf, size_t size, const char *fmt, ...) {
return ret; return ret;
} }
#if !MG_DISABLE_HEXDUMP
void mg_hexdump_connection(struct mg_connection *nc, const char *path,
const void *buf, int num_bytes, int ev) {
#if !defined(NO_LIBC) && !MG_DISABLE_STDIO
FILE *fp = NULL;
char *hexbuf, src[60], dst[60];
int buf_size = num_bytes * 5 + 100;
if (strcmp(path, "-") == 0) {
fp = stdout;
} else if (strcmp(path, "--") == 0) {
fp = stderr;
#if !MG_DISABLE_FILESYSTEM
} else {
fp = fopen(path, "a");
#endif
}
if (fp == NULL) return;
mg_conn_addr_to_str(nc, src, sizeof(src),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
mg_conn_addr_to_str(nc, dst, sizeof(dst), MG_SOCK_STRINGIFY_IP |
MG_SOCK_STRINGIFY_PORT |
MG_SOCK_STRINGIFY_REMOTE);
fprintf(
fp, "%lu %p %s %s %s %d\n", (unsigned long) time(NULL), (void *) nc, src,
ev == MG_EV_RECV ? "<-" : ev == MG_EV_SEND
? "->"
: ev == MG_EV_ACCEPT
? "<A"
: ev == MG_EV_CONNECT ? "C>" : "XX",
dst, num_bytes);
if (num_bytes > 0 && (hexbuf = (char *) MG_MALLOC(buf_size)) != NULL) {
mg_hexdump(buf, num_bytes, hexbuf, buf_size);
fprintf(fp, "%s", hexbuf);
MG_FREE(hexbuf);
}
if (fp != stdin && fp != stdout) fclose(fp);
#endif
}
#endif
int mg_is_big_endian(void) { int mg_is_big_endian(void) {
static const int n = 1; static const int n = 1;
/* TODO(mkm) use compiletime check with 4-byte char literal */ /* TODO(mkm) use compiletime check with 4-byte char literal */
......
...@@ -30,27 +30,6 @@ ...@@ -30,27 +30,6 @@
#include <mg_locals.h> #include <mg_locals.h>
#endif #endif
#ifndef MG_ENABLE_DEBUG
#define MG_ENABLE_DEBUG 0
#endif
#if MG_ENABLE_DEBUG && !defined(CS_ENABLE_DEBUG)
#define CS_ENABLE_DEBUG 1
#endif
#ifndef MG_DISABLE_STDIO
#define MG_DISABLE_STDIO 0
#endif
#if MG_DISABLE_STDIO && !defined(CS_DISABLE_STDIO)
#define CS_DISABLE_STDIO 1
#elif defined(CS_DISABLE_STDIO) && !MG_DISABLE_STDIO
#undef MG_DISABLE_STDIO
#define MG_DISABLE_STDIO 1
#endif
/* Amalgamated: #include "common/cs_dbg.h" */
#endif /* CS_MONGOOSE_SRC_COMMON_H_ */ #endif /* CS_MONGOOSE_SRC_COMMON_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "common/platform.h" #line 1 "common/platform.h"
...@@ -262,6 +241,10 @@ typedef struct _stati64 cs_stat_t; ...@@ -262,6 +241,10 @@ typedef struct _stati64 cs_stat_t;
#define MG_MAX_HTTP_HEADERS 40 #define MG_MAX_HTTP_HEADERS 40
#endif #endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#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
...@@ -364,6 +347,10 @@ typedef struct stat cs_stat_t; ...@@ -364,6 +347,10 @@ typedef struct stat cs_stat_t;
#define MG_MAX_HTTP_HEADERS 40 #define MG_MAX_HTTP_HEADERS 40
#endif #endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#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
...@@ -428,6 +415,10 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, ...@@ -428,6 +415,10 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
int interval, int count); int interval, int count);
#endif #endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif /* CS_PLATFORM == CS_P_ESP_LWIP */ #endif /* CS_PLATFORM == CS_P_ESP_LWIP */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_ESP_LWIP_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_ESP_LWIP_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -607,6 +598,10 @@ struct dirent *readdir(DIR *dir); ...@@ -607,6 +598,10 @@ struct dirent *readdir(DIR *dir);
#define MG_FS_SLFS #define MG_FS_SLFS
#endif #endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
...@@ -710,6 +705,10 @@ int _stat(const char *pathname, struct stat *st); ...@@ -710,6 +705,10 @@ int _stat(const char *pathname, struct stat *st);
#endif /* __TI_COMPILER_VERSION__ */ #endif /* __TI_COMPILER_VERSION__ */
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
...@@ -730,6 +729,10 @@ int _stat(const char *pathname, struct stat *st); ...@@ -730,6 +729,10 @@ int _stat(const char *pathname, struct stat *st);
/* Amalgamated: #include "mbed.h" */ /* Amalgamated: #include "mbed.h" */
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif /* CS_PLATFORM == CS_P_MBED */ #endif /* CS_PLATFORM == CS_P_MBED */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
...@@ -1195,10 +1198,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1195,10 +1198,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_FILESYSTEM 0 #define MG_DISABLE_FILESYSTEM 0
#endif #endif
#ifndef MG_DISABLE_HEXDUMP
#define MG_DISABLE_HEXDUMP 0
#endif
#ifndef MG_DISABLE_HTTP_DIGEST_AUTH #ifndef MG_DISABLE_HTTP_DIGEST_AUTH
#define MG_DISABLE_HTTP_DIGEST_AUTH 0 #define MG_DISABLE_HTTP_DIGEST_AUTH 0
#endif #endif
...@@ -1255,6 +1254,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1255,6 +1254,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_COAP 0 #define MG_ENABLE_COAP 0
#endif #endif
#ifndef MG_ENABLE_DEBUG
#define MG_ENABLE_DEBUG 0
#endif
#ifndef MG_ENABLE_DNS_SERVER #ifndef MG_ENABLE_DNS_SERVER
#define MG_ENABLE_DNS_SERVER 0 #define MG_ENABLE_DNS_SERVER 0
#endif #endif
...@@ -1267,6 +1270,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1267,6 +1270,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_GETADDRINFO 0 #define MG_ENABLE_GETADDRINFO 0
#endif #endif
#ifndef MG_ENABLE_HEXDUMP
#define MG_ENABLE_HEXDUMP CS_ENABLE_STDIO
#endif
#ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART #ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART
#define MG_ENABLE_HTTP_STREAMING_MULTIPART 0 #define MG_ENABLE_HTTP_STREAMING_MULTIPART 0
#endif #endif
...@@ -1295,6 +1302,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1295,6 +1302,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_SSL 0 #define MG_ENABLE_SSL 0
#endif #endif
#ifndef MG_ENABLE_STDIO
#define MG_ENABLE_STDIO CS_ENABLE_STDIO
#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
...@@ -1303,16 +1314,14 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1303,16 +1314,14 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#endif #endif
#endif #endif
#if MG_ENABLE_DEBUG && !defined(CS_ENABLE_DEBUG)
#define CS_ENABLE_DEBUG 1
#endif
/* All of the below features depend on filesystem access, disable them. */ /* All of the below features depend on filesystem access, disable them. */
#if MG_DISABLE_FILESYSTEM #if MG_DISABLE_FILESYSTEM
#undef MG_DISABLE_DAV
#define MG_DISABLE_DAV 1
#undef MG_DISABLE_CGI
#define MG_DISABLE_CGI 1
#undef MG_DISABLE_DIRECTORY_LISTING #undef MG_DISABLE_DIRECTORY_LISTING
#define MG_DISABLE_DIRECTORY_LISTING 1 #define MG_DISABLE_DIRECTORY_LISTING 1
#undef MG_DISABLE_DAV
#define MG_DISABLE_DAV 1
#endif /* MG_DISABLE_FILESYSTEM */ #endif /* MG_DISABLE_FILESYSTEM */
#ifdef MG_NO_BSD_SOCKETS #ifdef MG_NO_BSD_SOCKETS
...@@ -1427,7 +1436,9 @@ typedef void (*mg_event_handler_t)(struct mg_connection *, int ev, void *); ...@@ -1427,7 +1436,9 @@ typedef void (*mg_event_handler_t)(struct mg_connection *, int ev, void *);
*/ */
struct mg_mgr { struct mg_mgr {
struct mg_connection *active_connections; struct mg_connection *active_connections;
#if MG_ENABLE_HEXDUMP
const char *hexdump_file; /* Debug hexdump file path */ const char *hexdump_file; /* Debug hexdump file path */
#endif
#if !MG_DISABLE_SOCKETPAIR #if !MG_DISABLE_SOCKETPAIR
sock_t ctl[2]; /* Socketpair for mg_broadcast() */ sock_t ctl[2]; /* Socketpair for mg_broadcast() */
#endif #endif
...@@ -2168,6 +2179,7 @@ void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags); ...@@ -2168,6 +2179,7 @@ void mg_sock_to_str(sock_t sock, char *buf, size_t len, int flags);
void mg_sock_addr_to_str(const union socket_address *sa, char *buf, size_t len, void mg_sock_addr_to_str(const union socket_address *sa, char *buf, size_t len,
int flags); int flags);
#if MG_ENABLE_HEXDUMP
/* /*
* Generates a human-readable hexdump of memory chunk. * Generates a human-readable hexdump of memory chunk.
* *
...@@ -2187,6 +2199,7 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len); ...@@ -2187,6 +2199,7 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len);
*/ */
void mg_hexdump_connection(struct mg_connection *nc, const char *path, void mg_hexdump_connection(struct mg_connection *nc, const char *path,
const void *buf, int num_bytes, int ev); const void *buf, int num_bytes, int ev);
#endif
/* /*
* Prints message to the buffer. If the buffer is large enough to hold the * Prints message to the buffer. If the buffer is large enough to hold the
......
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