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;
87 #define L_CONTINUATION 0x2
89 TAILQ_ENTRY(vline) vlines;
94 typedef int (*printfn)(void *, const char *, ...);
96 typedef void (*parserinit)(struct parser *);
98 typedef int (*parsechunkfn)(struct parser *, const char *, size_t);
99 typedef int (*parserfreefn)(struct parser *);
100 typedef int (*parserserial)(struct parser *, FILE *);
109 #define PARSER_IN_BODY 1
110 #define PARSER_IN_PRE 2
111 #define PARSER_IN_PATCH_HDR 4
116 parserserial serialize;
118 TAILQ_HEAD(, line) head;
122 * differnt types of trust for a certificate. Following
123 * gemini://thfr.info/gemini/modified-trust-verify.gmi
136 size_t last_line_off;
143 struct vline *top_line;
144 struct vline *current_line;
146 TAILQ_HEAD(vhead, vline) head;
149 #define TAB_CURRENT 0x1 /* only for save_session */
150 #define TAB_KILLED 0x2 /* only for save_session */
151 #define TAB_URGENT 0x4
152 #define TAB_LAZY 0x8 /* to lazy load tabs */
154 #define NEW_TAB_URL "about:new"
158 TAILQ_HEAD(tabshead, tab);
159 extern struct tabshead tabshead;
160 extern struct tabshead ktabshead;
162 TAILQ_ENTRY(tab) tabs;
167 enum trust_state trust;
168 const char *client_cert;
169 int client_cert_temp;
173 char *last_input_url;
176 char meta[GEMINI_URL_LEN];
179 struct buffer buffer;
182 short loading_anim_step;
183 unsigned long loading_timer;
186 extern TAILQ_HEAD(proxylist, proxy) proxies;
194 TAILQ_ENTRY(proxy) proxies;
212 extern STAILQ_HEAD(downloads, download) downloads;
218 STAILQ_ENTRY(download) entries;
221 void recompute_downloads(void);
222 struct download *enqueue_download(uint32_t, const char *);
223 struct download *download_by_id(uint32_t);
226 void recompute_help(void);
229 int setup_parser_for(struct tab*);
235 void parseconfig(const char *, int);
238 void sandbox_net_process(void);
239 void sandbox_ui_process(void);
242 extern int operating;
243 extern int safe_mode;
245 #define LU_MODE_NONE 0x0
246 #define LU_MODE_NOHIST 0x1
247 #define LU_MODE_NOCACHE 0x2
249 void gopher_send_search_req(struct tab *, const char *);
250 void load_page_from_str(struct tab *, const char *);
251 void load_url(struct tab *, const char *, const char *, int);
252 void load_url_in_tab(struct tab *, const char *, const char *, int);
253 int load_previous_page(struct tab*);
254 int load_next_page(struct tab*);
255 void write_buffer(const char *, struct tab *);
256 void humanify_url(const char *, const char *, char *, size_t);
257 int bookmark_page(const char *);
258 int ui_send_net(int, uint32_t, int, const void *, uint16_t);
261 void erase_buffer(struct buffer *);
262 void empty_linelist(struct buffer*);
263 void empty_vlist(struct buffer*);
264 int wrap_text(struct buffer*, const char*, struct line*, size_t, int);
265 int wrap_page(struct buffer *, int width);
267 #endif /* TELESCOPE_H */