From: nishi Date: Sat, 17 Feb 2024 00:50:50 +0000 (+0000) Subject: httpd, and fix X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d7506e9a757e8e901211090a744ece5f966e0cf7;p=libw3.git httpd, and fix git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@234 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/Makefile b/Example/Makefile index 6ea2506..3dd1a46 100644 --- a/Example/Makefile +++ b/Example/Makefile @@ -15,6 +15,9 @@ examples: ifeq ($(TCL),YES) $(MAKE) -C ./tclw3 CC=$(CC) TCL_LIBS="$(TCL_LIBS)" TCL_CFLAGS="$(TCL_CFLAGS)" SUFFIX=$(SUFFIX) endif +ifeq ($(HTTPD),YES) + $(MAKE) -C ./httpd CC=$(CC) SUFFIX=$(SUFFIX) +endif install: $(MAKE) -C ./fetch CC=$(CC) PREFIX=$(PREFIX) SUFFIX=$(SUFFIX) install @@ -26,6 +29,9 @@ install: ifeq ($(TCL),YES) $(MAKE) -C ./tclw3 CC=$(CC) PREFIX=$(PREFIX) SUFFIX=$(SUFFIX) install endif +ifeq ($(HTTPD),YES) + $(MAKE) -C ./httpd CC=$(CC) PREFIX=$(PREFIX) SUFFIX=$(SUFFIX) install +endif clean: rm -f *.o *.so *.core *~ *.exe *.res @@ -36,5 +42,8 @@ clean: $(MAKE) -C ./ftp-list SUFFIX=$(SUFFIX) clean $(MAKE) -C ./nntp-list SUFFIX=$(SUFFIX) clean ifeq ($(TCL),YES) - $(MAKE) -C ./tclw3 CC=$(CC) SUFFIX=$(SUFFIX) clean + $(MAKE) -C ./tclw3 SUFFIX=$(SUFFIX) clean +endif +ifeq ($(HTTPD),YES) + $(MAKE) -C ./httpd SUFFIX=$(SUFFIX) clean endif diff --git a/Example/httpd/Makefile b/Example/httpd/Makefile new file mode 100644 index 0000000..13fb04e --- /dev/null +++ b/Example/httpd/Makefile @@ -0,0 +1,15 @@ +# $Id$: +.PHONY: clean install + +./httpd$(SUFFIX): ./httpd.c $(RESFILE) + $(CC) -g -o $@ -I ../../Library -L ../../Library $^ -lw3 + +../libw3.res: + $(MAKE) -C .. ./libw3.res WINDRES=$(WINDRES) + +clean: + rm -f httpd *.o *.so *.core *~ *.exe *.res + +install: ./httpd + mkdir -p $(PREFIX)/bin + cp ./httpd $(PREFIX)/bin/w3-httpd diff --git a/Example/httpd/httpd.c b/Example/httpd/httpd.c new file mode 100644 index 0000000..7dc4603 --- /dev/null +++ b/Example/httpd/httpd.c @@ -0,0 +1,17 @@ +/* + * $Id$ + * + * HTTP Daemon. + */ + +#include + +#include +#include + +int main(int argc, char** argv) { + if(argv[1] != NULL && strcmp(argv[1], "--version") == 0) { + printf("LibW3 %s\n", LIBW3_VERSION); + return 0; + } +} diff --git a/Example/w3b/w3b.c b/Example/w3b/w3b.c index 9a7f8d9..286edbc 100644 --- a/Example/w3b/w3b.c +++ b/Example/w3b/w3b.c @@ -108,9 +108,9 @@ void data_handler(struct W3* w3, char* data, size_t size) { } struct W3URL* global_u; -void nntpresp_handler(struct W3* w3, int status, char* data){ - if(status == 200){ - if(databuf == NULL){ +void nntpresp_handler(struct W3* w3, int status, char* data) { + if(status == 200) { + if(databuf == NULL) { databuf = malloc(1); databuf[0] = 0; } @@ -118,7 +118,7 @@ void nntpresp_handler(struct W3* w3, int status, char* data){ char* hyp = malloc(2 + strlen(data) + 3 + 1); hyp[0] = '\n'; int i; - for(i = 0; data[i] != 0; i++){ + for(i = 0; data[i] != 0; i++) { hyp[i + 1] = '-'; } for(i = 0; i < 3; i++) hyp[strlen(data) + i + 1] = '-'; @@ -132,13 +132,13 @@ void nntpresp_handler(struct W3* w3, int status, char* data){ W3_Set_Method(w3, "GROUP"); W3_Set_Path(w3, global_u->path + 1); W3_NNTP_Send_Request(w3); - }else if(status == 211 || status == 223){ + } else if(status == 211 || status == 223) { W3_Set_Method(w3, "HEAD"); W3_NNTP_Send_Request(w3); - }else if(status == 221){ + } else if(status == 221) { W3_Set_Method(w3, "NEXT"); W3_NNTP_Send_Request(w3); - }else{ + } else { W3_NNTP_Disconnect(w3); } } diff --git a/Library/protocol.mk b/Library/protocol.mk index c2c1099..508e2a1 100644 --- a/Library/protocol.mk +++ b/Library/protocol.mk @@ -7,3 +7,4 @@ #GOPHER=NO #NEX=NO #FILE=NO +#NNTP=NO diff --git a/Makefile b/Makefile index 619d3ca..0c5b104 100644 --- a/Makefile +++ b/Makefile @@ -114,6 +114,8 @@ endif ifeq ($(shell uname -s),Haiku) LIBS += -lnetwork endif +HTTPD := YES +# HTTPd uses fork() - this means you cannot build it for Windows. Sorry. endif ifeq ($(DEBUG),YES) @@ -131,7 +133,7 @@ all: ./Library/W3Version.h ./w3.pc $(ALL) $(MAKE) -C ./Library CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" WINDOWS=YES WINARCH=$(WINARCH) TCL=$(TCL) SSL=$(SSL) ./Example: ./Library/w3.dll - $(MAKE) -C ./Example CC=$(CC) TCL=$(TCL) TCL_LIBS="$(TCL_LIBS)" TCL_CFLAGS="$(TCL_CFLAGS)" examples SUFFIX=.exe + $(MAKE) -C ./Example CC=$(CC) TCL=$(TCL) TCL_LIBS="$(TCL_LIBS)" TCL_CFLAGS="$(TCL_CFLAGS)" HTTPD=$(HTTPD) examples SUFFIX=.exe ./Library/W3Version.h: ./W3Version.h.m4 m4 -DSUFFIX=\"W\" $(FLAGS) $< > $@ @@ -151,7 +153,7 @@ all: ./Library/W3Version.h ./w3.pc $(ALL) $(MAKE) -C ./Library CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" TCL=$(TCL) SSL=$(SSL) ./libw3.a ./Example: ./Library/libw3.so - $(MAKE) -C ./Example CC=$(CC) TCL_LIBS="$(TCL_LIBS)" TCL_CFLAGS="$(TCL_CFLAGS)" TCL=$(TCL) examples + $(MAKE) -C ./Example CC=$(CC) TCL_LIBS="$(TCL_LIBS)" TCL_CFLAGS="$(TCL_CFLAGS)" TCL=$(TCL) HTTPD=$(HTTPD) examples ./Library/W3Version.h: ./W3Version.h.m4 m4 -DSUFFIX=\"\" $(FLAGS) $< > $@ @@ -212,6 +214,7 @@ ifeq ($(TCL),YES) cp -rf /usr/$(MINGW)/sys-root/mingw/share/tcl8.6 w3-$(VERSION)/Example/tclw3/lib/tcl8.6 endif else + mkdir -p w3-$(VERSION)/Example/httpd cp ./Library/*.so w3-$(VERSION)/Library/ cp ./Example/fetch/fetch w3-$(VERSION)/Example/fetch/ cp ./Example/interactive/interactive w3-$(VERSION)/Example/interactive/ @@ -219,6 +222,7 @@ else cp ./Example/w3b/w3b w3-$(VERSION)/Example/w3b/ cp ./Example/ftp-list/ftp-list w3-$(VERSION)/Example/ftp-list/ cp ./Example/nntp-list/nntp-list w3-$(VERSION)/Example/nntp-list/ + cp ./Example/httpd/httpd w3-$(VERSION)/Example/httpd/ ifeq ($(TCL),YES) cp ./Example/tclw3/tclw3 w3-$(VERSION)/Example/tclw3/bin/ endif diff --git a/W3Version.h.m4 b/W3Version.h.m4 index dbd5c51..7e9a7e4 100644 --- a/W3Version.h.m4 +++ b/W3Version.h.m4 @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.15D" \ +#define LIBW3_VERSION "2.16" \ SUFFIX ifdef(`HTTP_SUPPORT', `#define LIBW3_HTTP_SUPPORT', `')