Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
241090a8
Commit
241090a8
authored
Oct 14, 2016
by
Deomid Ryabkov
Committed by
Cesanta Bot
Oct 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CS_DISABLE_(STDIO|HEXDUMP) -> CS_ENABLE_$1
PUBLISHED_FROM=9fd0cebfa8df53b5d9574a8d013305ddda5e7a18
parent
618bef0e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
140 additions
and
110 deletions
+140
-110
struct_mg_mgr.md
docs/c-api/net.h/struct_mg_mgr.md
+2
-0
cs_dbg.h
examples/CC3200/cs_dbg.h
+11
-3
build.sh
examples/ESP8266_RTOS/build.sh
+10
-0
sdk.version
examples/ESP8266_RTOS/sdk.version
+1
-0
cs_dbg.h
examples/ESP8266_RTOS/user/cs_dbg.h
+0
-1
user_main.c
examples/ESP8266_RTOS/user/user_main.c
+9
-14
cs_dbg.h
examples/MSP432/ccs/MSP432_MG_hello/cs_dbg.h
+11
-3
mongoose.c
mongoose.c
+52
-58
mongoose.h
mongoose.h
+44
-31
No files found.
docs/c-api/net.h/struct_mg_mgr.md
View file @
241090a8
...
...
@@ -5,7 +5,9 @@ symbol_kind: "struct"
signature
:
|
struct mg_mgr {
struct mg_connection *active_connections;
#if MG_ENABLE_HEXDUMP
const char *hexdump_file; /* Debug hexdump file path */
#endif
#if !MG_DISABLE_SOCKETPAIR
sock_t ctl[2]; /* Socketpair for mg_broadcast() */
#endif
...
...
examples/CC3200/cs_dbg.h
View file @
241090a8
...
...
@@ -6,10 +6,18 @@
#ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
#include <stdio.h>
#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
extern
"C"
{
#endif
/* __cplusplus */
...
...
@@ -28,7 +36,7 @@ enum cs_log_level {
void
cs_log_set_level
(
enum
cs_log_level
level
);
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
void
cs_log_set_file
(
FILE
*
file
);
...
...
@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
#endif
#else
/* CS_
DIS
ABLE_STDIO */
#else
/* CS_
EN
ABLE_STDIO */
#define LOG(l, x)
#define DBG(x)
...
...
examples/ESP8266_RTOS/build.sh
0 → 100755
View file @
241090a8
#!/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'
examples/ESP8266_RTOS/sdk.version
0 → 100644
View file @
241090a8
docker.cesanta.com/esp8266-build-rtos:1.4.0-r2
examples/ESP8266_RTOS/user/cs_dbg.h
deleted
120000 → 0
View file @
618bef0e
.
/
..
/
..
/
..
/
..
/
common
/
cs_dbg
.
h
\ No newline at end of file
examples/ESP8266_RTOS/user/user_main.c
View file @
241090a8
...
...
@@ -6,7 +6,6 @@
#include "esp_common.h"
#include "mongoose.h"
#include "cs_dbg.h"
#define AP_SSID "Mongoose"
#define AP_PASS "Mongoose"
...
...
@@ -25,14 +24,13 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
"Content-Type: text/plain
\r\n
"
"
\r\n
"
"Hello %s
\n
"
;
LOG
(
LL_DEBUG
,
(
"conn %p ev %d"
,
nc
,
ev
));
switch
(
ev
)
{
case
MG_EV_ACCEPT
:
{
char
addr
[
32
];
mg_sock_addr_to_str
(
&
nc
->
sa
,
addr
,
sizeof
(
addr
),
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
;
}
case
MG_EV_HTTP_REQUEST
:
{
...
...
@@ -40,15 +38,14 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
struct
http_message
*
hm
=
(
struct
http_message
*
)
p
;
mg_sock_addr_to_str
(
&
nc
->
sa
,
addr
,
sizeof
(
addr
),
MG_SOCK_STRINGIFY_IP
|
MG_SOCK_STRINGIFY_PORT
);
LOG
(
LL_INFO
,
(
"HTTP request from %s: %.*s %.*s"
,
addr
,
(
int
)
hm
->
method
.
len
,
hm
->
method
.
p
,
(
int
)
hm
->
uri
.
len
,
hm
->
uri
.
p
));
printf
(
"HTTP request from %s: %.*s %.*s
\n
"
,
addr
,
(
int
)
hm
->
method
.
len
,
hm
->
method
.
p
,
(
int
)
hm
->
uri
.
len
,
hm
->
uri
.
p
);
mg_printf
(
nc
,
reply_fmt
,
addr
);
nc
->
flags
|=
MG_F_SEND_AND_CLOSE
;
break
;
}
case
MG_EV_CLOSE
:
{
LOG
(
LL_INFO
,
(
"Connection %p closed"
,
nc
)
);
printf
(
"Connection %p closed
\n
"
,
nc
);
break
;
}
}
...
...
@@ -71,30 +68,28 @@ void setup_ap(void) {
cfg
.
max_connection
=
10
;
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_dhcps_stop
();
wifi_softap_set_dhcps_offer_option
(
OFFER_ROUTER
,
&
off
);
wifi_softap_dhcps_start
();
wifi_get_ip_info
(
SOFTAP_IF
,
&
info
);
LOG
(
LL_INFO
,
(
"WiFi AP: SSID %s, channel %d, IP "
IPSTR
""
,
cfg
.
ssid
,
cfg
.
channel
,
IP2STR
(
&
info
.
ip
)
));
printf
(
"WiFi AP: SSID %s, channel %d, IP "
IPSTR
"
\n
"
,
cfg
.
ssid
,
cfg
.
channel
,
IP2STR
(
&
info
.
ip
));
}
static
void
mg_task
(
void
*
arg
)
{
struct
mg_mgr
mgr
;
struct
mg_connection
*
nc
;
cs_log_set_level
(
LL_INFO
);
LOG
(
LL_INFO
,
(
"SDK version: %s"
,
system_get_sdk_version
()));
printf
(
"SDK version: %s
\n
"
,
system_get_sdk_version
());
setup_ap
();
mg_mgr_init
(
&
mgr
,
NULL
);
nc
=
mg_bind
(
&
mgr
,
MG_LISTEN_ADDR
,
ev_handler
);
if
(
nc
==
NULL
)
{
LOG
(
LL_ERROR
,
(
"Error setting up listener!"
)
);
printf
(
"Error setting up listener!
\n
"
);
return
;
}
mg_set_protocol_http_websocket
(
nc
);
...
...
examples/MSP432/ccs/MSP432_MG_hello/cs_dbg.h
View file @
241090a8
...
...
@@ -6,10 +6,18 @@
#ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
#include <stdio.h>
#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
extern
"C"
{
#endif
/* __cplusplus */
...
...
@@ -28,7 +36,7 @@ enum cs_log_level {
void
cs_log_set_level
(
enum
cs_log_level
level
);
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
void
cs_log_set_file
(
FILE
*
file
);
...
...
@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
#endif
#else
/* CS_
DIS
ABLE_STDIO */
#else
/* CS_
EN
ABLE_STDIO */
#define LOG(l, x)
#define DBG(x)
...
...
mongoose.c
View file @
241090a8
...
...
@@ -160,8 +160,10 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
#ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_
#ifndef CS_DISABLE_STDIO
#define CS_DISABLE_STDIO 0
/* Amalgamated: #include "common/platform.h" */
#if CS_ENABLE_STDIO
#include <stdio.h>
#endif
#ifndef CS_ENABLE_DEBUG
...
...
@@ -172,10 +174,6 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
#define CS_LOG_TS_DIFF 0
#endif
#if !CS_DISABLE_STDIO
#include <stdio.h>
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
...
...
@@ -194,7 +192,7 @@ enum cs_log_level {
void
cs_log_set_level
(
enum
cs_log_level
level
);
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
void
cs_log_set_file
(
FILE
*
file
);
...
...
@@ -222,7 +220,7 @@ void cs_log_printf(const char *fmt, ...);
#endif
#else
/* CS_
DIS
ABLE_STDIO */
#else
/* CS_
EN
ABLE_STDIO */
#define LOG(l, x)
#define DBG(x)
...
...
@@ -256,7 +254,7 @@ enum cs_log_level cs_log_level =
LL_ERROR
;
#endif
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
FILE
*
cs_log_file
=
NULL
;
...
...
@@ -289,11 +287,11 @@ void cs_log_set_file(FILE *file) {
cs_log_file
=
file
;
}
#endif
/*
!CS_DIS
ABLE_STDIO */
#endif
/*
CS_EN
ABLE_STDIO */
void
cs_log_set_level
(
enum
cs_log_level
level
)
{
cs_log_level
=
level
;
#if CS_LOG_TS_DIFF &&
!CS_DIS
ABLE_STDIO
#if CS_LOG_TS_DIFF &&
CS_EN
ABLE_STDIO
cs_log_ts
=
cs_time
();
#endif
}
...
...
@@ -426,7 +424,7 @@ void cs_base64_encode(const unsigned char *src, int src_len, char *dst) {
#undef BASE64_OUT
#undef BASE64_FLUSH
#if
!CS_DIS
ABLE_STDIO
#if
CS_EN
ABLE_STDIO
#define BASE64_OUT(ch) \
do { \
fprintf(f, "%c", (ch)); \
...
...
@@ -441,7 +439,7 @@ void cs_fprint_base64(FILE *f, const unsigned char *src, int src_len) {
#undef BASE64_OUT
#undef BASE64_FLUSH
#endif
/*
!CS_DIS
ABLE_STDIO */
#endif
/*
CS_EN
ABLE_STDIO */
/* Convert one byte of encoded base64 input stream to 6-bit chunk */
static
unsigned
char
from_b64
(
unsigned
char
ch
)
{
...
...
@@ -1779,7 +1777,7 @@ MG_INTERNAL void mg_call(struct mg_connection *nc,
ev_handler
==
nc
->
handler
?
"user"
:
"proto"
,
ev
,
ev_data
,
nc
->
flags
,
(
int
)
nc
->
recv_mbuf
.
len
,
(
int
)
nc
->
send_mbuf
.
len
));
#if !defined(NO_LIBC) &&
!MG_DIS
ABLE_HEXDUMP
#if !defined(NO_LIBC) &&
MG_EN
ABLE_HEXDUMP
/* LCOV_EXCL_START */
if
(
nc
->
mgr
->
hexdump_file
!=
NULL
&&
ev
!=
MG_EV_POLL
&&
ev
!=
MG_EV_SEND
/* handled separately */
)
{
...
...
@@ -2343,7 +2341,7 @@ void mg_send(struct mg_connection *nc, const void *buf, int len) {
}
else
{
mg_if_tcp_send
(
nc
,
buf
,
len
);
}
#if !defined(NO_LIBC) &&
!MG_DIS
ABLE_HEXDUMP
#if !defined(NO_LIBC) &&
MG_EN
ABLE_HEXDUMP
if
(
nc
->
mgr
&&
nc
->
mgr
->
hexdump_file
!=
NULL
)
{
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,
mg_sock_addr_to_str
(
&
sa
,
buf
,
len
,
flags
);
}
#if
!MG_DIS
ABLE_HEXDUMP
#if
MG_EN
ABLE_HEXDUMP
int
mg_hexdump
(
const
void
*
buf
,
int
len
,
char
*
dst
,
int
dst_len
)
{
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
buf
;
char
ascii
[
17
]
=
""
;
...
...
@@ -7821,6 +7819,44 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len) {
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
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, ...) {
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
)
{
static
const
int
n
=
1
;
/* TODO(mkm) use compiletime check with 4-byte char literal */
...
...
mongoose.h
View file @
241090a8
...
...
@@ -30,27 +30,6 @@
#include <mg_locals.h>
#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_ */
#ifdef MG_MODULE_LINES
#line 1 "common/platform.h"
...
...
@@ -262,6 +241,10 @@ typedef struct _stati64 cs_stat_t;
#define MG_MAX_HTTP_HEADERS 40
#endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif
/* CS_PLATFORM == CS_P_WINDOWS */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_WINDOWS_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -364,6 +347,10 @@ typedef struct stat cs_stat_t;
#define MG_MAX_HTTP_HEADERS 40
#endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif
/* CS_PLATFORM == CS_P_UNIX */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_UNIX_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -428,6 +415,10 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
int
interval
,
int
count
);
#endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif
/* CS_PLATFORM == CS_P_ESP_LWIP */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_ESP_LWIP_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -607,6 +598,10 @@ struct dirent *readdir(DIR *dir);
#define MG_FS_SLFS
#endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#ifdef __cplusplus
}
#endif
...
...
@@ -710,6 +705,10 @@ int _stat(const char *pathname, struct stat *st);
#endif
/* __TI_COMPILER_VERSION__ */
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#ifdef __cplusplus
}
#endif
...
...
@@ -730,6 +729,10 @@ int _stat(const char *pathname, struct stat *st);
/* Amalgamated: #include "mbed.h" */
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#endif
/* CS_PLATFORM == CS_P_MBED */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -1195,10 +1198,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_FILESYSTEM 0
#endif
#ifndef MG_DISABLE_HEXDUMP
#define MG_DISABLE_HEXDUMP 0
#endif
#ifndef MG_DISABLE_HTTP_DIGEST_AUTH
#define MG_DISABLE_HTTP_DIGEST_AUTH 0
#endif
...
...
@@ -1255,6 +1254,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_COAP 0
#endif
#ifndef MG_ENABLE_DEBUG
#define MG_ENABLE_DEBUG 0
#endif
#ifndef MG_ENABLE_DNS_SERVER
#define MG_ENABLE_DNS_SERVER 0
#endif
...
...
@@ -1267,6 +1270,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_GETADDRINFO 0
#endif
#ifndef MG_ENABLE_HEXDUMP
#define MG_ENABLE_HEXDUMP CS_ENABLE_STDIO
#endif
#ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART
#define MG_ENABLE_HTTP_STREAMING_MULTIPART 0
#endif
...
...
@@ -1295,6 +1302,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_SSL 0
#endif
#ifndef MG_ENABLE_STDIO
#define MG_ENABLE_STDIO CS_ENABLE_STDIO
#endif
#ifndef MG_ENABLE_THREADS
/* ifdef-ok */
#ifdef _WIN32
#define MG_ENABLE_THREADS 1
...
...
@@ -1303,16 +1314,14 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#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. */
#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
#define MG_DISABLE_DIRECTORY_LISTING 1
#undef MG_DISABLE_DAV
#define MG_DISABLE_DAV 1
#endif
/* MG_DISABLE_FILESYSTEM */
#ifdef MG_NO_BSD_SOCKETS
...
...
@@ -1427,7 +1436,9 @@ typedef void (*mg_event_handler_t)(struct mg_connection *, int ev, void *);
*/
struct
mg_mgr
{
struct
mg_connection
*
active_connections
;
#if MG_ENABLE_HEXDUMP
const
char
*
hexdump_file
;
/* Debug hexdump file path */
#endif
#if !MG_DISABLE_SOCKETPAIR
sock_t
ctl
[
2
];
/* Socketpair for mg_broadcast() */
#endif
...
...
@@ -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
,
int
flags
);
#if MG_ENABLE_HEXDUMP
/*
* 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);
*/
void
mg_hexdump_connection
(
struct
mg_connection
*
nc
,
const
char
*
path
,
const
void
*
buf
,
int
num_bytes
,
int
ev
);
#endif
/*
* Prints message to the buffer. If the buffer is large enough to hold the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment