add enable_cache to manpage
[xombrero.git] / xombrero.h
blob210fb52bf1b285d83267bb9a190698023b36029d
1 /*
2 * Copyright (c) 2011 Conformal Systems LLC <info@conformal.com>
3 * Copyright (c) 2011 Marco Peereboom <marco@peereboom.us>
4 * Copyright (c) 2010, 2011, 2012 Edd Barrett <vext01@gmail.com>
5 * Copyright (c) 2012, 2013 Josh Rickmar <jrick@devio.us>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <ctype.h>
21 #include <dlfcn.h>
22 #include <err.h>
23 #include <errno.h>
24 #include <libgen.h>
25 #include <pwd.h>
26 #include <regex.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <dirent.h>
32 #include <fcntl.h>
33 #include <inttypes.h>
35 #include <sys/types.h>
36 #if defined(__linux__)
37 #include "linux/util.h"
38 #include "linux/tree.h"
39 #include <bsd/stdlib.h>
40 #include <X11/Xlib.h>
41 #include <sys/un.h>
42 # if !defined(sane_libbsd_headers)
43 void arc4random_buf(void *, size_t);
44 u_int32_t arc4random_uniform(u_int32_t);
45 # endif
46 #elif defined(__APPLE__)
47 #include "osx/util.h"
48 #include "osx/tree.h"
49 #include <stdlib.h>
50 #include <X11/Xlib.h>
51 #include <sys/un.h>
52 #include <sys/param.h>
53 #include <sys/ucred.h>
54 #define LOGIN_NAME_MAX MAXLOGNAME
55 #elif defined(__FreeBSD__)
56 #include <libutil.h>
57 #include "freebsd/util.h"
58 #include <sys/tree.h>
59 #include <X11/Xlib.h>
60 #include <sys/un.h>
61 #include <sys/param.h>
62 #define LOGIN_NAME_MAX MAXLOGNAME
63 #elif defined(__DragonFly__)
64 #include <sys/param.h>
65 #include <sys/un.h>
66 #include <libutil.h>
67 #include "dragonfly/util.h"
68 #include <sys/tree.h>
69 #include <X11/Xlib.h>
70 #define LOGIN_NAME_MAX MAXLOGNAME
71 #elif defined(__NetBSD__)
72 #include <sys/param.h>
73 #include <sys/un.h>
74 #include "netbsd/util.h"
75 #include <sys/tree.h>
76 #include <X11/Xlib.h>
77 #define LOGIN_NAME_MAX_MAXLOGNAME
78 #elif defined(__OpenBSD__)
79 #include <util.h>
80 #include <sys/tree.h>
81 #include <X11/Xlib.h>
82 #include <sys/un.h>
83 #else
84 /* mingw */
85 void arc4random_buf(void *, size_t);
86 uint32_t arc4random_uniform(uint32_t);
87 #include "tree.h"
88 #endif
89 #include <sys/queue.h>
90 #include <sys/socket.h>
91 #include <sys/stat.h>
92 #include <sys/time.h>
94 #include <gtk/gtk.h>
95 #include <gdk/gdk.h>
96 #include <gdk/gdkkeysyms.h>
98 #if GTK_CHECK_VERSION(3,0,0)
99 /* we still use GDK_* instead of GDK_KEY_* */
100 #include <gdk/gdkkeysyms-compat.h>
101 #endif
103 #include <webkit/webkit.h>
104 #include <libsoup/soup.h>
105 #include <JavaScriptCore/JavaScript.h>
106 #include <gnutls/gnutls.h>
107 #include <gnutls/x509.h>
109 /* set if you don't want to use resource limits */
110 #ifndef XT_RESOURCE_LIMITS_DISABLE
111 #include <sys/resource.h>
112 #endif
114 #include "javascript.h"
116 javascript.h borrowed from vimprobable2 under the following license:
118 Copyright (c) 2009 Leon Winter
119 Copyright (c) 2009-2011 Hannes Schueller
120 Copyright (c) 2009-2010 Matto Fransen
121 Copyright (c) 2010-2011 Hans-Peter Deifel
122 Copyright (c) 2010-2011 Thomas Adam
123 Copyright (c) 2011 Albert Kim
124 Copyright (c) 2011 Daniel Carl
126 Permission is hereby granted, free of charge, to any person obtaining a copy
127 of this software and associated documentation files (the "Software"), to deal
128 in the Software without restriction, including without limitation the rights
129 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130 copies of the Software, and to permit persons to whom the Software is
131 furnished to do so, subject to the following conditions:
133 The above copyright notice and this permission notice shall be included in
134 all copies or substantial portions of the Software.
136 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
142 THE SOFTWARE.
145 /*#define XT_DEBUG*/
146 #ifdef XT_DEBUG
147 #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
148 #define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
149 #define XT_D_MOVE 0x0001
150 #define XT_D_KEY 0x0002
151 #define XT_D_TAB 0x0004
152 #define XT_D_URL 0x0008
153 #define XT_D_CMD 0x0010
154 #define XT_D_NAV 0x0020
155 #define XT_D_DOWNLOAD 0x0040
156 #define XT_D_CONFIG 0x0080
157 #define XT_D_JS 0x0100
158 #define XT_D_FAVORITE 0x0200
159 #define XT_D_PRINTING 0x0400
160 #define XT_D_COOKIE 0x0800
161 #define XT_D_KEYBINDING 0x1000
162 #define XT_D_CLIP 0x2000
163 #define XT_D_BUFFERCMD 0x4000
164 #define XT_D_INSPECTOR 0x8000
165 #define XT_D_VISITED 0x10000
166 #define XT_D_HISTORY 0x20000
167 #define XT_D_MISC 0x40000
168 #define XT_D_CUSTOM_URI 0x80000
169 #define XT_D_CMD_ALIAS 0x100000
170 #define XT_D_SEARCH 0x200000
171 extern uint32_t swm_debug;
172 #else
173 #define DPRINTF(x...)
174 #define DNPRINTF(n,x...)
175 #endif
177 #define LENGTH(x) (sizeof x / sizeof x[0])
178 #define CLEAN(mask) (mask & ~(GDK_MOD2_MASK) & \
179 ~(GDK_BUTTON1_MASK) & \
180 ~(GDK_BUTTON2_MASK) & \
181 ~(GDK_BUTTON3_MASK) & \
182 ~(GDK_BUTTON4_MASK) & \
183 ~(GDK_BUTTON5_MASK))
185 #define XT_MARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"
186 #define XT_NOMARKS (sizeof(XT_MARKS) - 1)
187 #define XT_QMARKS "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
188 #define XT_NOQMARKS (sizeof(XT_QMARKS) - 1)
190 /* Path Separator */
191 #ifndef PS
192 #define PS "/"
193 #define PSC '/'
194 #endif
196 struct tab {
197 TAILQ_ENTRY(tab) entry;
198 GtkWidget *vbox;
199 GtkWidget *tab_content;
200 struct {
201 GtkWidget *label;
202 GtkWidget *favicon;
203 GtkWidget *eventbox;
204 GtkWidget *box;
205 } tab_elems;
206 GtkWidget *label;
207 GtkWidget *spinner;
208 GtkWidget *uri_entry;
209 #if !GTK_CHECK_VERSION(3, 0, 0)
210 GtkStyle *default_style;
211 #endif
212 GtkWidget *search_entry;
213 GtkWidget *toolbar;
214 GtkWidget *browser_win;
215 GtkWidget *statusbar;
216 struct {
217 GtkWidget *ebox; /* non window-less widget for colors */
218 GtkWidget *uri;
219 GtkWidget *buffercmd;
220 GtkWidget *zoom;
221 GtkWidget *position;
222 GtkWidget *tabs;
223 GtkWidget *proxy;
224 } sbe;
225 GtkWidget *cmd;
226 GtkWidget *buffers;
227 GtkWidget *oops;
228 GtkWidget *backward;
229 GtkWidget *forward;
230 GtkWidget *stop;
231 GtkWidget *gohome;
232 GtkWidget *js_toggle;
233 GtkWidget *proxy_toggle;
234 GtkEntryCompletion *completion;
235 guint tab_id;
236 WebKitWebView *wv;
238 WebKitWebBackForwardList *bfl;
239 WebKitWebHistoryItem *item;
241 /* favicon */
242 WebKitNetworkRequest *icon_request;
243 WebKitDownload *icon_download;
244 gchar *icon_dest_uri;
246 /* adjustments for browser */
247 GtkAdjustment *adjust_h;
248 GtkAdjustment *adjust_v;
250 /* flags */
251 int mode;
252 #define XT_MODE_COMMAND (0)
253 #define XT_MODE_INSERT (1)
254 #define XT_MODE_HINT (2)
255 #define XT_MODE_PASSTHROUGH (3)
256 int (*mode_cb)(struct tab *, GdkEventKey *, gpointer);
257 gpointer mode_cb_data;
258 int focus_wv;
259 int ctrl_click;
260 gchar *status;
261 int xtp_meaning; /* identifies dls/favorites */
262 int xtp_arg;
263 char *session_key;
264 gchar *tmp_uri;
265 int popup; /* 1 if cmd_entry has popup visible */
266 int download_requested;
268 /* hints */
269 int script_init;
270 int new_tab;
272 /* custom stylesheet */
273 int styled;
274 char *stylesheet;
276 /* search */
277 char *search_text;
278 int search_forward;
279 guint search_id;
281 /* settings */
282 WebKitWebSettings *settings;
283 int user_agent_id;
284 int http_accept_id;
285 gboolean load_images;
287 /* marks */
288 double mark[XT_NOMARKS];
290 /* inspector */
291 WebKitWebInspector *inspector;
292 GtkWidget *inspector_window;
293 GtkWidget *inspector_view;
295 /* focused text entry */
296 #if WEBKIT_CHECK_VERSION(1, 5, 0)
297 WebKitDOMElement *active;
298 char *active_text;
299 #endif
301 /* signal handles */
302 gulong progress_handle;
304 /* cert chain (pem) */
305 char *cert_chain;
307 TAILQ_HEAD(tab_list, tab);
309 struct karg {
310 int i;
311 char *s;
312 int precount;
313 void *ptr;
316 struct download {
317 RB_ENTRY(download) entry;
318 int id;
319 WebKitDownload *download;
320 struct tab *tab;
322 RB_HEAD(download_list, download);
323 RB_PROTOTYPE(download_list, download, entry, download_rb_cmp);
325 struct history {
326 RB_ENTRY(history) entry;
327 gchar *uri;
328 gchar *title;
329 time_t time; /* When the item was added. */
331 RB_HEAD(history_list, history);
332 RB_PROTOTYPE(history_list, history, entry, history_rb_cmp);
334 #define XT_STS_FLAGS_INCLUDE_SUBDOMAINS (1)
335 #define XT_STS_FLAGS_EXPAND (2)
336 #define XT_STS_FILE ("strict-transport")
338 struct strict_transport {
339 RB_ENTRY(strict_transport) entry;
340 gchar *host;
341 time_t timeout;
342 int flags;
344 RB_HEAD(strict_transport_tree, strict_transport);
345 RB_PROTOTYPE(strict_transport_tree, strict_transport, entry, strict_transport_rb_cmp);
347 struct secviolation {
348 RB_ENTRY(secviolation) entry;
349 int xtp_arg;
350 struct tab *t;
351 char *uri;
353 RB_HEAD(secviolation_list, secviolation);
354 RB_PROTOTYPE(secviolation_list, secviolation, entry, secviolation_rb_cmp);
356 struct user_agent {
357 RB_ENTRY(user_agent) entry;
358 int id;
359 char *value;
361 RB_HEAD(user_agent_list, user_agent);
362 RB_PROTOTYPE(user_agent_list, user_agent, entry, user_agent_rb_cmp);
364 struct http_accept {
365 RB_ENTRY(http_accept) entry;
366 int id;
367 char *value;
369 RB_HEAD(http_accept_list, http_accept);
370 RB_PROTOTYPE(http_accept_list, http_accept, entry, http_accept_rb_cmp);
372 struct domain_id {
373 RB_ENTRY(domain_id) entry;
374 int ua_id; /* user agent id key */
375 int ha_id; /* http accept header id key */
376 char *domain;
378 RB_HEAD(domain_id_list, domain_id);
379 RB_PROTOTYPE(domain_id_list, domain_id, entry, domain_id_rb_cmp);
381 /* utility */
382 #define XT_NAME ("xombrero")
383 #define XT_DIR (".xombrero")
384 #define XT_CB_HANDLED (TRUE)
385 #define XT_CB_PASSTHROUGH (FALSE)
386 #define XT_CONF_FILE ("xombrero.conf")
387 #define XT_CSS_FILE ("xombrero.css")
388 #define XT_FAVS_FILE ("favorites")
389 #define XT_SOD_FILE ("startofday")
390 #define XT_HSTS_PRELOAD_FILE ("hsts-preload")
391 #define XT_USER_AGENT_FILE ("user-agent-headers")
392 #define XT_HTTP_ACCEPT_FILE ("http-accept-headers")
393 #define XT_RESERVED_CHARS "$&+,/:;=?@ \"<>#%%{}|^~[]`"
395 int run_script(struct tab *, char *);
396 void js_autorun(struct tab *);
397 void xt_icon_from_file(struct tab *, char *);
398 GtkWidget *create_window(const gchar *);
399 void show_oops(struct tab *, const char *, ...);
400 gchar *get_html_page(gchar *, gchar *, gchar *, bool);
401 const gchar *get_uri(struct tab *);
402 const gchar *get_title(struct tab *, bool);
403 void load_uri(struct tab *t, gchar *uri);
404 gboolean match_uri(const gchar *uri, const gchar *key);
405 int valid_url_type(char *);
406 void expand_tilde(char *, size_t, const char *);
407 char *html_escape(const char *val);
408 void set_status(struct tab *t, gchar *fmt, ...);
410 void load_webkit_string(struct tab *, const char *, gchar *, int);
411 void button_set_stockid(GtkWidget *, char *);
412 void button_set_file(GtkWidget *, char *);
413 void webview_progress_changed_cb(WebKitWebView *, GParamSpec *, struct tab *);
415 /* cookies */
416 int remove_cookie(int);
417 int remove_cookie_domain(int);
418 int remove_cookie_all(void);
419 void print_cookie(char *msg, SoupCookie *);
420 void setup_cookies(void);
422 /* history */
423 int insert_history_item(const gchar *uri, const gchar *title, time_t time);
424 int save_global_history_to_disk(struct tab *t);
425 int restore_global_history(void);
426 char *color_visited_helper(void);
427 int color_visited(struct tab *t, char *visited);
429 /* completion */
430 void completion_add(struct tab *);
431 void completion_add_uri(const gchar *uri);
433 /* external editor */
434 #define XT_EE_BUFSZ (64 * 1024)
435 int edit_src(struct tab *t, struct karg *args);
436 int edit_element(struct tab *t, struct karg *a);
438 /* proxy */
439 #define XT_PRXY_SHOW (1<<0)
440 #define XT_PRXY_TOGGLE (1<<1)
442 /* url modify */
443 #define XT_URL (1<<0)
444 #define XT_URL_PLUS (1<<1)
445 #define XT_URL_MIN (1<<2)
447 /* inspector */
448 #define XT_INS_SHOW (1<<0)
449 #define XT_INS_HIDE (1<<1)
450 #define XT_INS_CLOSE (1<<2)
452 WebKitWebView* inspector_inspect_web_view_cb(WebKitWebInspector *,
453 WebKitWebView*, struct tab *);
454 void setup_inspector(struct tab *);
455 int inspector_cmd(struct tab *, struct karg *);
457 /* tld public suffix */
458 void tld_tree_init();
459 char *tld_get_suffix(const char *);
461 /* about */
462 #define XT_XTP_STR "xxxt://"
463 #define XT_XTP_SCHEME "xxxt"
464 #define XT_URI_ABOUT ("about:")
465 #define XT_URI_ABOUT_LEN (strlen(XT_URI_ABOUT))
466 #define XT_URI_ABOUT_ABOUT ("about")
467 #define XT_URI_ABOUT_ALLTHETHINGS ("allthethings")
468 #define XT_URI_ABOUT_BLANK ("blank")
469 #define XT_URI_ABOUT_CERTS ("certs")
470 #define XT_URI_ABOUT_COOKIEWL ("cookiewl")
471 #define XT_URI_ABOUT_COOKIEJAR ("cookiejar")
472 #define XT_URI_ABOUT_DOWNLOADS ("downloads")
473 #define XT_URI_ABOUT_FAVORITES ("favorites")
474 #define XT_URI_ABOUT_HELP ("help")
475 #define XT_URI_ABOUT_HISTORY ("history")
476 #define XT_URI_ABOUT_JSWL ("jswl")
477 #define XT_URI_ABOUT_PLUGINWL ("plwl")
478 #define XT_URI_ABOUT_HTTPS ("https")
479 #define XT_URI_ABOUT_SET ("set")
480 #define XT_URI_ABOUT_STATS ("stats")
481 #define XT_URI_ABOUT_MARCO ("marco")
482 #define XT_URI_ABOUT_STARTPAGE ("startpage")
483 #define XT_URI_ABOUT_WEBKIT ("webkit")
484 #define XT_URI_ABOUT_SEARCH ("search")
485 #define XT_URI_ABOUT_SECVIOLATION ("secviolation")
486 #define XT_URI_ABOUT_RUNTIME ("runtime")
488 struct about_type {
489 char *name;
490 int (*func)(struct tab *, struct karg *);
493 struct sp {
494 char *line;
495 TAILQ_ENTRY(sp) entry;
497 TAILQ_HEAD(sp_list, sp);
499 int blank(struct tab *, struct karg *);
500 int help(struct tab *, struct karg *);
501 int stats(struct tab *, struct karg *);
502 void show_certs(struct tab *, gnutls_x509_crt_t *,
503 size_t, char *);
504 int ca_cmd(struct tab *, struct karg *);
505 int cookie_show_wl(struct tab *, struct karg *);
506 int xtp_page_ab(struct tab *, struct karg *);
507 int xtp_page_cl(struct tab *, struct karg *);
508 int xtp_page_dl(struct tab *, struct karg *);
509 int xtp_page_fl(struct tab *, struct karg *);
510 int xtp_page_hl(struct tab *, struct karg *);
511 int xtp_page_sl(struct tab *, struct karg *);
512 int xtp_page_sv(struct tab *, struct karg *);
513 int parse_xtp_url(struct tab *, const char *);
514 int add_favorite(struct tab *, struct karg *);
515 void update_favorite_tabs(struct tab *);
516 void update_history_tabs(struct tab *);
517 void update_download_tabs(struct tab *);
518 size_t about_list_size(void);
519 int cookie_cmd(struct tab *, struct karg *);
520 int js_cmd(struct tab *, struct karg *);
521 int pl_cmd(struct tab *, struct karg *);
522 int https_cmd(struct tab *, struct karg *);
523 void startpage_add(const char *, ...);
526 * xtp tab meanings
527 * identifies which tabs have xtp pages in (corresponding to about_list indices)
529 #define XT_XTP_TAB_MEANING_NORMAL (-1) /* normal url */
530 #define XT_XTP_TAB_MEANING_AB (0) /* any other about page */
531 #define XT_XTP_TAB_MEANING_BL (2) /* about:blank in this tab */
532 #define XT_XTP_TAB_MEANING_CL (5) /* cookie manager in this tab */
533 #define XT_XTP_TAB_MEANING_DL (6) /* download manager in this tab */
534 #define XT_XTP_TAB_MEANING_FL (7) /* favorite manager in this tab */
535 #define XT_XTP_TAB_MEANING_HL (9) /* history manager in this tab */
536 #define XT_XTP_TAB_MEANING_SET (11) /* settings manager/viewer */
537 #define XT_XTP_TAB_MEANING_SL (18) /* search engine chooser */
538 #define XT_XTP_TAB_MEANING_RT (19) /* about:runtime in this tab */
539 #define XT_XTP_TAB_MEANING_SV (20) /* about:secviolation in tab */
541 /* whitelists */
542 #define XT_WL_TOGGLE (1<<0)
543 #define XT_WL_ENABLE (1<<1)
544 #define XT_WL_DISABLE (1<<2)
545 #define XT_WL_FQDN (1<<3) /* default */
546 #define XT_WL_TOPLEVEL (1<<4)
547 #define XT_WL_PERSISTENT (1<<5)
548 #define XT_WL_SESSION (1<<6)
549 #define XT_WL_RELOAD (1<<7)
550 #define XT_SHOW (1<<8)
551 #define XT_DELETE (1<<9)
552 #define XT_SAVE (1<<10)
553 #define XT_OPEN (1<<11)
554 #define XT_CACHE (1<<12)
555 #define XT_WL_REGEX (1<<13)
557 #define XT_WL_INVALID (0)
558 #define XT_WL_JAVASCRIPT (1)
559 #define XT_WL_COOKIE (2)
560 #define XT_WL_PLUGIN (3)
561 #define XT_WL_HTTPS (4)
563 struct wl_entry {
564 regex_t *re;
565 char *pat;
566 int handy; /* app use */
567 TAILQ_ENTRY(wl_entry) entry;
569 TAILQ_HEAD(wl_list, wl_entry);
571 int wl_show(struct tab *, struct karg *, char *,
572 struct wl_list *);
574 /* uri aliases */
575 struct alias {
576 char *a_name;
577 char *a_uri;
578 TAILQ_ENTRY(alias) entry;
580 TAILQ_HEAD(alias_list, alias);
582 /* mime types */
583 struct mime_type {
584 char *mt_type;
585 char *mt_action;
586 int mt_default;
587 int mt_download;
588 TAILQ_ENTRY(mime_type) entry;
590 TAILQ_HEAD(mime_type_list, mime_type);
592 struct wl_entry * wl_find(const gchar *, struct wl_list *);
593 int wl_save(struct tab *, struct karg *, int);
594 int toggle_cwl(struct tab *, struct karg *);
595 int toggle_js(struct tab *, struct karg *);
596 int toggle_pl(struct tab *, struct karg *);
597 int toggle_force_https(struct tab *, struct karg *);
599 /* input autofocus */
600 void input_autofocus(struct tab *);
601 void *input_check_mode(struct tab *);
602 int command_mode(struct tab *, struct karg *);
604 /* settings */
605 #define XT_BM_NORMAL (0)
606 #define XT_BM_WHITELIST (1)
607 #define XT_BM_KIOSK (2)
609 #define XT_GM_CLASSIC (0)
610 #define XT_GM_MINIMAL (1)
612 #define XT_TABS_NORMAL (0)
613 #define XT_TABS_COMPACT (1)
615 #define XT_STATUSBAR_URL (0)
616 #define XT_STATUSBAR_TITLE (1)
618 #define XT_EM_HYBRID (0)
619 #define XT_EM_VI (1)
621 #define XT_DM_START (0)
622 #define XT_DM_ASK (1)
623 #define XT_DM_ADD (2)
625 #define XT_REFERER_ALWAYS (0)
626 #define XT_REFERER_NEVER (1)
627 #define XT_REFERER_SAME_DOMAIN (2)
628 #define XT_REFERER_CUSTOM (3)
629 #define XT_REFERER_SAME_FQDN (4)
631 #define CTRL GDK_CONTROL_MASK
632 #define MOD1 GDK_MOD1_MASK
633 #define SHFT GDK_SHIFT_MASK
635 /* runtime default settings */
636 #define XT_DS_SHOW_TABS (1)
637 #define XT_DS_TAB_STYLE XT_TABS_NORMAL
638 #define XT_DS_STATUSBAR_STYLE XT_STATUSBAR_URL
639 #define XT_DS_SHOW_URL (1)
640 #define XT_DS_SHOW_SCROLLBARS (1)
641 #define XT_DS_SHOW_STATUSBAR (0)
642 #define XT_DS_CTRL_CLICK_FOCUS (0)
643 #define XT_DS_COOKIES_ENABLED (1)
644 #define XT_DS_READ_ONLY_COOKIES (0)
645 #define XT_DS_ENABLE_SCRIPTS (1)
646 #define XT_DS_ENABLE_PLUGINS (1)
647 #define XT_DS_DEFAULT_ZOOM_LEVEL (1.0)
648 #define XT_DS_DEFAULT_SCRIPT ("")
649 #define XT_DS_REFRESH_INTERVAL (10)
650 #define XT_DS_ENABLE_PLUGIN_WHITELIST (0)
651 #define XT_DS_ENABLE_COOKIE_WHITELIST (0)
652 #define XT_DS_ENABLE_JS_WHITELIST (0)
653 #define XT_DS_ENABLE_LOCALSTORAGE (1)
654 #define XT_DS_SESSION_TIMEOUT (3600)
655 #define XT_DS_COOKIE_POLICY SOUP_COOKIE_JAR_ACCEPT_ALWAYS
656 #define XT_DS_SSL_STRICT_CERTS FALSE
657 #define XT_DS_SSL_CA_FILE ("")
658 #define XT_DS_ENABLE_STRICT_TRANSPORT TRUE
659 #define XT_DS_APPEND_NEXT (1)
660 #define XT_DS_HOME ("https://www.cyphertite.com/")
661 #define XT_DS_SEARCH_STRING ("about:search")
662 #define XT_DS_COLOR_VISITED_URIS (1)
663 #define XT_DS_SESSION_AUTOSAVE (0)
664 #define XT_DS_GUESS_SEARCH (0)
665 #define XT_DS_ENABLE_SPELL_CHECKING (0)
666 #define XT_DS_SPELL_CHECK_LANGUAGES ("en_US")
667 #define XT_DS_URL_REGEX ("^[[:blank:]]*[^[:blank:]]*([[:alnum:]-]+\\.)+[[:alnum:]-][^[:blank:]]*[[:blank:]]*$")
668 #define XT_DS_ENCODING ("UTF-8")
669 #define XT_DS_AUTOFOCUS_ONLOAD (0)
670 #define XT_DS_ENABLE_JS_AUTORUN (1)
671 #define XT_DS_USERSTYLE_GLOBAL (0)
672 #define XT_DS_AUTO_LOAD_IMAGES (1)
673 #define XT_DS_ENABLE_AUTOSCROLL (0)
674 #define XT_DS_ENABLE_FAVICON_ENTRY (1)
675 #define XT_DS_ENABLE_FAVICON_TABS (0)
676 #define XT_DS_EXTERNAL_EDITOR (NULL)
677 #define XT_DS_REFERER_MODE XT_REFERER_ALWAYS
678 #define XT_DS_REFERER_CUSTOM ("always")
679 #define XT_DS_DOWNLOAD_NOTIFICATIONS (0)
680 #define XT_DS_CMD_FONT_NAME ("monospace normal 9")
681 #define XT_DS_OOPS_FONT_NAME ("monospace normal 9")
682 #define XT_DS_STATUSBAR_FONT_NAME ("monospace normal 9")
683 #define XT_DS_TABBAR_FONT_NAME ("monospace normal 9")
684 #define XT_DS_ALLOW_INSECURE_CONTENT (TRUE)
685 #define XT_DS_ALLOW_INSECURE_SCRIPTS (TRUE)
686 #define XT_DS_WARN_CERT_CHANGES (0)
687 #define XT_DS_RESOURCE_DIR ("/usr/local/share/xombrero")
688 #define XT_DS_DO_NOT_TRACK (0)
689 #define XT_DS_PRELOAD_STRICT_TRANSPORT (1)
690 #define XT_DS_GNUTLS_PRIORITY_STRING (NULL)
693 /* actions */
694 #define XT_STYLE_CURRENT_TAB (0)
695 #define XT_STYLE_GLOBAL (1)
697 #define XT_TAB_LAST (-4)
698 #define XT_TAB_FIRST (-3)
699 #define XT_TAB_PREV (-2)
700 #define XT_TAB_NEXT (-1)
701 #define XT_TAB_INVALID (0)
702 #define XT_TAB_NEW (1)
703 #define XT_TAB_DELETE (2)
704 #define XT_TAB_DELQUIT (3)
705 #define XT_TAB_OPEN (4)
706 #define XT_TAB_UNDO_CLOSE (5)
707 #define XT_TAB_SHOW (6)
708 #define XT_TAB_HIDE (7)
709 #define XT_TAB_NEXTSTYLE (8)
710 #define XT_TAB_LOAD_IMAGES (9)
711 #define XT_TAB_ONLY (10)
713 #define XT_URL_SHOW (1)
714 #define XT_URL_HIDE (2)
716 /* XTP classes (xxxt://<class>) */
717 #define XT_XTP_INVALID (0) /* invalid */
718 #define XT_XTP_DL (1) /* downloads */
719 #define XT_XTP_HL (2) /* history */
720 #define XT_XTP_CL (3) /* cookies */
721 #define XT_XTP_FL (4) /* favorites */
722 #define XT_XTP_SL (5) /* search */
723 #define XT_XTP_AB (6) /* about */
724 #define XT_XTP_SV (7) /* security violation */
725 #define XT_XTP_RT (8) /* set */
727 /* XTP download actions */
728 #define XT_XTP_DL_LIST (1)
729 #define XT_XTP_DL_CANCEL (2)
730 #define XT_XTP_DL_REMOVE (3)
731 #define XT_XTP_DL_UNLINK (4)
732 #define XT_XTP_DL_START (5)
734 /* XTP history actions */
735 #define XT_XTP_HL_LIST (1)
736 #define XT_XTP_HL_REMOVE (2)
737 #define XT_XTP_HL_REMOVE_ALL (3)
739 /* XTP cookie actions */
740 #define XT_XTP_CL_LIST (1)
741 #define XT_XTP_CL_REMOVE (2)
742 #define XT_XTP_CL_REMOVE_DOMAIN (3)
743 #define XT_XTP_CL_REMOVE_ALL (4)
745 /* XTP cookie actions */
746 #define XT_XTP_FL_LIST (1)
747 #define XT_XTP_FL_REMOVE (2)
749 /* XPT search actions */
750 #define XT_XTP_SL_SET (1)
752 /* XPT about actions */
753 #define XT_XTP_AB_EDIT_CONF (1)
755 /* XTP security violation actions */
756 #define XT_XTP_SV_SHOW_NEW_CERT (1)
757 #define XT_XTP_SV_ALLOW_SESSION (2)
758 #define XT_XTP_SV_CACHE (3)
759 #define XT_XTP_SV_SHOW_CACHED_CERT (4)
761 /* XTP set actions */
762 #define XT_XTP_RT_SAVE (1)
764 /* needed for xtp_page_rt in settings.c */
765 void generate_xtp_session_key(char **);
767 struct key_binding {
768 char *cmd;
769 guint mask;
770 guint use_in_entry;
771 guint key;
772 TAILQ_ENTRY(key_binding) entry; /* in bss so no need to init */
774 TAILQ_HEAD(keybinding_list, key_binding);
776 struct custom_uri {
777 char *uri;
778 char cmd[PATH_MAX];
779 TAILQ_ENTRY(custom_uri) entry;
781 TAILQ_HEAD(custom_uri_list, custom_uri);
783 struct cmd_alias {
784 char *alias;
785 char *cmd;
786 TAILQ_ENTRY(cmd_alias) entry;
788 TAILQ_HEAD(cmd_alias_list, cmd_alias);
790 struct set_reject {
791 char *name;
792 char *value;
793 TAILQ_ENTRY(set_reject) entry;
795 TAILQ_HEAD(set_reject_list, set_reject);
797 struct settings {
798 char *name;
799 int type;
800 #define XT_S_INVALID (0)
801 #define XT_S_INT (1)
802 #define XT_S_STR (2)
803 #define XT_S_FLOAT (3)
804 #define XT_S_BOOL (4)
805 uint32_t flags;
806 #define XT_SF_RESTART (1<<0)
807 #define XT_SF_RUNTIME (1<<1)
808 #define XT_SF_INVISIBLE (1<<2)
809 int *ival;
810 char **sval;
811 struct special *s;
812 gfloat *fval;
813 int (*activate)(char *);
814 int (*ismodified)(char **);
815 char *tt;
818 struct special {
819 int (*set)(struct settings *, char *);
820 char *(*get)(struct settings *);
821 void (*walk)(struct settings *,
822 void (*cb)(struct settings *, char *, void *),
823 void *);
824 char *valid_options[];
827 int set(struct tab *, struct karg *);
828 int xtp_page_rt(struct tab *, struct karg *);
829 size_t get_settings_size(void);
830 int settings_add(char *, char *);
831 void setup_proxy(char *);
832 int proxy_cmd(struct tab *, struct karg *);
833 int set_browser_mode(struct settings *, char *);
834 int set_encoding(struct tab *, struct karg *);
835 int set_gui_mode(struct settings *, char *);
836 int set_cookie_policy(struct settings *, char *);
837 int set_search_string(char *);
838 int set_ssl_ca_file(struct settings *, char *);
839 char *get_browser_mode(struct settings *);
840 char *get_gui_mode(struct settings *);
841 char *get_cookie_policy(struct settings *);
842 void init_keybindings(void);
843 void config_parse(char *, int);
844 char *get_setting_name(int);
845 void statusbar_set_visibility(void);
846 int tabaction(struct tab *, struct karg *);
847 int urlaction(struct tab *, struct karg *);
848 int userstyle_cmd(struct tab *, struct karg *);
849 struct tab *get_current_tab(void);
850 int resizetab(struct tab *, struct karg *);
851 int cert_cmd(struct tab *, struct karg *);
852 void focus_webview(struct tab *);
853 int is_g_object_setting(GObject *, char *);
854 int set_scrollbar_visibility(struct tab *, int);
855 int save_runtime_setting(const char *, const char *);
856 void wl_add(const char *, struct wl_list *, int);
858 #if GTK_CHECK_VERSION(3,0,0)
859 #define modify_font gtk_widget_override_font
860 #else
861 #define modify_font gtk_widget_modify_font
862 #endif
864 #define XT_DL_START (0)
865 #define XT_DL_RESTART (1)
866 int download_start(struct tab *, struct download *, int flag);
868 extern int tabless;
869 extern int enable_socket;
870 extern int single_instance;
871 extern int fancy_bar;
872 extern int browser_mode;
873 extern int enable_localstorage;
874 extern char *statusbar_elems;
875 extern SoupURI *proxy_uri;
877 extern int show_tabs;
878 extern int tab_style;
879 extern int statusbar_style;
880 extern int show_url;
881 extern int show_scrollbars;
882 extern int show_statusbar;
883 extern int ctrl_click_focus;
884 extern int cookies_enabled;
885 extern int read_only_cookies;
886 extern int enable_cache;
887 extern int enable_scripts;
888 extern int enable_plugins;
889 extern gfloat default_zoom_level;
890 extern char default_script[PATH_MAX];
891 extern int window_height;
892 extern int window_width;
893 extern int window_maximize;
894 extern int icon_size;
895 extern int refresh_interval;
896 extern int enable_plugin_whitelist;
897 extern int enable_cookie_whitelist;
898 extern int enable_js_whitelist;
899 extern int session_timeout;
900 extern int cookie_policy;
901 extern char ssl_ca_file[PATH_MAX];
902 extern char *resource_dir;
903 extern gboolean ssl_strict_certs;
904 extern gboolean enable_strict_transport;
905 extern int append_next;
906 extern char *home;
907 extern char *search_string;
908 extern char *http_proxy;
909 extern int http_proxy_starts_enabled;
910 extern char *external_editor;
911 extern char download_dir[PATH_MAX];
912 extern int download_mode;
913 extern char runtime_settings[PATH_MAX];
914 extern int allow_volatile_cookies;
915 extern int color_visited_uris;
916 extern int save_global_history;
917 extern int save_rejected_cookies;
918 extern int session_autosave;
919 extern int guess_search;
920 extern gint max_connections;
921 extern gint max_host_connections;
922 extern gint enable_spell_checking;
923 extern char *spell_check_languages;
924 extern char *url_regex;
925 extern int history_autosave;
926 extern char search_file[PATH_MAX];
927 extern char command_file[PATH_MAX];
928 extern char *encoding;
929 extern int autofocus_onload;
930 extern int enable_js_autorun;
931 extern char *cmd_font_name;
932 extern char *oops_font_name;
933 extern char *statusbar_font_name;
934 extern char *tabbar_font_name;
935 extern int edit_mode;
936 extern char *userstyle;
937 extern char *stylesheet;
938 extern int userstyle_global;
939 extern int auto_load_images;
940 extern int enable_autoscroll;
941 extern int enable_favicon_entry;
942 extern int enable_favicon_tabs;
943 extern int referer_mode;
944 extern char *referer_custom;
945 extern int download_notifications;
946 extern int warn_cert_changes;
947 extern regex_t url_re;
948 extern int allow_insecure_content;
949 extern int allow_insecure_scripts;
950 extern int do_not_track;
951 extern int preload_strict_transport;
952 extern char *gnutls_priority_string;
953 extern int anonymize_headers;
955 /* globals */
956 extern void (*os_init)(void);
957 extern char *version;
958 extern char *icons[];
959 extern char rc_fname[PATH_MAX];
960 extern char work_dir[PATH_MAX];
961 extern char temp_dir[PATH_MAX];
962 extern struct passwd *pwd;
963 extern SoupCookieJar *s_cookiejar;
964 extern SoupCookieJar *p_cookiejar;
965 extern SoupSession *session;
966 extern GtkNotebook *notebook;
967 extern GtkListStore *completion_model;
968 extern uint64_t blocked_cookies;
969 extern SoupSession *session;
971 extern void (*_soup_cookie_jar_add_cookie)(SoupCookieJar *, SoupCookie *);
973 extern struct history_list hl;
974 extern int hl_purge_count;
975 extern struct download_list downloads;
976 extern struct tab_list tabs;
977 extern struct about_type about_list[];
978 extern struct wl_list c_wl;
979 extern struct wl_list js_wl;
980 extern struct wl_list pl_wl;
981 extern struct wl_list force_https;
982 extern struct wl_list svil;
983 extern struct strict_transport_tree st_tree;
984 extern struct alias_list aliases;
985 extern struct mime_type_list mtl;
986 extern struct keybinding_list kbl;
987 extern struct sp_list spl;
988 extern struct user_agent_list ua_list;
989 extern struct http_accept_list ha_list;
990 extern struct cmd_alias_list cal;
991 extern struct custom_uri_list cul;
992 extern struct secviolation_list svl;
993 extern struct set_reject_list srl;
994 extern struct settings rs[];
996 extern PangoFontDescription *cmd_font;
997 extern PangoFontDescription *oops_font;
998 extern PangoFontDescription *statusbar_font;
999 extern PangoFontDescription *tabbar_font;