2 * Copyright (c) 2021, 2024 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.
21 #include <stdio.h> /* XXX: for parsers.h */
25 #define MIN(a, b) ((a) < (b) ? (a) : (b))
26 #define MAX(a, b) ((a) > (b) ? (a) : (b))
28 #define GEMINI_URL_LEN 1024
29 #define TITLE_MAX 128+1 /* account for NUL too */
31 #define SIDE_WINDOW_LEFT 0x1
32 #define SIDE_WINDOW_BOTTOM 0x2
78 TAILQ_ENTRY(line) lines;
86 #define L_CONTINUATION 0x2
88 TAILQ_ENTRY(vline) vlines;
92 * different types of trust for a certificate. Following
93 * gemini://thfr.info/gemini/modified-trust-verify.gmi
112 #define PARSER_IN_BODY 1
113 #define PARSER_IN_PRE 2
114 #define PARSER_IN_PATCH_HDR 4
116 const struct parser *parser;
118 size_t last_line_off;
125 struct vline *top_line;
126 struct vline *current_line;
129 TAILQ_HEAD(, line) head;
130 TAILQ_HEAD(vhead, vline) vhead;
133 #define TAB_CURRENT 0x1 /* only for save_session */
134 #define TAB_KILLED 0x2 /* only for save_session */
135 #define TAB_URGENT 0x4
136 #define TAB_LAZY 0x8 /* to lazy load tabs */
138 #define NEW_TAB_URL "about:new"
142 TAILQ_HEAD(tabshead, tab);
143 extern struct tabshead tabshead;
144 extern struct tabshead ktabshead;
146 TAILQ_ENTRY(tab) tabs;
151 enum trust_state trust;
152 int faulty_gemserver;
153 const char *client_cert;
154 int client_cert_temp;
158 char *last_input_url;
161 char meta[GEMINI_URL_LEN];
164 struct buffer buffer;
167 short loading_anim_step;
168 unsigned long loading_timer;
171 extern TAILQ_HEAD(proxylist, proxy) proxies;
179 TAILQ_ENTRY(proxy) proxies;
197 extern STAILQ_HEAD(downloads, download) downloads;
204 STAILQ_ENTRY(download) entries;
207 void recompute_downloads(void);
208 struct download *enqueue_download(uint32_t, const char *, const char *);
209 struct download *download_by_id(uint32_t);
210 void download_finished(struct download *);
213 void recompute_help(void);
216 int setup_parser_for(struct tab*);
222 void parseconfig(const char *, int);
225 void sandbox_net_process(void);
226 void sandbox_ui_process(void);
229 extern int operating;
230 extern int safe_mode;
232 #define LU_MODE_NONE 0x0
233 #define LU_MODE_NOHIST 0x1
234 #define LU_MODE_NOCACHE 0x2
236 void gopher_send_search_req(struct tab *, const char *);
237 void load_page_from_str(struct tab *, const char *);
238 void load_url(struct tab *, const char *, const char *, int);
239 void load_url_in_tab(struct tab *, const char *, const char *, int);
240 int load_previous_page(struct tab*);
241 int load_next_page(struct tab*);
242 void write_buffer(const char *, struct tab *);
243 void humanify_url(const char *, const char *, char *, size_t);
244 int bookmark_page(const char *);
245 int ui_send_net(int, uint32_t, int, const void *, uint16_t);
248 void erase_buffer(struct buffer *);
249 void empty_linelist(struct buffer*);
250 void empty_vlist(struct buffer*);
251 int wrap_text(struct buffer*, const char*, struct line*, size_t, int, int);
252 int wrap_page(struct buffer *, int, int);
254 #endif /* TELESCOPE_H */