mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-14 09:48:01 +08:00
Merge branch 'master' into undef
This commit is contained in:
commit
90b22716ea
112
.github/workflows/test.yml
vendored
112
.github/workflows/test.yml
vendored
@ -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
|
||||
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
|
4
Makefile
4
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')> $@
|
||||
|
9
examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile
Normal file
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
9
examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile
Normal file
@ -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)
|
@ -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:
|
9
examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile
Normal file
@ -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)
|
@ -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:
|
@ -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:
|
@ -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:
|
9
examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile
Normal file
@ -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)
|
9
examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile
Normal file
9
examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile
Normal file
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
@ -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)
|
||||
|
9
examples/stm32/stm32-nucleo-f429z/Makefile
Normal file
9
examples/stm32/stm32-nucleo-f429z/Makefile
Normal file
@ -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)
|
9
examples/stm32/stm32-nucleo-f746z/Makefile
Normal file
9
examples/stm32/stm32-nucleo-f746z/Makefile
Normal file
@ -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)
|
9
examples/stm32/stm32-nucleo-h743z/Makefile
Normal file
9
examples/stm32/stm32-nucleo-h743z/Makefile
Normal file
@ -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)
|
68
mongoose.c
68
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 <http://www.gnu.org/licenses/>.
|
||||
// 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 <https://www.cesanta.com/license>.
|
||||
// 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 <string.h>
|
||||
|
||||
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));
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
// 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 <https://www.cesanta.com/license>.
|
||||
// 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);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "base64.h"
|
||||
#include <string.h>
|
||||
|
||||
static int mg_b64idx(int c) {
|
||||
|
22
src/dns.c
22
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;
|
||||
|
@ -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) {
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
// 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 <https://www.cesanta.com/license>.
|
||||
// license, as set out in https://www.mongoose.ws/licensing/
|
||||
|
@ -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);
|
||||
|
@ -1 +0,0 @@
|
||||
void mg_connect_resolved(struct mg_connection *);
|
@ -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];
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
26
src/sock.c
26
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));
|
||||
|
@ -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) {
|
||||
}
|
||||
|
@ -23,9 +23,11 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
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"
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user