]> Nishi Git Mirror - libw3.git/commitdiff
httpd, and fix
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 17 Feb 2024 00:50:50 +0000 (00:50 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 17 Feb 2024 00:50:50 +0000 (00:50 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@234 d27a3e52-49c5-7645-884c-6793ebffc270

Example/Makefile
Example/httpd/Makefile [new file with mode: 0644]
Example/httpd/httpd.c [new file with mode: 0644]
Example/w3b/w3b.c
Library/protocol.mk
Makefile
W3Version.h.m4

index 6ea2506a1aa2833e7950616cd8cfad1b8cbed172..3dd1a46c4d4b411e0034f201e8e30a3588718eb3 100644 (file)
@@ -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 (file)
index 0000000..13fb04e
--- /dev/null
@@ -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 (file)
index 0000000..7dc4603
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * $Id$
+ *
+ * HTTP Daemon.
+ */
+
+#include <W3Core.h>
+
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char** argv) {
+       if(argv[1] != NULL && strcmp(argv[1], "--version") == 0) {
+               printf("LibW3 %s\n", LIBW3_VERSION);
+               return 0;
+       }
+}
index 9a7f8d95b444f89ef3a568b52ad28c9bbd3b0715..286edbc4c066734a9ae4eb967275b8bb31a4665e 100644 (file)
@@ -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);
        }
 }
index c2c109920a5bb6dfa740323250dd717bd73b97ad..508e2a10fcfb0f954d4e89236fb9019f8481a456 100644 (file)
@@ -7,3 +7,4 @@
 #GOPHER=NO
 #NEX=NO
 #FILE=NO
+#NNTP=NO
index 619d3ca4cc1ada1a5c03bdbcac7c22003cfdee5f..0c5b10468a9e303813bfe17352f2a053a9930544 100644 (file)
--- 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
index dbd5c5158fca23b8ad9e644030b39212952d523e..7e9a7e488a4274389e0b86cc248e3f6b6e4461e9 100644 (file)
@@ -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', `')