From 634d15d59476cb61fce9d2d811b03b3698b8a296 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 27 Jan 2024 01:04:33 +0000 Subject: [PATCH] pop3 git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@101 d27a3e52-49c5-7645-884c-6793ebffc270 --- Example/Makefile | 15 ++++++++++++++- Example/pop3-list/Makefile | 18 ++++++++++++++++++ Example/pop3-list/pop3-list.c | 25 +++++++++++++++++++++++++ Library/Core.c | 11 ++++++++++- Makefile | 16 ++++++++-------- 5 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 Example/pop3-list/Makefile create mode 100644 Example/pop3-list/pop3-list.c diff --git a/Example/Makefile b/Example/Makefile index a9f42c5..4b219b4 100644 --- a/Example/Makefile +++ b/Example/Makefile @@ -1,9 +1,22 @@ # $Id$ -.PHONY: clean +.PHONY: clean examples install ./libw3.res: ./libw3.rc $(WINDRES) $< -O coff -o $@ +examples: + $(MAKE) -C ./fetch CC=$(CC) + $(MAKE) -C ./interactive CC=$(CC) + $(MAKE) -C ./pop3-list CC=$(CC) + +install: + $(MAKE) -C ./fetch CC=$(CC) PREFIX=$(PREFIX) install + $(MAKE) -C ./interactive CC=$(CC) PREFIX=$(PREFIX) install + $(MAKE) -C ./pop3-list CC=$(CC) PREFIX=$(PREFIX) install + clean: rm -f *.o *.so *.core *~ *.exe *.res + $(MAKE) -C ./fetch clean + $(MAKE) -C ./interactive clean + $(MAKE) -C ./pop3-list clean diff --git a/Example/pop3-list/Makefile b/Example/pop3-list/Makefile new file mode 100644 index 0000000..2b6a5df --- /dev/null +++ b/Example/pop3-list/Makefile @@ -0,0 +1,18 @@ +# $Id$ +.PHONY: clean install + +./pop3-list: ./pop3-list.o $(RESFILE) + $(CC) -g -o $@ -L ../../Library $^ -lw3 + +./%.o: ./%.c + $(CC) -g -c -o $@ -I ../../Library $< + +../libw3.res: + $(MAKE) -C .. ./libw3.res WINDRES=$(WINDRES) + +clean: + rm -f pop3-list *.o *.so *.core *~ *.exe *.res + +install: ./pop3-list + mkdir -p $(PREFIX)/bin + cp ./pop3-list $(PREFIX)/bin/w3-pop3-list diff --git a/Example/pop3-list/pop3-list.c b/Example/pop3-list/pop3-list.c new file mode 100644 index 0000000..d42d82d --- /dev/null +++ b/Example/pop3-list/pop3-list.c @@ -0,0 +1,25 @@ +/* + * $Id$ + * + * Lists the POP3 mails + */ + +#include +#include + +#include +#include /* It has some useful functions, you know */ + +#include +#include +#include +#include +#include +#include + +void list_handler(struct W3* w3, char* data, size_t size) { +} + +int main(int argc, char** argv) { + W3_Library_Init(); +} diff --git a/Library/Core.c b/Library/Core.c index 6e921fe..21f2d40 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -7,6 +7,7 @@ #include "W3File.h" #include "W3Gopher.h" #include "W3HTTP.h" +#include "W3POP3.h" #include #include @@ -70,8 +71,10 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port) { if(strcmp(protocol, "http") == 0) { #ifdef SSL_SUPPORT } else if(strcmp(protocol, "https") == 0) { + } else if(strcmp(protocol, "pop3s") == 0){ #endif } else if(strcmp(protocol, "gopher") == 0) { + } else if(strcmp(protocol, "pop3") == 0) { } else { __W3_Debug("Protocol", "Not suppported"); W3_Free(w3); @@ -109,12 +112,18 @@ void W3_Set_Path(struct W3* w3, const char* path) { void W3_Send_Request(struct W3* w3) { if(strcmp(w3->protocol, "http") == 0 #ifdef SSL_SUPPORT - || strcmp(w3->protocol, "https") == 0 + || strcmp(w3->protocol, "https") == 0 #endif ) { __W3_HTTP_Request(w3); } else if(strcmp(w3->protocol, "gopher") == 0) { __W3_Gopher_Request(w3); + } else if(strcmp(w3->protocol, "pop3") == 0 +#ifdef SSL_SUPPORT + || strcmp(w3->protocol, "pop3s") == 0 +#endif + ){ + __W3_POP3_Request(w3); } else if(strcmp(w3->protocol, "file") == 0) { __W3_File_Request(w3); } diff --git a/Makefile b/Makefile index 2925248..780d180 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ CFLAGS += -g -D__DEBUG__ endif ifeq ($(WINDOWS),YES) -.PHONY: all clean ./Library/w3.dll ./Example/fetch format +.PHONY: all clean ./Library/w3.dll ./Example format ALL := ./Library/w3.dll ./Example @@ -65,7 +65,7 @@ all: ./w3.pc ./Library/W3Version.h $(ALL) else -.PHONY: all clean ./Library/libw3.so ./Library/libw3.a ./Example/fetch format +.PHONY: all clean ./Library/libw3.so ./Library/libw3.a ./Example format ALL := ./Library/libw3.so ./Library/libw3.a ./Example @@ -78,8 +78,7 @@ all: ./w3.pc ./Library/W3Version.h $(ALL) $(MAKE) -C ./Library CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" ./libw3.a ./Example: ./Library/libw3.so - $(MAKE) -C ./Example/fetch CC=$(CC) - $(MAKE) -C ./Example/interactive CC=$(CC) + $(MAKE) -C ./Example CC=$(CC) examples ./Library/W3Version.h: m4 -DSUFFIX=\"\" ./W3Version.h.p > $@ @@ -102,17 +101,16 @@ clean: -rm ./w3.pc w3-*.zip w3-*.tar.gz w3-*.lzh ./Library/W3Version.h $(MAKE) -C ./Library clean $(MAKE) -C ./Example clean - $(MAKE) -C ./Example/fetch clean - $(MAKE) -C ./Example/interactive clean install: ./w3.pc - $(MAKE) -C ./Library install PREFIX=$(PREFIX) - $(MAKE) -C ./Example install PREFIX=$(PREFIX) + $(MAKE) -C ./Library install PREFIX=$(PREFIX) CC=$(CC) + $(MAKE) -C ./Example install PREFIX=$(PREFIX) CC=$(CC) mkdir -p $(PREFIX)/lib/pkgconfig cp ./w3.pc $(PREFIX)/lib/pkgconfig/ archive: all mkdir -p w3-$(VERSION)/Library + mkdir -p w3-$(VERSION)/Example/pop3-list mkdir -p w3-$(VERSION)/Example/interactive mkdir -p w3-$(VERSION)/Example/fetch cp -rf ./Library/*.h w3-$(VERSION)/Library/ @@ -121,10 +119,12 @@ ifdef WINDOWS cp ./Library/*.dll w3-$(VERSION)/Library/ cp ./Example/fetch/fetch.exe w3-$(VERSION)/Example/fetch/ cp ./Example/interactive/interactive.exe w3-$(VERSION)/Example/interactive/ + cp ./Example/pop3-list/pop3-list.exe w3-$(VERSION)/Example/pop3-list/ else cp ./Library/*.so w3-$(VERSION)/Library/ cp ./Example/fetch/fetch w3-$(VERSION)/Example/fetch/ cp ./Example/interactive/interactive w3-$(VERSION)/Example/interactive/ + cp ./Example/pop3-list/pop3-list w3-$(VERSION)/Example/pop3-list/ endif -mv w3-$(VERSION)/*.h w3-$(VERSION)/Library/ -mv w3-$(VERSION)/*.so w3-$(VERSION)/Library/ -- 2.43.0