From f72cc74e8b8b590ad4b2a5aa4dd68be0362a8597 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 27 Jan 2024 00:53:00 +0000 Subject: [PATCH] pop3 support git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@100 d27a3e52-49c5-7645-884c-6793ebffc270 --- Library/Core.c | 8 ++++---- Library/DNS.c | 2 +- Library/Gopher.c | 6 +++--- Library/Makefile | 2 +- Library/POP3.c | 10 ++++++++++ Library/URL.c | 3 +-- Library/W3POP3.h | 17 +++++++++++++++++ 7 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 Library/POP3.c create mode 100644 Library/W3POP3.h diff --git a/Library/Core.c b/Library/Core.c index 2dfac35..6e921fe 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -5,8 +5,8 @@ #include "W3Util.h" #include "W3File.h" -#include "W3HTTP.h" #include "W3Gopher.h" +#include "W3HTTP.h" #include #include @@ -71,7 +71,7 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port) { #ifdef SSL_SUPPORT } else if(strcmp(protocol, "https") == 0) { #endif - }else if(strcmp(protocol, "gopher") == 0){ + } else if(strcmp(protocol, "gopher") == 0) { } else { __W3_Debug("Protocol", "Not suppported"); W3_Free(w3); @@ -109,11 +109,11 @@ 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){ + } else if(strcmp(w3->protocol, "gopher") == 0) { __W3_Gopher_Request(w3); } else if(strcmp(w3->protocol, "file") == 0) { __W3_File_Request(w3); diff --git a/Library/DNS.c b/Library/DNS.c index c04a5e2..4efabfb 100644 --- a/Library/DNS.c +++ b/Library/DNS.c @@ -7,8 +7,8 @@ #include #ifdef __MINGW32__ -#include #include +#include #include #else #include diff --git a/Library/Gopher.c b/Library/Gopher.c index 03dca5d..d9746c3 100644 --- a/Library/Gopher.c +++ b/Library/Gopher.c @@ -4,15 +4,15 @@ #include "W3Core.h" #include "W3Util.h" -#include #include +#include void __W3_Gopher_Request(struct W3* w3) { __W3_Debug("LibW3-Gopher", "Sending the request"); __W3_Auto_Write(w3, w3->path, strlen(w3->path)); __W3_Auto_Write(w3, "\r\n", 2); char* buf = malloc(w3->readsize); - while(true){ + while(true) { int len = __W3_Auto_Read(w3, buf, w3->readsize); if(len <= 0) break; void* funcptr = __W3_Get_Event(w3, "data"); @@ -20,6 +20,6 @@ void __W3_Gopher_Request(struct W3* w3) { void (*func)(struct W3*, char*, size_t) = (void (*)(struct W3*, char*, size_t))funcptr; func(w3, buf, len); } - } + } free(buf); } diff --git a/Library/Makefile b/Library/Makefile index d9977e5..19b112b 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -1,7 +1,7 @@ # $Id$ .PHONY: clean install -OBJS = ./Core.o ./Util.o ./DNS.o ./HTTP.o ./Gopher.o ./File.o ./URL.o +OBJS = ./Core.o ./Util.o ./DNS.o ./HTTP.o ./Gopher.o ./POP3.o ./File.o ./URL.o ifeq ($(WINDOWS),YES) ./w3.dll: $(OBJS) diff --git a/Library/POP3.c b/Library/POP3.c new file mode 100644 index 0000000..8891e11 --- /dev/null +++ b/Library/POP3.c @@ -0,0 +1,10 @@ +/* $Id$ */ +#include "W3POP3.h" + +#include "W3Core.h" +#include "W3Util.h" + +#include +#include + +void __W3_POP3_Request(struct W3* w3) {} diff --git a/Library/URL.c b/Library/URL.c index f7e62c9..59ebdc9 100644 --- a/Library/URL.c +++ b/Library/URL.c @@ -58,10 +58,9 @@ struct W3URL* W3_Parse_URL(const char* _url) { r->port = 80; } else if(strcmp(r->protocol, "https") == 0) { r->port = 443; - }else if(strcmp(r->protocol, "gopher") == 0) { + } else if(strcmp(r->protocol, "gopher") == 0) { r->port = 70; } - } r->host = __W3_Strdup(url + start); str = malloc(strlen(r->host) + 64); diff --git a/Library/W3POP3.h b/Library/W3POP3.h new file mode 100644 index 0000000..56acb79 --- /dev/null +++ b/Library/W3POP3.h @@ -0,0 +1,17 @@ +/* $Id$ */ +#ifndef __W3POP3_H__ +#define __W3POP3_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "W3Core.h" + +void __W3_POP3_Request(struct W3* w3); + +#ifdef __cplusplus +} +#endif + +#endif -- 2.43.0