]> Nishi Git Mirror - libw3.git/commitdiff
gophers support
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Tue, 13 Feb 2024 02:27:37 +0000 (02:27 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Tue, 13 Feb 2024 02:27:37 +0000 (02:27 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@205 d27a3e52-49c5-7645-884c-6793ebffc270

Library/Core.c
Library/Gemini.c
Library/URL.c
W3Version.h.p

index 628b61520bcbc3ff09aae90ccef6bfc35ef06716..513c634da39766ea9edf79ac4661425f7012e532 100644 (file)
@@ -58,7 +58,9 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port) {
        bool ssl = false;
        if(strcmp(protocol, "https") == 0) {
                ssl = true;
-       }else if(strcmp(protocol, "gemini") == 0) {
+       } else if(strcmp(protocol, "gemini") == 0) {
+               ssl = true;
+       } else if(strcmp(protocol, "gophers") == 0) {
                ssl = true;
        }
        w3->props = NULL;
@@ -82,6 +84,7 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port) {
                } else if(strcmp(protocol, "https") == 0) {
                } else if(strcmp(protocol, "pop3s") == 0) {
                } else if(strcmp(protocol, "gemini") == 0) {
+               } else if(strcmp(protocol, "gophers") == 0) {
 #endif
                } else if(strcmp(protocol, "gopher") == 0) {
                } else if(strcmp(protocol, "pop3") == 0) {
@@ -134,7 +137,11 @@ void W3_Send_Request(struct W3* w3) {
 #endif
        ) {
                __W3_HTTP_Request(w3);
-       } else if(strcmp(w3->protocol, "gopher") == 0) {
+       } else if(strcmp(w3->protocol, "gopher") == 0
+#ifdef SSL_SUPPORT
+                 || strcmp(w3->protocol, "gophers") == 0
+#endif
+       ) {
                __W3_Gopher_Request(w3);
        } else if(strcmp(w3->protocol, "pop3") == 0
 #ifdef SSL_SUPPORT
index 9a96db5b1f12960080970323e05d834218c60cef..523d57465a844491c0a41b77eb21441a0048685d 100644 (file)
@@ -4,9 +4,9 @@
 #include "W3Util.h"
 
 #include <stdbool.h>
-#include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 void __W3_Gemini_Request(struct W3* w3) {
        __W3_Debug("LibW3-Gemini", "Sending the request");
@@ -29,20 +29,20 @@ void __W3_Gemini_Request(struct W3* w3) {
                int len = __W3_Auto_Read(w3, buf, w3->readsize);
                if(len <= 0) break;
                int i = 0;
-               if(status){
-                       for(i = 0; i < len; i++){
-                               if(buf[i] == '\n'){
+               if(status) {
+                       for(i = 0; i < len; i++) {
+                               if(buf[i] == '\n') {
                                        status = false;
                                        break;
-                               }else if(buf[i] == '\r'){
-                                       if(!bcode){
-                                               if(atoi(code) == 20){
+                               } else if(buf[i] == '\r') {
+                                       if(!bcode) {
+                                               if(atoi(code) == 20) {
                                                        void* funcptr = __W3_Get_Event(w3, "header");
                                                        if(funcptr != NULL) {
                                                                void (*func)(struct W3*, char*, char*) = (void (*)(struct W3*, char*, char*))funcptr;
                                                                func(w3, "Content-Type", meta);
                                                        }
-                                               }else if(atoi(code) >= 30 && atoi(code) < 40){
+                                               } else if(atoi(code) >= 30 && atoi(code) < 40) {
                                                        void* funcptr = __W3_Get_Event(w3, "header");
                                                        if(funcptr != NULL) {
                                                                void (*func)(struct W3*, char*, char*) = (void (*)(struct W3*, char*, char*))funcptr;
@@ -50,7 +50,7 @@ void __W3_Gemini_Request(struct W3* w3) {
                                                        }
                                                }
                                        }
-                               }else if(!bcode){
+                               } else if(!bcode) {
                                        char* tmp = meta;
                                        char* cbuf = malloc(2);
                                        cbuf[0] = buf[i];
@@ -58,15 +58,15 @@ void __W3_Gemini_Request(struct W3* w3) {
                                        meta = __W3_Concat(tmp, cbuf);
                                        free(tmp);
                                        free(cbuf);
-                               }else if(bcode){
-                                       if(buf[i] == ' '){
+                               } else if(bcode) {
+                                       if(buf[i] == ' ') {
                                                bcode = false;
                                                void* funcptr = __W3_Get_Event(w3, "status");
                                                if(funcptr != NULL) {
                                                        void (*func)(struct W3*, int) = (void (*)(struct W3*, int))funcptr;
                                                        func(w3, atoi(code));
                                                }
-                                       }else{
+                                       } else {
                                                char* tmp = code;
                                                char* cbuf = malloc(2);
                                                cbuf[0] = buf[i];
index a3f8ec656b5f666c675092cd13ff890abbcd22a4..459b1aa341c80b533da4d190bc2124915220125c 100644 (file)
@@ -58,7 +58,7 @@ 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 || strcmp(r->protocol, "gophers") == 0) {
                                        r->port = 70;
                                } else if(strcmp(r->protocol, "gemini") == 0) {
                                        r->port = 1965;
index 723af1d1190721c5239343f6e9d7748953dca6d6..e235c3ce474d3bfff680eeb7aeecfe751e677692 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "2.6" \
+#define LIBW3_VERSION "2.7" \
 SUFFIX
 
 #ifdef __cplusplus