# $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 $@
#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){
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");
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");
$(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 > $@