From: nishi Date: Sat, 27 Jan 2024 00:41:00 +0000 (+0000) Subject: gopher support X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0eee2dff54de56021353e85cf05f77e2dec33241;p=libw3.git gopher support git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@99 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Library/Gopher.c b/Library/Gopher.c index 3f64add..03dca5d 100644 --- a/Library/Gopher.c +++ b/Library/Gopher.c @@ -1,5 +1,25 @@ /* $Id$ */ #include "W3Gopher.h" +#include "W3Core.h" +#include "W3Util.h" + +#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){ + int len = __W3_Auto_Read(w3, buf, w3->readsize); + if(len <= 0) break; + void* funcptr = __W3_Get_Event(w3, "data"); + if(funcptr != NULL) { + void (*func)(struct W3*, char*, size_t) = (void (*)(struct W3*, char*, size_t))funcptr; + func(w3, buf, len); + } + } + free(buf); } diff --git a/Library/URL.c b/Library/URL.c index 21767d2..f7e62c9 100644 --- a/Library/URL.c +++ b/Library/URL.c @@ -58,7 +58,10 @@ 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) { + r->port = 70; } + } r->host = __W3_Strdup(url + start); str = malloc(strlen(r->host) + 64); diff --git a/W3Version.h.p b/W3Version.h.p index ead9e3e..b3e03fd 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "1.6A" \ +#define LIBW3_VERSION "1.6B" \ SUFFIX #ifdef __cplusplus