Fix VC98 build

This commit is contained in:
cpq 2023-02-12 10:41:51 +00:00
parent 8321f9f6e9
commit 5aebed95a4
3 changed files with 28 additions and 18 deletions

View File

@ -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 CFLAGS_MONGOOSE += -DMG_ENABLE_LINES=1 -DMG_ENABLE_IPV6=1
ifeq ($(OS),Windows_NT) 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 PROG ?= example.exe # Use .exe suffix for the binary
CC = gcc # Use MinGW gcc compiler CC = gcc # Use MinGW gcc compiler
CFLAGS += -lws2_32 # Link against Winsock library CFLAGS += -lws2_32 # Link against Winsock library
DELETE = cmd /C del /q /f /s # Command prompt command to delete files DELETE = cmd /C del /q /f /s # Command prompt command to delete files
OUT ?= -o $(PROG) # Build output
else else
# Mac, Linux # Mac, Linux
PROG ?= example PROG ?= example
DELETE = rm -rf DELETE = rm -rf
OUT ?= -o $(PROG)
endif endif
all: $(PROG) all: $(PROG)
$(RUN) ./$(PROG) $(ARGS) $(RUN) ./$(PROG) $(ARGS)
$(PROG): $(SOURCES) $(PROG): $(SOURCES)
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) -o $@ $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
clean: clean:
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM $(DELETE) $(PROG) *.o *.obj *.exe *.dSYM

View File

@ -1853,15 +1853,19 @@ static void printdirentry(const char *name, void *userdata) {
mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size); mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size);
} }
#if defined(MG_HTTP_DIRLIST_TIME) #if defined(MG_HTTP_DIRLIST_TIME)
{
char time_str[30]; char time_str[30];
struct tm *time_info = localtime(&t); struct tm *time_info = localtime(&t);
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
mg_snprintf(mod, sizeof(mod), "%s", time_str); mg_snprintf(mod, sizeof(mod), "%s", time_str);
}
#elif defined(MG_HTTP_DIRLIST_TIME_UTC) #elif defined(MG_HTTP_DIRLIST_TIME_UTC)
{
char time_str[30]; char time_str[30];
struct tm *time_info = gmtime(&t); struct tm *time_info = gmtime(&t);
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
mg_snprintf(mod, sizeof(mod), "%s", time_str); mg_snprintf(mod, sizeof(mod), "%s", time_str);
}
#else #else
mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t); mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t);
#endif #endif

View File

@ -564,15 +564,19 @@ static void printdirentry(const char *name, void *userdata) {
mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size); mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size);
} }
#if defined(MG_HTTP_DIRLIST_TIME) #if defined(MG_HTTP_DIRLIST_TIME)
{
char time_str[30]; char time_str[30];
struct tm *time_info = localtime(&t); struct tm *time_info = localtime(&t);
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
mg_snprintf(mod, sizeof(mod), "%s", time_str); mg_snprintf(mod, sizeof(mod), "%s", time_str);
}
#elif defined(MG_HTTP_DIRLIST_TIME_UTC) #elif defined(MG_HTTP_DIRLIST_TIME_UTC)
{
char time_str[30]; char time_str[30];
struct tm *time_info = gmtime(&t); struct tm *time_info = gmtime(&t);
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
mg_snprintf(mod, sizeof(mod), "%s", time_str); mg_snprintf(mod, sizeof(mod), "%s", time_str);
}
#else #else
mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t); mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t);
#endif #endif