gmni

a gemini line mode client
git clone https://git.clttr.info/gmni.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 4bc55aaa138171db365377db0624c3ce0d878257
parent 78eb57cad45aa27e83d3a5e78be0bb5ce4d631f7
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 20 Sep 2020 14:13:18 -0400

Print line feed on text/* response if not included

Adds -l flag to suppress this behavior

Diffstat:
Msrc/gmnic.c | 18++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/gmnic.c b/src/gmnic.c @@ -34,9 +34,10 @@ main(int argc, char *argv[]) }; enum input_mode input_mode = INPUT_READ; FILE *input_source = stdin; + bool linefeed = true; int c; - while ((c = getopt(argc, argv, "46C:d:D:hLiIN")) != -1) { + while ((c = getopt(argc, argv, "46C:d:D:hlLiIN")) != -1) { switch (c) { case '4': assert(0); // TODO @@ -67,6 +68,9 @@ main(int argc, char *argv[]) case 'h': usage(argv[0]); return 0; + case 'l': + linefeed = false; + break; case 'L': assert(0); // TODO: Follow redirects break; @@ -81,7 +85,7 @@ main(int argc, char *argv[]) input_mode = INPUT_SUPPRESS; break; default: - fprintf(stderr, "fatal: unknown flag %c", c); + fprintf(stderr, "fatal: unknown flag %c\n", c); return 1; } } @@ -167,8 +171,9 @@ main(int argc, char *argv[]) if (resp.status / 10 != 2) { break; } - for (int n = 1; n > 0;) { - char buf[BUFSIZ]; + char buf[BUFSIZ]; + int n; + for (n = 1; n > 0;) { n = BIO_read(resp.bio, buf, BUFSIZ); if (n == -1) { fprintf(stderr, "Error: read\n"); @@ -185,6 +190,11 @@ main(int argc, char *argv[]) w += x; } } + if (strncmp(resp.meta, "text/", 5) == 0 + && linefeed + && buf[n - 1] != '\n') { + printf("\n"); + } break; }