diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-09-04 19:16:30 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-09-04 19:16:30 +0200 |
commit | 6842f8712508262d0ea27692f13caa686419601e (patch) | |
tree | 8c074ca18dc70c02392fc951f6e8e21db00d7cdb /sys/src/cmd/mothra/gopher.c | |
parent | f6e73a6a22db00925f2f447815287bf2a086054b (diff) |
add mothra
Diffstat (limited to 'sys/src/cmd/mothra/gopher.c')
-rw-r--r-- | sys/src/cmd/mothra/gopher.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/src/cmd/mothra/gopher.c b/sys/src/cmd/mothra/gopher.c new file mode 100644 index 000000000..2e231eae6 --- /dev/null +++ b/sys/src/cmd/mothra/gopher.c @@ -0,0 +1,38 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include <event.h> +#include <panel.h> +#include "mothra.h" +void httpheader(Url *, char *); +/* + * Given a url, return a file descriptor on which caller can + * read a gopher document. + */ +int gopher(Url *url){ + int pfd[2]; + char port[30]; + if(pipe(pfd)==-1) return -1; + switch(rfork(RFFDG|RFPROC|RFNOWAIT)){ + case -1: + close(pfd[0]); + close(pfd[1]); + return -1; + case 0: + dup(pfd[1], 1); + close(pfd[0]); + close(pfd[1]); + sprint(port, "%d", url->port); + execl("/bin/aux/gopher2html", + "gopher2html", url->ipaddr, port, url->reltext+1, 0); + fprint(2, "Can't exec aux/gopher2html!\n"); + print("<head><title>Mothra error</title></head>\n"); + print("<body><h1>Mothra error</h1>\n"); + print("Can't exec aux/gopher2html!</body>\n"); + exits("no exec"); + default: + close(pfd[1]); + url->type=HTML; + return pfd[0]; + } +} |