]> Nishi Git Mirror - libw3.git/commitdiff
gopher support
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 00:41:00 +0000 (00:41 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 27 Jan 2024 00:41:00 +0000 (00:41 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@99 d27a3e52-49c5-7645-884c-6793ebffc270

Library/Gopher.c
Library/URL.c
W3Version.h.p

index 3f64add8db5b2c6063f91b5255d08c16b48242dc..03dca5db61ed1c66842c2eff330bff32e3e0ecb9 100644 (file)
@@ -1,5 +1,25 @@
 /* $Id$ */
 #include "W3Gopher.h"
 
+#include "W3Core.h"
+#include "W3Util.h"
+
+#include <string.h>
+#include <stdlib.h>
+
 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);
 }
index 21767d213de4c8dee0ac50dc25d273bcff92187e..f7e62c9b6b45529fc0ceb215ec38582239e6d3de 100644 (file)
@@ -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);
index ead9e3e9fc1b4a27828d9fc37f17421fb4ce4d2f..b3e03fdb107a9d762f70239aeba884d7c35ef89d 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "1.6A" \
+#define LIBW3_VERSION "1.6B" \
 SUFFIX
 
 #ifdef __cplusplus