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.
26 #define MIN(a, b) ((a) < (b) ? (a) : (b))
27 #define MAX(a, b) ((a) > (b) ? (a) : (b))
29 #define GEMINI_URL_LEN 1024
32 /* ui <-> client/fs */
33 IMSG_GET, /* data is URL, peerid the tab id */
70 TAILQ_ENTRY(line) lines;
74 const struct line *parent;
77 TAILQ_ENTRY(vline) vlines;
83 /* typedef void (*initparserfn)(struct parser*); */
85 typedef int (*parsechunkfn)(struct parser*, const char*, size_t);
86 typedef int (*parserfreefn)(struct parser*);
88 typedef void (imsg_handlerfn)(struct imsg*, size_t);
100 TAILQ_HEAD(, line) head;
104 TAILQ_HEAD(mhisthead, hist) head;
109 TAILQ_ENTRY(hist) entries;
117 struct vline *current_line;
121 short loading_anim_step;
122 struct event loadingev;
124 TAILQ_HEAD(vhead, vline) head;
128 * differnt types of trust for a certificate. Following
129 * gemini://thfr.info/gemini/modified-trust-verify.gmi
139 char domain[GEMINI_URL_LEN];
140 /* enough space for ``PROTO:HASH''. probably isn't a good
146 extern TAILQ_HEAD(tabshead, tab) tabshead;
149 TAILQ_ENTRY(tab) tabs;
153 enum trust_state trust;
155 struct histhead hist;
156 struct hist *hist_cur;
160 char meta[GEMINI_URL_LEN];
169 /* should load the given url in the tab. Optionally, it may
170 * consider the given url as relative to the one already
171 * present in tab. It must set tab->urlstr to a serialized
172 * human-friendly URL. */
173 void (*loadfn)(struct tab*, const char*);
177 TAILQ_HEAD(map, keymap) m;
178 void (*unhandled_input)(void);
185 void (*fn)(struct tab*);
187 TAILQ_ENTRY(keymap) keymaps;
192 int fs_main(struct imsgbuf*);
193 int load_certs(struct ohash*);
196 int client_main(struct imsgbuf*);
199 void gemtext_initparser(struct parser*);
202 void telescope_ohash_init(struct ohash*, unsigned int, ptrdiff_t);
203 struct tofu_entry *telescope_lookup_tofu(struct ohash*, const char*);
204 void telescope_ohash_insert(struct ohash*, struct tofu_entry*);
207 void hist_clear_forward(struct histhead*, struct hist*);
208 void hist_push(struct histhead*, struct hist*);
211 int kbd(const char*);
212 const char *unkbd(int);
213 int kmap_define_key(struct kmap*, const char*, void(*)(struct tab*));
216 int setup_parser_for(struct tab*);
219 extern const char *about_new;
221 #define CANNOT_FETCH 0
222 #define TOO_MUCH_REDIRECTS 1
223 #define MALFORMED_RESPONSE 2
224 #define UNKNOWN_TYPE_OR_CSET 3
225 extern const char *err_pages[70];
228 int parser_append(struct parser*, const char*, size_t);
229 int parser_set_buf(struct parser*, const char*, size_t);
232 void sandbox_network_process(void);
233 void sandbox_ui_process(void);
234 void sandbox_fs_process(void);
237 void load_about_url(struct tab*, const char*);
238 void load_gemini_url(struct tab*, const char*);
239 void load_url(struct tab*, const char*);
240 int load_previous_page(struct tab*);
241 int load_next_page(struct tab*);
242 void stop_tab(struct tab*);
243 void add_to_bookmarks(const char*);
246 void textplain_initparser(struct parser*);
249 int ui_init(int, char * const*);
250 void ui_on_tab_loaded(struct tab*);
251 void ui_on_tab_refresh(struct tab*);
252 void ui_require_input(struct tab*, int);
253 void ui_notify(const char*, ...) __attribute__((format(printf, 1, 2)));
257 int mark_nonblock(int);
258 int has_prefix(const char*, const char*);
259 void dispatch_imsg(struct imsgbuf*, imsg_handlerfn**, size_t);
262 void wrap_text(struct tab*, const char*, struct line*, size_t);
263 int hardwrap_text(struct tab*, struct line*, size_t);
265 #endif /* TELESCOPE_H */