diff --git a/examples/http-server/Makefile b/examples/http-server/Makefile index 91de167b..2770e93c 100644 --- a/examples/http-server/Makefile +++ b/examples/http-server/Makefile @@ -6,22 +6,24 @@ CFLAGS_MONGOOSE += -DMG_HTTP_DIRLIST_TIME=1 -DMG_ENABLE_SSI=1 CFLAGS_MONGOOSE += -DMG_ENABLE_LINES=1 -DMG_ENABLE_IPV6=1 ifeq ($(OS),Windows_NT) - # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD + # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe PROG ?= example.exe # Use .exe suffix for the binary CC = gcc # Use MinGW gcc compiler CFLAGS += -lws2_32 # Link against Winsock library DELETE = cmd /C del /q /f /s # Command prompt command to delete files + OUT ?= -o $(PROG) # Build output else # Mac, Linux PROG ?= example DELETE = rm -rf + OUT ?= -o $(PROG) endif all: $(PROG) $(RUN) ./$(PROG) $(ARGS) $(PROG): $(SOURCES) - $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) -o $@ + $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT) clean: $(DELETE) $(PROG) *.o *.obj *.exe *.dSYM diff --git a/mongoose.c b/mongoose.c index dfb4b651..be28e9f8 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1853,15 +1853,19 @@ static void printdirentry(const char *name, void *userdata) { mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size); } #if defined(MG_HTTP_DIRLIST_TIME) - char time_str[30]; - struct tm *time_info = localtime(&t); - strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); - mg_snprintf(mod, sizeof(mod), "%s", time_str); + { + char time_str[30]; + struct tm *time_info = localtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); + } #elif defined(MG_HTTP_DIRLIST_TIME_UTC) - char time_str[30]; - struct tm *time_info = gmtime(&t); - strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); - mg_snprintf(mod, sizeof(mod), "%s", time_str); + { + char time_str[30]; + struct tm *time_info = gmtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); + } #else mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t); #endif diff --git a/src/http.c b/src/http.c index 4d6d36f5..3ae80234 100644 --- a/src/http.c +++ b/src/http.c @@ -564,15 +564,19 @@ static void printdirentry(const char *name, void *userdata) { mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size); } #if defined(MG_HTTP_DIRLIST_TIME) - char time_str[30]; - struct tm *time_info = localtime(&t); - strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); - mg_snprintf(mod, sizeof(mod), "%s", time_str); + { + char time_str[30]; + struct tm *time_info = localtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); + } #elif defined(MG_HTTP_DIRLIST_TIME_UTC) - char time_str[30]; - struct tm *time_info = gmtime(&t); - strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); - mg_snprintf(mod, sizeof(mod), "%s", time_str); + { + char time_str[30]; + struct tm *time_info = gmtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); + } #else mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t); #endif