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.
24 #define GEMINI_URL_LEN 1024
27 IMSG_GET, /* data is URL, peerid the tab id */
58 TAILQ_ENTRY(line) lines;
64 /* typedef void (*initparserfn)(struct parser*); */
66 typedef int (*parsechunkfn)(struct parser*, const char*, size_t);
67 typedef int (*parserfreefn)(struct parser*);
69 typedef void (imsg_handlerfn)(struct imsg*, size_t);
80 TAILQ_HEAD(, line) head;
85 extern TAILQ_HEAD(tabshead, tab) tabshead;
88 TAILQ_ENTRY(tab) tabs;
92 char urlstr[GEMINI_URL_LEN];
96 char meta[GEMINI_URL_LEN];
105 /* should load the given url in the tab. Optionally, it may
106 * consider the given url as relative to the one already
107 * present in tab. It must set tab->urlstr to a serialized
108 * human-friendly URL. */
109 void (*loadfn)(struct tab*, const char*);
112 extern struct event imsgev;
115 int client_main(struct imsgbuf *b);
118 void gemtext_initparser(struct parser*);
121 int setup_parser_for(struct tab*);
124 extern const char *about_new;
126 #define CANNOT_FETCH 0
127 #define TOO_MUCH_REDIRECTS 1
128 #define MALFORMED_RESPONSE 2
129 #define UNKNOWN_TYPE_OR_CSET 3
130 extern const char *err_pages[70];
133 int parser_append(struct parser*, const char*, size_t);
134 int parser_set_buf(struct parser*, const char*, size_t);
137 void sandbox_network_process(void);
140 void load_about_url(struct tab*, const char*);
141 void load_gemini_url(struct tab*, const char*);
142 void load_url(struct tab*, const char*);
143 void stop_tab(struct tab*);
146 void textplain_initparser(struct parser*);
150 void ui_on_tab_loaded(struct tab*);
151 void ui_on_tab_refresh(struct tab*);
152 void ui_require_input(struct tab*, int);
156 int mark_nonblock(int);
157 char *telescope_strnchr(char*, char, size_t);
158 int has_prefix(const char*, const char*);
160 #endif /* TELESCOPE_H */