Re-added support for https (#33) - fiche - A pastebin adjusted for gopher use | |
git clone git://vernunftzentrum.de/fiche.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit cdd910b150a765a662bcb1a0d605ed0af42e311d | |
parent 1cba8ad493da3874fa0cc9735192398e77a99fb7 | |
Author: solusipse <[email protected]> | |
Date: Sun, 17 Sep 2017 14:34:44 +0200 | |
Re-added support for https (#33) | |
Diffstat: | |
fiche.c | 9 ++++++++- | |
fiche.h | 6 ++++++ | |
main.c | 7 +++++++ | |
3 files changed, 21 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/fiche.c b/fiche.c | |
@@ -201,6 +201,8 @@ void fiche_init(Fiche_Settings *settings) { | |
9999, | |
// slug length | |
4, | |
+ // https | |
+ false, | |
// buffer length | |
32768, | |
// user name | |
@@ -360,7 +362,12 @@ static void get_date(char *buf) { | |
static int set_domain_name(Fiche_Settings *settings) { | |
- const char *prefix = "http://"; | |
+ char *prefix = ""; | |
+ if (settings->https) { | |
+ prefix = "https://"; | |
+ } else { | |
+ prefix = "http://"; | |
+ } | |
const int len = strlen(settings->domain) + strlen(prefix) + 1; | |
char *b = malloc(len); | |
diff --git a/fiche.h b/fiche.h | |
@@ -24,6 +24,7 @@ $ cat fiche.c | nc localhost 9999 | |
#define FICHE_H | |
#include <stdint.h> | |
+#include <stdbool.h> | |
/** | |
@@ -53,6 +54,11 @@ typedef struct Fiche_Settings { | |
uint8_t slug_len; | |
/** | |
+ * @brief If set, returns url with https prefix instead of http | |
+ */ | |
+ bool https; | |
+ | |
+ /** | |
* @brief Connection buffer length | |
* | |
* @remarks Length of this buffer limits max size of uploaded files | |
diff --git a/main.c b/main.c | |
@@ -68,6 +68,13 @@ int main(int argc, char **argv) { | |
} | |
break; | |
+ // https | |
+ case 'S': | |
+ { | |
+ fs.https = true; | |
+ } | |
+ break; | |
+ | |
// output directory path | |
case 'o': | |
{ |