]> Nishi Git Mirror - libw3.git/commitdiff
patched to work with windows - fetch now outputs to output.bin
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Wed, 24 Jan 2024 10:25:07 +0000 (10:25 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Wed, 24 Jan 2024 10:25:07 +0000 (10:25 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@56 d27a3e52-49c5-7645-884c-6793ebffc270

Example/Makefile
Example/fetch.c
Library/Core.c
Makefile
W3Version.h.p

index 933a11347cb8e82039a0527a1371bf072846ee61..6bf8dafd712dbda820141c0185593fa5c7f119ca 100644 (file)
@@ -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 $@
index 2d0b42db873d4b1d6a49336d1508dd0bbb29eca8..f8a60a31095dec22df01eaa5bf86b358c5b9ea25 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+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");
index 8c61d0ad356b36c4e46a06096dfa8f70b0e7e171..1f34525f7685b54117a83c0a73f42d635b108ac0 100644 (file)
@@ -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");
index f812e14a8c87dd54070ddcfd05f6e7f23964f12e..6233a50abbb90a609a800d7612c3e26c2fb84beb 100644 (file)
--- 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 > $@
index d454196b5fbe092210dc10a02a063e03d5df8a88..9bb9cdbcf1b059078b746bdfbbf968313e8f3cd7 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "1.2B" \
+#define LIBW3_VERSION "1.2C" \
 SUFFIX
 
 #ifdef __cplusplus