From a308872c883a90b36a97f8cfcd6b61d5d59ae393 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Wed, 19 Aug 2020 21:55:42 +0100 Subject: [PATCH] Fix warnings and sync line numbers of unamalgamated sources --- mongoose.c | 73 ++++------------------ mongoose.h | 37 ----------- src/common/platforms/lwip/mg_lwip_net_if.c | 19 +++--- src/mg_http.c | 2 +- tools/amalgam.py | 5 ++ 5 files changed, 27 insertions(+), 109 deletions(-) diff --git a/mongoose.c b/mongoose.c index 6236b2fd..d3596639 100644 --- a/mongoose.c +++ b/mongoose.c @@ -21,7 +21,6 @@ #ifdef MG_MODULE_LINES #line 1 "src/mg_internal.h" #endif - #ifndef CS_MONGOOSE_SRC_INTERNAL_H_ #define CS_MONGOOSE_SRC_INTERNAL_H_ @@ -182,7 +181,6 @@ MG_INTERNAL int mg_sntp_parse_reply(const char *buf, int len, #ifdef MG_MODULE_LINES #line 1 "src/common/mg_mem.h" #endif - #ifndef CS_COMMON_MG_MEM_H_ #define CS_COMMON_MG_MEM_H_ @@ -214,7 +212,6 @@ extern "C" { #ifdef MG_MODULE_LINES #line 1 "src/common/cs_base64.c" #endif - #ifndef EXCLUDE_COMMON /* Amalgamated: #include "common/cs_base64.h" */ @@ -418,7 +415,6 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst, int *dec_len) { #ifdef MG_MODULE_LINES #line 1 "src/common/cs_dbg.h" #endif - #ifndef CS_COMMON_CS_DBG_H_ #define CS_COMMON_CS_DBG_H_ @@ -553,7 +549,6 @@ void cs_log_printf(const char *fmt, ...) PRINTF_LIKE(1, 2); #ifdef MG_MODULE_LINES #line 1 "src/common/cs_dbg.c" #endif - /* Amalgamated: #include "common/cs_dbg.h" */ #include @@ -683,7 +678,6 @@ void cs_log_set_level(enum cs_log_level level) { #ifdef MG_MODULE_LINES #line 1 "src/common/cs_dirent.h" #endif - #ifndef CS_COMMON_CS_DIRENT_H_ #define CS_COMMON_CS_DIRENT_H_ @@ -721,7 +715,6 @@ struct dirent *readdir(DIR *dir); #ifdef MG_MODULE_LINES #line 1 "src/common/cs_dirent.c" #endif - #ifndef EXCLUDE_COMMON /* Amalgamated: #include "common/mg_mem.h" */ @@ -816,7 +809,6 @@ typedef int cs_dirent_dummy; #ifdef MG_MODULE_LINES #line 1 "src/common/cs_time.c" #endif - /* Amalgamated: #include "common/cs_time.h" */ #ifndef _WIN32 @@ -898,7 +890,6 @@ double cs_timegm(const struct tm *tm) { #ifdef MG_MODULE_LINES #line 1 "src/common/cs_endian.h" #endif - #ifndef CS_COMMON_CS_ENDIAN_H_ #define CS_COMMON_CS_ENDIAN_H_ @@ -1399,7 +1390,6 @@ void cs_hmac_sha1(const unsigned char *key, size_t keylen, #ifdef MG_MODULE_LINES #line 1 "src/common/mbuf.c" #endif - #ifndef EXCLUDE_COMMON #include @@ -1537,7 +1527,6 @@ void mbuf_move(struct mbuf *from, struct mbuf *to) { #ifdef MG_MODULE_LINES #line 1 "src/common/mg_str.c" #endif - /* Amalgamated: #include "common/mg_mem.h" */ /* Amalgamated: #include "common/mg_str.h" */ /* Amalgamated: #include "common/platform.h" */ @@ -1702,7 +1691,6 @@ int mg_str_starts_with(struct mg_str s, struct mg_str prefix) { #ifdef MG_MODULE_LINES #line 1 "src/common/str_util.c" #endif - #ifndef EXCLUDE_COMMON /* Amalgamated: #include "common/str_util.h" */ @@ -2221,7 +2209,6 @@ size_t mg_match_prefix(const char *pattern, int pattern_len, const char *str) { #ifdef MG_MODULE_LINES #line 1 "src/mg_net.c" #endif - /* Amalgamated: #include "common/cs_time.h" */ /* Amalgamated: #include "mg_dns.h" */ /* Amalgamated: #include "mg_internal.h" */ @@ -3417,7 +3404,6 @@ double mg_time(void) { #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if_socket.h" #endif - #ifndef CS_MONGOOSE_SRC_NET_IF_SOCKET_H_ #define CS_MONGOOSE_SRC_NET_IF_SOCKET_H_ @@ -3441,7 +3427,6 @@ extern const struct mg_iface_vtable mg_socket_iface_vtable; #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if_socks.h" #endif - #ifndef CS_MONGOOSE_SRC_NET_IF_SOCKS_H_ #define CS_MONGOOSE_SRC_NET_IF_SOCKS_H_ @@ -3518,7 +3503,6 @@ double mg_mgr_min_timer(const struct mg_mgr *mgr) { #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if_null.c" #endif - static void mg_null_if_connect_tcp(struct mg_connection *c, const union socket_address *sa) { c->flags |= MG_F_CLOSE_IMMEDIATELY; @@ -3645,7 +3629,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_NULL_IFACE_VTABLE; #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if_socket.c" #endif - #if MG_ENABLE_NET_IF_SOCKET /* Amalgamated: #include "mg_net_if_socket.h" */ @@ -4225,7 +4208,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_SOCKET_IFACE_VTABLE; #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if_socks.c" #endif - #if MG_ENABLE_SOCKS struct socksdata { @@ -4461,7 +4443,6 @@ struct mg_iface *mg_socks_mk_iface(struct mg_mgr *mgr, const char *proxy_addr) { #ifdef MG_MODULE_LINES #line 1 "src/mg_ssl_if_openssl.c" #endif - #if MG_ENABLE_SSL && MG_SSL_IF == MG_SSL_IF_OPENSSL #ifdef __APPLE__ @@ -4875,7 +4856,6 @@ const char *mg_set_ssl(struct mg_connection *nc, const char *cert, #ifdef MG_MODULE_LINES #line 1 "src/mg_ssl_if_mbedtls.c" #endif - #if MG_ENABLE_SSL && MG_SSL_IF == MG_SSL_IF_MBEDTLS #include @@ -5389,7 +5369,6 @@ int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len) { #ifdef MG_MODULE_LINES #line 1 "src/mg_uri.c" #endif - /* Amalgamated: #include "mg_internal.h" */ /* Amalgamated: #include "mg_uri.h" */ @@ -5649,7 +5628,6 @@ out: #ifdef MG_MODULE_LINES #line 1 "src/mg_http.c" #endif - #if MG_ENABLE_HTTP /* Amalgamated: #include "common/cs_md5.h" */ @@ -7173,7 +7151,7 @@ void mg_http_serve_file_internal(struct mg_connection *nc, }; mg_http_send_error(nc, code, "Open failed"); } else { - char etag[50], current_time[50], last_modified[50], range[70]; + char etag[50], current_time[50], last_modified[50], range[76]; time_t t = (time_t) mg_time(); int64_t r1 = 0, r2 = 0, cl = st.st_size; struct mg_str *range_hdr = mg_get_http_header(hm, "Range"); @@ -8838,7 +8816,6 @@ void mg_register_http_endpoint(struct mg_connection *nc, const char *uri_path, #ifdef MG_MODULE_LINES #line 1 "src/mg_http_cgi.c" #endif - #ifndef _WIN32 #include #endif @@ -9350,7 +9327,6 @@ MG_INTERNAL void mg_http_free_proto_data_cgi(struct mg_http_proto_data_cgi *d) { #ifdef MG_MODULE_LINES #line 1 "src/mg_http_ssi.c" #endif - #if MG_ENABLE_HTTP && MG_ENABLE_HTTP_SSI && MG_ENABLE_FILESYSTEM static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm, @@ -9552,7 +9528,6 @@ MG_INTERNAL void mg_handle_ssi_request(struct mg_connection *nc, #ifdef MG_MODULE_LINES #line 1 "src/mg_http_webdav.c" #endif - #if MG_ENABLE_HTTP && MG_ENABLE_HTTP_WEBDAV MG_INTERNAL int mg_is_dav_request(const struct mg_str *s) { @@ -9820,7 +9795,6 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path, #ifdef MG_MODULE_LINES #line 1 "src/mg_http_websocket.c" #endif - #if MG_ENABLE_HTTP && MG_ENABLE_HTTP_WEBSOCKET /* Amalgamated: #include "common/cs_sha1.h" */ @@ -10338,7 +10312,6 @@ struct mg_connection *mg_connect_ws( #ifdef MG_MODULE_LINES #line 1 "src/mg_util.c" #endif - /* Amalgamated: #include "common/cs_base64.h" */ /* Amalgamated: #include "mg_internal.h" */ /* Amalgamated: #include "mg_util.h" */ @@ -10681,7 +10654,6 @@ struct mg_str mg_url_encode(const struct mg_str src) { #ifdef MG_MODULE_LINES #line 1 "src/mg_mqtt.c" #endif - #if MG_ENABLE_MQTT #include @@ -11213,7 +11185,6 @@ void mg_mqtt_disconnect(struct mg_connection *nc) { #ifdef MG_MODULE_LINES #line 1 "src/mg_mqtt_server.c" #endif - /* Amalgamated: #include "mg_internal.h" */ /* Amalgamated: #include "mg_mqtt_server.h" */ @@ -11406,7 +11377,6 @@ struct mg_mqtt_session *mg_mqtt_next(struct mg_mqtt_broker *brk, #ifdef MG_MODULE_LINES #line 1 "src/mg_dns.c" #endif - #if MG_ENABLE_DNS /* Amalgamated: #include "mg_internal.h" */ @@ -11786,7 +11756,6 @@ void mg_set_protocol_dns(struct mg_connection *nc) { #ifdef MG_MODULE_LINES #line 1 "src/mg_dns_server.c" #endif - #if MG_ENABLE_DNS_SERVER /* Amalgamated: #include "mg_internal.h" */ @@ -11856,7 +11825,6 @@ int mg_dns_reply_record(struct mg_dns_reply *reply, #ifdef MG_MODULE_LINES #line 1 "src/mg_resolv.c" #endif - #if MG_ENABLE_ASYNC_RESOLVER /* Amalgamated: #include "mg_internal.h" */ @@ -12147,7 +12115,6 @@ void mg_set_nameserver(struct mg_mgr *mgr, const char *nameserver) { #ifdef MG_MODULE_LINES #line 1 "src/mg_coap.c" #endif - /* Amalgamated: #include "mg_internal.h" */ /* Amalgamated: #include "mg_coap.h" */ @@ -12731,7 +12698,6 @@ int mg_set_protocol_coap(struct mg_connection *nc) { #ifdef MG_MODULE_LINES #line 1 "src/mg_sntp.c" #endif - /* Amalgamated: #include "mg_internal.h" */ /* Amalgamated: #include "mg_sntp.h" */ /* Amalgamated: #include "mg_util.h" */ @@ -13018,7 +12984,6 @@ struct mg_connection *mg_sntp_get_time(struct mg_mgr *mgr, #ifdef MG_MODULE_LINES #line 1 "src/mg_socks.c" #endif - #if MG_ENABLE_SOCKS /* Amalgamated: #include "mg_socks.h" */ @@ -13176,7 +13141,6 @@ void mg_set_protocol_socks(struct mg_connection *c) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/cc3200/cc3200_libc.c" #endif - #if CS_PLATFORM == CS_P_CC3200 /* Amalgamated: #include "common/mg_mem.h" */ @@ -13278,7 +13242,6 @@ int _isatty(int fd) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/msp432/msp432_libc.c" #endif - #if CS_PLATFORM == CS_P_MSP432 #include @@ -13295,7 +13258,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/nrf5/nrf5_libc.c" #endif - #if (CS_PLATFORM == CS_P_NRF51 || CS_PLATFORM == CS_P_NRF52) && \ defined(__ARMCC_VERSION) int gettimeofday(struct timeval *tp, void *tzp) { @@ -13308,7 +13270,6 @@ int gettimeofday(struct timeval *tp, void *tzp) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_fs_slfs.h" #endif - #ifndef CS_COMMON_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_ #define CS_COMMON_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_ @@ -13343,7 +13304,6 @@ void fs_slfs_unset_file_flags(const char *name); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_fs_slfs.c" #endif - /* Standard libc interface to TI SimpleLink FS. */ #if defined(MG_FS_SLFS) || defined(CC3200_FS_SLFS) @@ -13632,7 +13592,6 @@ void fs_slfs_unset_file_flags(const char *name) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_fs.c" #endif - #if MG_NET_IF == MG_NET_IF_SIMPLELINK && \ (defined(MG_FS_SLFS) || defined(MG_FS_SPIFFS)) @@ -14042,7 +14001,6 @@ int sl_fs_init(void) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_socket.c" #endif - #if MG_NET_IF == MG_NET_IF_SIMPLELINK #include @@ -14144,7 +14102,6 @@ void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_net_if.h" #endif - #ifndef CS_COMMON_PLATFORMS_SIMPLELINK_SL_NET_IF_H_ #define CS_COMMON_PLATFORMS_SIMPLELINK_SL_NET_IF_H_ @@ -14168,7 +14125,6 @@ extern const struct mg_iface_vtable mg_simplelink_iface_vtable; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_net_if.c" #endif - /* Amalgamated: #include "common/platforms/simplelink/sl_net_if.h" */ #if MG_ENABLE_NET_IF_SIMPLELINK @@ -14587,7 +14543,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_SL_IFACE_VTABLE; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/sl_ssl_if.c" #endif - #if MG_ENABLE_SSL && MG_SSL_IF == MG_SSL_IF_SIMPLELINK /* Amalgamated: #include "common/mg_mem.h" */ @@ -14825,7 +14780,6 @@ int sl_set_ssl_opts(int sock, struct mg_connection *nc) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/lwip/mg_lwip_net_if.h" #endif - #ifndef CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ #define CS_COMMON_PLATFORMS_LWIP_MG_NET_IF_LWIP_H_ @@ -14877,7 +14831,6 @@ void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/lwip/mg_lwip_net_if.c" #endif - #if MG_ENABLE_NET_IF_LWIP_LOW_LEVEL /* Amalgamated: #include "common/mg_mem.h" */ @@ -15000,7 +14953,7 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, static err_t mg_lwip_tcp_conn_cb(void *arg, struct tcp_pcb *tpcb, err_t err) { struct mg_connection *nc = (struct mg_connection *) arg; DBG(("%p connect to %s:%u = %d", nc, IPADDR_NTOA(ipX_2_ip(&tpcb->remote_ip)), - tpcb->remote_port, err)); + tpcb->remote_port, (int) err)); if (nc == NULL) { tcp_abort(tpcb); return ERR_ARG; @@ -15016,7 +14969,7 @@ static err_t mg_lwip_tcp_conn_cb(void *arg, struct tcp_pcb *tpcb, err_t err) { static void mg_lwip_tcp_error_cb(void *arg, err_t err) { struct mg_connection *nc = (struct mg_connection *) arg; - DBG(("%p conn error %d", nc, err)); + DBG(("%p conn error %d", nc, (int) err)); if (nc == NULL || (nc->flags & MG_F_CLOSE_IMMEDIATELY)) return; struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; cs->pcb.tcp = NULL; /* Has already been deallocated */ @@ -15034,7 +14987,7 @@ static err_t mg_lwip_tcp_recv_cb(void *arg, struct tcp_pcb *tpcb, struct mg_lwip_conn_state *cs = (nc ? (struct mg_lwip_conn_state *) nc->sock : NULL); DBG(("%p %p %p %p %u %d", nc, cs, tpcb, p, (p != NULL ? p->tot_len : 0), - err)); + (int) err)); if (p == NULL) { if (nc != NULL && !(nc->flags & MG_F_CLOSE_IMMEDIATELY)) { if (cs->rx_chain != NULL) { @@ -15119,13 +15072,13 @@ static void mg_lwip_if_connect_tcp_tcpip(void *arg) { tcp_sent(tpcb, mg_lwip_tcp_sent_cb); tcp_recv(tpcb, mg_lwip_tcp_recv_cb); cs->err = TCP_BIND(tpcb, IP_ADDR_ANY, 0 /* any port */); - DBG(("%p tcp_bind = %d", nc, cs->err)); + DBG(("%p tcp_bind = %d", nc, (int) cs->err)); if (cs->err != ERR_OK) { mg_lwip_post_signal(MG_SIG_CONNECT_RESULT, nc); return; } cs->err = tcp_connect(tpcb, ip, port, mg_lwip_tcp_conn_cb); - DBG(("%p tcp_connect %p = %d", nc, tpcb, cs->err)); + DBG(("%p tcp_connect %p = %d", nc, tpcb, (int) cs->err)); if (cs->err != ERR_OK) { mg_lwip_post_signal(MG_SIG_CONNECT_RESULT, nc); return; @@ -15217,7 +15170,7 @@ static void mg_lwip_if_connect_udp_tcpip(void *arg) { struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; struct udp_pcb *upcb = udp_new(); cs->err = UDP_BIND(upcb, IP_ADDR_ANY, 0 /* any port */); - DBG(("%p udp_bind %p = %d", nc, upcb, cs->err)); + DBG(("%p udp_bind %p = %d", nc, upcb, (int) cs->err)); if (cs->err == ERR_OK) { udp_recv(upcb, mg_lwip_udp_recv_cb, nc); cs->pcb.udp = upcb; @@ -15299,7 +15252,7 @@ static void mg_lwip_if_listen_tcp_tcpip(void *arg) { ip_addr_t *ip = (ip_addr_t *) &sa->sin.sin_addr.s_addr; u16_t port = ntohs(sa->sin.sin_port); cs->err = TCP_BIND(tpcb, ip, port); - DBG(("%p tcp_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, cs->err)); + DBG(("%p tcp_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, (int) cs->err)); if (cs->err != ERR_OK) { tcp_close(tpcb); ctx->ret = -1; @@ -15327,7 +15280,7 @@ static void mg_lwip_if_listen_udp_tcpip(void *arg) { ip_addr_t *ip = (ip_addr_t *) &sa->sin.sin_addr.s_addr; u16_t port = ntohs(sa->sin.sin_port); cs->err = UDP_BIND(upcb, ip, port); - DBG(("%p udb_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, cs->err)); + DBG(("%p udb_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, (int) cs->err)); if (cs->err != ERR_OK) { udp_remove(upcb); ctx->ret = -1; @@ -15387,7 +15340,8 @@ static void mg_lwip_tcp_write_tcpip(void *arg) { cs->err = tcp_write(tpcb, ctx->data, len, TCP_WRITE_FLAG_COPY); unsent = (tpcb->unsent != NULL ? tpcb->unsent->len : 0); unacked = (tpcb->unacked != NULL ? tpcb->unacked->len : 0); - DBG(("%p tcp_write %u = %d, %u %u", tpcb, len, cs->err, unsent, unacked)); + DBG(("%p tcp_write %u = %d, %u %u", + tpcb, len, (int) cs->err, unsent, unacked)); if (cs->err != ERR_OK) { /* * We ignore ERR_MEM because memory will be freed up when the data is sent @@ -15610,7 +15564,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_LWIP_IFACE_VTABLE; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/lwip/mg_lwip_ev_mgr.c" #endif - #if MG_NET_IF == MG_NET_IF_LWIP_LOW_LEVEL #ifndef MG_SIG_QUEUE_LEN @@ -15770,7 +15723,6 @@ time_t mg_lwip_if_poll(struct mg_iface *iface, int timeout_ms) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/wince/wince_libc.c" #endif - #ifdef WINCE const char *strerror(int err) { @@ -15843,7 +15795,6 @@ static void mg_gmt_time_string(char *buf, size_t buf_len, time_t *t) { #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/pic32/pic32_net_if.h" #endif - #ifndef CS_COMMON_PLATFORMS_PIC32_NET_IF_H_ #define CS_COMMON_PLATFORMS_PIC32_NET_IF_H_ @@ -15867,7 +15818,6 @@ extern const struct mg_iface_vtable mg_pic32_iface_vtable; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/pic32/pic32_net_if.c" #endif - #if MG_ENABLE_NET_IF_PIC32 int mg_pic32_if_create_conn(struct mg_connection *nc) { @@ -16158,7 +16108,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_PIC32_IFACE_VTABLE; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/windows/windows_direct.c" #endif - #ifdef _WIN32 int rmdir(const char *dirname) { diff --git a/mongoose.h b/mongoose.h index 7808e914..84fb4421 100644 --- a/mongoose.h +++ b/mongoose.h @@ -510,7 +510,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_esp32.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_ESP32_H_ #define CS_COMMON_PLATFORMS_PLATFORM_ESP32_H_ #if CS_PLATFORM == CS_P_ESP32 @@ -551,7 +550,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_esp8266.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_ESP8266_H_ #define CS_COMMON_PLATFORMS_PLATFORM_ESP8266_H_ #if CS_PLATFORM == CS_P_ESP8266 @@ -608,7 +606,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_cc3100.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_CC3100_H_ #define CS_COMMON_PLATFORMS_PLATFORM_CC3100_H_ #if CS_PLATFORM == CS_P_CC3100 @@ -653,7 +650,6 @@ int inet_pton(int af, const char *src, void *dst); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_cc3200.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_CC3200_H_ #define CS_COMMON_PLATFORMS_PLATFORM_CC3200_H_ #if CS_PLATFORM == CS_P_CC3200 @@ -774,7 +770,6 @@ int stat(const char *pathname, struct stat *st); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_cc3220.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_CC3220_H_ #define CS_COMMON_PLATFORMS_PLATFORM_CC3220_H_ #if CS_PLATFORM == CS_P_CC3220 @@ -882,7 +877,6 @@ int stat(const char *pathname, struct stat *st); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_msp432.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_ #define CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_ #if CS_PLATFORM == CS_P_MSP432 @@ -986,7 +980,6 @@ int _stat(const char *pathname, struct stat *st); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_tm4c129.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_TM4C129_H_ #define CS_COMMON_PLATFORMS_PLATFORM_TM4C129_H_ #if CS_PLATFORM == CS_P_TM4C129 @@ -1042,7 +1035,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_mbed.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ #define CS_COMMON_PLATFORMS_PLATFORM_MBED_H_ #if CS_PLATFORM == CS_P_MBED @@ -1207,7 +1199,6 @@ int gettimeofday(struct timeval *tp, void *tzp); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/simplelink/cs_simplelink.h" #endif - #ifndef CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ #define CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ @@ -1574,7 +1565,6 @@ const char *strerror(); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_nxp_lpc.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_NXP_LPC_H_ #define CS_COMMON_PLATFORMS_PLATFORM_NXP_LPC_H_ @@ -1626,7 +1616,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_nxp_kinetis.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_NXP_KINETIS_H_ #define CS_COMMON_PLATFORMS_PLATFORM_NXP_KINETIS_H_ @@ -1656,7 +1645,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_pic32.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_PIC32_H_ #define CS_COMMON_PLATFORMS_PLATFORM_PIC32_H_ @@ -1692,7 +1680,6 @@ char *inet_ntoa(struct in_addr in); #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_rs14100.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_RS14100_H_ #define CS_COMMON_PLATFORMS_PLATFORM_RS14100_H_ #if CS_PLATFORM == CS_P_RS14100 @@ -1740,7 +1727,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/platform_stm32.h" #endif - #ifndef CS_COMMON_PLATFORMS_PLATFORM_STM32_H_ #define CS_COMMON_PLATFORMS_PLATFORM_STM32_H_ #if CS_PLATFORM == CS_P_STM32 @@ -1778,7 +1764,6 @@ typedef struct stat cs_stat_t; #ifdef MG_MODULE_LINES #line 1 "src/common/platforms/lwip/mg_lwip.h" #endif - #ifndef CS_COMMON_PLATFORMS_LWIP_MG_LWIP_H_ #define CS_COMMON_PLATFORMS_LWIP_MG_LWIP_H_ @@ -1845,7 +1830,6 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, #ifdef MG_MODULE_LINES #line 1 "src/common/cs_md5.h" #endif - #ifndef CS_COMMON_MD5_H_ #define CS_COMMON_MD5_H_ @@ -1877,7 +1861,6 @@ void cs_md5_final(unsigned char *md, cs_md5_ctx *c); #ifdef MG_MODULE_LINES #line 1 "src/common/cs_sha1.h" #endif - #ifndef CS_COMMON_SHA1_H_ #define CS_COMMON_SHA1_H_ @@ -1915,7 +1898,6 @@ void cs_hmac_sha1(const unsigned char *key, size_t key_len, #ifdef MG_MODULE_LINES #line 1 "src/common/cs_time.h" #endif - #ifndef CS_COMMON_CS_TIME_H_ #define CS_COMMON_CS_TIME_H_ @@ -1944,7 +1926,6 @@ double cs_timegm(const struct tm *tm); #ifdef MG_MODULE_LINES #line 1 "src/common/mg_str.h" #endif - #ifndef CS_COMMON_MG_STR_H_ #define CS_COMMON_MG_STR_H_ @@ -2044,7 +2025,6 @@ int mg_str_starts_with(struct mg_str s, struct mg_str prefix); #ifdef MG_MODULE_LINES #line 1 "src/common/mbuf.h" #endif - /* * Mbufs are mutable/growing memory buffers, like C++ strings. * Mbuf can append data to the end of a buffer or insert data into arbitrary @@ -2142,7 +2122,6 @@ void mbuf_trim(struct mbuf *); #ifdef MG_MODULE_LINES #line 1 "src/common/cs_base64.h" #endif - #ifndef CS_COMMON_CS_BASE64_H_ #define CS_COMMON_CS_BASE64_H_ @@ -2195,7 +2174,6 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst, int *dec_len); #ifdef MG_MODULE_LINES #line 1 "src/common/str_util.h" #endif - #ifndef CS_COMMON_STR_UTIL_H_ #define CS_COMMON_STR_UTIL_H_ @@ -3135,7 +3113,6 @@ struct { \ #ifdef MG_MODULE_LINES #line 1 "src/mg_features.h" #endif - #ifndef CS_MONGOOSE_SRC_FEATURES_H_ #define CS_MONGOOSE_SRC_FEATURES_H_ @@ -3310,7 +3287,6 @@ struct { \ #ifdef MG_MODULE_LINES #line 1 "src/mg_net_if.h" #endif - #ifndef CS_MONGOOSE_SRC_NET_IF_H_ #define CS_MONGOOSE_SRC_NET_IF_H_ @@ -3440,7 +3416,6 @@ double mg_mgr_min_timer(const struct mg_mgr *mgr); #ifdef MG_MODULE_LINES #line 1 "src/mg_ssl_if.h" #endif - #ifndef CS_MONGOOSE_SRC_SSL_IF_H_ #define CS_MONGOOSE_SRC_SSL_IF_H_ @@ -3494,7 +3469,6 @@ int mg_ssl_if_write(struct mg_connection *nc, const void *data, size_t len); #ifdef MG_MODULE_LINES #line 1 "src/mg_net.h" #endif - /* * === Core API: TCP/UDP/SSL * @@ -4080,7 +4054,6 @@ double mg_time(void); #ifdef MG_MODULE_LINES #line 1 "src/mg_uri.h" #endif - /* * === URI */ @@ -4146,7 +4119,6 @@ int mg_normalize_uri_path(const struct mg_str *in, struct mg_str *out); #ifdef MG_MODULE_LINES #line 1 "src/mg_util.h" #endif - /* * === Utility API */ @@ -4360,7 +4332,6 @@ struct mg_str mg_url_encode(const struct mg_str src); #ifdef MG_MODULE_LINES #line 1 "src/mg_http.h" #endif - /* * === Common API reference */ @@ -5373,7 +5344,6 @@ int mg_http_create_digest_auth_header(char *buf, size_t buf_len, #ifdef MG_MODULE_LINES #line 1 "src/mg_mqtt.h" #endif - /* * === MQTT API reference */ @@ -5588,7 +5558,6 @@ int mg_mqtt_vmatch_topic_expression(const char *exp, struct mg_str topic); #ifdef MG_MODULE_LINES #line 1 "src/mg_mqtt_server.h" #endif - /* * === MQTT Server API reference */ @@ -5679,7 +5648,6 @@ struct mg_mqtt_session *mg_mqtt_next(struct mg_mqtt_broker *brk, #ifdef MG_MODULE_LINES #line 1 "src/mg_dns.h" #endif - /* * === DNS API reference */ @@ -5843,7 +5811,6 @@ void mg_set_protocol_dns(struct mg_connection *nc); #ifdef MG_MODULE_LINES #line 1 "src/mg_dns_server.h" #endif - /* * === DNS server API reference * @@ -5936,7 +5903,6 @@ void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r); #ifdef MG_MODULE_LINES #line 1 "src/mg_resolv.h" #endif - /* * === API reference */ @@ -6016,7 +5982,6 @@ int mg_resolve_from_hosts_file(const char *host, union socket_address *usa); #ifdef MG_MODULE_LINES #line 1 "src/mg_coap.h" #endif - /* * === CoAP API reference * @@ -6168,7 +6133,6 @@ uint32_t mg_coap_compose(struct mg_coap_message *cm, struct mbuf *io); #ifdef MG_MODULE_LINES #line 1 "src/mg_sntp.h" #endif - #ifndef CS_MONGOOSE_SRC_SNTP_H_ #define CS_MONGOOSE_SRC_SNTP_H_ @@ -6221,7 +6185,6 @@ struct mg_connection *mg_sntp_get_time(struct mg_mgr *mgr, #ifdef MG_MODULE_LINES #line 1 "src/mg_socks.h" #endif - #ifndef CS_MONGOOSE_SRC_SOCKS_H_ #define CS_MONGOOSE_SRC_SOCKS_H_ diff --git a/src/common/platforms/lwip/mg_lwip_net_if.c b/src/common/platforms/lwip/mg_lwip_net_if.c index a38eaf17..9a12e537 100644 --- a/src/common/platforms/lwip/mg_lwip_net_if.c +++ b/src/common/platforms/lwip/mg_lwip_net_if.c @@ -121,7 +121,7 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle, static err_t mg_lwip_tcp_conn_cb(void *arg, struct tcp_pcb *tpcb, err_t err) { struct mg_connection *nc = (struct mg_connection *) arg; DBG(("%p connect to %s:%u = %d", nc, IPADDR_NTOA(ipX_2_ip(&tpcb->remote_ip)), - tpcb->remote_port, err)); + tpcb->remote_port, (int) err)); if (nc == NULL) { tcp_abort(tpcb); return ERR_ARG; @@ -137,7 +137,7 @@ static err_t mg_lwip_tcp_conn_cb(void *arg, struct tcp_pcb *tpcb, err_t err) { static void mg_lwip_tcp_error_cb(void *arg, err_t err) { struct mg_connection *nc = (struct mg_connection *) arg; - DBG(("%p conn error %d", nc, err)); + DBG(("%p conn error %d", nc, (int) err)); if (nc == NULL || (nc->flags & MG_F_CLOSE_IMMEDIATELY)) return; struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; cs->pcb.tcp = NULL; /* Has already been deallocated */ @@ -155,7 +155,7 @@ static err_t mg_lwip_tcp_recv_cb(void *arg, struct tcp_pcb *tpcb, struct mg_lwip_conn_state *cs = (nc ? (struct mg_lwip_conn_state *) nc->sock : NULL); DBG(("%p %p %p %p %u %d", nc, cs, tpcb, p, (p != NULL ? p->tot_len : 0), - err)); + (int) err)); if (p == NULL) { if (nc != NULL && !(nc->flags & MG_F_CLOSE_IMMEDIATELY)) { if (cs->rx_chain != NULL) { @@ -240,13 +240,13 @@ static void mg_lwip_if_connect_tcp_tcpip(void *arg) { tcp_sent(tpcb, mg_lwip_tcp_sent_cb); tcp_recv(tpcb, mg_lwip_tcp_recv_cb); cs->err = TCP_BIND(tpcb, IP_ADDR_ANY, 0 /* any port */); - DBG(("%p tcp_bind = %d", nc, cs->err)); + DBG(("%p tcp_bind = %d", nc, (int) cs->err)); if (cs->err != ERR_OK) { mg_lwip_post_signal(MG_SIG_CONNECT_RESULT, nc); return; } cs->err = tcp_connect(tpcb, ip, port, mg_lwip_tcp_conn_cb); - DBG(("%p tcp_connect %p = %d", nc, tpcb, cs->err)); + DBG(("%p tcp_connect %p = %d", nc, tpcb, (int) cs->err)); if (cs->err != ERR_OK) { mg_lwip_post_signal(MG_SIG_CONNECT_RESULT, nc); return; @@ -338,7 +338,7 @@ static void mg_lwip_if_connect_udp_tcpip(void *arg) { struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; struct udp_pcb *upcb = udp_new(); cs->err = UDP_BIND(upcb, IP_ADDR_ANY, 0 /* any port */); - DBG(("%p udp_bind %p = %d", nc, upcb, cs->err)); + DBG(("%p udp_bind %p = %d", nc, upcb, (int) cs->err)); if (cs->err == ERR_OK) { udp_recv(upcb, mg_lwip_udp_recv_cb, nc); cs->pcb.udp = upcb; @@ -420,7 +420,7 @@ static void mg_lwip_if_listen_tcp_tcpip(void *arg) { ip_addr_t *ip = (ip_addr_t *) &sa->sin.sin_addr.s_addr; u16_t port = ntohs(sa->sin.sin_port); cs->err = TCP_BIND(tpcb, ip, port); - DBG(("%p tcp_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, cs->err)); + DBG(("%p tcp_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, (int) cs->err)); if (cs->err != ERR_OK) { tcp_close(tpcb); ctx->ret = -1; @@ -448,7 +448,7 @@ static void mg_lwip_if_listen_udp_tcpip(void *arg) { ip_addr_t *ip = (ip_addr_t *) &sa->sin.sin_addr.s_addr; u16_t port = ntohs(sa->sin.sin_port); cs->err = UDP_BIND(upcb, ip, port); - DBG(("%p udb_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, cs->err)); + DBG(("%p udb_bind(%s:%u) = %d", nc, IPADDR_NTOA(ip), port, (int) cs->err)); if (cs->err != ERR_OK) { udp_remove(upcb); ctx->ret = -1; @@ -508,7 +508,8 @@ static void mg_lwip_tcp_write_tcpip(void *arg) { cs->err = tcp_write(tpcb, ctx->data, len, TCP_WRITE_FLAG_COPY); unsent = (tpcb->unsent != NULL ? tpcb->unsent->len : 0); unacked = (tpcb->unacked != NULL ? tpcb->unacked->len : 0); - DBG(("%p tcp_write %u = %d, %u %u", tpcb, len, cs->err, unsent, unacked)); + DBG(("%p tcp_write %u = %d, %u %u", + tpcb, len, (int) cs->err, unsent, unacked)); if (cs->err != ERR_OK) { /* * We ignore ERR_MEM because memory will be freed up when the data is sent diff --git a/src/mg_http.c b/src/mg_http.c index 39bf78bf..219d411a 100644 --- a/src/mg_http.c +++ b/src/mg_http.c @@ -1522,7 +1522,7 @@ void mg_http_serve_file_internal(struct mg_connection *nc, }; mg_http_send_error(nc, code, "Open failed"); } else { - char etag[50], current_time[50], last_modified[50], range[70]; + char etag[50], current_time[50], last_modified[50], range[76]; time_t t = (time_t) mg_time(); int64_t r1 = 0, r2 = 0, cl = st.st_size; struct mg_str *range_hdr = mg_get_http_header(hm, "Range"); diff --git a/tools/amalgam.py b/tools/amalgam.py index 8fbe35e6..f58bb571 100755 --- a/tools/amalgam.py +++ b/tools/amalgam.py @@ -121,9 +121,14 @@ def emit_body(out, name, parent_name): return with open(resolved_name) as f: + leading_spaces = True in_comment = False comment = '' for l in f: + if leading_spaces: + if not l.strip(): + continue + leading_spaces = False if in_comment: comment += l if re.match('\s*\*/$', l):