mirror of
https://git.sr.ht/~sircmpwn/gmni
synced 2024-11-23 00:42:15 +01:00
Print line feed on text/* response if not included
Adds -l flag to suppress this behavior
This commit is contained in:
parent
78eb57cad4
commit
4bc55aaa13
18
src/gmnic.c
18
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user