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 */
68 TAILQ_ENTRY(line) lines;
72 const struct line *parent;
75 TAILQ_ENTRY(vline) vlines;
81 /* typedef void (*initparserfn)(struct parser*); */
83 typedef int (*parsechunkfn)(struct parser*, const char*, size_t);
84 typedef int (*parserfreefn)(struct parser*);
86 typedef void (imsg_handlerfn)(struct imsg*, size_t);
98 TAILQ_HEAD(, line) head;
102 TAILQ_HEAD(mhisthead, hist) head;
107 TAILQ_ENTRY(hist) entries;
115 struct vline *current_line;
119 short loading_anim_step;
120 struct event loadingev;
122 TAILQ_HEAD(vhead, vline) head;
126 * differnt types of trust for a certificate. Following
127 * gemini://thfr.info/gemini/modified-trust-verify.gmi
136 extern TAILQ_HEAD(tabshead, tab) tabshead;
139 TAILQ_ENTRY(tab) tabs;
143 enum trust_state trust;
145 struct histhead hist;
146 struct hist *hist_cur;
150 char meta[GEMINI_URL_LEN];
159 /* should load the given url in the tab. Optionally, it may
160 * consider the given url as relative to the one already
161 * present in tab. It must set tab->urlstr to a serialized
162 * human-friendly URL. */
163 void (*loadfn)(struct tab*, const char*);
167 TAILQ_HEAD(map, keymap) m;
168 void (*unhandled_input)(void);
175 void (*fn)(struct tab*);
177 TAILQ_ENTRY(keymap) keymaps;
181 int fs_main(struct imsgbuf*);
184 int client_main(struct imsgbuf*);
187 void gemtext_initparser(struct parser*);
190 void hist_clear_forward(struct histhead*, struct hist*);
191 void hist_push(struct histhead*, struct hist*);
194 int kbd(const char*);
195 const char *unkbd(int);
196 int kmap_define_key(struct kmap*, const char*, void(*)(struct tab*));
199 int setup_parser_for(struct tab*);
202 extern const char *about_new;
204 #define CANNOT_FETCH 0
205 #define TOO_MUCH_REDIRECTS 1
206 #define MALFORMED_RESPONSE 2
207 #define UNKNOWN_TYPE_OR_CSET 3
208 extern const char *err_pages[70];
211 int parser_append(struct parser*, const char*, size_t);
212 int parser_set_buf(struct parser*, const char*, size_t);
215 void sandbox_network_process(void);
216 void sandbox_ui_process(void);
217 void sandbox_fs_process(void);
220 void load_about_url(struct tab*, const char*);
221 void load_gemini_url(struct tab*, const char*);
222 void load_url(struct tab*, const char*);
223 int load_previous_page(struct tab*);
224 int load_next_page(struct tab*);
225 void stop_tab(struct tab*);
226 void add_to_bookmarks(const char*);
229 void textplain_initparser(struct parser*);
233 void ui_on_tab_loaded(struct tab*);
234 void ui_on_tab_refresh(struct tab*);
235 void ui_require_input(struct tab*, int);
236 void ui_notify(const char*, ...) __attribute__((format(printf, 1, 2)));
240 int mark_nonblock(int);
241 int has_prefix(const char*, const char*);
242 void dispatch_imsg(struct imsgbuf*, imsg_handlerfn**, size_t);
245 void wrap_text(struct tab*, const char*, struct line*, size_t);
246 int hardwrap_text(struct tab*, struct line*, size_t);
248 #endif /* TELESCOPE_H */