2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/socket.h>
31 #include "minibuffer.h"
33 #include "telescope.h"
36 static struct option longopts[] = {
37 {"colors", no_argument, NULL, 'c'},
38 {"help", no_argument, NULL, 'h'},
39 {"version", no_argument, NULL, 'v'},
43 static const char *opts = "Cc:hnT:v";
45 static struct imsgev *iev_fs, *iev_net;
47 struct tabshead tabshead = TAILQ_HEAD_INITIALIZER(tabshead);
48 struct proxylist proxies = TAILQ_HEAD_INITIALIZER(proxies);
50 enum telescope_process {
56 /* the first is also the fallback one */
57 static struct proto protos[] = {
58 { "gemini", load_gemini_url },
59 { "about", load_about_url },
64 #define CANNOT_FETCH 0
65 #define TOO_MUCH_REDIRECTS 1
66 #define MALFORMED_RESPONSE 2
67 #define UNKNOWN_TYPE_OR_CSET 3
68 #define UNKNOWN_PROTOCOL 4
70 /* XXX: keep in sync with telescope.c:/^normalize_code/ */
71 const char *err_pages[70] = {
72 [CANNOT_FETCH] = "# Couldn't load the page\n",
73 [TOO_MUCH_REDIRECTS] = "# Too much redirects\n",
74 [MALFORMED_RESPONSE] = "# Got a malformed response\n",
75 [UNKNOWN_TYPE_OR_CSET] = "# Unsupported type or charset\n",
76 [UNKNOWN_PROTOCOL] = "# Unknown protocol\n",
78 [10] = "# Input required\n",
79 [11] = "# Input required\n",
80 [40] = "# Temporary failure\n",
81 [41] = "# Server unavailable\n",
82 [42] = "# CGI error\n",
83 [43] = "# Proxy error\n",
84 [44] = "# Slow down\n",
85 [50] = "# Permanent failure\n",
86 [51] = "# Not found\n",
88 [53] = "# Proxy request refused\n",
89 [59] = "# Bad request\n",
90 [60] = "# Client certificate required\n",
91 [61] = "# Certificate not authorised\n",
92 [62] = "# Certificate not valid\n"
95 static void die(void) __attribute__((__noreturn__));
96 static struct tab *tab_by_id(uint32_t);
97 static void handle_imsg_err(struct imsg*, size_t);
98 static void handle_imsg_check_cert(struct imsg*, size_t);
99 static void handle_check_cert_user_choice(int, struct tab *);
100 static void handle_maybe_save_new_cert(int, struct tab *);
101 static void handle_imsg_got_code(struct imsg*, size_t);
102 static void handle_imsg_got_meta(struct imsg*, size_t);
103 static void handle_maybe_save_page(int, struct tab *);
104 static void handle_save_page_path(const char *, struct tab *);
105 static void handle_imsg_file_opened(struct imsg*, size_t);
106 static void handle_imsg_buf(struct imsg*, size_t);
107 static void handle_imsg_eof(struct imsg*, size_t);
108 static void handle_imsg_bookmark_ok(struct imsg*, size_t);
109 static void handle_imsg_save_cert_ok(struct imsg*, size_t);
110 static void handle_imsg_update_cert_ok(struct imsg *, size_t);
111 static void handle_dispatch_imsg(int, short, void*);
112 static void load_page_from_str(struct tab*, const char*);
113 static int do_load_url(struct tab*, const char *, const char *);
114 static void parse_session_line(char *, const char **, uint32_t *);
115 static void load_last_session(void);
116 static pid_t start_child(enum telescope_process, const char *, int);
117 static int ui_send_net(int, uint32_t, const void *, uint16_t);
118 static int ui_send_fs(int, uint32_t, const void *, uint16_t);
120 static imsg_handlerfn *handlers[] = {
121 [IMSG_ERR] = handle_imsg_err,
122 [IMSG_CHECK_CERT] = handle_imsg_check_cert,
123 [IMSG_GOT_CODE] = handle_imsg_got_code,
124 [IMSG_GOT_META] = handle_imsg_got_meta,
125 [IMSG_BUF] = handle_imsg_buf,
126 [IMSG_EOF] = handle_imsg_eof,
127 [IMSG_BOOKMARK_OK] = handle_imsg_bookmark_ok,
128 [IMSG_SAVE_CERT_OK] = handle_imsg_save_cert_ok,
129 [IMSG_UPDATE_CERT_OK] = handle_imsg_update_cert_ok,
130 [IMSG_FILE_OPENED] = handle_imsg_file_opened,
133 static struct ohash certs;
135 static void __attribute__((__noreturn__))
142 tab_by_id(uint32_t id)
146 TAILQ_FOREACH(t, &tabshead, tabs) {
155 handle_imsg_err(struct imsg *imsg, size_t datalen)
160 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
164 page[datalen-1] = '\0';
166 if (asprintf(&page, "# Error loading %s\n\n> %s\n",
167 tab->hist_cur->h, page) == -1)
169 load_page_from_str(tab, page);
174 handle_imsg_check_cert(struct imsg *imsg, size_t datalen)
176 const char *hash, *host, *port;
178 struct tofu_entry *e;
182 if (hash[datalen-1] != '\0')
185 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
188 if (tab->proxy != NULL) {
189 host = tab->proxy->host;
190 port = tab->proxy->port;
192 host = tab->uri.host;
193 port = tab->uri.port;
196 if ((e = tofu_lookup(&certs, host, port)) == NULL) {
197 /* TODO: an update in libressl/libretls changed
198 * significantly. Find a better approach at storing
200 if (datalen > sizeof(e->hash))
203 tofu_res = 1; /* trust on first use */
204 if ((e = calloc(1, sizeof(*e))) == NULL)
206 strlcpy(e->domain, host, sizeof(e->domain));
207 if (*port != '\0' && strcmp(port, "1965")) {
208 strlcat(e->domain, ":", sizeof(e->domain));
209 strlcat(e->domain, port, sizeof(e->domain));
211 strlcpy(e->hash, hash, sizeof(e->hash));
213 ui_send_fs(IMSG_SAVE_CERT, tab->id, e, sizeof(*e));
215 tofu_res = !strcmp(hash, e->hash);
218 if (e->verified == -1)
219 tab->trust = TS_TEMP_TRUSTED;
220 else if (e->verified == 1)
221 tab->trust = TS_VERIFIED;
223 tab->trust = TS_TRUSTED;
225 ui_send_net(IMSG_CERT_STATUS, imsg->hdr.peerid,
226 &tofu_res, sizeof(tofu_res));
228 tab->trust = TS_UNTRUSTED;
229 load_page_from_str(tab, "# Certificate mismatch\n");
230 if ((tab->cert = strdup(hash)) == NULL)
232 ui_yornp("Certificate mismatch. Proceed?",
233 handle_check_cert_user_choice, tab);
238 handle_check_cert_user_choice(int accept, struct tab *tab)
240 ui_send_net(IMSG_CERT_STATUS, tab->id, &accept,
245 * trust the certificate for this session only. If
246 * the page results in a redirect while we're asking
247 * the user to save, we'll end up with an invalid
248 * tabid (one request == one tab id) and crash. It
249 * also makes sense to save it for the current session
250 * if the user accepted it.
252 tofu_temp_trust(&certs, tab->uri.host, tab->uri.port, tab->cert);
254 ui_yornp("Save the new certificate?",
255 handle_maybe_save_new_cert, tab);
263 handle_maybe_save_new_cert(int accept, struct tab *tab)
265 struct tofu_entry *e;
266 const char *host, *port;
268 if (tab->proxy != NULL) {
269 host = tab->proxy->host;
270 port = tab->proxy->port;
272 host = tab->uri.host;
273 port = tab->uri.port;
279 if ((e = calloc(1, sizeof(*e))) == NULL)
282 strlcpy(e->domain, host, sizeof(e->domain));
283 if (*port != '\0' && strcmp(port, "1965")) {
284 strlcat(e->domain, ":", sizeof(e->domain));
285 strlcat(e->domain, port, sizeof(e->domain));
287 strlcpy(e->hash, tab->cert, sizeof(e->hash));
288 ui_send_fs(IMSG_UPDATE_CERT, 0, e, sizeof(*e));
290 tofu_update(&certs, e);
292 tab->trust = TS_TRUSTED;
300 normalize_code(int n)
303 if (n == 10 || n == 11)
309 if (n == 30 || n == 31)
317 if (n <= 53 || n == 59)
325 return MALFORMED_RESPONSE;
329 handle_imsg_got_code(struct imsg *imsg, size_t datalen)
333 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
336 if (sizeof(tab->code) != datalen)
339 memcpy(&tab->code, imsg->data, sizeof(tab->code));
340 tab->code = normalize_code(tab->code);
341 if (tab->code != 30 && tab->code != 31)
342 tab->redirect_count = 0;
346 handle_imsg_got_meta(struct imsg *imsg, size_t datalen)
350 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
353 if (sizeof(tab->meta) <= datalen)
356 memcpy(tab->meta, imsg->data, datalen);
358 if (tab->code < 10) { /* internal errors */
359 load_page_from_str(tab, err_pages[tab->code]);
360 } else if (tab->code < 20) { /* 1x */
361 load_page_from_str(tab, err_pages[tab->code]);
362 ui_require_input(tab, tab->code == 11);
363 } else if (tab->code == 20) {
364 if (setup_parser_for(tab)) {
365 ui_send_net(IMSG_PROCEED, tab->id, NULL, 0);
367 load_page_from_str(tab, err_pages[UNKNOWN_TYPE_OR_CSET]);
368 ui_yornp("Can't display page, wanna save?",
369 handle_maybe_save_page, tab);
371 } else if (tab->code < 40) { /* 3x */
372 tab->redirect_count++;
374 /* TODO: make customizable? */
375 if (tab->redirect_count > 5) {
376 load_page_from_str(tab,
377 err_pages[TOO_MUCH_REDIRECTS]);
379 do_load_url(tab, tab->meta, NULL);
380 } else { /* 4x, 5x & 6x */
381 load_page_from_str(tab, err_pages[tab->code]);
386 handle_maybe_save_page(int dosave, struct tab *tab)
389 ui_read("Save to path", handle_save_page_path, tab);
395 handle_save_page_path(const char *path, struct tab *tab)
402 tab->path = strdup(path);
404 ui_send_fs(IMSG_FILE_OPEN, tab->id, path, strlen(path)+1);
408 handle_imsg_file_opened(struct imsg *imsg, size_t datalen)
415 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL) {
421 if (imsg->fd == -1) {
425 if (e[datalen-1] != '\0')
427 l = asprintf(&page, "# Can't open file\n\n> %s: %s\n",
431 load_page_from_str(tab, page);
435 ui_send_net(IMSG_PROCEED, tab->id, NULL, 0);
440 handle_imsg_buf(struct imsg *imsg, size_t datalen)
444 char *page, buf[FMT_SCALED_STRSIZE] = {0};
446 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
449 tab->bytes += datalen;
451 if (!tab->buffer.page.parse(&tab->buffer.page,
452 imsg->data, datalen))
455 write(tab->fd, imsg->data, datalen);
456 fmt_scaled(tab->bytes, buf);
457 l = asprintf(&page, "Saving to \"%s\"... (%s)\n",
462 load_page_from_str(tab, page);
466 ui_on_tab_refresh(tab);
470 handle_imsg_eof(struct imsg *imsg, size_t datalen)
474 char *page, buf[FMT_SCALED_STRSIZE] = {0};
476 if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
480 if (!tab->buffer.page.free(&tab->buffer.page))
483 fmt_scaled(tab->bytes, buf);
484 l = asprintf(&page, "Saved to \"%s\" (%s)\n",
489 load_page_from_str(tab, page);
498 ui_on_tab_refresh(tab);
499 ui_on_tab_loaded(tab);
503 handle_imsg_bookmark_ok(struct imsg *imsg, size_t datalen)
507 if (datalen != sizeof(res))
510 memcpy(&res, imsg->data, sizeof(res));
512 message("Added to bookmarks!");
514 message("Failed to add to bookmarks: %s",
519 handle_imsg_save_cert_ok(struct imsg *imsg, size_t datalen)
523 if (datalen != sizeof(res))
525 memcpy(&res, imsg->data, datalen);
527 message("Failed to save the cert for: %s",
532 handle_imsg_update_cert_ok(struct imsg *imsg, size_t datalen)
536 if (datalen != sizeof(res))
538 memcpy(&res, imsg->data, datalen);
540 message("Failed to update the certificate");
544 handle_dispatch_imsg(int fd, short ev, void *d)
546 struct imsgev *iev = d;
548 if (dispatch_imsg(iev, ev, handlers, sizeof(handlers)) == -1)
549 err(1, "connection closed");
553 load_page_from_str(struct tab *tab, const char *page)
555 erase_buffer(&tab->buffer);
556 gemtext_initparser(&tab->buffer.page);
557 if (!tab->buffer.page.parse(&tab->buffer.page, page, strlen(page)))
559 if (!tab->buffer.page.free(&tab->buffer.page))
561 ui_on_tab_refresh(tab);
562 ui_on_tab_loaded(tab);
566 load_about_url(struct tab *tab, const char *url)
568 tab->trust = TS_VERIFIED;
570 gemtext_initparser(&tab->buffer.page);
572 ui_send_fs(IMSG_GET, tab->id,
573 tab->hist_cur->h, strlen(tab->hist_cur->h)+1);
577 load_gemini_url(struct tab *tab, const char *url)
582 tab->id = tab_new_id();
584 memset(&req, 0, sizeof(req));
585 strlcpy(req.host, tab->uri.host, sizeof(req.host));
586 strlcpy(req.port, tab->uri.port, sizeof(req.host));
588 strlcpy(req.req, tab->hist_cur->h, sizeof(req.req));
589 strlcat(req.req, "\r\n", sizeof(req.req));
591 req.proto = PROTO_GEMINI;
593 ui_send_net(IMSG_GET_RAW, tab->id,
598 load_via_proxy(struct tab *tab, const char *url, struct proxy *p)
603 tab->id = tab_new_id();
606 memset(&req, 0, sizeof(req));
607 strlcpy(req.host, p->host, sizeof(req.host));
608 strlcpy(req.port, p->port, sizeof(req.host));
610 strlcpy(req.req, tab->hist_cur->h, sizeof(req.req));
611 strlcat(req.req, "\r\n", sizeof(req.req));
613 req.proto = p->proto;
615 ui_send_net(IMSG_GET_RAW, tab->id,
620 * Effectively load the given url in the given tab. Return 1 when
621 * loading the page asynchronously, and thus when an erase_buffer can
622 * be done right after this function return, or 0 when loading the
623 * page synchronously. In this last case, erase_buffer *MUST* be
624 * called by the handling function (such as load_page_from_str).
627 do_load_url(struct tab *tab, const char *url, const char *base)
643 tab->trust = TS_UNKNOWN;
646 memcpy(&uri, &tab->uri, sizeof(tab->uri));
648 phos_parse_absolute_uri(base, &uri);
650 if (!phos_resolve_uri_from_str(&uri, url, &tab->uri)) {
651 if (asprintf(&t, "#error loading %s\n>%s\n",
652 url, "Can't parse the URI") == -1)
654 strlcpy(tab->hist_cur->h, url, sizeof(tab->hist_cur->h));
655 load_page_from_str(tab, t);
660 phos_serialize_uri(&tab->uri, tab->hist_cur->h,
661 sizeof(tab->hist_cur->h));
663 for (p = protos; p->schema != NULL; ++p) {
664 if (!strcmp(tab->uri.scheme, p->schema)) {
670 TAILQ_FOREACH(proxy, &proxies, proxies) {
671 if (!strcmp(tab->uri.scheme, proxy->match_proto)) {
672 load_via_proxy(tab, url, proxy);
677 load_page_from_str(tab, err_pages[UNKNOWN_PROTOCOL]);
682 * Load url in tab. If tab is marked as lazy, only prepare the url
683 * but don't load it. If tab is lazy and a url was already prepared,
687 load_url(struct tab *tab, const char *url, const char *base)
691 lazy = tab->flags & TAB_LAZY;
693 if (lazy && tab->hist_cur != NULL) {
695 tab->flags &= ~TAB_LAZY;
698 if (!lazy || tab->hist_cur == NULL) {
699 if (tab->hist_cur != NULL)
700 hist_clear_forward(&tab->hist,
701 TAILQ_NEXT(tab->hist_cur, entries));
703 if ((tab->hist_cur = calloc(1, sizeof(*tab->hist_cur))) == NULL) {
708 strlcpy(tab->buffer.page.title, url,
709 sizeof(tab->buffer.page.title));
710 hist_push(&tab->hist, tab->hist_cur);
713 strlcpy(tab->hist_cur->h, url,
714 sizeof(tab->hist_cur->h));
717 if (!lazy && do_load_url(tab, url, base))
718 erase_buffer(&tab->buffer);
722 load_previous_page(struct tab *tab)
726 if ((h = TAILQ_PREV(tab->hist_cur, mhisthead, entries)) == NULL)
729 do_load_url(tab, h->h, NULL);
734 load_next_page(struct tab *tab)
738 if ((h = TAILQ_NEXT(tab->hist_cur, entries)) == NULL)
741 do_load_url(tab, h->h, NULL);
746 * Free every resource linked to the tab, including the tab itself.
747 * Removes the tab from the tablist, but doesn't update the
748 * current_tab though.
751 free_tab(struct tab *tab)
755 if (evtimer_pending(&tab->loadingev, NULL))
756 evtimer_del(&tab->loadingev);
758 TAILQ_REMOVE(&tabshead, tab, tabs);
763 stop_tab(struct tab *tab)
765 ui_send_net(IMSG_STOP, tab->id, NULL, 0);
772 load_page_from_str(tab, "Stopped.\n");
777 add_to_bookmarks(const char *str)
779 ui_send_fs(IMSG_BOOKMARK_PAGE, 0,
790 ui_send_fs(IMSG_SESSION_START, 0, NULL, 0);
792 TAILQ_FOREACH(tab, &tabshead, tabs) {
794 if (tab == current_tab)
795 flags |= TAB_CURRENT;
797 t = tab->hist_cur->h;
798 ui_send_fs(IMSG_SESSION_TAB, flags, t, strlen(t)+1);
800 t = tab->buffer.page.title;
801 ui_send_fs(IMSG_SESSION_TAB_TITLE, 0, t, strlen(t)+1);
804 ui_send_fs(IMSG_SESSION_END, 0, NULL, 0);
808 * Parse a line of the session file. The format is:
810 * URL [flags,...] [title]\n
813 parse_session_line(char *line, const char **title, uint32_t *flags)
819 if ((s = strchr(line, ' ')) == NULL)
824 if ((t = strchr(s, ' ')) != NULL) {
829 while ((ap = strsep(&s, ",")) != NULL) {
832 else if (!strcmp(ap, "current"))
833 *flags |= TAB_CURRENT;
835 message("unknown tab flag: %s", ap);
840 load_last_session(void)
843 char *nl, *line = NULL;
848 struct tab *tab, *curr = NULL;
850 if ((session = fopen(session_file, "r")) == NULL) {
852 new_tab("about:new", NULL);
853 switch_to_tab(new_tab("about:help", NULL));
857 while ((linelen = getline(&line, &linesize, session)) != -1) {
858 if ((nl = strchr(line, '\n')) != NULL)
860 parse_session_line(line, &title, &flags);
861 if ((tab = new_tab(line, NULL)) == NULL)
863 strlcpy(tab->buffer.page.title, title,
864 sizeof(tab->buffer.page.title));
865 if (flags & TAB_CURRENT)
870 message("error reading %s: %s",
871 session_file, strerror(errno));
878 if (last_time_crashed())
879 switch_to_tab(new_tab("about:crash", NULL));
885 start_child(enum telescope_process p, const char *argv0, int fd)
891 switch (pid = fork()) {
901 if (dup2(fd, 3) == -1)
902 err(1, "cannot setup imsg fd");
904 argv[argc++] = argv0;
907 errx(1, "Can't start ui process");
909 argv[argc++] = "-Tf";
912 argv[argc++] = "-Tn";
917 execvp(argv0, (char *const *)argv);
918 err(1, "execvp(%s)", argv0);
922 ui_send_net(int type, uint32_t peerid, const void *data,
925 return imsg_compose_event(iev_net, type, peerid, 0, -1, data,
930 ui_send_fs(int type, uint32_t peerid, const void *data, uint16_t datalen)
932 return imsg_compose_event(iev_fs, type, peerid, 0, -1, data,
936 static void __attribute__((noreturn))
939 fprintf(stderr, "USAGE: %s [-hnv] [-c config] [url]\n",
941 fprintf(stderr, "version: " PACKAGE " " VERSION "\n");
946 main(int argc, char * const *argv)
948 struct imsgev net_ibuf, fs_ibuf;
949 int pipe2net[2], pipe2fs[2];
950 int ch, configtest = 0, fail = 0;
955 const char *url = NEW_TAB_URL;
960 signal(SIGCHLD, SIG_IGN);
961 signal(SIGPIPE, SIG_IGN);
963 if (getenv("NO_COLOR") != NULL)
966 strlcpy(path, getenv("HOME"), sizeof(path));
967 strlcat(path, "/.telescope/config", sizeof(path));
969 while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
972 exit(ui_print_colors());
975 strlcpy(path, optarg, sizeof(path));
991 errx(1, "invalid process spec %c",
996 printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
1010 else if (proc == PROC_FS)
1012 else if (proc == PROC_NET)
1023 /* setup keys before reading the config */
1024 TAILQ_INIT(&global_map.m);
1025 global_map.unhandled_input = global_key_unbound;
1026 TAILQ_INIT(&minibuffer_map.m);
1029 parseconfig(path, fail);
1036 if ((sessionfd = lock_session()) == -1)
1037 errx(1, "can't lock session, is another instance of "
1038 "telescope already running?");
1040 /* Start children. */
1041 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe2fs) == -1)
1042 err(1, "socketpair");
1043 start_child(PROC_FS, argv0, pipe2fs[1]);
1044 imsg_init(&fs_ibuf.ibuf, pipe2fs[0]);
1046 iev_fs->handler = handle_dispatch_imsg;
1048 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe2net) == -1)
1049 err(1, "socketpair");
1050 start_child(PROC_NET, argv0, pipe2net[1]);
1051 imsg_init(&net_ibuf.ibuf, pipe2net[0]);
1052 iev_net = &net_ibuf;
1053 iev_net->handler = handle_dispatch_imsg;
1057 /* initialize tofu & load certificates */
1058 tofu_init(&certs, 5, offsetof(struct tofu_entry, domain));
1063 /* Setup event handlers for pipes to fs/net */
1064 iev_fs->events = EV_READ;
1065 event_set(&iev_fs->ev, iev_fs->ibuf.fd, iev_fs->events,
1066 iev_fs->handler, iev_fs);
1067 event_add(&iev_fs->ev, NULL);
1069 iev_net->events = EV_READ;
1070 event_set(&iev_net->ev, iev_net->ibuf.fd, iev_net->events,
1071 iev_net->handler, iev_net);
1072 event_add(&iev_net->ev, NULL);
1075 load_last_session();
1076 if (has_url || TAILQ_EMPTY(&tabshead))
1079 sandbox_ui_process();
1084 ui_send_fs(IMSG_QUIT, 0, NULL, 0);
1085 ui_send_net(IMSG_QUIT, 0, NULL, 0);
1086 imsg_flush(&iev_fs->ibuf);
1087 imsg_flush(&iev_net->ibuf);