aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2020-11-11 10:29:36 +0000
committerGitHub <noreply@github.com>2020-11-11 10:29:36 +0000
commit3f165adb3d9a4caf7cc4c146cb712ec1db772e24 (patch)
treef8dac2150c376df8139399b0454d9124a2d03f87
parentUpdate ChangeLog (diff)
parentRemove useless loop (diff)
downloadw3m-3f165adb3d9a4caf7cc4c146cb712ec1db772e24.tar.gz
w3m-3f165adb3d9a4caf7cc4c146cb712ec1db772e24.zip
Merge pull request #154 from bptato/master
Support Gopher search and binary files
-rw-r--r--file.c44
-rw-r--r--proto.h1
-rw-r--r--url.c8
3 files changed, 53 insertions, 0 deletions
diff --git a/file.c b/file.c
index 358f20a..268e3f8 100644
--- a/file.c
+++ b/file.c
@@ -1974,6 +1974,16 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
t = "gopher:directory";
TRAP_OFF;
goto page_loaded;
+ case '7':
+ if(pu.query != NULL) {
+ page = loadGopherDir(&f, &pu, &charset);
+ t = "gopher:directory";
+ } else {
+ page = loadGopherSearch(&f, &pu, &charset);
+ t = "gopher:search";
+ }
+ TRAP_OFF;
+ goto page_loaded;
case 's':
t = "audio/basic";
break;
@@ -1983,6 +1993,9 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
case 'h':
t = "text/html";
break;
+ case '9':
+ do_download = 1;
+ break;
}
}
#endif /* USE_GOPHER */
@@ -7455,6 +7468,9 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
case '1':
p = "[directory]";
break;
+ case '7':
+ p = "[search]";
+ break;
case 'm':
p = "[message]";
break;
@@ -7470,6 +7486,9 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
case 'i':
link = 0;
break;
+ case '9':
+ p = "[binary]";
+ break;
default:
p = "[unsupported]";
break;
@@ -7502,6 +7521,31 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
Strcat_charp(tmp, "</table>\n</body>\n</html>\n");
return tmp;
}
+
+Str
+loadGopherSearch(URLFile *uf, ParsedURL *pu, wc_ces * charset)
+{
+ Str tmp;
+ char *volatile p, *volatile q;
+ MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
+ tmp = parsedURL2Str(pu);
+ p = html_quote(tmp->ptr);
+#ifdef USE_M17N
+ wc_ces doc_charset = DocumentCharset;
+ tmp =
+ convertLine(NULL, Strnew_charp(file_unquote(tmp->ptr)), RAW_MODE,
+ charset, doc_charset);
+#endif
+ q = html_quote(tmp->ptr);
+
+ tmp = Strnew_m_charp("<html>\n<head>\n<base href=\"", p, "\">\n<title>", q,
+ "</title>\n</head>\n<body>\n<h1>Search ", q,
+ "</h1>\n<form role=\"search\">\n<div>\n"
+ "<input type=\"search\" name=\"\">"
+ "</div>\n</form>\n</body>", NULL);
+
+ return tmp;
+}
#endif /* USE_GOPHER */
/*
diff --git a/proto.h b/proto.h
index b20538e..749a3c0 100644
--- a/proto.h
+++ b/proto.h
@@ -262,6 +262,7 @@ extern void loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src,
extern Buffer *loadHTMLString(Str page);
#ifdef USE_GOPHER
extern Str loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset);
+extern Str loadGopherSearch(URLFile *uf, ParsedURL *pu, wc_ces * charset);
#endif /* USE_GOPHER */
extern Buffer *loadBuffer(URLFile *uf, Buffer *newBuf);
#ifdef USE_IMAGE
diff --git a/url.c b/url.c
index ce0a53c..aef66ad 100644
--- a/url.c
+++ b/url.c
@@ -1853,6 +1853,8 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
case 's':
case 'g':
case 'h':
+ case '7':
+ case '9':
tmp = Strnew_charp(pu->file);
gophertmp = Strdup(tmp);
Strdelete(tmp, n, 1);
@@ -1865,6 +1867,12 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
} else {
type = '\0';
}
+ if(pu->query != NULL) {
+ tmp = Strnew_charp(pu->file);
+ Strcat_char(tmp, '\t');
+ Strcat_charp(tmp, pu->query);
+ pu->file = tmp->ptr;
+ }
if (non_null(GOPHER_proxy) &&
!Do_not_use_proxy &&
pu->host != NULL && !check_no_proxy(pu->host)) {