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;
} 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) {
#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
#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");
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;
}
}
}
- }else if(!bcode){
+ } else if(!bcode) {
char* tmp = meta;
char* cbuf = malloc(2);
cbuf[0] = buf[i];
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];
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;
extern "C" {
#endif
-#define LIBW3_VERSION "2.6" \
+#define LIBW3_VERSION "2.7" \
SUFFIX
#ifdef __cplusplus