diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 65515979..8c9256f9 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -68,46 +68,142 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: stm32-freertos-tcp
- run: make -C examples/stm32-freertos-tcp build
+ run: make -C examples/stm32/stm32-freertos-tcp build
stm32-nucleo-f746z:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: stm32-nucleo-f746z
- run: make -C examples/stm32-nucleo-f746z build
+ run: make -C examples/stm32/stm32-nucleo-f746z build
stm32-nucleo-f429z:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: stm32-nucleo-f429z
- run: make -C examples/stm32-nucleo-f429z build
+ run: make -C examples/stm32/stm32-nucleo-f429z build
stm32-nucleo-h743z:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: stm32-nucleo-h743z
- run: make -C examples/stm32-nucleo-h743z build
+ run: make -C examples/stm32/stm32-nucleo-h743z build
nxp-mimxrt1020-azurertos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: nxp-mimxrt1020-azurertos
- run: make -C examples/nxp-mimxrt1020-azurertos build
+ run: make -C examples/nxp/nxp-mimxrt1020-azurertos build
nxp-frdmk66f-freertos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: nxp-frdmk66f-freertos
- run: make -C examples/nxp-frdmk66f-freertos build
+ run: make -C examples/nxp/nxp-frdmk66f-freertos build
nxp-lpcxpresso54s018m-freertos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: nxp-lpcxpresso54s018m-freertos
- run: make -C examples/nxp-lpcxpresso54s018m-freertos build
+ run: make -C examples/nxp/nxp-lpcxpresso54s018m-freertos build
nxp-mimxrt1020-freertos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: nxp-mimxrt1020-freertos
- run: make -C examples/nxp-mimxrt1020-freertos build
\ No newline at end of file
+ run: make -C examples/nxp/nxp-mimxrt1020-freertos build
+ nxp-evkbimxrt1050-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkbimxrt1050-lwip-freertos
+ run: make -C examples/nxp/nxp-evkbimxrt1050-lwip-freertos build
+ nxp-evkmimxrt1020-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1020-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1020-lwip-freertos build
+ nxp-evkmimxrt1024-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1024-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1024-lwip-freertos build
+ nxp-evkmimxrt1060-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1060-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1060-lwip-freertos build
+ nxp-evkmimxrt1064-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1064-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1064-lwip-freertos build
+ nxp-evkmimxrt1160-cm7-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1160-cm7-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos build
+ nxp-evkmimxrt1170-cm4-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1170-cm4-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos build
+ nxp-evkmimxrt1170-cm7-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-evkmimxrt1170-cm7-lwip-freertos
+ run: make -C examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos build
+ nxp-frdmk64f-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-frdmk64f-lwip-freertos
+ run: make -C examples/nxp/nxp-frdmk64f-lwip-freertos build
+ nxp-frdmk66f-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-frdmk66f-lwip-freertos
+ run: make -C examples/nxp/nxp-frdmk66f-lwip-freertos build
+ nxp-lpcxpresso54018-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-lpcxpresso54018-lwip-freertos
+ run: make -C examples/nxp/nxp-lpcxpresso54018-lwip-freertos build
+ nxp-lpcxpresso54608-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-lpcxpresso54608-lwip-freertos
+ run: make -C examples/nxp/nxp-lpcxpresso54608-lwip-freertos build
+ nxp-lpcxpresso54618-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-lpcxpresso54618-lwip-freertos
+ run: make -C examples/nxp/nxp-lpcxpresso54618-lwip-freertos build
+ nxp-lpcxpresso54628-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-lpcxpresso54628-lwip-freertos
+ run: make -C examples/nxp/nxp-lpcxpresso54628-lwip-freertos build
+ nxp-twrk65f180m-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-twrk65f180m-lwip-freertos
+ run: make -C examples/nxp/nxp-twrk65f180m-lwip-freertos build
+ nxp-twrkv58f220m-lwip-freertos:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: nxp-twrkv58f220m-lwip-freertos
+ run: make -C examples/nxp/nxp-twrkv58f220m-lwip-freertos build
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 8d6fe019..f7ebab39 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
SRCS = mongoose.c test/unit_test.c test/packed_fs.c
HDRS = $(wildcard src/*.h)
DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1
-WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef
+WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wmissing-prototypes -Wundef
OPTS ?= -O3 -g3
INCS ?= -Isrc -I.
CFLAGS ?= $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) $(EXTRA)
@@ -122,7 +122,7 @@ uninstall:
rm -rf $(DESTDIR)$(PREFIX)/lib/libmongoose.a $(DESTDIR)$(PREFIX)/lib/libmongoose.so.$(VERSION) $(DESTDIR)$(PREFIX)/include/mongoose.h $(DESTDIR)$(PREFIX)/lib/libmongoose.so
mongoose.c: Makefile $(wildcard src/*)
- (cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/private.h src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
+ (cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
mongoose.h: $(HDRS) Makefile
(cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/config.h src/arch.h src/arch_*.h src/str.h src/log.h src/timer.h src/util.h src/fs.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/ws.h src/sntp.h src/mqtt.h src/dns.h | sed -e 's,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@
diff --git a/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile b/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile b/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp-frdmk66f-freertos/Makefile b/examples/nxp/nxp-frdmk66f-freertos/Makefile
similarity index 76%
rename from examples/nxp-frdmk66f-freertos/Makefile
rename to examples/nxp/nxp-frdmk66f-freertos/Makefile
index 1400540e..59bc811c 100644
--- a/examples/nxp-frdmk66f-freertos/Makefile
+++ b/examples/nxp/nxp-frdmk66f-freertos/Makefile
@@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR))
build:
git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/source/
+ cp ./../../../mongoose.[ch] $(NAME)/source/
make -C $(NAME) build
clean:
diff --git a/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile b/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp-lpcxpresso54s018m-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile
similarity index 76%
rename from examples/nxp-lpcxpresso54s018m-freertos/Makefile
rename to examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile
index 1400540e..59bc811c 100644
--- a/examples/nxp-lpcxpresso54s018m-freertos/Makefile
+++ b/examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile
@@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR))
build:
git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/source/
+ cp ./../../../mongoose.[ch] $(NAME)/source/
make -C $(NAME) build
clean:
diff --git a/examples/nxp-mimxrt1020-azurertos/Makefile b/examples/nxp/nxp-mimxrt1020-azurertos/Makefile
similarity index 76%
rename from examples/nxp-mimxrt1020-azurertos/Makefile
rename to examples/nxp/nxp-mimxrt1020-azurertos/Makefile
index 1400540e..59bc811c 100644
--- a/examples/nxp-mimxrt1020-azurertos/Makefile
+++ b/examples/nxp/nxp-mimxrt1020-azurertos/Makefile
@@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR))
build:
git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/source/
+ cp ./../../../mongoose.[ch] $(NAME)/source/
make -C $(NAME) build
clean:
diff --git a/examples/nxp-mimxrt1020-freertos/Makefile b/examples/nxp/nxp-mimxrt1020-freertos/Makefile
similarity index 76%
rename from examples/nxp-mimxrt1020-freertos/Makefile
rename to examples/nxp/nxp-mimxrt1020-freertos/Makefile
index 1400540e..59bc811c 100644
--- a/examples/nxp-mimxrt1020-freertos/Makefile
+++ b/examples/nxp/nxp-mimxrt1020-freertos/Makefile
@@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR))
build:
git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/source/
+ cp ./../../../mongoose.[ch] $(NAME)/source/
make -C $(NAME) build
clean:
diff --git a/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile b/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile b/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile
new file mode 100644
index 00000000..2cc7c5b1
--- /dev/null
+++ b/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/stm32-nucleo-f429z/Makefile b/examples/stm32-nucleo-f429z/Makefile
deleted file mode 100644
index fe9aa4ed..00000000
--- a/examples/stm32-nucleo-f429z/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-NAME ?= $(notdir $(CURDIR))
-
-build:
- git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
- make -C $(NAME) build
-
-clean:
- rm -rf $(NAME)
diff --git a/examples/stm32-nucleo-f746z/Makefile b/examples/stm32-nucleo-f746z/Makefile
deleted file mode 100644
index fe9aa4ed..00000000
--- a/examples/stm32-nucleo-f746z/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-NAME ?= $(notdir $(CURDIR))
-
-build:
- git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
- make -C $(NAME) build
-
-clean:
- rm -rf $(NAME)
diff --git a/examples/stm32-nucleo-h743z/Makefile b/examples/stm32-nucleo-h743z/Makefile
deleted file mode 100644
index fe9aa4ed..00000000
--- a/examples/stm32-nucleo-h743z/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-NAME ?= $(notdir $(CURDIR))
-
-build:
- git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
- cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
- make -C $(NAME) build
-
-clean:
- rm -rf $(NAME)
diff --git a/examples/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h b/examples/stm32/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h
rename to examples/stm32/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.c
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.c
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.c
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h
diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h
similarity index 100%
rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h
rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h
diff --git a/examples/stm32-freertos-tcp/Makefile b/examples/stm32/stm32-freertos-tcp/Makefile
similarity index 85%
rename from examples/stm32-freertos-tcp/Makefile
rename to examples/stm32/stm32-freertos-tcp/Makefile
index 323a664f..5c08a57a 100644
--- a/examples/stm32-freertos-tcp/Makefile
+++ b/examples/stm32/stm32-freertos-tcp/Makefile
@@ -1,13 +1,13 @@
# FreeRTOS/{FreeRTOS-Kernel V10.4.3,FreeRTOS-Plus-TCP V2.3.2}
PROG = firmware
ARCH = stm32f7
-PROJECT_ROOT_PATH = $(realpath $(CURDIR)/../..)
+PROJECT_ROOT_PATH = $(realpath $(CURDIR)/../../..)
DOCKER ?= docker run --rm -v $(PROJECT_ROOT_PATH):$(PROJECT_ROOT_PATH) -w $(CURDIR) mdashnet/armgcc
FREERTOS_KERNEL_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-kernel
FREERTOS_PLUS_TCP_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-tcp
MONGOOSE_FLAGS = -DMG_ARCH=MG_ARCH_FREERTOS_TCP
-MCU_FLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=softfp -mfpu=vfpv4
+MCU_FLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=softfp -mfpu=vfpv4
#-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard
INCLUDES = -I$(PROJECT_ROOT_PATH) -I$(ARCH) -I$(FREERTOS_KERNEL_PATH)/include -I$(FREERTOS_PLUS_TCP_PATH)/include
@@ -36,19 +36,19 @@ SOURCES += $(FREERTOS_KERNEL_PATH)/portable/MemMang/heap_5.c
SOURCES += $(FREERTOS_KERNEL_PATH)/portable/GCC/ARM_CM7/r0p1/port.c
# FreeRTOS TCP stack sources
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_ARP.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DHCP.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DNS.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_IP.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Sockets.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Stream_Buffer.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_ARP.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DHCP.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DNS.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_IP.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Sockets.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Stream_Buffer.c
SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_IP.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_WIN.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_UDP_IP.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_WIN.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_UDP_IP.c
SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/Common/phyHandling.c
SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/BufferManagement/BufferAllocation_1.c
SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/NetworkInterface.c
-SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c
+SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c
OBJECTS = obj/boot.o $(SOURCES:%.c=obj/%.o)
diff --git a/examples/stm32-freertos-tcp/README.md b/examples/stm32/stm32-freertos-tcp/README.md
similarity index 100%
rename from examples/stm32-freertos-tcp/README.md
rename to examples/stm32/stm32-freertos-tcp/README.md
diff --git a/examples/stm32-freertos-tcp/main.c b/examples/stm32/stm32-freertos-tcp/main.c
similarity index 100%
rename from examples/stm32-freertos-tcp/main.c
rename to examples/stm32/stm32-freertos-tcp/main.c
diff --git a/examples/stm32-freertos-tcp/openocd.cfg b/examples/stm32/stm32-freertos-tcp/openocd.cfg
similarity index 100%
rename from examples/stm32-freertos-tcp/openocd.cfg
rename to examples/stm32/stm32-freertos-tcp/openocd.cfg
diff --git a/examples/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h b/examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h b/examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/boot.s b/examples/stm32/stm32-freertos-tcp/stm32f7/boot.s
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/boot.s
rename to examples/stm32/stm32-freertos-tcp/stm32f7/boot.s
diff --git a/examples/stm32-freertos-tcp/stm32f7/cmsis_gcc.h b/examples/stm32/stm32-freertos-tcp/stm32f7/cmsis_gcc.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/cmsis_gcc.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/cmsis_gcc.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cm7.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cm7.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/core_cm7.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cm7.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmFunc.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmFunc.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/core_cmFunc.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmFunc.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmInstr.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmInstr.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/core_cmInstr.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmInstr.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmSimd.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmSimd.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/core_cmSimd.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmSimd.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/device.h b/examples/stm32/stm32-freertos-tcp/stm32f7/device.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/device.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/device.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/link.ld b/examples/stm32/stm32-freertos-tcp/stm32f7/link.ld
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/link.ld
rename to examples/stm32/stm32-freertos-tcp/stm32f7/link.ld
diff --git a/examples/stm32-freertos-tcp/stm32f7/portmacro.h b/examples/stm32/stm32-freertos-tcp/stm32f7/portmacro.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/portmacro.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/portmacro.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/stm32f746xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/stm32f746xx.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/stm32f746xx.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/stm32f746xx.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/stm32f7xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/stm32f7xx.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/stm32f7xx.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/stm32f7xx.h
diff --git a/examples/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h
similarity index 100%
rename from examples/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h
rename to examples/stm32/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h
diff --git a/examples/stm32/stm32-nucleo-f429z/Makefile b/examples/stm32/stm32-nucleo-f429z/Makefile
new file mode 100644
index 00000000..92b4174e
--- /dev/null
+++ b/examples/stm32/stm32-nucleo-f429z/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/stm32/stm32-nucleo-f746z/Makefile b/examples/stm32/stm32-nucleo-f746z/Makefile
new file mode 100644
index 00000000..92b4174e
--- /dev/null
+++ b/examples/stm32/stm32-nucleo-f746z/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/examples/stm32/stm32-nucleo-h743z/Makefile b/examples/stm32/stm32-nucleo-h743z/Makefile
new file mode 100644
index 00000000..92b4174e
--- /dev/null
+++ b/examples/stm32/stm32-nucleo-h743z/Makefile
@@ -0,0 +1,9 @@
+NAME ?= $(notdir $(CURDIR))
+
+build:
+ git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
+ cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/
+ make -C $(NAME) build
+
+clean:
+ rm -rf $(NAME)
diff --git a/mongoose.c b/mongoose.c
index 15b0ec8c..59398ad8 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -5,7 +5,7 @@
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. For the terms of this
-// license, see .
+// license, see http://www.gnu.org/licenses/
//
// You are free to use this software under the terms of the GNU General
// Public License, but WITHOUT ANY WARRANTY; without even the implied
@@ -13,18 +13,14 @@
// See the GNU General Public License for more details.
//
// Alternatively, you can license this software under a commercial
-// license, as set out in .
+// license, as set out in https://www.mongoose.ws/licensing/
#include "mongoose.h"
-#ifdef MG_ENABLE_LINES
-#line 1 "src/private.h"
-#endif
-void mg_connect_resolved(struct mg_connection *);
-
#ifdef MG_ENABLE_LINES
#line 1 "src/base64.c"
#endif
+
#include
static int mg_b64idx(int c) {
@@ -177,7 +173,7 @@ static size_t mg_dns_parse_name_depth(const uint8_t *s, size_t len, size_t ofs,
return i;
}
-size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst,
+static size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst,
size_t dstlen) {
return mg_dns_parse_name_depth(s, n, ofs, dst, dstlen, 0);
}
@@ -188,22 +184,22 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs,
memset(rr, 0, sizeof(*rr));
if (len < sizeof(struct mg_dns_header)) return 0; // Too small
- if (len > 512) return 0; // Too large, we don't expect that
- if (s >= e) return 0; // Overflow
+ if (len > 512) return 0; // Too large, we don't expect that
+ if (s >= e) return 0; // Overflow
if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0)
return 0;
s += rr->nlen + 4;
if (s > e) return 0;
- rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]);
- rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]);
- if (is_question) return (size_t)(rr->nlen + 4);
+ rr->atype = (uint16_t) (((uint16_t) s[-4] << 8) | s[-3]);
+ rr->aclass = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]);
+ if (is_question) return (size_t) (rr->nlen + 4);
s += 6;
if (s > e) return 0;
- rr->alen = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]);
+ rr->alen = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]);
if (s + rr->alen > e) return 0;
- return (size_t)(rr->nlen + rr->alen + 10);
+ return (size_t) (rr->nlen + rr->alen + 10);
}
bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) {
@@ -303,7 +299,7 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data,
(void) fn_data;
}
-void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
+static void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
uint16_t txnid, bool ipv6) {
struct {
struct mg_dns_header header;
@@ -316,7 +312,7 @@ void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
pkt.header.num_questions = mg_htons(1);
for (i = n = 0; i < sizeof(pkt.data) - 5; i++) {
if (name->ptr[i] == '.' || i >= name->len) {
- pkt.data[n] = (uint8_t)(i - n);
+ pkt.data[n] = (uint8_t) (i - n);
memcpy(&pkt.data[n + 1], name->ptr + n, i - n);
n = i + 1;
}
@@ -358,7 +354,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms,
#if MG_ENABLE_LOG
char buf[100];
#endif
- d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1;
+ d->txnid = s_reqs ? (uint16_t) (s_reqs->txnid + 1) : 1;
d->next = s_reqs;
s_reqs = d;
d->expire = mg_millis() + (unsigned long) ms;
@@ -923,7 +919,7 @@ struct mg_str *mg_http_get_header(struct mg_http_message *h, const char *name) {
return NULL;
}
-void mg_http_parse_headers(const char *s, const char *end,
+static void mg_http_parse_headers(const char *s, const char *end,
struct mg_http_header *h, int max_headers) {
int i;
for (i = 0; i < max_headers; i++) {
@@ -1123,6 +1119,7 @@ static void restore_http_cb(struct mg_connection *c) {
c->pfn = http_cb;
}
+char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime);
char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) {
snprintf(buf, len, "\"%lx." MG_INT64_FMT "\"", (unsigned long) mtime,
(int64_t) size);
@@ -1476,7 +1473,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm,
path[path_size - 1] = '\0'; // Double-check
remove_double_dots(path);
n = strlen(path);
- LOG(LL_DEBUG, ("--> %s", path));
+ LOG(LL_VERBOSE_DEBUG, ("%lu %s", c->id, path));
while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
flags = fs->stat(path, NULL, NULL); // Does it exist?
if (flags == 0) {
@@ -2576,7 +2573,7 @@ static uint32_t blk0(union char64long16 *block, int i) {
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
w = rol(w, 30);
-void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
+static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
uint32_t a, b, c, d, e;
union char64long16 block[1];
@@ -2829,8 +2826,7 @@ void mg_sntp_send(struct mg_connection *c, unsigned long utc) {
s_sntmp_next = utc + SNTP_INTERVAL_SEC;
buf[0] = (3 << 6) | (4 << 3) | 3;
mg_send(c, buf, sizeof(buf));
- LOG(LL_DEBUG,
- ("%p request sent, ct %lu, next at %lu", c->fd, utc, s_sntmp_next));
+ LOG(LL_DEBUG, ("%lu ct %lu, next at %lu", c->id, utc, s_sntmp_next));
}
}
@@ -2948,7 +2944,19 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client,
}
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
- long n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
+ long n;
+#if defined(_WIN32)
+ // See #1338, #1382. On Windows, UDP send() can fail despite connected.
+ // Use sendto() instead. But not UNIX: e.g. on Mac we'll get EISCONN
+ if (c->is_udp) {
+ union usa usa;
+ socklen_t slen = tousa(&c->peer, &usa);
+ n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
+ } else
+#endif
+ {
+ n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
+ }
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
}
@@ -2974,7 +2982,7 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
#endif
}
-SOCKET mg_open_listener(const char *url, struct mg_addr *addr) {
+static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) {
SOCKET fd = INVALID_SOCKET;
int s_err = 0; // Memoized socket error, in case closesocket() overrides it
memset(addr, 0, sizeof(*addr));
@@ -3214,12 +3222,12 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
SOCKET fd = accept(FD(lsn), &usa.sa, &sa_len);
if (fd == INVALID_SOCKET) {
#if MG_ARCH == MG_ARCH_AZURERTOS
- // AzureRTOS, in non-block socket mode can mark listening socket readable
- // even it is not. See comment for 'select' func implementation in nx_bsd.c
- // That's not an error, just should try later
- if (MG_SOCK_ERRNO != EAGAIN)
+ // AzureRTOS, in non-block socket mode can mark listening socket readable
+ // even it is not. See comment for 'select' func implementation in nx_bsd.c
+ // That's not an error, just should try later
+ if (MG_SOCK_ERRNO != EAGAIN)
#endif
- LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
+ LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
#if (!defined(_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP))
} else if ((long) fd >= FD_SETSIZE) {
LOG(LL_ERROR, ("%ld > %ld", (long) fd, (long) FD_SETSIZE));
diff --git a/mongoose.h b/mongoose.h
index a1d00646..8a73373d 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -5,7 +5,7 @@
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. For the terms of this
-// license, see .
+// license, see http://www.gnu.org/licenses/
//
// You are free to use this software under the terms of the GNU General
// Public License, but WITHOUT ANY WARRANTY; without even the implied
@@ -13,7 +13,7 @@
// See the GNU General Public License for more details.
//
// Alternatively, you can license this software under a commercial
-// license, as set out in .
+// license, as set out in https://www.mongoose.ws/licensing/
#ifndef MONGOOSE_H
#define MONGOOSE_H
@@ -819,6 +819,7 @@ struct mg_connection *mg_listen(struct mg_mgr *, const char *url,
mg_event_handler_t fn, void *fn_data);
struct mg_connection *mg_connect(struct mg_mgr *, const char *url,
mg_event_handler_t fn, void *fn_data);
+void mg_connect_resolved(struct mg_connection *);
bool mg_send(struct mg_connection *, const void *, size_t);
int mg_printf(struct mg_connection *, const char *fmt, ...);
int mg_vprintf(struct mg_connection *, const char *fmt, va_list ap);
diff --git a/src/base64.c b/src/base64.c
index 5989f67b..605851e6 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -1,3 +1,4 @@
+#include "base64.h"
#include
static int mg_b64idx(int c) {
diff --git a/src/dns.c b/src/dns.c
index 6318c537..4e6879c4 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -63,7 +63,7 @@ static size_t mg_dns_parse_name_depth(const uint8_t *s, size_t len, size_t ofs,
return i;
}
-size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst,
+static size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst,
size_t dstlen) {
return mg_dns_parse_name_depth(s, n, ofs, dst, dstlen, 0);
}
@@ -74,22 +74,22 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs,
memset(rr, 0, sizeof(*rr));
if (len < sizeof(struct mg_dns_header)) return 0; // Too small
- if (len > 512) return 0; // Too large, we don't expect that
- if (s >= e) return 0; // Overflow
+ if (len > 512) return 0; // Too large, we don't expect that
+ if (s >= e) return 0; // Overflow
if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0)
return 0;
s += rr->nlen + 4;
if (s > e) return 0;
- rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]);
- rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]);
- if (is_question) return (size_t)(rr->nlen + 4);
+ rr->atype = (uint16_t) (((uint16_t) s[-4] << 8) | s[-3]);
+ rr->aclass = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]);
+ if (is_question) return (size_t) (rr->nlen + 4);
s += 6;
if (s > e) return 0;
- rr->alen = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]);
+ rr->alen = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]);
if (s + rr->alen > e) return 0;
- return (size_t)(rr->nlen + rr->alen + 10);
+ return (size_t) (rr->nlen + rr->alen + 10);
}
bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) {
@@ -189,7 +189,7 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data,
(void) fn_data;
}
-void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
+static void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
uint16_t txnid, bool ipv6) {
struct {
struct mg_dns_header header;
@@ -202,7 +202,7 @@ void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
pkt.header.num_questions = mg_htons(1);
for (i = n = 0; i < sizeof(pkt.data) - 5; i++) {
if (name->ptr[i] == '.' || i >= name->len) {
- pkt.data[n] = (uint8_t)(i - n);
+ pkt.data[n] = (uint8_t) (i - n);
memcpy(&pkt.data[n + 1], name->ptr + n, i - n);
n = i + 1;
}
@@ -244,7 +244,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms,
#if MG_ENABLE_LOG
char buf[100];
#endif
- d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1;
+ d->txnid = s_reqs ? (uint16_t) (s_reqs->txnid + 1) : 1;
d->next = s_reqs;
s_reqs = d;
d->expire = mg_millis() + (unsigned long) ms;
diff --git a/src/http.c b/src/http.c
index 2727d634..54222d08 100644
--- a/src/http.c
+++ b/src/http.c
@@ -172,7 +172,7 @@ struct mg_str *mg_http_get_header(struct mg_http_message *h, const char *name) {
return NULL;
}
-void mg_http_parse_headers(const char *s, const char *end,
+static void mg_http_parse_headers(const char *s, const char *end,
struct mg_http_header *h, int max_headers) {
int i;
for (i = 0; i < max_headers; i++) {
@@ -372,6 +372,7 @@ static void restore_http_cb(struct mg_connection *c) {
c->pfn = http_cb;
}
+char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime);
char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) {
snprintf(buf, len, "\"%lx." MG_INT64_FMT "\"", (unsigned long) mtime,
(int64_t) size);
@@ -725,7 +726,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm,
path[path_size - 1] = '\0'; // Double-check
remove_double_dots(path);
n = strlen(path);
- LOG(LL_DEBUG, ("--> %s", path));
+ LOG(LL_VERBOSE_DEBUG, ("%lu %s", c->id, path));
while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
flags = fs->stat(path, NULL, NULL); // Does it exist?
if (flags == 0) {
diff --git a/src/license.h b/src/license.h
index 47a86452..c62f00f4 100644
--- a/src/license.h
+++ b/src/license.h
@@ -5,7 +5,7 @@
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. For the terms of this
-// license, see .
+// license, see http://www.gnu.org/licenses/
//
// You are free to use this software under the terms of the GNU General
// Public License, but WITHOUT ANY WARRANTY; without even the implied
@@ -13,4 +13,4 @@
// See the GNU General Public License for more details.
//
// Alternatively, you can license this software under a commercial
-// license, as set out in .
+// license, as set out in https://www.mongoose.ws/licensing/
diff --git a/src/net.h b/src/net.h
index 0950db9c..527bf78d 100644
--- a/src/net.h
+++ b/src/net.h
@@ -67,6 +67,7 @@ struct mg_connection *mg_listen(struct mg_mgr *, const char *url,
mg_event_handler_t fn, void *fn_data);
struct mg_connection *mg_connect(struct mg_mgr *, const char *url,
mg_event_handler_t fn, void *fn_data);
+void mg_connect_resolved(struct mg_connection *);
bool mg_send(struct mg_connection *, const void *, size_t);
int mg_printf(struct mg_connection *, const char *fmt, ...);
int mg_vprintf(struct mg_connection *, const char *fmt, va_list ap);
diff --git a/src/private.h b/src/private.h
deleted file mode 100644
index eeb40939..00000000
--- a/src/private.h
+++ /dev/null
@@ -1 +0,0 @@
-void mg_connect_resolved(struct mg_connection *);
diff --git a/src/sha1.c b/src/sha1.c
index d4b4655d..2719c10d 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -62,7 +62,7 @@ static uint32_t blk0(union char64long16 *block, int i) {
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
w = rol(w, 30);
-void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
+static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
uint32_t a, b, c, d, e;
union char64long16 block[1];
diff --git a/src/sntp.c b/src/sntp.c
index dc932fbf..ad4c8a90 100644
--- a/src/sntp.c
+++ b/src/sntp.c
@@ -54,8 +54,7 @@ void mg_sntp_send(struct mg_connection *c, unsigned long utc) {
s_sntmp_next = utc + SNTP_INTERVAL_SEC;
buf[0] = (3 << 6) | (4 << 3) | 3;
mg_send(c, buf, sizeof(buf));
- LOG(LL_DEBUG,
- ("%p request sent, ct %lu, next at %lu", c->fd, utc, s_sntmp_next));
+ LOG(LL_DEBUG, ("%lu ct %lu, next at %lu", c->id, utc, s_sntmp_next));
}
}
diff --git a/src/sock.c b/src/sock.c
index 087ffac5..d268ea2d 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -101,7 +101,19 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client,
}
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
- long n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
+ long n;
+#if defined(_WIN32)
+ // See #1338, #1382. On Windows, UDP send() can fail despite connected.
+ // Use sendto() instead. But not UNIX: e.g. on Mac we'll get EISCONN
+ if (c->is_udp) {
+ union usa usa;
+ socklen_t slen = tousa(&c->peer, &usa);
+ n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
+ } else
+#endif
+ {
+ n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
+ }
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
}
@@ -127,7 +139,7 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
#endif
}
-SOCKET mg_open_listener(const char *url, struct mg_addr *addr) {
+static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) {
SOCKET fd = INVALID_SOCKET;
int s_err = 0; // Memoized socket error, in case closesocket() overrides it
memset(addr, 0, sizeof(*addr));
@@ -367,12 +379,12 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
SOCKET fd = accept(FD(lsn), &usa.sa, &sa_len);
if (fd == INVALID_SOCKET) {
#if MG_ARCH == MG_ARCH_AZURERTOS
- // AzureRTOS, in non-block socket mode can mark listening socket readable
- // even it is not. See comment for 'select' func implementation in nx_bsd.c
- // That's not an error, just should try later
- if (MG_SOCK_ERRNO != EAGAIN)
+ // AzureRTOS, in non-block socket mode can mark listening socket readable
+ // even it is not. See comment for 'select' func implementation in nx_bsd.c
+ // That's not an error, just should try later
+ if (MG_SOCK_ERRNO != EAGAIN)
#endif
- LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
+ LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
#if (!defined(_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP))
} else if ((long) fd >= FD_SETSIZE) {
LOG(LL_ERROR, ("%ld > %ld", (long) fd, (long) FD_SETSIZE));
diff --git a/test/mongoose_custom.c b/test/mongoose_custom.c
index 3d882d7f..fa4de347 100644
--- a/test/mongoose_custom.c
+++ b/test/mongoose_custom.c
@@ -23,6 +23,7 @@ struct mg_connection *mg_connect(struct mg_mgr *mgr, const char *url,
return NULL;
}
+void mg_connect_resolved(struct mg_connection *c);
void mg_connect_resolved(struct mg_connection *c) {
(void) c;
}
@@ -52,5 +53,6 @@ struct mg_connection *mg_mkpipe(struct mg_mgr *mgr, mg_event_handler_t fn,
return NULL;
}
+void _fini(void);
void _fini(void) {
}
diff --git a/test/pack.c b/test/pack.c
index 183de982..a296a13f 100644
--- a/test/pack.c
+++ b/test/pack.c
@@ -23,9 +23,11 @@
#include
static const char *code =
+ "const char *mg_unlist(size_t no);\n"
"const char *mg_unlist(size_t no) {\n"
" return packed_files[no].name;\n"
"}\n"
+ "const char *mg_unpack(const char *name, size_t *size, time_t *mtime);\n"
"const char *mg_unpack(const char *name, size_t *size, time_t *mtime) {\n"
" const struct packed_file *p;\n"
" for (p = packed_files; p->name != NULL; p++) {\n"
diff --git a/test/unit_test.c b/test/unit_test.c
index 42391149..9e5f26d8 100644
--- a/test/unit_test.c
+++ b/test/unit_test.c
@@ -340,11 +340,11 @@ static void test_mqtt(void) {
opts.will_topic = mg_str("mg_will_topic");
opts.will_message = mg_str("mg_will_messsage");
c = mg_mqtt_connect(&mgr, url, &opts, mqtt_cb, buf);
- for (i = 0; i < 100 && buf[0] == 0; i++) mg_mgr_poll(&mgr, 10);
+ for (i = 0; i < 200 && buf[0] == 0; i++) mg_mgr_poll(&mgr, 10);
ASSERT(buf[0] == 'X');
mg_mqtt_sub(c, &topic, 1);
mg_mqtt_pub(c, &topic, &data, 1, false);
- for (i = 0; i < 100 && buf[1] == 0; i++) mg_mgr_poll(&mgr, 10);
+ for (i = 0; i < 200 && buf[1] == 0; i++) mg_mgr_poll(&mgr, 10);
ASSERT(strcmp(buf, "Xx/f12/hi") == 0);
mg_mgr_free(&mgr);