Introduction
Introduction Statistics Contact Development Disclaimer Help
support + type, thanks pazz0 for the patch - gopherproxy-c - Gopher HTTP proxy …
git clone git://git.codemadness.org/gopherproxy-c
Log
Files
Refs
README
LICENSE
---
commit 46a7c58d416fe82d8b2d8aed37f9168574e33e46
parent f4621b7ad329dfb9e68e7ee2527dacd73c8aac33
Author: Hiltjo Posthuma <[email protected]>
Date: Wed, 15 May 2019 19:20:27 +0200
support + type, thanks pazz0 for the patch
This supports multiple mirror types. It uses the last non-+ type as described
in the RFC. If a + type is specified without a previous type then it is an
error. Also allow the + type with 'h', because "why not".
Diffstat:
M gopherproxy.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/gopherproxy.c b/gopherproxy.c
@@ -211,7 +211,7 @@ servedir(const char *server, const char *port, const char *…
{
struct visited v;
FILE *fp;
- char line[1024], uri[1024];
+ char line[1024], uri[1024], primarytype;
size_t totalsiz, linenr;
ssize_t n;
int fd, r, i, len;
@@ -232,6 +232,7 @@ servedir(const char *server, const char *port, const char *…
die(500, "fdopen: %s\n", strerror(errno));
totalsiz = 0;
+ primarytype = '\0';
for (linenr = 1; fgets(line, sizeof(line), fp); linenr++) {
n = strcspn(line, "\n");
if (line[n] != '\n')
@@ -254,6 +255,11 @@ servedir(const char *server, const char *port, const char …
memset(&v, 0, sizeof(v));
v._type = line[0];
+ if (v._type != '+')
+ primarytype = v._type;
+ else if (!primarytype)
+ die(500, "%s:%s %s:%d: undefined primary server\n",
+ server, port, path, linenr);
/* "username" */
i = 1;
@@ -313,12 +319,12 @@ servedir(const char *server, const char *port, const char…
if (!strcmp(v.port, "70"))
snprintf(uri, sizeof(uri), "%s/%c%s",
- v.server, v._type, v.path);
+ v.server, primarytype, v.path);
else
snprintf(uri, sizeof(uri), "%s:%s/%c%s",
- v.server, v.port, v._type, v.path);
+ v.server, v.port, primarytype, v.path);
- switch (v._type) {
+ switch (primarytype) {
case 'i': /* info */
case '3': /* error */
fputs(typestr(v._type), stdout);
@@ -339,7 +345,7 @@ servedir(const char *server, const char *port, const char *…
case '8': /* telnet */
case 'T': /* tn3270 */
fputs(typestr(v._type), stdout);
- printf(" <a href=\"%s://", v._type == '8' ? "telnet" :…
+ printf(" <a href=\"%s://", primarytype == '8' ? "telne…
if (v.path[0]) {
xmlencode(v.path);
fputs("@", stdout);
@@ -354,7 +360,7 @@ servedir(const char *server, const char *port, const char *…
default: /* other */
fputs(typestr(v._type), stdout);
fputs(" <a href=\"", stdout);
- if (v._type == 'h' && !strncmp(v.path, "URL:", sizeof(…
+ if (primarytype == 'h' && !strncmp(v.path, "URL:", siz…
xmlencode(v.path + sizeof("URL:") - 1);
} else {
fputs("?q=", stdout);
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.