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