commit - 714541bb1ec600ba5ca24c8d243fa0941022c0b0
commit + 1c690d0a1f96f2f2dfd18549d98cef5952bf1584
blob - f306afe0be611e79be075c677169b2d50d181fdc
blob + 84089d22a40adcf6b8c5da2cc1fbd03dcc39e56d
--- telescope.c
+++ telescope.c
static void handle_imsg_update_cert_ok(struct imsg *, size_t);
static void handle_dispatch_imsg(int, short, void*);
static void load_page_from_str(struct tab*, const char*);
-static void load_about_url(struct tab*, const char*);
-static void load_finger_url(struct tab *, const char *);
-static void load_gemini_url(struct tab*, const char*);
-static void load_gopher_url(struct tab *, const char *);
-static void load_via_proxy(struct tab *, const char *,
+static int load_about_url(struct tab*, const char*);
+static int load_finger_url(struct tab *, const char *);
+static int load_gemini_url(struct tab*, const char*);
+static int load_gopher_url(struct tab *, const char *);
+static int load_via_proxy(struct tab *, const char *,
struct proxy *);
-static void make_request(struct tab *, struct get_req *, int,
+static int make_request(struct tab *, struct get_req *, int,
const char *);
static int do_load_url(struct tab*, const char *, const char *);
static void parse_session_line(char *, const char **, uint32_t *);
static struct proto {
const char *schema;
const char *port;
- void (*loadfn)(struct tab*, const char*);
+ int (*loadfn)(struct tab*, const char*);
} protos[] = {
{"about", NULL, load_about_url},
{"finger", "79", load_finger_url},
ui_on_tab_loaded(tab);
}
-static void
+static int
load_about_url(struct tab *tab, const char *url)
{
tab->trust = TS_VERIFIED;
ui_send_fs(IMSG_GET, tab->id,
tab->hist_cur->h, strlen(tab->hist_cur->h)+1);
+
+ return 1;
}
-static void
+static int
load_finger_url(struct tab *tab, const char *url)
{
struct get_req req;
strlcat(req.req, "\r\n", sizeof(req.req));
parser_init(tab, textplain_initparser);
- make_request(tab, &req, PROTO_FINGER, NULL);
+ return make_request(tab, &req, PROTO_FINGER, NULL);
}
-static void
+static int
load_gemini_url(struct tab *tab, const char *url)
{
struct get_req req;
strlcpy(req.host, tab->uri.host, sizeof(req.host));
strlcpy(req.port, tab->uri.port, sizeof(req.host));
- make_request(tab, &req, PROTO_GEMINI, tab->hist_cur->h);
+ return make_request(tab, &req, PROTO_GEMINI, tab->hist_cur->h);
}
-static void
+static int
load_gopher_url(struct tab *tab, const char *url)
{
struct get_req req;
parser_init(tab, textplain_initparser);
path += 2;
} else {
- return;
+ return 0;
}
- make_request(tab, &req, PROTO_GOPHER, path);
+ return make_request(tab, &req, PROTO_GOPHER, path);
}
-static void
+static int
load_via_proxy(struct tab *tab, const char *url, struct proxy *p)
{
struct get_req req;
tab->proxy = p;
- make_request(tab, &req, p->proto, tab->hist_cur->h);
+ return make_request(tab, &req, p->proto, tab->hist_cur->h);
}
-static void
+static int
make_request(struct tab *tab, struct get_req *req, int proto, const char *r)
{
stop_tab(tab);
}
ui_send_net(IMSG_GET_RAW, tab->id, req, sizeof(*req));
+
+ /*
+ * So the various load_*_url can `return make_request` and
+ * do_load_url is happy.
+ */
+ return 1;
}
/*
strlcpy(tab->uri.port, p->port,
sizeof(tab->uri.port));
- p->loadfn(tab, url);
- return 1;
+ return p->loadfn(tab, url);
}
}
TAILQ_FOREACH(proxy, &proxies, proxies) {
- if (!strcmp(tab->uri.scheme, proxy->match_proto)) {
- load_via_proxy(tab, url, proxy);
- return 1;
- }
+ if (!strcmp(tab->uri.scheme, proxy->match_proto))
+ return load_via_proxy(tab, url, proxy);
}
load_page_from_str(tab, err_pages[UNKNOWN_PROTOCOL]);