use dprintf and reorder so a fflush is not needed, saves some lines - gopherpro… | |
git clone git://git.codemadness.org/gopherproxy-c | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit a3dbec3aff240cf18792ac54e40d7ea04dae4d07 | |
parent 09feebbc6b6947493acdadf0afca1a61da517c40 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sun, 12 Aug 2018 19:27:16 +0200 | |
use dprintf and reorder so a fflush is not needed, saves some lines | |
+ minor cleanup | |
Diffstat: | |
M README | 2 +- | |
M gopherproxy.c | 13 +++++-------- | |
2 files changed, 6 insertions(+), 9 deletions(-) | |
--- | |
diff --git a/README b/README | |
@@ -3,7 +3,7 @@ gopherproxy | |
Build dependencies: | |
- C compiler. | |
-- libc | |
+- libc + some BSD extensions (dprintf). | |
- POSIX system. | |
- make (optional). | |
diff --git a/gopherproxy.c b/gopherproxy.c | |
@@ -502,19 +502,16 @@ main(void) | |
headerset = 1; | |
switch (_type) { | |
case '0': | |
- printf("Content-Type: text/plain; charset=utf-8\r\n\r\… | |
- fflush(stdout); | |
+ dprintf(1, "Content-Type: text/plain; charset=utf-8\r\… | |
servefile(u.host, u.port, path); | |
return 0; | |
case '1': | |
case '7': | |
break; /* handled below */ | |
case '9': | |
- printf("Content-Type: application/octet-stream\r\n"); | |
if ((p = strrchr(path, '/'))) | |
- printf("Content-Disposition: attachment; filen… | |
- printf("\r\n"); | |
- fflush(stdout); | |
+ dprintf(1, "Content-Disposition: attachment; f… | |
+ dprintf(1, "Content-Type: application/octet-stream\r\n… | |
servefile(u.host, u.port, path); | |
return 0; | |
default: | |
@@ -524,10 +521,10 @@ main(void) | |
} | |
} | |
- fputs("Content-Type: text/html; charset=utf-8\r\n\r\n", stdout); | |
headerset = 1; | |
- | |
fputs( | |
+ "Content-Type: text/html; charset=utf-8\r\n" | |
+ "\r\n" | |
"<!DOCTYPE html>\n" | |
"<html dir=\"ltr\">\n" | |
"<head>\n" |