From d14b34d018ffa83b134db09d80d4fa92d5b96e8e Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 24 Jan 2024 10:25:07 +0000 Subject: [PATCH] patched to work with windows - fetch now outputs to output.bin git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@56 d27a3e52-49c5-7645-884c-6793ebffc270 --- Example/Makefile | 5 +++++ Example/fetch.c | 6 +++++- Library/Core.c | 4 ++++ Makefile | 2 +- W3Version.h.p | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Example/Makefile b/Example/Makefile index 933a113..6bf8daf 100644 --- a/Example/Makefile +++ b/Example/Makefile @@ -1,8 +1,13 @@ # $Id$: .PHONY: clean install +ifeq ($(WINDOWS),YES) +./fetch.exe: ./fetch.c $(RESFILE) + $(CC) -o $@ -I ../Library -L ../Library $^ -lw3 +else ./fetch: ./fetch.c $(RESFILE) $(CC) -o $@ -I ../Library -L ../Library $^ -lw3 +endif ./libw3.res: ./libw3.rc $(WINDRES) $< -O coff -o $@ diff --git a/Example/fetch.c b/Example/fetch.c index 2d0b42d..f8a60a3 100644 --- a/Example/fetch.c +++ b/Example/fetch.c @@ -10,8 +10,10 @@ #include #include +FILE* f; + void fetch_data(struct W3* w3, char* data, size_t size){ - write(1, data, size); + fwrite(data, size, 1, f); } void status(struct W3* w3, int status){ @@ -44,10 +46,12 @@ int main(int argc, char** argv){ W3_On(w3, "status", (void*)status); W3_On(w3, "data", (void*)fetch_data); W3_On(w3, "header", (void*)header); + f = fopen("example.bin", "wb"); if(argv[3] != NULL && strcmp(argv[3], "POST") == 0 && argv[4] != NULL){ W3_Set_Data(w3, argv[4], strlen(argv[4])); } W3_Send_Request(w3); + fclose(f); W3_Free(w3); }else{ fprintf(stderr, "Failed to fetch\n"); diff --git a/Library/Core.c b/Library/Core.c index 8c61d0a..1f34525 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -60,6 +60,10 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port){ w3->data = NULL; w3->readsize = 512; w3->protocol = __W3_Strdup(protocol); +#ifdef SSL_SUPPORT + w3->ssl = NULL; + w3->ssl_ctx = NULL; +#endif if(strcmp(protocol, "file") != 0){ w3->hostname = __W3_Strdup(hostname); if(ssl) __W3_Debug("Protocol", "Enabled SSL"); diff --git a/Makefile b/Makefile index f812e14..6233a50 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ all: ./w3.pc ./Library/W3Version.h $(ALL) $(MAKE) -C ./Library CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" WINDOWS=YES ./Example/fetch.exe: ./Library/w3.dll - $(MAKE) -C ./Example CC=$(CC) fetch RESFILE=./libw3.res WINDRES=$(WINDRES) + $(MAKE) -C ./Example CC=$(CC) fetch.exe RESFILE=./libw3.res WINDRES=$(WINDRES) WINDOWS=YES ./Library/W3Version.h: m4 -DSUFFIX=\"W\" ./W3Version.h.p > $@ diff --git a/W3Version.h.p b/W3Version.h.p index d454196..9bb9cdb 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "1.2B" \ +#define LIBW3_VERSION "1.2C" \ SUFFIX #ifdef __cplusplus -- 2.43.0