diff --git a/src/client.c b/src/client.c
index 86152d6183462636cca4eecbd47824569a688cb1..f1674d534a9a5f2edcb6c7be678e17ad5724a9a7 100644
--- a/src/client.c
+++ b/src/client.c
@@ -175,7 +175,7 @@ goto cleanup;
}
char *endptr;
if (*endptr != ' ' || resp->status < 10 || resp->status >= 70) {
res = GEMINI_ERR_PROTOCOL;
goto cleanup;
@@ -268,5 +268,5 @@
enum gemini_status_class
gemini_response_class(enum gemini_status status)
{
}
diff --git a/src/gmni.c b/src/gmni.c
index b4efdc0235dac0279ce284f2c6b19f680a191647..5b1f37522e93da360e74ba92ccb00c530bd41463 100644
--- a/src/gmni.c
+++ b/src/gmni.c
@@ -10,6 +10,7 @@ #include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
+#include <termios.h>
#include <unistd.h>
#include "gmni.h"
@@ -19,6 +20,41 @@ {
fprintf(stderr,
"usage: %s [-46lLiIN] [-E cert] [-d input] [-D path] gemini://...\n",
argv_0);
+}
+static char *
+get_input(const struct gemini_response *resp, FILE *source)
+{
fprintf(stderr, "%s: ", resp->meta);
if (resp->status == GEMINI_STATUS_SENSITIVE_INPUT) {
r = tcgetattr(fileno(source), &attrs);
struct termios new_attrs;
r = tcgetattr(fileno(source), &new_attrs);
if (r != -1) {
new_attrs.c_lflag &= ~ECHO;
tcsetattr(fileno(source), TCSANOW, &new_attrs);
}
}
fprintf(stderr, "Error reading input: %s\n",
feof(source) ? "EOF" :
strerror(ferror(source)));
return NULL;
attrs.c_lflag &= ~ECHO;
tcsetattr(fileno(source), TCSANOW, &attrs);
}
int
@@ -119,7 +155,6 @@ exit = true;
goto next;
}
char *new_url, *input = NULL;
switch (gemini_response_class(resp.status)) {
case GEMINI_STATUS_CLASS_INPUT:
if (input_mode == INPUT_SUPPRESS) {
@@ -127,27 +162,19 @@ exit = true;
break;
}
if (fileno(input_source) != -1 &&
isatty(fileno(input_source))) {
fprintf(stderr, "%s: ", resp.meta);
}
size_t s = 0;
ssize_t n = getline(&input, &s, input_source);
if (n == -1) {
fprintf(stderr, "Error reading input: %s\n",
feof(input_source) ? "EOF" :
strerror(ferror(input_source)));
char *input = get_input(&resp, input_source);
if (!input) {
r = 1;
exit = true;
break;
}
input[n - 1] = '\0'; // Drop LF
new_url = gemini_input_url(url, input);
char *new_url = gemini_input_url(url, input);
assert(new_url);
free(input);
free(url);
url = new_url;
assert(url);
goto next;
case GEMINI_STATUS_CLASS_REDIRECT:
free(url);
text/gemini
This content has been proxied by September (3851b).