2 * Copyright (c) 2010, 2011 Marco Peereboom <marco@peereboom.us>
3 * Copyright (c) 2011 Stevan Andjelkovic <stevan@student.chalmers.se>
4 * Copyright (c) 2010, 2011 Edd Barrett <vext01@gmail.com>
5 * Copyright (c) 2011 Todd T. Fries <todd@fries.net>
6 * Copyright (c) 2011 Raphael Graf <r@undefined.ch>
7 * Copyright (c) 2011 Michal Mazurek <akfaew@jasminek.net>
8 * Copyright (c) 2012 Josh Rickmar <jrick@devio.us>
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 SoupURI
*proxy_uri
= NULL
;
28 PangoFontDescription
*cmd_font
;
29 PangoFontDescription
*oops_font
;
30 PangoFontDescription
*statusbar_font
;
31 PangoFontDescription
*tabbar_font
;
34 int tabless
= 0; /* allow only 1 tab */
35 char search_file
[PATH_MAX
];
36 char command_file
[PATH_MAX
];
37 char runtime_settings
[PATH_MAX
]; /* override of settings */
39 /* settings that require restart */
40 int enable_socket
= 0;
41 int single_instance
= 0; /* only allow one xombrero to run */
42 int fancy_bar
= 1; /* fancy toolbar */
43 int browser_mode
= XT_BM_NORMAL
;
44 int gui_mode
= XT_GM_CLASSIC
;
45 char *statusbar_elems
= NULL
;
46 int window_height
= 768;
47 int window_width
= 1024;
48 int window_maximize
= 0;
49 int icon_size
= 2; /* 1 = smallest, 2+ = bigger */
50 char *resource_dir
= NULL
;
51 char download_dir
[PATH_MAX
];
52 int allow_volatile_cookies
= 0;
53 int save_global_history
= 0; /* save global history to disk */
54 struct user_agent
*user_agent
= NULL
;
55 struct http_accept
*http_accept
= NULL
;
56 int save_rejected_cookies
= 0;
57 gint max_connections
= 25;
58 gint max_host_connections
= 5;
59 int history_autosave
= 0;
60 int edit_mode
= XT_EM_HYBRID
;
61 char *include_config
= NULL
;
63 /* runtime settings */
64 int show_tabs
= XT_DS_SHOW_TABS
; /* show tabs on notebook */
65 int tab_style
= XT_DS_TAB_STYLE
; /* tab bar style */
66 int statusbar_style
= XT_DS_STATUSBAR_STYLE
; /* status bar style */
67 int show_url
= XT_DS_SHOW_URL
; /* show url toolbar on notebook */
68 int show_scrollbars
= XT_DS_SHOW_SCROLLBARS
;
69 int show_statusbar
= XT_DS_SHOW_STATUSBAR
; /* vimperator style status bar */
70 int ctrl_click_focus
= XT_DS_CTRL_CLICK_FOCUS
; /* ctrl click gets focus */
71 int cookies_enabled
= XT_DS_COOKIES_ENABLED
; /* enable cookies */
72 int read_only_cookies
= XT_DS_READ_ONLY_COOKIES
; /* enable to not write cookies */
73 int enable_scripts
= XT_DS_ENABLE_SCRIPTS
;
74 int enable_plugins
= XT_DS_ENABLE_PLUGINS
;
75 gfloat default_zoom_level
= XT_DS_DEFAULT_ZOOM_LEVEL
;
76 char default_script
[PATH_MAX
]; /* special setting - is never g_free'd */
77 int refresh_interval
= XT_DS_REFRESH_INTERVAL
; /* download refresh interval */
78 int enable_plugin_whitelist
= XT_DS_ENABLE_PLUGIN_WHITELIST
;
79 int enable_cookie_whitelist
= XT_DS_ENABLE_COOKIE_WHITELIST
;
80 int enable_js_whitelist
= XT_DS_ENABLE_JS_WHITELIST
;
81 int enable_localstorage
= XT_DS_ENABLE_LOCALSTORAGE
;
82 int session_timeout
= XT_DS_SESSION_TIMEOUT
; /* cookie session timeout */
83 int cookie_policy
= XT_DS_COOKIE_POLICY
;
84 char ssl_ca_file
[PATH_MAX
]; /* special setting - is never g_free'd */
85 gboolean ssl_strict_certs
= XT_DS_SSL_STRICT_CERTS
;
86 gboolean enable_strict_transport
= XT_DS_ENABLE_STRICT_TRANSPORT
;
87 int append_next
= XT_DS_APPEND_NEXT
; /* append tab after current tab */
88 char *home
= NULL
; /* allocated/set at startup */
89 char *search_string
= NULL
; /* allocated/set at startup */
90 char *http_proxy
= NULL
;
91 int http_proxy_starts_enabled
= 1;
92 int download_mode
= XT_DM_START
;
93 int color_visited_uris
= XT_DS_COLOR_VISITED_URIS
;
94 int session_autosave
= XT_DS_SESSION_AUTOSAVE
;
95 int guess_search
= XT_DS_GUESS_SEARCH
;
96 gint enable_spell_checking
= XT_DS_ENABLE_SPELL_CHECKING
;
97 char *spell_check_languages
= NULL
; /* allocated/set at startup */
98 char *url_regex
= NULL
; /* allocated/set at startup */
99 char *encoding
= NULL
; /* allocated/set at startup */
100 int autofocus_onload
= XT_DS_AUTOFOCUS_ONLOAD
;
101 int enable_js_autorun
= XT_DS_ENABLE_JS_AUTORUN
;
102 char *userstyle
= NULL
; /* allocated/set at startup */
103 int userstyle_global
= XT_DS_USERSTYLE_GLOBAL
;
104 int auto_load_images
= XT_DS_AUTO_LOAD_IMAGES
;
105 int enable_autoscroll
= XT_DS_ENABLE_AUTOSCROLL
;
106 int enable_favicon_entry
= XT_DS_ENABLE_FAVICON_ENTRY
;
107 int enable_favicon_tabs
= XT_DS_ENABLE_FAVICON_TABS
;
108 char *external_editor
= NULL
;
109 int referer_mode
= XT_DS_REFERER_MODE
;
110 char *referer_custom
= NULL
;
111 int download_notifications
= XT_DS_DOWNLOAD_NOTIFICATIONS
;
112 int warn_cert_changes
= 0;
113 int allow_insecure_content
= XT_DS_ALLOW_INSECURE_CONTENT
;
114 int allow_insecure_scripts
= XT_DS_ALLOW_INSECURE_SCRIPTS
;
115 int do_not_track
= XT_DS_DO_NOT_TRACK
;
116 int preload_strict_transport
= XT_DS_PRELOAD_STRICT_TRANSPORT
;
117 char *gnutls_priority_string
= XT_DS_GNUTLS_PRIORITY_STRING
;
119 char *cmd_font_name
= NULL
; /* these are all set at startup */
120 char *oops_font_name
= NULL
;
121 char *statusbar_font_name
= NULL
;
122 char *tabbar_font_name
= NULL
;
124 char *get_download_dir(struct settings
*);
125 char *get_default_script(struct settings
*);
126 char *get_runtime_dir(struct settings
*);
127 char *get_tab_style(struct settings
*);
128 char *get_statusbar_style(struct settings
*);
129 char *get_edit_mode(struct settings
*);
130 char *get_download_mode(struct settings
*);
131 char *get_work_dir(struct settings
*);
132 char *get_referer(struct settings
*);
133 char *get_ssl_ca_file(struct settings
*);
134 char *get_userstyle(struct settings
*);
135 char *get_gnutls_priority_string(struct settings
*);
137 int add_cookie_wl(struct settings
*, char *);
138 int add_js_wl(struct settings
*, char *);
139 int add_pl_wl(struct settings
*, char *);
140 int add_mime_type(struct settings
*, char *);
141 int add_alias(struct settings
*, char *);
142 int add_kb(struct settings
*, char *);
143 int add_ua(struct settings
*, char *);
144 int add_http_accept(struct settings
*, char *);
145 int add_cmd_alias(struct settings
*, char *);
146 int add_custom_uri(struct settings
*, char *);
147 int add_force_https(struct settings
*, char *);
149 int set_append_next(char *);
150 int set_autofocus_onload(char *);
151 int set_cmd_font(char *);
152 int set_color_visited_uris(char *);
153 int set_cookie_policy_rt(char *);
154 int set_cookies_enabled(char *);
155 int set_ctrl_click_focus(char *);
156 int set_fancy_bar(char *);
157 int set_home(char *);
158 int set_download_dir(struct settings
*, char *);
159 int set_download_notifications(char *);
160 int set_default_script(struct settings
*, char *);
161 int set_default_script_rt(char *);
162 int set_default_zoom_level(char *);
163 int set_enable_cookie_whitelist(char *);
164 int set_enable_js_autorun(char *);
165 int set_enable_js_whitelist(char *);
166 int set_enable_localstorage(char *);
167 int set_enable_plugins(char *);
168 int set_enable_plugin_whitelist(char *);
169 int set_enable_scripts(char *);
170 int set_enable_spell_checking(char *);
171 int set_enable_strict_transport(char *);
172 int set_encoding_rt(char *);
173 int set_runtime_dir(struct settings
*, char *);
174 int set_tabbar_font(char *value
);
175 int set_tab_style(struct settings
*, char *);
176 int set_tab_style_rt(char *);
177 int set_statusbar_style(struct settings
*, char *);
178 int set_statusbar_style_rt(char *);
179 int set_edit_mode(struct settings
*, char *);
180 int set_work_dir(struct settings
*, char *);
181 int set_auto_load_images(char *);
182 int set_enable_autoscroll(char *);
183 int set_enable_favicon_entry(char *);
184 int set_enable_favicon_tabs(char *);
185 int set_guess_search(char *);
186 int set_download_mode(struct settings
*, char *);
187 int set_download_mode_rt(char *);
188 int set_oops_font(char *);
189 int set_read_only_cookies(char *);
190 int set_referer(struct settings
*, char *);
191 int set_referer_rt(char *);
192 int set_refresh_interval(char *);
193 int set_search_string(char *s
);
194 int set_session_autosave(char *);
195 int set_session_timeout(char *);
196 int set_show_scrollbars(char *);
197 int set_show_statusbar(char *);
198 int set_show_tabs(char *);
199 int set_show_url(char *);
200 int set_spell_check_languages(char *);
201 int set_ssl_ca_file_rt(char *);
202 int set_ssl_strict_certs(char *);
203 int set_statusbar_font(char *);
204 int set_url_regex(char *);
205 int set_userstyle(struct settings
*, char *);
206 int set_userstyle_rt(char *);
207 int set_userstyle_global(char *);
208 int set_external_editor(char *);
209 int set_warn_cert_changes(char *);
210 int set_allow_insecure_content(char *);
211 int set_allow_insecure_scripts(char *);
212 int set_http_proxy(char *);
213 int set_do_not_track(char *);
214 int set_gnutls_priority_string(struct settings
*, char *);
216 int check_allow_insecure_content(char **);
217 int check_allow_insecure_scripts(char **);
218 int check_allow_volatile_cookies(char **);
219 int check_append_next(char **);
220 int check_auto_load_images(char **);
221 int check_autofocus_onload(char **);
222 int check_browser_mode(char **);
223 int check_cmd_font(char **);
224 int check_color_visited_uris(char **);
225 int check_cookie_policy(char **);
226 int check_cookies_enabled(char **);
227 int check_ctrl_click_focus(char **);
228 int check_default_script(char **);
229 int check_default_zoom_level(char **);
230 int check_download_dir(char **);
231 int check_download_mode(char **);
232 int check_download_notifications(char **);
233 int check_edit_mode(char **);
234 int check_enable_autoscroll(char **);
235 int check_enable_cookie_whitelist(char **);
236 int check_enable_favicon_entry(char **);
237 int check_enable_favicon_tabs(char **);
238 int check_enable_js_autorun(char **);
239 int check_enable_js_whitelist(char **);
240 int check_enable_localstorage(char **);
241 int check_enable_plugin_whitelist(char **);
242 int check_enable_plugins(char **);
243 int check_enable_scripts(char **);
244 int check_enable_socket(char **);
245 int check_enable_spell_checking(char **);
246 int check_enable_strict_transport(char **);
247 int check_encoding(char **);
248 int check_external_editor(char **);
249 int check_fancy_bar(char **);
250 int check_gnutls_search_string(char **);
251 int check_guess_search(char **);
252 int check_gui_mode(char **);
253 int check_history_autosave(char **);
254 int check_home(char **);
255 int check_http_proxy(char **);
256 int check_http_proxy_starts_enabled(char **);
257 int check_icon_size(char **);
258 int check_max_connections(char **);
259 int check_max_host_connections(char **);
260 int check_oops_font(char **);
261 int check_read_only_cookies(char **);
262 int check_referer(char **);
263 int check_refresh_interval(char **);
264 int check_resource_dir(char **);
265 int check_save_global_history(char **);
266 int check_save_rejected_cookies(char **);
267 int check_search_string(char **);
268 int check_session_autosave(char **);
269 int check_session_timeout(char **);
270 int check_show_scrollbars(char **);
271 int check_show_statusbar(char **);
272 int check_show_tabs(char **);
273 int check_show_url(char **);
274 int check_single_instance(char **);
275 int check_spell_check_languages(char **);
276 int check_ssl_ca_file(char **);
277 int check_ssl_strict_certs(char **);
278 int check_statusbar_elems(char **);
279 int check_statusbar_font(char **);
280 int check_statusbar_style(char **);
281 int check_tab_style(char **);
282 int check_tabbar_font(char **);
283 int check_url_regex(char **);
284 int check_userstyle(char **);
285 int check_userstyle_global(char **);
286 int check_warn_cert_changes(char **);
287 int check_window_height(char **);
288 int check_window_maximize(char **);
289 int check_window_width(char **);
290 int check_work_dir(char **);
291 int check_do_not_track(char **);
293 void walk_mime_type(struct settings
*, void (*)(struct settings
*,
294 char *, void *), void *);
295 void walk_alias(struct settings
*, void (*)(struct settings
*,
296 char *, void *), void *);
297 void walk_cookie_wl(struct settings
*, void (*)(struct settings
*,
298 char *, void *), void *);
299 void walk_js_wl(struct settings
*, void (*)(struct settings
*,
300 char *, void *), void *);
301 void walk_pl_wl(struct settings
*, void (*)(struct settings
*,
302 char *, void *), void *);
303 void walk_kb(struct settings
*, void (*)(struct settings
*, char *,
305 void walk_ua(struct settings
*, void (*)(struct settings
*, char *,
307 void walk_http_accept(struct settings
*, void (*)(struct settings
*,
308 char *, void *), void *);
309 void walk_cmd_alias(struct settings
*, void (*)(struct settings
*,
310 char *, void *), void *);
311 void walk_custom_uri(struct settings
*, void (*)(struct settings
*,
312 char *, void *), void *);
313 void walk_force_https(struct settings
*, void (*)(struct settings
*,
314 char *, void *), void *);
316 struct special s_browser_mode
= {
320 { "kiosk", "normal", "whitelist", NULL
}
323 struct special s_gui_mode
= {
327 { "classic", "minimal", NULL
}
330 struct special s_cookie
= {
334 { "accept", "no3rdparty", "reject", NULL
}
337 struct special s_alias
= {
344 struct special s_cmd_alias
= {
351 struct special s_mime
= {
358 struct special s_js
= {
365 struct special s_pl
= {
372 struct special s_kb
= {
379 struct special s_cookie_wl
= {
386 struct special s_uri
= {
393 struct special s_default_script
= {
400 struct special s_ssl_ca_file
= {
407 struct special s_download_dir
= {
414 struct special s_work_dir
= {
421 struct special s_tab_style
= {
425 { "compact", "normal", NULL
}
428 struct special s_statusbar_style
= {
432 { "title", "url", NULL
}
435 struct special s_edit_mode
= {
439 { "hybrid", "vi", NULL
}
442 struct special s_download_mode
= {
446 { "add", "ask", "start", NULL
}
449 struct special s_ua
= {
456 struct special s_http_accept
= {
463 struct special s_referer
= {
467 { "always", "never", "same-domain", "same-fqdn", NULL
}
470 struct special s_userstyle
= {
477 struct special s_force_https
= {
484 struct special s_gnutls_priority_string
= {
485 set_gnutls_priority_string
,
486 get_gnutls_priority_string
,
491 struct settings rs
[] = {
492 { "allow_insecure_content", XT_S_BOOL
, 0, &allow_insecure_content
, NULL
, NULL
, NULL
, set_allow_insecure_content
, check_allow_insecure_content
, TT_ALLOW_INSECURE_CONTENT
},
493 { "allow_insecure_scripts", XT_S_BOOL
, 0, &allow_insecure_scripts
, NULL
, NULL
, NULL
, set_allow_insecure_scripts
, check_allow_insecure_scripts
, TT_ALLOW_INSECURE_SCRIPTS
},
494 { "allow_volatile_cookies", XT_S_BOOL
, 0, &allow_volatile_cookies
, NULL
, NULL
, NULL
, NULL
, check_allow_volatile_cookies
, TT_ALLOW_VOLATILE_COOKIES
},
495 { "append_next", XT_S_BOOL
, 0, &append_next
, NULL
, NULL
, NULL
, set_append_next
, check_append_next
, TT_APPEND_NEXT
},
496 { "auto_load_images", XT_S_BOOL
, 0, &auto_load_images
, NULL
, NULL
, NULL
, set_auto_load_images
, check_auto_load_images
, TT_AUTO_LOAD_IMAGES
},
497 { "autofocus_onload", XT_S_BOOL
, 0, &autofocus_onload
, NULL
, NULL
, NULL
, set_autofocus_onload
, check_autofocus_onload
, TT_AUTOFOCUS_ONLOAD
},
498 { "browser_mode", XT_S_STR
, 0, NULL
, NULL
,&s_browser_mode
, NULL
, NULL
, check_browser_mode
, TT_BROWSER_MODE
},
499 { "cmd_font", XT_S_STR
, 0, NULL
, &cmd_font_name
, NULL
, NULL
, set_cmd_font
, check_cmd_font
, TT_CMD_FONT
},
500 { "color_visited_uris", XT_S_BOOL
, 0, &color_visited_uris
, NULL
, NULL
, NULL
, set_color_visited_uris
, check_color_visited_uris
, TT_COLOR_VISITED_URIS
},
501 { "cookie_policy", XT_S_STR
, 0, NULL
, NULL
,&s_cookie
, NULL
, set_cookie_policy_rt
, check_cookie_policy
, TT_COOKIE_POLICY
},
502 { "cookies_enabled", XT_S_BOOL
, 0, &cookies_enabled
, NULL
, NULL
, NULL
, set_cookies_enabled
, check_cookies_enabled
, TT_COOKIES_ENABLED
},
503 { "ctrl_click_focus", XT_S_BOOL
, 0, &ctrl_click_focus
, NULL
, NULL
, NULL
, set_ctrl_click_focus
, check_ctrl_click_focus
, TT_CTRL_CLICK_FOCUS
},
504 { "default_script", XT_S_STR
, 1, NULL
, NULL
,&s_default_script
, NULL
, set_default_script_rt
, check_default_script
, TT_DEFAULT_SCRIPT
},
505 { "default_zoom_level", XT_S_FLOAT
, 0, NULL
, NULL
, NULL
, &default_zoom_level
, set_default_zoom_level
, check_default_zoom_level
, TT_DEFAULT_ZOOM_LEVEL
},
506 { "do_not_track", XT_S_BOOL
, 0, &do_not_track
, NULL
, NULL
, NULL
, set_do_not_track
, check_do_not_track
, TT_DO_NOT_TRACK
},
507 { "download_dir", XT_S_STR
, 0, NULL
, NULL
,&s_download_dir
, NULL
, NULL
, check_download_dir
, TT_DOWNLOAD_DIR
},
508 { "download_mode", XT_S_STR
, 0, NULL
, NULL
,&s_download_mode
, NULL
, set_download_mode_rt
, check_download_mode
, TT_DOWNLOAD_MODE
},
509 { "download_notifications", XT_S_BOOL
, 0, &download_notifications
, NULL
, NULL
, NULL
, set_download_notifications
, check_download_notifications
, TT_DOWNLOAD_NOTIFICATIONS
},
510 { "edit_mode", XT_S_STR
, 0, NULL
, NULL
,&s_edit_mode
, NULL
, NULL
, check_edit_mode
, NULL
},
511 { "enable_autoscroll", XT_S_BOOL
, 0, &enable_autoscroll
, NULL
, NULL
, NULL
, set_enable_autoscroll
, check_enable_autoscroll
, TT_ENABLE_AUTOSCROLL
},
512 { "enable_cookie_whitelist", XT_S_BOOL
, 0, &enable_cookie_whitelist
, NULL
, NULL
, NULL
, set_enable_cookie_whitelist
, check_enable_cookie_whitelist
, TT_ENABLE_COOKIE_WHITELIST
},
513 { "enable_favicon_entry", XT_S_BOOL
, 0, &enable_favicon_entry
, NULL
, NULL
, NULL
, set_enable_favicon_entry
, check_enable_favicon_entry
, TT_ENABLE_FAVICON_ENTRY
},
514 { "enable_favicon_tabs", XT_S_BOOL
, 0, &enable_favicon_tabs
, NULL
, NULL
, NULL
, set_enable_favicon_tabs
, check_enable_favicon_tabs
, TT_ENABLE_FAVICON_TABS
},
515 { "enable_js_autorun", XT_S_BOOL
, 0, &enable_js_autorun
, NULL
, NULL
, NULL
, set_enable_js_autorun
, check_enable_js_autorun
, TT_ENABLE_JS_AUTORUN
},
516 { "enable_js_whitelist", XT_S_BOOL
, 0, &enable_js_whitelist
, NULL
, NULL
, NULL
, set_enable_js_whitelist
, check_enable_js_whitelist
, TT_ENABLE_JS_WHITELIST
},
517 { "enable_localstorage", XT_S_BOOL
, 0, &enable_localstorage
, NULL
, NULL
, NULL
, set_enable_localstorage
, check_enable_localstorage
, TT_ENABLE_LOCALSTORAGE
},
518 { "enable_plugin_whitelist", XT_S_BOOL
, 0, &enable_plugin_whitelist
, NULL
, NULL
, NULL
, set_enable_plugin_whitelist
, check_enable_plugin_whitelist
, TT_ENABLE_PLUGIN_WHITELIST
},
519 { "enable_plugins", XT_S_BOOL
, 0, &enable_plugins
, NULL
, NULL
, NULL
, set_enable_plugins
, check_enable_plugins
, TT_ENABLE_PLUGINS
},
520 { "enable_scripts", XT_S_BOOL
, 0, &enable_scripts
, NULL
, NULL
, NULL
, set_enable_scripts
, check_enable_scripts
, TT_ENABLE_SCRIPTS
},
521 { "enable_socket", XT_S_BOOL
,XT_SF_RESTART
,&enable_socket
, NULL
, NULL
, NULL
, NULL
, check_enable_socket
, TT_ENABLE_SOCKET
},
522 { "enable_spell_checking", XT_S_BOOL
, 0, &enable_spell_checking
, NULL
, NULL
, NULL
, set_enable_spell_checking
, check_enable_spell_checking
, TT_ENABLE_SPELL_CHECKING
},
523 { "enable_strict_transport", XT_S_BOOL
, 0, &enable_strict_transport
, NULL
, NULL
, NULL
, set_enable_strict_transport
, check_enable_strict_transport
, TT_ENABLE_STRICT_TRANSPORT
},
524 { "encoding", XT_S_STR
, 0, NULL
, &encoding
, NULL
, NULL
, NULL
, check_encoding
, TT_ENCODING
},
525 { "external_editor", XT_S_STR
,0, NULL
, &external_editor
, NULL
, NULL
, set_external_editor
, check_external_editor
, TT_EXTERNAL_EDITOR
},
526 { "fancy_bar", XT_S_BOOL
,XT_SF_RESTART
,&fancy_bar
, NULL
, NULL
, NULL
, set_fancy_bar
, check_fancy_bar
, TT_FANCY_BAR
},
527 { "gnutls_priority_string", XT_S_STR
, 0, NULL
, NULL
,&s_gnutls_priority_string
, NULL
, NULL
, check_gnutls_search_string
, TT_GNUTLS_PRIORITY_STRING
},
528 { "guess_search", XT_S_BOOL
, 0, &guess_search
, NULL
, NULL
, NULL
, set_guess_search
, check_guess_search
, TT_GUESS_SEARCH
},
529 { "gui_mode", XT_S_STR
, 0, NULL
, NULL
,&s_gui_mode
, NULL
, NULL
, check_gui_mode
, TT_GUI_MODE
},
530 { "history_autosave", XT_S_BOOL
, 0, &history_autosave
, NULL
, NULL
, NULL
, NULL
, check_history_autosave
, TT_HISTORY_AUTOSAVE
},
531 { "home", XT_S_STR
, 0, NULL
, &home
, NULL
, NULL
, set_home
, check_home
, TT_HOME
},
532 { "http_proxy", XT_S_STR
, 0, NULL
, &http_proxy
, NULL
, NULL
, set_http_proxy
, check_http_proxy
, TT_HTTP_PROXY
},
533 { "http_proxy_starts_enabled", XT_S_BOOL
, 0, &http_proxy_starts_enabled
, NULL
, NULL
, NULL
, NULL
, check_http_proxy_starts_enabled
, TT_HTTP_PROXY_STARTS_ENABLED
},
534 { "icon_size", XT_S_INT
, 0, &icon_size
, NULL
, NULL
, NULL
, NULL
, check_icon_size
, TT_ICON_SIZE
},
535 { "include_config", XT_S_STR
, XT_SF_INVISIBLE
, NULL
, &include_config
, NULL
, NULL
, NULL
, NULL
},
536 { "max_connections", XT_S_INT
, XT_SF_RESTART
,&max_connections
, NULL
, NULL
, NULL
, NULL
, check_max_connections
, TT_MAX_CONNECTIONS
},
537 { "max_host_connections", XT_S_INT
, XT_SF_RESTART
,&max_host_connections
, NULL
, NULL
, NULL
, NULL
, check_max_host_connections
, TT_MAX_HOST_CONNECTIONS
},
538 { "oops_font", XT_S_STR
, 0, NULL
, &oops_font_name
, NULL
, NULL
, set_oops_font
, check_oops_font
, TT_OOPS_FONT
},
539 { "preload_strict_transport", XT_S_BOOL
, 0, &preload_strict_transport
, NULL
, NULL
, NULL
, NULL
, NULL
, TT_PRELOAD_STRICT_TRANSPORT
},
540 { "read_only_cookies", XT_S_BOOL
, 0, &read_only_cookies
, NULL
, NULL
, NULL
, NULL
, check_read_only_cookies
, TT_READ_ONLY_COOKIES
},
541 { "referer", XT_S_STR
, 0, NULL
, NULL
,&s_referer
, NULL
, set_referer_rt
, check_referer
, TT_REFERER
},
542 { "refresh_interval", XT_S_INT
, 0, &refresh_interval
, NULL
, NULL
, NULL
, set_refresh_interval
, check_refresh_interval
, TT_REFRESH_INTERVAL
},
543 { "resource_dir", XT_S_STR
, 0, NULL
, &resource_dir
, NULL
, NULL
, NULL
, check_resource_dir
, TT_RESOURCE_DIR
},
544 { "save_global_history", XT_S_BOOL
,XT_SF_RESTART
,&save_global_history
, NULL
, NULL
, NULL
, NULL
, check_save_global_history
, TT_SAVE_GLOBAL_HISTORY
},
545 { "save_rejected_cookies", XT_S_BOOL
,XT_SF_RESTART
,&save_rejected_cookies
, NULL
, NULL
, NULL
, NULL
, check_save_rejected_cookies
, TT_SAVE_REJECTED_COOKIES
},
546 { "search_string", XT_S_STR
, 0, NULL
, &search_string
, NULL
, NULL
, set_search_string
, check_search_string
, TT_SEARCH_STRING
},
547 { "session_autosave", XT_S_BOOL
, 0, &session_autosave
, NULL
, NULL
, NULL
, set_session_autosave
, check_session_autosave
, TT_SESSION_AUTOSAVE
},
548 { "session_timeout", XT_S_INT
, 0, &session_timeout
, NULL
, NULL
, NULL
, set_session_timeout
, check_session_timeout
, TT_SESSION_TIMEOUT
},
549 { "show_scrollbars", XT_S_BOOL
, 0, &show_scrollbars
, NULL
, NULL
, NULL
, set_show_scrollbars
, check_show_scrollbars
, TT_SHOW_SCROLLBARS
},
550 { "show_statusbar", XT_S_BOOL
, 0, &show_statusbar
, NULL
, NULL
, NULL
, set_show_statusbar
, check_show_statusbar
, TT_SHOW_STATUSBAR
},
551 { "show_tabs", XT_S_BOOL
, 0, &show_tabs
, NULL
, NULL
, NULL
, set_show_tabs
, check_show_tabs
, TT_SHOW_TABS
},
552 { "show_url", XT_S_BOOL
, 0, &show_url
, NULL
, NULL
, NULL
, set_show_url
, check_show_url
, TT_SHOW_URL
},
553 { "single_instance", XT_S_BOOL
,XT_SF_RESTART
,&single_instance
, NULL
, NULL
, NULL
, NULL
, check_single_instance
, TT_SINGLE_INSTANCE
},
554 { "spell_check_languages", XT_S_STR
, 0, NULL
, &spell_check_languages
, NULL
, NULL
, set_spell_check_languages
, check_spell_check_languages
, TT_SPELL_CHECK_LANGUAGES
},
555 { "ssl_ca_file", XT_S_STR
, 0, NULL
, NULL
,&s_ssl_ca_file
, NULL
, set_ssl_ca_file_rt
, check_ssl_ca_file
, TT_SSL_CA_FILE
},
556 { "ssl_strict_certs", XT_S_BOOL
, 0, &ssl_strict_certs
, NULL
, NULL
, NULL
, set_ssl_strict_certs
, check_ssl_strict_certs
, TT_SSL_STRICT_CERTS
},
557 { "statusbar_elems", XT_S_STR
, 0, NULL
, &statusbar_elems
, NULL
, NULL
, NULL
, check_statusbar_elems
, TT_STATUSBAR_ELEMS
},
558 { "statusbar_font", XT_S_STR
, 0, NULL
, &statusbar_font_name
, NULL
, NULL
, set_statusbar_font
, check_statusbar_font
, TT_STATUSBAR_FONT
},
559 { "statusbar_style", XT_S_STR
, 0, NULL
, NULL
,&s_statusbar_style
, NULL
, set_statusbar_style_rt
, check_statusbar_style
, TT_STATUSBAR_STYLE
},
560 { "tab_style", XT_S_STR
, 0, NULL
, NULL
,&s_tab_style
, NULL
, set_tab_style_rt
, check_tab_style
, TT_TAB_STYLE
},
561 { "tabbar_font", XT_S_STR
, 0, NULL
, &tabbar_font_name
, NULL
, NULL
, set_tabbar_font
, check_tabbar_font
, TT_TABBAR_FONT
},
562 { "url_regex", XT_S_STR
, 0, NULL
, &url_regex
, NULL
, NULL
, set_url_regex
, check_url_regex
, TT_URL_REGEX
},
563 { "userstyle", XT_S_STR
, 0, NULL
, NULL
,&s_userstyle
, NULL
, set_userstyle_rt
, check_userstyle
, TT_USERSTYLE
},
564 { "userstyle_global", XT_S_BOOL
, 0, &userstyle_global
, NULL
, NULL
, NULL
, set_userstyle_global
, check_userstyle_global
, TT_USERSTYLE_GLOBAL
},
565 { "warn_cert_changes", XT_S_BOOL
, 0, &warn_cert_changes
, NULL
, NULL
, NULL
, set_warn_cert_changes
, check_warn_cert_changes
, TT_WARN_CERT_CHANGES
},
566 { "window_height", XT_S_INT
, 0, &window_height
, NULL
, NULL
, NULL
, NULL
, check_window_height
, TT_WINDOW_HEIGHT
},
567 { "window_maximize", XT_S_BOOL
, 0, &window_maximize
, NULL
, NULL
, NULL
, NULL
, check_window_maximize
, TT_WINDOW_MAXIMIZE
},
568 { "window_width", XT_S_INT
, 0, &window_width
, NULL
, NULL
, NULL
, NULL
, check_window_width
, TT_WINDOW_WIDTH
},
569 { "work_dir", XT_S_STR
, 0, NULL
, NULL
,&s_work_dir
, NULL
, NULL
, check_work_dir
, TT_WORK_DIR
},
571 /* special settings */
572 { "alias", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_alias
, NULL
, NULL
},
573 { "cmd_alias", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_cmd_alias
, NULL
, NULL
},
574 { "cookie_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_cookie_wl
, NULL
, NULL
},
575 { "custom_uri", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_uri
, NULL
, NULL
},
576 { "force_https", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_force_https
, NULL
, NULL
},
577 { "http_accept", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_http_accept
, NULL
, NULL
},
578 { "js_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_js
, NULL
, NULL
},
579 { "keybinding", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_kb
, NULL
, NULL
},
580 { "mime_type", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_mime
, NULL
, NULL
},
581 { "pl_wl", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_pl
, NULL
, NULL
},
582 { "user_agent", XT_S_STR
, XT_SF_RUNTIME
, NULL
, NULL
, &s_ua
, NULL
, NULL
},
586 set_http_proxy(char *proxy
)
590 /* see if we need to clear it */
591 if (proxy
== NULL
|| strlen(proxy
) == 0) {
596 uri
= soup_uri_new(proxy
);
597 if (uri
== NULL
|| !SOUP_URI_VALID_FOR_HTTP(uri
))
608 check_http_proxy(char **tt
)
610 *tt
= g_strdup("Default: (empty)");
611 return (g_strcmp0(http_proxy
, NULL
));
615 check_http_proxy_starts_enabled(char **tt
)
617 *tt
= g_strdup("Default: Enabled");
618 return (http_proxy_starts_enabled
!= 1);
622 check_icon_size(char **tt
)
624 *tt
= g_strdup_printf("Default: %d", 2);
625 return (icon_size
!= 2);
629 check_max_connections(char **tt
)
631 *tt
= g_strdup_printf("Default: %d", 25);
632 return (max_connections
!= 25);
636 check_max_host_connections(char **tt
)
638 *tt
= g_strdup_printf("Default: %d", 5);
639 return (max_host_connections
!= 5);
643 set_default_zoom_level(char *value
)
645 struct karg args
= {0};
648 if (value
== NULL
|| strlen(value
) == 0)
649 default_zoom_level
= XT_DS_DEFAULT_ZOOM_LEVEL
;
651 default_zoom_level
= g_strtod(value
, NULL
);
652 args
.i
= 100; /* adjust = 100 percent for no additional adjustment */
653 TAILQ_FOREACH(t
, &tabs
, entry
)
659 check_default_zoom_level(char **tt
)
661 *tt
= g_strdup_printf("Default: %f", XT_DS_DEFAULT_ZOOM_LEVEL
);
662 return (default_zoom_level
!= XT_DS_DEFAULT_ZOOM_LEVEL
);
666 set_cookies_enabled(char *value
)
671 if (value
== NULL
|| strlen(value
) == 0)
672 cookies_enabled
= XT_DS_COOKIES_ENABLED
;
674 tmp
= strtonum(value
, 0, 1, &errstr
);
677 cookies_enabled
= tmp
;
683 check_cookies_enabled(char **tt
)
685 *tt
= g_strdup_printf("Default: %s",
686 XT_DS_COOKIES_ENABLED
? "Enabled" : "Disabled");
687 return (cookies_enabled
!= XT_DS_COOKIES_ENABLED
);
691 set_append_next(char *value
)
696 if (value
== NULL
|| strlen(value
) == 0)
697 append_next
= XT_DS_APPEND_NEXT
;
699 tmp
= strtonum(value
, 0, 1, &errstr
);
708 check_append_next(char **tt
)
710 *tt
= g_strdup_printf("Default: %s",
711 XT_DS_APPEND_NEXT
? "Enabled" : "Disabled");
712 return (append_next
!= XT_DS_APPEND_NEXT
);
716 set_cmd_font(char *value
)
721 g_free(cmd_font_name
);
723 pango_font_description_free(cmd_font
);
724 if (value
== NULL
|| strlen(value
) == 0)
725 cmd_font_name
= g_strdup(XT_DS_CMD_FONT_NAME
);
727 cmd_font_name
= g_strdup(value
);
728 cmd_font
= pango_font_description_from_string(cmd_font_name
);
729 TAILQ_FOREACH(t
, &tabs
, entry
)
730 gtk_widget_modify_font(GTK_WIDGET(t
->cmd
), cmd_font
);
735 check_cmd_font(char **tt
)
737 *tt
= g_strdup_printf("Default: %s", XT_DS_CMD_FONT_NAME
);
738 return (g_strcmp0(cmd_font_name
, XT_DS_CMD_FONT_NAME
));
742 set_oops_font(char *value
)
747 g_free(oops_font_name
);
749 pango_font_description_free(oops_font
);
750 if (value
== NULL
|| strlen(value
) == 0)
751 cmd_font_name
= g_strdup(XT_DS_OOPS_FONT_NAME
);
753 oops_font_name
= g_strdup(value
);
754 oops_font
= pango_font_description_from_string(oops_font_name
);
755 TAILQ_FOREACH(t
, &tabs
, entry
)
756 gtk_widget_modify_font(GTK_WIDGET(t
->oops
), oops_font
);
761 check_oops_font(char **tt
)
763 *tt
= g_strdup_printf("Default: %s", XT_DS_OOPS_FONT_NAME
);
764 return (g_strcmp0(oops_font_name
, XT_DS_OOPS_FONT_NAME
));
768 check_read_only_cookies(char **tt
)
770 *tt
= g_strdup_printf("Default: %s",
771 XT_DS_READ_ONLY_COOKIES
? "Enabled" : "Disabled");
772 return (read_only_cookies
!= XT_DS_READ_ONLY_COOKIES
);
776 set_statusbar_font(char *value
)
780 if (statusbar_font_name
)
781 g_free(statusbar_font_name
);
783 pango_font_description_free(statusbar_font
);
784 if (value
== NULL
|| strlen(value
) == 0)
785 statusbar_font_name
= g_strdup(XT_DS_STATUSBAR_FONT_NAME
);
787 statusbar_font_name
= g_strdup(value
);
788 statusbar_font
= pango_font_description_from_string(
789 statusbar_font_name
);
790 TAILQ_FOREACH(t
, &tabs
, entry
) {
791 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.uri
),
793 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.buffercmd
),
795 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.zoom
),
797 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.position
),
799 gtk_widget_modify_font(GTK_WIDGET(t
->sbe
.proxy
),
806 check_statusbar_font(char **tt
)
808 *tt
= g_strdup_printf("Default: %s", XT_DS_STATUSBAR_FONT_NAME
);
809 return (g_strcmp0(statusbar_font_name
, XT_DS_STATUSBAR_FONT_NAME
));
813 set_tabbar_font(char *value
)
817 if (tabbar_font_name
)
818 g_free(tabbar_font_name
);
820 pango_font_description_free(tabbar_font
);
821 if (value
== NULL
|| strlen(value
) == 0)
822 tabbar_font_name
= g_strdup(XT_DS_TABBAR_FONT_NAME
);
824 tabbar_font_name
= g_strdup(value
);
825 tabbar_font
= pango_font_description_from_string(tabbar_font_name
);
826 TAILQ_FOREACH(t
, &tabs
, entry
)
827 gtk_widget_modify_font(GTK_WIDGET(t
->tab_elems
.label
),
833 check_tabbar_font(char **tt
)
835 *tt
= g_strdup_printf("Default: %s", XT_DS_TABBAR_FONT_NAME
);
836 return (g_strcmp0(tabbar_font_name
, XT_DS_TABBAR_FONT_NAME
));
840 set_color_visited_uris(char *value
)
845 if (value
== NULL
|| strlen(value
) == 0)
846 color_visited_uris
= XT_DS_COLOR_VISITED_URIS
;
848 tmp
= strtonum(value
, 0, 1, &errstr
);
851 color_visited_uris
= tmp
;
857 check_color_visited_uris(char **tt
)
859 *tt
= g_strdup_printf("Default: %s",
860 XT_DS_COLOR_VISITED_URIS
? "Enabled" : "Disabled");
861 return (color_visited_uris
!= XT_DS_COLOR_VISITED_URIS
);
865 set_home(char *value
)
869 if (value
== NULL
|| strlen(value
) == 0)
870 home
= g_strdup(XT_DS_HOME
);
872 home
= g_strdup(value
);
877 check_home(char **tt
)
879 *tt
= g_strdup_printf("Default: %s", XT_DS_HOME
);
880 return (g_strcmp0(home
, XT_DS_HOME
));
884 set_search_string(char *value
)
889 g_free(search_string
);
890 if (value
== NULL
|| strlen(value
) == 0) {
891 search_string
= NULL
;
892 TAILQ_FOREACH(t
, &tabs
, entry
)
893 gtk_widget_hide(t
->search_entry
);
895 search_string
= g_strdup(value
);
896 TAILQ_FOREACH(t
, &tabs
, entry
)
897 gtk_widget_show(t
->search_entry
);
903 check_search_string(char **tt
)
905 *tt
= g_strdup_printf("Default: %s", XT_DS_SEARCH_STRING
);
906 return (g_strcmp0(search_string
, XT_DS_SEARCH_STRING
));
910 get_settings_size(void)
916 get_setting_name(int i
)
924 get_as_string(struct settings
*s
)
931 if (s
->s
&& s
->s
->get
)
933 else if (s
->type
== XT_S_INT
)
934 r
= g_strdup_printf("%d", *s
->ival
);
935 else if (s
->type
== XT_S_STR
)
936 r
= g_strdup(*s
->sval
);
937 else if (s
->type
== XT_S_FLOAT
)
938 r
= g_strdup_printf("%f", *s
->fval
);
939 else if (s
->type
== XT_S_BOOL
)
940 r
= g_strdup_printf("%d", *s
->ival
);
942 r
= g_strdup_printf("INVALID TYPE");
948 settings_walk(void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
953 for (i
= 0; i
< LENGTH(rs
); i
++) {
954 if (rs
[i
].s
&& rs
[i
].s
->walk
)
955 rs
[i
].s
->walk(&rs
[i
], cb
, cb_args
);
957 s
= get_as_string(&rs
[i
]);
958 cb(&rs
[i
], s
, cb_args
);
965 check_allow_volatile_cookies(char **tt
)
967 *tt
= g_strdup("Default: Disabled");
968 return (allow_volatile_cookies
!= 0);
972 set_browser_mode(struct settings
*s
, char *val
)
974 if (!strcmp(val
, "whitelist")) {
975 browser_mode
= XT_BM_WHITELIST
;
976 allow_volatile_cookies
= 0;
977 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
;
979 enable_cookie_whitelist
= 1;
980 enable_plugin_whitelist
= 1;
982 read_only_cookies
= 0;
983 save_rejected_cookies
= 0;
984 session_timeout
= 3600;
986 enable_js_whitelist
= 1;
987 enable_localstorage
= 0;
988 referer_mode
= XT_REFERER_SAME_DOMAIN
;
989 allow_insecure_content
= 0;
990 allow_insecure_scripts
= 0;
992 } else if (!strcmp(val
, "normal")) {
993 browser_mode
= XT_BM_NORMAL
;
994 allow_volatile_cookies
= 0;
995 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
997 enable_cookie_whitelist
= 0;
998 enable_plugin_whitelist
= 0;
1000 read_only_cookies
= 0;
1001 save_rejected_cookies
= 0;
1002 session_timeout
= 3600;
1004 enable_js_whitelist
= 0;
1005 enable_localstorage
= 1;
1006 referer_mode
= XT_REFERER_ALWAYS
;
1007 allow_insecure_content
= 1;
1008 allow_insecure_scripts
= 1;
1010 } else if (!strcmp(val
, "kiosk")) {
1011 browser_mode
= XT_BM_KIOSK
;
1012 allow_volatile_cookies
= 0;
1013 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
1014 cookies_enabled
= 1;
1015 enable_cookie_whitelist
= 0;
1016 enable_plugin_whitelist
= 0;
1018 read_only_cookies
= 0;
1019 save_rejected_cookies
= 0;
1020 session_timeout
= 3600;
1022 enable_js_whitelist
= 0;
1023 enable_localstorage
= 1;
1024 referer_mode
= XT_REFERER_ALWAYS
;
1025 allow_insecure_content
= 1;
1026 allow_insecure_scripts
= 1;
1037 get_browser_mode(struct settings
*s
)
1041 if (browser_mode
== XT_BM_WHITELIST
)
1042 r
= g_strdup("whitelist");
1043 else if (browser_mode
== XT_BM_NORMAL
)
1044 r
= g_strdup("normal");
1045 else if (browser_mode
== XT_BM_KIOSK
)
1046 r
= g_strdup("kiosk");
1054 check_browser_mode(char **tt
)
1056 *tt
= g_strdup("Default: normal");
1057 return (browser_mode
!= XT_BM_NORMAL
);
1061 set_gui_mode(struct settings
*s
, char *val
)
1063 if (!strcmp(val
, "classic")) {
1066 tab_style
= XT_TABS_NORMAL
;
1069 show_scrollbars
= 1;
1070 } else if (!strcmp(val
, "minimal")) {
1073 tab_style
= XT_TABS_COMPACT
;
1076 show_scrollbars
= 0;
1084 get_gui_mode(struct settings
*s
)
1088 if (gui_mode
== XT_GM_CLASSIC
)
1089 r
= g_strdup("classic");
1090 else if (browser_mode
== XT_GM_MINIMAL
)
1091 r
= g_strdup("minimal");
1099 check_gui_mode(char **tt
)
1101 *tt
= g_strdup("Default: classic");
1102 return (gui_mode
!= XT_GM_CLASSIC
);
1106 check_history_autosave(char **tt
)
1108 *tt
= g_strdup("Default: Disabled");
1109 return (history_autosave
!= 0);
1113 set_cookie_policy(struct settings
*s
, char *val
)
1115 if (!strcmp(val
, "no3rdparty"))
1116 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
;
1117 else if (!strcmp(val
, "accept"))
1118 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
;
1119 else if (!strcmp(val
, "reject"))
1120 cookie_policy
= SOUP_COOKIE_JAR_ACCEPT_NEVER
;
1128 set_cookie_policy_rt(char *value
)
1130 if (value
== NULL
|| strlen(value
) == 0)
1131 cookie_policy
= XT_DS_COOKIE_POLICY
;
1132 else if (set_cookie_policy(NULL
, value
))
1134 g_object_set(G_OBJECT(s_cookiejar
), SOUP_COOKIE_JAR_ACCEPT_POLICY
,
1135 cookie_policy
, (void *)NULL
);
1140 check_cookie_policy(char **tt
)
1142 *tt
= g_strdup("Default (depends on browser_mode):\n"
1143 "\tnormal:\talways\n"
1144 "\twhitelist:\tno3rdparty\n"
1145 "\tkiosk:\talways");
1146 if (browser_mode
== XT_BM_WHITELIST
&&
1147 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
)
1149 if (browser_mode
== XT_BM_NORMAL
&&
1150 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1152 if (browser_mode
== XT_BM_KIOSK
&&
1153 cookie_policy
!= SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1159 get_cookie_policy(struct settings
*s
)
1163 if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
)
1164 r
= g_strdup("no3rdparty");
1165 else if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_ALWAYS
)
1166 r
= g_strdup("accept");
1167 else if (cookie_policy
== SOUP_COOKIE_JAR_ACCEPT_NEVER
)
1168 r
= g_strdup("reject");
1176 get_default_script(struct settings
*s
)
1178 if (default_script
[0] == '\0')
1180 return (g_strdup(default_script
));
1184 set_default_script(struct settings
*s
, char *val
)
1186 expand_tilde(default_script
, sizeof default_script
, val
);
1191 check_default_script(char **tt
)
1193 *tt
= g_strdup("Default: (empty)");
1194 return (g_strcmp0(default_script
, XT_DS_DEFAULT_SCRIPT
));
1198 set_default_script_rt(char *value
)
1200 if (value
== NULL
|| strlen(value
) == 0)
1201 return set_default_script(NULL
, "");
1202 return (set_default_script(NULL
, value
));
1206 set_do_not_track(char *value
)
1211 if (value
== NULL
|| strlen(value
) == 0)
1212 do_not_track
= XT_DS_DO_NOT_TRACK
;
1214 tmp
= strtonum(value
, 0, 1, &errstr
);
1223 check_do_not_track(char **tt
)
1225 *tt
= g_strdup("Default (depends on browser_mode):\n"
1226 "\tnormal:\tDisabled\n"
1227 "\twhitelist:\tEnabled\n"
1228 "\tkiosk:\tDisabled");
1229 if (browser_mode
== XT_BM_WHITELIST
&& do_not_track
!= 1)
1231 if (browser_mode
== XT_BM_NORMAL
&& do_not_track
!= 0)
1233 if (browser_mode
== XT_BM_KIOSK
&& do_not_track
!= 0)
1239 get_download_dir(struct settings
*s
)
1241 if (download_dir
[0] == '\0')
1243 return (g_strdup(download_dir
));
1247 set_download_dir(struct settings
*s
, char *val
)
1249 expand_tilde(download_dir
, sizeof download_dir
, val
);
1254 check_download_dir(char **tt
)
1257 char buf
[PATH_MAX
] = {0};
1259 /* XXX this might need some additonal magic on windows */
1260 if ((pwd
= getpwuid(getuid())) == NULL
)
1262 snprintf(buf
, sizeof buf
, "%s" PS
"downloads", pwd
->pw_dir
);
1263 *tt
= g_strdup_printf("Default: %s", buf
);
1264 return (g_strcmp0(download_dir
, buf
));
1268 add_alias(struct settings
*s
, char *line
)
1271 struct alias
*a
= NULL
;
1273 if (s
== NULL
|| line
== NULL
) {
1274 show_oops(NULL
, "add_alias invalid parameters");
1279 a
= g_malloc(sizeof(*a
));
1281 if ((alias
= strsep(&l
, " \t,")) == NULL
|| l
== NULL
) {
1282 show_oops(NULL
, "add_alias: incomplete alias definition");
1285 if (strlen(alias
) == 0 || strlen(l
) == 0) {
1286 show_oops(NULL
, "add_alias: invalid alias definition");
1290 a
->a_name
= g_strdup(alias
);
1291 a
->a_uri
= g_strdup(l
);
1293 DNPRINTF(XT_D_CONFIG
, "add_alias: %s for %s\n", a
->a_name
, a
->a_uri
);
1295 TAILQ_INSERT_TAIL(&aliases
, a
, entry
);
1305 walk_alias(struct settings
*s
,
1306 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1311 if (s
== NULL
|| cb
== NULL
) {
1312 show_oops(NULL
, "walk_alias invalid parameters");
1316 TAILQ_FOREACH(a
, &aliases
, entry
) {
1317 str
= g_strdup_printf("%s --> %s", a
->a_name
, a
->a_uri
);
1318 cb(s
, str
, cb_args
);
1324 add_mime_type(struct settings
*s
, char *line
)
1328 struct mime_type
*m
= NULL
;
1329 int downloadfirst
= 0;
1331 /* XXX this could be smarter */
1333 if (line
== NULL
|| strlen(line
) == 0) {
1334 show_oops(NULL
, "add_mime_type invalid parameters");
1343 m
= g_malloc(sizeof(*m
));
1345 if ((mime_type
= strsep(&l
, " \t,")) == NULL
|| l
== NULL
) {
1346 show_oops(NULL
, "add_mime_type: invalid mime_type");
1349 if (mime_type
[strlen(mime_type
) - 1] == '*') {
1350 mime_type
[strlen(mime_type
) - 1] = '\0';
1355 if (strlen(mime_type
) == 0 || strlen(l
) == 0) {
1356 show_oops(NULL
, "add_mime_type: invalid mime_type");
1360 m
->mt_type
= g_strdup(mime_type
);
1361 m
->mt_action
= g_strdup(l
);
1362 m
->mt_download
= downloadfirst
;
1364 DNPRINTF(XT_D_CONFIG
, "add_mime_type: type %s action %s default %d\n",
1365 m
->mt_type
, m
->mt_action
, m
->mt_default
);
1367 TAILQ_INSERT_TAIL(&mtl
, m
, entry
);
1377 walk_mime_type(struct settings
*s
,
1378 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1380 struct mime_type
*m
;
1383 if (s
== NULL
|| cb
== NULL
) {
1384 show_oops(NULL
, "walk_mime_type invalid parameters");
1388 TAILQ_FOREACH(m
, &mtl
, entry
) {
1389 str
= g_strdup_printf("%s%s --> %s",
1391 m
->mt_default
? "*" : "",
1393 cb(s
, str
, cb_args
);
1398 /* inherent to GTK not all keys will be caught at all times */
1399 /* XXX sort key bindings */
1400 struct key_binding keys
[] = {
1401 { "command_mode", 0, 1, GDK_Escape
},
1402 { "insert_mode", 0, 0, GDK_i
},
1403 { "cookiejar", MOD1
, 1, GDK_j
},
1404 { "downloadmgr", MOD1
, 1, GDK_d
},
1405 { "history", MOD1
, 1, GDK_h
},
1406 { "print", CTRL
, 1, GDK_p
},
1407 { "search", 0, 0, GDK_slash
},
1408 { "searchb", 0, 0, GDK_question
},
1409 { "statustoggle", CTRL
, 1, GDK_n
},
1410 { "command", 0, 0, GDK_colon
},
1411 { "qa", CTRL
, 1, GDK_q
},
1412 { "restart", MOD1
, 1, GDK_q
},
1413 { "js toggle", CTRL
, 1, GDK_j
},
1414 { "plugin toggle", MOD1
, 1, GDK_p
},
1415 { "cookie toggle", MOD1
, 1, GDK_c
},
1416 { "togglesrc", CTRL
, 1, GDK_s
},
1417 { "yankuri", 0, 0, GDK_y
},
1418 { "pasteuricur", 0, 0, GDK_p
},
1419 { "pasteurinew", 0, 0, GDK_P
},
1420 { "toplevel toggle", 0, 1, GDK_F4
},
1421 { "help", 0, 1, GDK_F1
},
1422 { "run_script", MOD1
, 1, GDK_r
},
1423 { "proxy toggle", 0, 1, GDK_F2
},
1424 { "editelement", CTRL
, 1, GDK_i
},
1425 { "passthrough", CTRL
, 1, GDK_z
},
1426 { "modurl", CTRL
, 1, GDK_Return
},
1429 { "searchnext", 0, 0, GDK_n
},
1430 { "searchprevious", 0, 0, GDK_N
},
1433 { "focusaddress", 0, 1, GDK_F6
},
1434 { "focussearch", 0, 1, GDK_F7
},
1437 { "hinting", 0, 0, GDK_f
},
1438 { "hinting", 0, 0, GDK_period
},
1439 { "hinting_newtab", SHFT
, 0, GDK_F
},
1440 { "hinting_newtab", 0, 0, GDK_comma
},
1442 /* custom stylesheet */
1443 { "userstyle", 0, 0, GDK_s
},
1444 { "userstyle_global", SHFT
, 0, GDK_S
},
1447 { "goback", 0, 0, GDK_BackSpace
},
1448 { "goback", MOD1
, 1, GDK_Left
},
1449 { "goforward", SHFT
, 1, GDK_BackSpace
},
1450 { "goforward", MOD1
, 1, GDK_Right
},
1451 { "reload", 0, 1, GDK_F5
},
1452 { "reload", CTRL
, 1, GDK_r
},
1453 { "reload", CTRL
, 1, GDK_l
},
1454 { "favorites", MOD1
, 1, GDK_f
},
1456 /* vertical movement */
1457 { "scrolldown", 0, 0, GDK_j
},
1458 { "scrolldown", 0, 0, GDK_Down
},
1459 { "scrollup", 0, 0, GDK_Up
},
1460 { "scrollup", 0, 0, GDK_k
},
1461 { "scrollbottom", 0, 0, GDK_G
},
1462 { "scrollbottom", 0, 0, GDK_End
},
1463 { "scrolltop", 0, 0, GDK_Home
},
1464 { "scrollpagedown", 0, 0, GDK_space
},
1465 { "scrollpagedown", CTRL
, 1, GDK_f
},
1466 { "scrollhalfdown", CTRL
, 1, GDK_d
},
1467 { "scrollpagedown", 0, 0, GDK_Page_Down
},
1468 { "scrollpageup", 0, 0, GDK_Page_Up
},
1469 { "scrollpageup", CTRL
, 1, GDK_b
},
1470 { "scrollhalfup", CTRL
, 1, GDK_u
},
1471 /* horizontal movement */
1472 { "scrollright", 0, 0, GDK_l
},
1473 { "scrollright", 0, 0, GDK_Right
},
1474 { "scrollleft", 0, 0, GDK_Left
},
1475 { "scrollleft", 0, 0, GDK_h
},
1476 { "scrollfarright", 0, 0, GDK_dollar
},
1477 { "scrollfarleft", 0, 0, GDK_0
},
1480 { "tabnew", CTRL
, 1, GDK_t
},
1481 { "999tabnew", CTRL
, 1, GDK_T
},
1482 { "tabclose", CTRL
, 1, GDK_w
},
1483 { "tabundoclose", 0, 0, GDK_U
},
1484 { "tabnext 1", CTRL
, 1, GDK_1
},
1485 { "tabnext 2", CTRL
, 1, GDK_2
},
1486 { "tabnext 3", CTRL
, 1, GDK_3
},
1487 { "tabnext 4", CTRL
, 1, GDK_4
},
1488 { "tabnext 5", CTRL
, 1, GDK_5
},
1489 { "tabnext 6", CTRL
, 1, GDK_6
},
1490 { "tabnext 7", CTRL
, 1, GDK_7
},
1491 { "tabnext 8", CTRL
, 1, GDK_8
},
1492 { "tabnext 9", CTRL
, 1, GDK_9
},
1493 { "tabfirst", CTRL
, 1, GDK_less
},
1494 { "tablast", CTRL
, 1, GDK_greater
},
1495 { "tabprevious", CTRL
, 1, GDK_Left
},
1496 { "tabnext", CTRL
, 1, GDK_Right
},
1497 { "focusout", CTRL
, 1, GDK_minus
},
1498 { "focusin", CTRL
, 1, GDK_plus
},
1499 { "focusin", CTRL
, 1, GDK_equal
},
1500 { "focusreset", CTRL
, 1, GDK_0
},
1502 /* command aliases (handy when -S flag is used) */
1503 { ":open ", 0, 1, GDK_F9
},
1504 { ":open <uri>", 0, 1, GDK_F10
},
1505 { ":tabnew ", 0, 1, GDK_F11
},
1506 { ":tabnew <uri>", 0, 1, GDK_F12
},
1510 walk_kb(struct settings
*s
,
1511 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1513 struct key_binding
*k
;
1516 if (s
== NULL
|| cb
== NULL
) {
1517 show_oops(NULL
, "walk_kb invalid parameters");
1521 TAILQ_FOREACH(k
, &kbl
, entry
) {
1527 if (gdk_keyval_name(k
->key
) == NULL
)
1530 strlcat(str
, k
->cmd
, sizeof str
);
1531 strlcat(str
, ",", sizeof str
);
1533 if (k
->mask
& GDK_SHIFT_MASK
)
1534 strlcat(str
, "S-", sizeof str
);
1535 if (k
->mask
& GDK_CONTROL_MASK
)
1536 strlcat(str
, "C-", sizeof str
);
1537 if (k
->mask
& GDK_MOD1_MASK
)
1538 strlcat(str
, "M1-", sizeof str
);
1539 if (k
->mask
& GDK_MOD2_MASK
)
1540 strlcat(str
, "M2-", sizeof str
);
1541 if (k
->mask
& GDK_MOD3_MASK
)
1542 strlcat(str
, "M3-", sizeof str
);
1543 if (k
->mask
& GDK_MOD4_MASK
)
1544 strlcat(str
, "M4-", sizeof str
);
1545 if (k
->mask
& GDK_MOD5_MASK
)
1546 strlcat(str
, "M5-", sizeof str
);
1548 strlcat(str
, gdk_keyval_name(k
->key
), sizeof str
);
1549 cb(s
, str
, cb_args
);
1554 init_keybindings(void)
1557 struct key_binding
*k
;
1559 for (i
= 0; i
< LENGTH(keys
); i
++) {
1560 k
= g_malloc0(sizeof *k
);
1561 k
->cmd
= keys
[i
].cmd
;
1562 k
->mask
= keys
[i
].mask
;
1563 k
->use_in_entry
= keys
[i
].use_in_entry
;
1564 k
->key
= keys
[i
].key
;
1565 TAILQ_INSERT_HEAD(&kbl
, k
, entry
);
1567 DNPRINTF(XT_D_KEYBINDING
, "init_keybindings: added: %s\n",
1568 k
->cmd
? k
->cmd
: "unnamed key");
1573 keybinding_clearall(void)
1575 struct key_binding
*k
, *next
;
1577 for (k
= TAILQ_FIRST(&kbl
); k
; k
= next
) {
1578 next
= TAILQ_NEXT(k
, entry
);
1582 DNPRINTF(XT_D_KEYBINDING
, "keybinding_clearall: %s\n",
1583 k
->cmd
? k
->cmd
: "unnamed key");
1584 TAILQ_REMOVE(&kbl
, k
, entry
);
1590 keybinding_add(char *cmd
, char *key
, int use_in_entry
)
1592 struct key_binding
*k
;
1593 guint keyval
, mask
= 0;
1596 DNPRINTF(XT_D_KEYBINDING
, "keybinding_add: %s %s\n", cmd
, key
);
1598 /* Keys which are to be used in entry have been prefixed with an
1599 * exclamation mark. */
1603 /* find modifier keys */
1604 if (strstr(key
, "S-"))
1605 mask
|= GDK_SHIFT_MASK
;
1606 if (strstr(key
, "C-"))
1607 mask
|= GDK_CONTROL_MASK
;
1608 if (strstr(key
, "M1-"))
1609 mask
|= GDK_MOD1_MASK
;
1610 if (strstr(key
, "M2-"))
1611 mask
|= GDK_MOD2_MASK
;
1612 if (strstr(key
, "M3-"))
1613 mask
|= GDK_MOD3_MASK
;
1614 if (strstr(key
, "M4-"))
1615 mask
|= GDK_MOD4_MASK
;
1616 if (strstr(key
, "M5-"))
1617 mask
|= GDK_MOD5_MASK
;
1620 for (i
= strlen(key
) - 1; i
> 0; i
--)
1624 /* validate keyname */
1625 keyval
= gdk_keyval_from_name(key
);
1626 if (keyval
== GDK_VoidSymbol
) {
1627 warnx("invalid keybinding name %s", key
);
1630 /* must run this test too, gtk+ doesn't handle 10 for example */
1631 if (gdk_keyval_name(keyval
) == NULL
) {
1632 warnx("invalid keybinding name %s", key
);
1636 /* Remove eventual dupes. */
1637 TAILQ_FOREACH(k
, &kbl
, entry
)
1638 if (k
->key
== keyval
&& k
->mask
== mask
) {
1639 TAILQ_REMOVE(&kbl
, k
, entry
);
1645 k
= g_malloc0(sizeof *k
);
1646 k
->cmd
= g_strdup(cmd
);
1648 k
->use_in_entry
= use_in_entry
;
1651 DNPRINTF(XT_D_KEYBINDING
, "keybinding_add: %s 0x%x %d 0x%x\n",
1656 DNPRINTF(XT_D_KEYBINDING
, "keybinding_add: adding: %s %s\n",
1657 k
->cmd
, gdk_keyval_name(keyval
));
1659 TAILQ_INSERT_HEAD(&kbl
, k
, entry
);
1665 cmd_alias_add(char *alias
, char *cmd
)
1667 struct cmd_alias
*c
;
1670 TAILQ_FOREACH(c
, &cal
, entry
)
1671 if (!strcmp((alias
), c
->alias
)) {
1672 TAILQ_REMOVE(&cal
, c
, entry
);
1676 c
= g_malloc(sizeof (struct cmd_alias
));
1677 c
->alias
= g_strchug(g_strdup(alias
));
1678 c
->cmd
= g_strchug(g_strdup(cmd
));
1680 DNPRINTF(XT_D_CUSTOM_URI
, "cmd_alias_add: %s %s\n", c
->alias
, c
->cmd
);
1682 TAILQ_INSERT_HEAD(&cal
, c
, entry
);
1687 custom_uri_add(char *uri
, char *cmd
)
1689 struct custom_uri
*u
;
1691 TAILQ_FOREACH(u
, &cul
, entry
)
1692 if (!strcmp((uri
), u
->uri
) && !strcmp(cmd
, u
->cmd
)) {
1693 TAILQ_REMOVE(&cul
, u
, entry
);
1697 u
= g_malloc(sizeof (struct custom_uri
));
1698 u
->uri
= g_strdup(uri
);
1699 expand_tilde(u
->cmd
, sizeof u
->cmd
, cmd
);
1701 DNPRINTF(XT_D_CUSTOM_URI
, "custom_uri_add: %s %s\n", u
->uri
, u
->cmd
);
1703 /* don't check here if the script is valid, wait until running it */
1704 TAILQ_INSERT_HEAD(&cul
, u
, entry
);
1709 add_kb(struct settings
*s
, char *entry
)
1713 DNPRINTF(XT_D_KEYBINDING
, "add_kb: %s\n", entry
);
1715 /* clearall is special */
1716 if (!strcmp(entry
, "clearall")) {
1717 keybinding_clearall();
1721 kb
= strstr(entry
, ",");
1727 return (keybinding_add(entry
, key
, key
[0] == '!'));
1731 add_custom_uri(struct settings
*s
, char *entry
)
1735 DNPRINTF(XT_D_CUSTOM_URI
, "add_custom_uri: %s\n", entry
);
1737 uri
= strstr(entry
, ",");
1743 return (custom_uri_add(entry
, cmd
));
1747 walk_custom_uri(struct settings
*s
,
1748 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1750 struct custom_uri
*u
;
1753 if (s
== NULL
|| cb
== NULL
) {
1754 show_oops(NULL
, "walk_custom_uri invalid parameters");
1758 TAILQ_FOREACH(u
, &cul
, entry
) {
1759 snprintf(buf
, sizeof buf
, "%s,%s", u
->uri
, u
->cmd
);
1760 cb(s
, buf
, cb_args
);
1765 add_ua(struct settings
*s
, char *value
)
1767 struct user_agent
*ua
;
1768 static int ua_count
= 0;
1770 ua
= g_malloc(sizeof *ua
);
1771 ua
->id
= ua_count
++;
1772 ua
->value
= g_strdup(value
);
1774 RB_INSERT(user_agent_list
, &ua_list
, ua
);
1781 walk_ua(struct settings
*s
,
1782 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1784 struct user_agent
*ua
;
1786 if (s
== NULL
|| cb
== NULL
) {
1787 show_oops(NULL
, "walk_ua invalid parameters");
1791 RB_FOREACH(ua
, user_agent_list
, &ua_list
)
1792 cb(s
, ua
->value
, cb_args
);
1796 add_force_https(struct settings
*s
, char *value
)
1798 wl_add(value
, &force_https
, XT_WL_PERSISTENT
);
1803 add_http_accept(struct settings
*s
, char *value
)
1805 struct http_accept
*ha
;
1806 static int ha_count
= 0;
1808 ha
= g_malloc(sizeof *ha
);
1809 ha
->id
= ha_count
++;
1810 ha
->value
= g_strdup(value
);
1812 RB_INSERT(http_accept_list
, &ha_list
, ha
);
1818 walk_http_accept(struct settings
*s
,
1819 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1821 struct http_accept
*ha
;
1823 if (s
== NULL
|| cb
== NULL
) {
1824 show_oops(NULL
, "%s: invalid parameters", __func__
);
1828 RB_FOREACH(ha
, http_accept_list
, &ha_list
)
1829 cb(s
, ha
->value
, cb_args
);
1833 add_cmd_alias(struct settings
*s
, char *entry
)
1837 DNPRINTF(XT_D_CMD_ALIAS
, "add_cmd_alias: %s\n", entry
);
1839 alias
= strstr(entry
, ",");
1845 return (cmd_alias_add(entry
, cmd
));
1849 walk_cmd_alias(struct settings
*s
,
1850 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
1852 struct cmd_alias
*c
;
1855 if (s
== NULL
|| cb
== NULL
) {
1856 show_oops(NULL
, "walk_cmd_alias invalid parameters");
1860 TAILQ_FOREACH(c
, &cal
, entry
) {
1861 snprintf(buf
, sizeof buf
, "%s --> %s", c
->alias
, c
->cmd
);
1862 cb(s
, buf
, cb_args
);
1867 set_allow_insecure_content(char *value
)
1873 if (value
== NULL
|| strlen(value
) == 0)
1874 allow_insecure_content
= XT_DS_ALLOW_INSECURE_CONTENT
;
1876 tmp
= strtonum(value
, 0, 1, &errstr
);
1879 allow_insecure_content
= tmp
;
1881 TAILQ_FOREACH(t
, &tabs
, entry
)
1882 if (is_g_object_setting(G_OBJECT(t
->settings
),
1883 "enable-display-of-insecure-content")) {
1884 g_object_set(G_OBJECT(t
->settings
),
1885 "enable-display-of-insecure-content",
1886 allow_insecure_content
, (char *)NULL
);
1887 webkit_web_view_set_settings(t
->wv
, t
->settings
);
1893 check_allow_insecure_content(char **tt
)
1895 *tt
= g_strdup("Default (depends on browser_mode):\n"
1896 "\tnormal:\tEnabled\n"
1897 "\twhitelist:\tDisabled\n"
1898 "\tkiosk:\tEnabled");
1899 if (browser_mode
== XT_BM_NORMAL
&& allow_insecure_content
!= 1)
1901 if (browser_mode
== XT_BM_WHITELIST
&& allow_insecure_content
!= 0)
1903 if (browser_mode
== XT_BM_KIOSK
&& allow_insecure_content
!= 1)
1909 set_allow_insecure_scripts(char *value
)
1915 if (value
== NULL
|| strlen(value
) == 0)
1916 allow_insecure_scripts
= XT_DS_ALLOW_INSECURE_SCRIPTS
;
1918 tmp
= strtonum(value
, 0, 1, &errstr
);
1921 allow_insecure_scripts
= tmp
;
1923 TAILQ_FOREACH(t
, &tabs
, entry
)
1924 if (is_g_object_setting(G_OBJECT(t
->settings
),
1925 "enable-running-of-insecure-content")) {
1926 g_object_set(G_OBJECT(t
->settings
),
1927 "enable-running-of-insecure-content",
1928 allow_insecure_scripts
, (char *)NULL
);
1929 webkit_web_view_set_settings(t
->wv
, t
->settings
);
1935 check_allow_insecure_scripts(char **tt
)
1937 *tt
= g_strdup("Default (depends on browser_mode):\n"
1938 "\tnormal:\tEnabled\n"
1939 "\twhitelist:\tDisabled\n"
1940 "\tkiosk:\tEnabled");
1941 if (browser_mode
== XT_BM_NORMAL
&& allow_insecure_scripts
!= 1)
1943 if (browser_mode
== XT_BM_WHITELIST
&& allow_insecure_scripts
!= 0)
1945 if (browser_mode
== XT_BM_KIOSK
&& allow_insecure_scripts
!= 1)
1951 set_auto_load_images(char *value
)
1957 if (value
== NULL
|| strlen(value
) == 0)
1958 auto_load_images
= XT_DS_AUTO_LOAD_IMAGES
;
1960 tmp
= strtonum(value
, 0, 1, &errstr
);
1963 auto_load_images
= tmp
;
1965 TAILQ_FOREACH(t
, &tabs
, entry
) {
1966 g_object_set(G_OBJECT(t
->settings
),
1967 "auto-load-images", auto_load_images
, (char *)NULL
);
1968 webkit_web_view_set_settings(t
->wv
, t
->settings
);
1974 check_auto_load_images(char **tt
)
1976 *tt
= g_strdup_printf("Default: %s",
1977 XT_DS_AUTO_LOAD_IMAGES
? "Enabled" : "Disabled");
1978 return (auto_load_images
!= XT_DS_AUTO_LOAD_IMAGES
);
1982 set_autofocus_onload(char *value
)
1987 if (value
== NULL
|| strlen(value
) == 0)
1988 autofocus_onload
= XT_DS_AUTOFOCUS_ONLOAD
;
1990 tmp
= strtonum(value
, 0, 1, &errstr
);
1993 autofocus_onload
= tmp
;
1999 check_autofocus_onload(char **tt
)
2001 *tt
= g_strdup_printf("Default: %s",
2002 XT_DS_AUTOFOCUS_ONLOAD
? "Enabled" : "Disabled");
2003 return (autofocus_onload
!= XT_DS_AUTOFOCUS_ONLOAD
);
2007 set_ctrl_click_focus(char *value
)
2012 if (value
== NULL
|| strlen(value
) == 0)
2013 ctrl_click_focus
= XT_DS_CTRL_CLICK_FOCUS
;
2015 tmp
= strtonum(value
, 0, 1, &errstr
);
2018 ctrl_click_focus
= tmp
;
2024 check_ctrl_click_focus(char **tt
)
2026 *tt
= g_strdup_printf("Default: %s",
2027 XT_DS_CTRL_CLICK_FOCUS
? "Enabled" : "Disabled");
2028 return (ctrl_click_focus
!= XT_DS_CTRL_CLICK_FOCUS
);
2032 set_download_notifications(char *value
)
2037 if (value
== NULL
|| strlen(value
) == 0)
2038 download_notifications
= XT_DS_DOWNLOAD_NOTIFICATIONS
;
2040 tmp
= strtonum(value
, 0, 1, &errstr
);
2043 download_notifications
= tmp
;
2049 check_download_notifications(char **tt
)
2051 *tt
= g_strdup_printf("Default: %s",
2052 XT_DS_DOWNLOAD_NOTIFICATIONS
? "Enabled" : "Disabled");
2053 return (download_notifications
!= XT_DS_DOWNLOAD_NOTIFICATIONS
);
2057 set_enable_autoscroll(char *value
)
2062 if (value
== NULL
|| strlen(value
) == 0)
2063 enable_autoscroll
= XT_DS_ENABLE_AUTOSCROLL
;
2065 tmp
= strtonum(value
, 0, 1, &errstr
);
2068 enable_autoscroll
= tmp
;
2074 check_enable_autoscroll(char **tt
)
2076 *tt
= g_strdup_printf("Default: %s",
2077 XT_DS_ENABLE_AUTOSCROLL
? "Enabled" : "Disabled");
2078 return (enable_autoscroll
!= XT_DS_ENABLE_AUTOSCROLL
);
2082 set_enable_cookie_whitelist(char *value
)
2087 if (value
== NULL
|| strlen(value
) == 0)
2088 enable_cookie_whitelist
= XT_DS_ENABLE_COOKIE_WHITELIST
;
2090 tmp
= strtonum(value
, 0, 1, &errstr
);
2093 enable_cookie_whitelist
= tmp
;
2099 check_enable_cookie_whitelist(char **tt
)
2101 *tt
= g_strdup("Default (depends on browser_mode):\n"
2102 "\tnormal:\tDisabled\n"
2103 "\twhitelist:\tEnabled\n"
2104 "\tkiosk:\tDisabled");
2105 if (browser_mode
== XT_BM_WHITELIST
&& enable_cookie_whitelist
!= 1)
2107 if (browser_mode
== XT_BM_NORMAL
&& enable_cookie_whitelist
!= 0)
2109 if (browser_mode
== XT_BM_KIOSK
&& enable_cookie_whitelist
!= 0)
2115 set_enable_js_autorun(char *value
)
2120 if (value
== NULL
|| strlen(value
) == 0)
2121 enable_js_autorun
= XT_DS_ENABLE_JS_AUTORUN
;
2123 tmp
= strtonum(value
, 0, 1, &errstr
);
2126 enable_js_autorun
= tmp
;
2132 check_enable_js_autorun(char **tt
)
2134 *tt
= g_strdup_printf("Default: %s",
2135 XT_DS_ENABLE_JS_AUTORUN
? "Enabled" : "Disabled");
2136 return (enable_js_autorun
!= XT_DS_ENABLE_JS_AUTORUN
);
2140 set_enable_js_whitelist(char *value
)
2145 if (value
== NULL
|| strlen(value
) == 0)
2146 enable_js_whitelist
= XT_DS_ENABLE_JS_WHITELIST
;
2148 tmp
= strtonum(value
, 0, 1, &errstr
);
2151 enable_js_whitelist
= tmp
;
2157 check_enable_js_whitelist(char **tt
)
2159 *tt
= g_strdup("Default (depends on browser_mode):\n"
2160 "\tnormal:\tDisabled\n"
2161 "\twhitelist:\tEnabled\n"
2162 "\tkiosk:\tDisabled");
2163 if (browser_mode
== XT_BM_WHITELIST
&& enable_js_whitelist
!= 1)
2165 if (browser_mode
== XT_BM_NORMAL
&& enable_js_whitelist
!= 0)
2167 if (browser_mode
== XT_BM_KIOSK
&& enable_js_whitelist
!= 0)
2173 set_enable_favicon_entry(char *value
)
2178 if (value
== NULL
|| strlen(value
) == 0)
2179 enable_favicon_entry
= XT_DS_ENABLE_FAVICON_ENTRY
;
2181 tmp
= strtonum(value
, 0, 1, &errstr
);
2184 enable_favicon_entry
= tmp
;
2190 check_enable_favicon_entry(char **tt
)
2192 *tt
= g_strdup_printf("Default: %s",
2193 XT_DS_ENABLE_FAVICON_ENTRY
? "Enabled" : "Disabled");
2194 return (enable_favicon_entry
!= XT_DS_ENABLE_FAVICON_ENTRY
);
2198 set_enable_favicon_tabs(char *value
)
2203 if (value
== NULL
|| strlen(value
) == 0)
2204 enable_favicon_tabs
= XT_DS_ENABLE_FAVICON_TABS
;
2206 tmp
= strtonum(value
, 0, 1, &errstr
);
2209 enable_favicon_tabs
= tmp
;
2215 check_enable_favicon_tabs(char **tt
)
2217 *tt
= g_strdup_printf("Default: %s",
2218 XT_DS_ENABLE_FAVICON_TABS
? "Enabled" : "Disabled");
2219 return (enable_favicon_tabs
!= XT_DS_ENABLE_FAVICON_TABS
);
2223 set_enable_localstorage(char *value
)
2229 if (value
== NULL
|| strlen(value
) == 0)
2230 enable_localstorage
= XT_DS_ENABLE_LOCALSTORAGE
;
2232 tmp
= strtonum(value
, 0, 1, &errstr
);
2235 enable_localstorage
= tmp
;
2237 TAILQ_FOREACH(t
, &tabs
, entry
)
2238 g_object_set(G_OBJECT(t
->settings
),
2239 "enable-html5-local-storage", enable_localstorage
,
2245 check_enable_localstorage(char **tt
)
2247 *tt
= g_strdup("Default (depends on browser_mode):\n"
2248 "\tnormal:\tEnabled\n"
2249 "\twhitelist:\tDisabled\n"
2250 "\tkiosk:\tEnabled");
2251 if (browser_mode
== XT_BM_WHITELIST
&& enable_localstorage
!= 0)
2253 if (browser_mode
== XT_BM_NORMAL
&& enable_localstorage
!= 1)
2255 if (browser_mode
== XT_BM_KIOSK
&& enable_localstorage
!= 1)
2261 set_enable_plugins(char *value
)
2267 if (value
== NULL
|| strlen(value
) == 0)
2268 enable_plugins
= XT_DS_ENABLE_PLUGINS
;
2270 tmp
= strtonum(value
, 0, 1, &errstr
);
2273 enable_plugins
= tmp
;
2275 TAILQ_FOREACH(t
, &tabs
, entry
)
2276 g_object_set(G_OBJECT(t
->settings
), "enable-plugins",
2277 enable_plugins
, (char *)NULL
);
2282 check_enable_plugins(char **tt
)
2284 *tt
= g_strdup("Default (depends on browser_mode):\n"
2285 "\tnormal:\tEnabled\n"
2286 "\twhitelist:\tDisabled\n"
2287 "\tkiosk:\tEnabled");
2288 if (browser_mode
== XT_BM_WHITELIST
&& enable_plugins
!= 0)
2290 if (browser_mode
== XT_BM_NORMAL
&& enable_plugins
!= 1)
2292 if (browser_mode
== XT_BM_KIOSK
&& enable_plugins
!= 1)
2298 set_enable_plugin_whitelist(char *value
)
2303 if (value
== NULL
|| strlen(value
) == 0)
2304 enable_plugin_whitelist
= XT_DS_ENABLE_PLUGIN_WHITELIST
;
2306 tmp
= strtonum(value
, 0, 1, &errstr
);
2309 enable_plugin_whitelist
= tmp
;
2315 check_enable_plugin_whitelist(char **tt
)
2317 *tt
= g_strdup("Default (depends on browser_mode):\n"
2318 "\tnormal:\tDisabled\n"
2319 "\twhitelist:\tEnabled\n"
2320 "\tkiosk:\tDisabled");
2321 if (browser_mode
== XT_BM_WHITELIST
&& enable_plugin_whitelist
!= 1)
2323 if (browser_mode
== XT_BM_NORMAL
&& enable_plugin_whitelist
!= 0)
2325 if (browser_mode
== XT_BM_KIOSK
&& enable_plugin_whitelist
!= 0)
2331 set_enable_scripts(char *value
)
2337 if (value
== NULL
|| strlen(value
) == 0)
2338 enable_scripts
= XT_DS_ENABLE_SCRIPTS
;
2340 tmp
= strtonum(value
, 0, 1, &errstr
);
2343 enable_scripts
= tmp
;
2345 TAILQ_FOREACH(t
, &tabs
, entry
)
2346 g_object_set(G_OBJECT(t
->settings
), "enable-scripts",
2347 enable_scripts
, (char *)NULL
);
2352 check_enable_scripts(char **tt
)
2354 *tt
= g_strdup("Default (depends on browser_mode):\n"
2355 "\tnormal:\tEnabled\n"
2356 "\twhitelist:\tDisabled\n"
2357 "\tkiosk:\tEnabled");
2358 if (browser_mode
== XT_BM_WHITELIST
&& enable_scripts
!= 0)
2360 if (browser_mode
== XT_BM_NORMAL
&& enable_scripts
!= 1)
2362 if (browser_mode
== XT_BM_KIOSK
&& enable_scripts
!= 1)
2368 check_enable_socket(char **tt
)
2370 *tt
= g_strdup("Default: Disabled");
2371 return (enable_socket
!= 0);
2375 set_enable_spell_checking(char *value
)
2381 if (value
== NULL
|| strlen(value
) == 0)
2382 enable_spell_checking
= XT_DS_ENABLE_SPELL_CHECKING
;
2384 tmp
= strtonum(value
, 0, 1, &errstr
);
2387 enable_spell_checking
= tmp
;
2389 TAILQ_FOREACH(t
, &tabs
, entry
)
2390 g_object_set(G_OBJECT(t
->settings
), "enable_spell_checking",
2391 enable_spell_checking
, (char *)NULL
);
2396 check_enable_spell_checking(char **tt
)
2398 *tt
= g_strdup_printf("Default: %s",
2399 XT_DS_ENABLE_SPELL_CHECKING
? "Enabled" : "Disabled");
2400 return (enable_spell_checking
!= XT_DS_ENABLE_SPELL_CHECKING
);
2404 set_enable_strict_transport(char *value
)
2409 if (value
== NULL
|| strlen(value
) == 0)
2410 enable_strict_transport
= XT_DS_ENABLE_STRICT_TRANSPORT
;
2412 tmp
= strtonum(value
, 0, 1, &errstr
);
2415 enable_strict_transport
= tmp
;
2421 check_enable_strict_transport(char **tt
)
2423 *tt
= g_strdup_printf("Default: %s",
2424 XT_DS_ENABLE_STRICT_TRANSPORT
? "Enabled" : "Disabled");
2425 return (enable_strict_transport
!= XT_DS_ENABLE_STRICT_TRANSPORT
);
2430 * XXX: this is currently broken. Need to figure out what to do with
2431 * this. Problemm is set_encoding will refresh the tab it's run on, so
2432 * we can either put a big fat warning in the manpage and refresh every
2433 * single open tab with the new encoding or scrap it as a runtime
2437 set_encoding_rt(char *value
)
2439 struct karg args
= {0};
2441 if (value
== NULL
|| strlen(value
) == 0)
2445 encoding
= g_strdup(value
);
2447 set_encoding(get_current_tab(), &args
);
2453 check_encoding(char **tt
)
2455 *tt
= g_strdup_printf("Default: %s", XT_DS_ENCODING
);
2456 return (g_strcmp0(encoding
, XT_DS_ENCODING
));
2460 check_gnutls_search_string(char **tt
)
2462 *tt
= g_strdup("Default: (empty)");
2463 return (g_strcmp0(gnutls_priority_string
,
2464 XT_DS_GNUTLS_PRIORITY_STRING
));
2468 set_gnutls_priority_string(struct settings
*s
, char *value
)
2470 return (!g_setenv("G_TLS_GNUTLS_PRIORITY", value
, FALSE
));
2474 get_gnutls_priority_string(struct settings
*s
)
2476 return (g_strdup(g_getenv("G_TLS_GNUTLS_PRIORITY")));
2480 set_guess_search(char *value
)
2485 if (value
== NULL
|| strlen(value
) == 0)
2486 guess_search
= XT_DS_GUESS_SEARCH
;
2488 tmp
= strtonum(value
, 0, 1, &errstr
);
2497 check_guess_search(char **tt
)
2499 *tt
= g_strdup_printf("Default: %s",
2500 XT_DS_GUESS_SEARCH
? "Enabled" : "Disabled");
2501 return (guess_search
!= XT_DS_GUESS_SEARCH
);
2505 get_referer(struct settings
*s
)
2507 if (referer_mode
== XT_REFERER_ALWAYS
)
2508 return (g_strdup("always"));
2509 if (referer_mode
== XT_REFERER_NEVER
)
2510 return (g_strdup("never"));
2511 if (referer_mode
== XT_REFERER_SAME_DOMAIN
)
2512 return (g_strdup("same-domain"));
2513 if (referer_mode
== XT_REFERER_SAME_FQDN
)
2514 return (g_strdup("same-fqdn"));
2515 if (referer_mode
== XT_REFERER_CUSTOM
)
2516 return (g_strdup(referer_custom
));
2521 set_referer(struct settings
*s
, char *value
)
2523 if (referer_custom
) {
2524 g_free(referer_custom
);
2525 referer_custom
= NULL
;
2528 if (!strcmp(value
, "always"))
2529 referer_mode
= XT_REFERER_ALWAYS
;
2530 else if (!strcmp(value
, "never"))
2531 referer_mode
= XT_REFERER_NEVER
;
2532 else if (!strcmp(value
, "same-domain"))
2533 referer_mode
= XT_REFERER_SAME_DOMAIN
;
2534 else if (!strcmp(value
, "same-fqdn"))
2535 referer_mode
= XT_REFERER_SAME_FQDN
;
2536 else if (!valid_url_type(value
)) {
2537 referer_mode
= XT_REFERER_CUSTOM
;
2538 referer_custom
= g_strdup(value
);
2540 /* we've already free'd the custom referer */
2541 if (referer_mode
== XT_REFERER_CUSTOM
)
2542 referer_mode
= XT_REFERER_NEVER
;
2550 set_referer_rt(char *value
)
2552 if (value
== NULL
|| strlen(value
) == 0) {
2554 g_free(referer_custom
);
2555 referer_custom
= g_strdup(XT_DS_REFERER_CUSTOM
);
2556 referer_mode
= XT_DS_REFERER_MODE
;
2559 return (set_referer(NULL
, value
));
2563 check_referer(char **tt
)
2565 *tt
= g_strdup("Default (depends on browser_mode):\n"
2566 "\tnormal:\talways\n"
2567 "\twhitelist:\tsame-domain\n"
2568 "\tkiosk:\talways");
2569 if (browser_mode
== XT_BM_WHITELIST
&&
2570 referer_mode
!= XT_REFERER_SAME_DOMAIN
)
2572 if (browser_mode
== XT_BM_NORMAL
&& referer_mode
!= XT_REFERER_ALWAYS
)
2574 if (browser_mode
== XT_BM_KIOSK
&& referer_mode
!= XT_REFERER_ALWAYS
)
2580 get_ssl_ca_file(struct settings
*s
)
2582 if (strlen(ssl_ca_file
) == 0)
2584 return (g_strdup(ssl_ca_file
));
2588 set_refresh_interval(char *value
)
2593 if (value
== NULL
|| strlen(value
) == 0)
2594 refresh_interval
= XT_DS_REFRESH_INTERVAL
;
2596 tmp
= strtonum(value
, 0, INT_MAX
, &errstr
);
2599 refresh_interval
= tmp
;
2605 check_resource_dir(char **tt
)
2607 *tt
= g_strdup_printf("Default: %s", XT_DS_RESOURCE_DIR
);
2608 return (g_strcmp0(resource_dir
, XT_DS_RESOURCE_DIR
));
2612 check_save_global_history(char **tt
)
2614 *tt
= g_strdup("Default: Disabled");
2615 return (save_global_history
!= 0);
2619 check_save_rejected_cookies(char **tt
)
2621 *tt
= g_strdup("Default: Disabled");
2622 return (save_rejected_cookies
!= 0);
2626 check_refresh_interval(char **tt
)
2628 *tt
= g_strdup_printf("Default: %d", XT_DS_REFRESH_INTERVAL
);
2629 return (refresh_interval
!= XT_DS_REFRESH_INTERVAL
);
2633 set_session_autosave(char *value
)
2638 if (value
== NULL
|| strlen(value
) == 0)
2639 session_autosave
= XT_DS_SESSION_AUTOSAVE
;
2641 tmp
= strtonum(value
, 0, 1, &errstr
);
2644 session_autosave
= tmp
;
2650 check_session_autosave(char **tt
)
2652 *tt
= g_strdup_printf("Default: %s",
2653 XT_DS_SESSION_AUTOSAVE
? "Enabled" : "Disabled");
2654 return (session_autosave
!= XT_DS_SESSION_AUTOSAVE
);
2658 set_session_timeout(char *value
)
2663 if (value
== NULL
|| strlen(value
) == 0)
2664 session_timeout
= XT_DS_SESSION_TIMEOUT
;
2666 tmp
= strtonum(value
, 0, INT_MAX
, &errstr
);
2669 session_timeout
= tmp
;
2675 check_session_timeout(char **tt
)
2677 *tt
= g_strdup_printf("Default: %d", XT_DS_SESSION_TIMEOUT
);
2678 return (session_timeout
!= XT_DS_SESSION_TIMEOUT
);
2682 set_show_scrollbars(char *value
)
2688 if (value
== NULL
|| strlen(value
) == 0)
2689 tmp
= XT_DS_SHOW_SCROLLBARS
;
2691 tmp
= strtonum(value
, 0, 1, &errstr
);
2695 show_scrollbars
= tmp
;
2696 TAILQ_FOREACH(t
, &tabs
, entry
)
2697 if (set_scrollbar_visibility(t
, show_scrollbars
))
2703 check_show_scrollbars(char **tt
)
2705 *tt
= g_strdup("Default (depends on gui_mode):\n"
2706 "\tclassic:\tEnabled\n"
2707 "\tminimal:\tDisabled");
2708 if (gui_mode
== XT_GM_CLASSIC
&& show_scrollbars
!= 1)
2710 if (gui_mode
== XT_GM_MINIMAL
&& show_scrollbars
!= 0)
2716 set_show_statusbar(char *value
)
2721 if (value
== NULL
|| strlen(value
) == 0)
2722 tmp
= XT_DS_SHOW_STATUSBAR
;
2724 tmp
= strtonum(value
, 0, 1, &errstr
);
2728 show_statusbar
= tmp
;
2729 statusbar_set_visibility();
2734 check_show_statusbar(char **tt
)
2736 *tt
= g_strdup("Default (depends on gui_mode):\n"
2737 "\tclassic:\tDisabled\n"
2738 "\tminimal:\tEnabled");
2739 if (gui_mode
== XT_GM_CLASSIC
&& show_statusbar
!= 0)
2741 if (gui_mode
== XT_GM_MINIMAL
&& show_statusbar
!= 1)
2747 set_show_tabs(char *value
)
2749 struct karg args
= {0};
2753 if (value
== NULL
|| strlen(value
) == 0)
2754 val
= XT_DS_SHOW_TABS
;
2756 val
= strtonum(value
, 0, 1, &errstr
);
2760 args
.i
= val
? XT_TAB_SHOW
: XT_TAB_HIDE
;
2761 tabaction(get_current_tab(), &args
);
2766 check_show_tabs(char **tt
)
2768 *tt
= g_strdup("Default (depends on gui_mode):\n"
2769 "\tclassic:\tEnabled\n"
2770 "\tminimal:\tDisabled");
2771 if (gui_mode
== XT_GM_CLASSIC
&& show_tabs
!= 1)
2773 if (gui_mode
== XT_GM_MINIMAL
&& show_tabs
!= 0)
2779 set_show_url(char *value
)
2781 struct karg args
= {0};
2785 if (value
== NULL
|| strlen(value
) == 0)
2786 val
= XT_DS_SHOW_URL
;
2788 val
= strtonum(value
, 0, 1, &errstr
);
2792 args
.i
= val
? XT_URL_SHOW
: XT_URL_HIDE
;
2793 urlaction(get_current_tab(), &args
);
2798 check_show_url(char **tt
)
2800 *tt
= g_strdup("Default (depends on gui_mode):\n"
2801 "\tclassic:\tEnabled\n"
2802 "\tminimal:\tDisabled");
2803 if (gui_mode
== XT_GM_CLASSIC
&& show_url
!= 1)
2805 if (gui_mode
== XT_GM_MINIMAL
&& show_url
!= 0)
2811 check_single_instance(char **tt
)
2813 *tt
= g_strdup("Default: Disabled");
2814 return (single_instance
!= 0);
2818 set_spell_check_languages(char *value
)
2822 if (spell_check_languages
)
2823 g_free(spell_check_languages
);
2824 if (value
== NULL
|| strlen(value
) == 0)
2825 spell_check_languages
= g_strdup(XT_DS_SPELL_CHECK_LANGUAGES
);
2827 spell_check_languages
= g_strdup(value
);
2828 TAILQ_FOREACH(t
, &tabs
, entry
)
2829 g_object_set(G_OBJECT(t
->settings
), "spell_checking_languages",
2830 spell_check_languages
, (char *)NULL
);
2835 check_spell_check_languages(char **tt
)
2837 *tt
= g_strdup_printf("Default: %s", XT_DS_SPELL_CHECK_LANGUAGES
);
2838 return (g_strcmp0(spell_check_languages
, XT_DS_SPELL_CHECK_LANGUAGES
));
2842 check_valid_file(char *name
)
2846 if (name
== NULL
|| stat(name
, &sb
))
2852 set_ssl_ca_file_rt(char *value
)
2854 if (value
== NULL
|| strlen(value
) == 0) {
2855 strlcpy(ssl_ca_file
, XT_DS_SSL_CA_FILE
, sizeof ssl_ca_file
);
2856 g_object_set(session
, SOUP_SESSION_SSL_CA_FILE
, "", NULL
);
2859 return (set_ssl_ca_file(NULL
, value
));
2863 check_ssl_ca_file(char **tt
)
2865 *tt
= g_strdup("Default: (empty)");
2866 return (g_strcmp0(ssl_ca_file
, XT_DS_SSL_CA_FILE
));
2870 set_ssl_strict_certs(char *value
)
2875 if (value
== NULL
|| strlen(value
) == 0)
2876 ssl_strict_certs
= XT_DS_SSL_STRICT_CERTS
;
2878 tmp
= strtonum(value
, 0, 1, &errstr
);
2881 ssl_strict_certs
= tmp
;
2883 g_object_set(session
, SOUP_SESSION_SSL_STRICT
, ssl_strict_certs
, NULL
);
2888 check_ssl_strict_certs(char **tt
)
2890 *tt
= g_strdup_printf("Default: %s",
2891 XT_DS_SSL_STRICT_CERTS
? "Enabled" : "Disabled");
2892 return (ssl_strict_certs
!= XT_DS_SSL_STRICT_CERTS
);
2896 check_statusbar_elems(char **tt
)
2898 *tt
= g_strdup("Default: BP");
2899 return (g_strcmp0(statusbar_elems
, "BP"));
2903 set_external_editor(char *editor
)
2905 if (external_editor
)
2906 g_free(external_editor
);
2907 if (editor
== NULL
|| strlen(editor
) == 0)
2908 external_editor
= NULL
;
2910 external_editor
= g_strdup(editor
);
2915 check_external_editor(char **tt
)
2917 *tt
= g_strdup("Default: (empty)");
2918 return (g_strcmp0(external_editor
, NULL
));
2922 set_fancy_bar(char *value
)
2928 if (value
== NULL
|| strlen(value
) == 0)
2929 fancy_bar
= 1; /* XXX */
2931 tmp
= strtonum(value
, 0, 1, &errstr
);
2936 TAILQ_FOREACH(t
, &tabs
, entry
)
2938 gtk_widget_show(t
->backward
);
2939 gtk_widget_show(t
->forward
);
2940 gtk_widget_show(t
->stop
);
2941 gtk_widget_show(t
->js_toggle
);
2942 if (search_string
&& strlen(search_string
))
2943 gtk_widget_show(t
->search_entry
);
2945 gtk_widget_hide(t
->backward
);
2946 gtk_widget_hide(t
->forward
);
2947 gtk_widget_hide(t
->stop
);
2948 gtk_widget_hide(t
->js_toggle
);
2949 gtk_widget_hide(t
->search_entry
);
2955 check_fancy_bar(char **tt
)
2957 *tt
= g_strdup("Default (depends on gui_mode):\n"
2958 "\tclassic:\tEnabled\n"
2959 "\tminimal:\tDisabled");
2960 if (gui_mode
== XT_GM_CLASSIC
&& fancy_bar
!= 1)
2962 if (gui_mode
== XT_GM_MINIMAL
&& fancy_bar
!= 0)
2968 setup_proxy(char *uri
)
2973 g_object_set(session
, "proxy_uri", NULL
, (char *)NULL
);
2974 soup_uri_free(proxy_uri
);
2976 TAILQ_FOREACH(t
, &tabs
, entry
)
2977 gtk_label_set_text(GTK_LABEL(t
->sbe
.proxy
), "");
2980 if (http_proxy
!= uri
) {
2987 http_proxy
= g_strdup(uri
);
2988 DNPRINTF(XT_D_CONFIG
, "setup_proxy: %s\n", uri
);
2989 proxy_uri
= soup_uri_new(http_proxy
);
2990 if (proxy_uri
!= NULL
&& SOUP_URI_VALID_FOR_HTTP(proxy_uri
)) {
2991 g_object_set(session
, "proxy-uri", proxy_uri
,
2993 TAILQ_FOREACH(t
, &tabs
, entry
)
2994 gtk_label_set_text(GTK_LABEL(t
->sbe
.proxy
),
3001 get_tab_style(struct settings
*s
)
3003 if (tab_style
== XT_TABS_NORMAL
)
3004 return (g_strdup("normal"));
3006 return (g_strdup("compact"));
3010 set_tab_style(struct settings
*s
, char *val
)
3012 if (!strcmp(val
, "normal"))
3013 tab_style
= XT_TABS_NORMAL
;
3014 else if (!strcmp(val
, "compact"))
3015 tab_style
= XT_TABS_COMPACT
;
3023 check_tab_style(char **tt
)
3025 *tt
= g_strdup("Default (depends on gui_mode):\n"
3026 "\tclassic:\tnormal\n"
3027 "\tminimal:\tcompact");
3028 if (gui_mode
== XT_GM_CLASSIC
&& tab_style
!= XT_TABS_NORMAL
)
3030 if (gui_mode
== XT_GM_MINIMAL
&& tab_style
!= XT_TABS_COMPACT
)
3036 set_tab_style_rt(char *value
)
3038 struct karg args
= {0};
3041 if (value
== NULL
|| strlen(value
) == 0) {
3042 if (tab_style
== XT_DS_TAB_STYLE
)
3044 tab_style
= XT_TABS_COMPACT
;
3045 args
.i
= XT_TAB_NEXTSTYLE
;
3047 old_tab_style
= tab_style
;
3048 if (set_tab_style(NULL
, value
))
3050 if (old_tab_style
!= tab_style
) {
3051 tab_style
= old_tab_style
;
3052 args
.i
= XT_TAB_NEXTSTYLE
;
3055 tabaction(get_current_tab(), &args
);
3060 get_statusbar_style(struct settings
*s
)
3062 if (statusbar_style
== XT_STATUSBAR_URL
)
3063 return (g_strdup("url"));
3065 return (g_strdup("title"));
3069 set_statusbar_style(struct settings
*s
, char *val
)
3071 if (!strcmp(val
, "url"))
3072 statusbar_style
= XT_STATUSBAR_URL
;
3073 else if (!strcmp(val
, "title"))
3074 statusbar_style
= XT_STATUSBAR_TITLE
;
3082 set_statusbar_style_rt(char *value
)
3085 const gchar
*page_uri
;
3087 if (value
== NULL
|| strlen(value
) == 0) {
3088 if (statusbar_style
== XT_DS_STATUSBAR_STYLE
)
3090 statusbar_style
= XT_DS_STATUSBAR_STYLE
;
3092 if (!strcmp(value
, "url"))
3093 statusbar_style
= XT_STATUSBAR_URL
;
3094 else if (!strcmp(value
, "title"))
3095 statusbar_style
= XT_STATUSBAR_TITLE
;
3099 TAILQ_FOREACH(t
, &tabs
, entry
) {
3100 if (statusbar_style
== XT_STATUSBAR_TITLE
)
3101 set_status(t
, "%s", get_title(t
, FALSE
));
3102 else if ((page_uri
= get_uri(t
)) != NULL
)
3103 set_status(t
, "%s", page_uri
);
3110 check_statusbar_style(char **tt
)
3112 *tt
= g_strdup("Default: url");
3113 return (statusbar_style
!= XT_DS_STATUSBAR_STYLE
);
3117 set_url_regex(char *value
)
3119 if (value
== NULL
|| strlen(value
) == 0) {
3122 url_regex
= g_strdup(XT_DS_URL_REGEX
);
3124 if (regcomp(&url_re
, value
, REG_EXTENDED
| REG_NOSUB
))
3128 url_regex
= g_strdup(value
);
3134 check_url_regex(char **tt
)
3136 *tt
= g_strdup_printf("Default: %s", XT_DS_URL_REGEX
);
3137 return (g_strcmp0(url_regex
, XT_DS_URL_REGEX
));
3141 set_userstyle(struct settings
*s
, char *value
)
3144 char script
[PATH_MAX
] = {'\0'};
3147 if (value
== NULL
|| strlen(value
) == 0) {
3148 snprintf(script
, sizeof script
, "%s" PS
"style.css", resource_dir
);
3149 tmp
= g_filename_to_uri(script
, NULL
, NULL
);
3158 expand_tilde(script
, sizeof script
, value
);
3159 tmp
= g_filename_to_uri(script
, NULL
, NULL
);
3170 stylesheet
= g_strdup(userstyle
);
3175 get_userstyle(struct settings
*s
)
3178 return (g_filename_from_uri(userstyle
, NULL
, NULL
));
3183 set_userstyle_rt(char *value
)
3185 return (set_userstyle(NULL
, value
));
3189 check_userstyle(char **tt
)
3195 snprintf(buf
, sizeof buf
, "%s" PS
"%s", resource_dir
, "style.css");
3196 *tt
= g_strdup_printf("Default: %s", buf
);
3197 file
= g_filename_from_uri(userstyle
, NULL
, NULL
);
3198 rv
= g_strcmp0(file
, buf
);
3205 set_userstyle_global(char *value
)
3207 struct karg args
= {0};
3211 if (value
== NULL
|| strlen(value
) == 0) {
3212 if (userstyle_global
== XT_DS_USERSTYLE_GLOBAL
)
3214 userstyle_global
= 1;
3215 args
.i
= XT_STYLE_GLOBAL
;
3216 userstyle_cmd(get_current_tab(), &args
);
3218 old_style
= userstyle_global
;
3219 tmp
= strtonum(value
, 0, 1, &errstr
);
3222 if (tmp
!= old_style
) {
3223 args
.i
= XT_STYLE_GLOBAL
;
3224 userstyle_cmd(get_current_tab(), &args
);
3231 check_userstyle_global(char **tt
)
3233 *tt
= g_strdup_printf("Default: %s",
3234 XT_DS_USERSTYLE_GLOBAL
? "Enabled" : "Disabled");
3235 return (userstyle_global
!= XT_DS_USERSTYLE_GLOBAL
);
3239 set_warn_cert_changes(char *value
)
3244 if (value
== NULL
|| strlen(value
) == 0)
3245 warn_cert_changes
= XT_DS_WARN_CERT_CHANGES
;
3247 tmp
= strtonum(value
, 0, 1, &errstr
);
3250 warn_cert_changes
= tmp
;
3256 check_warn_cert_changes(char **tt
)
3258 *tt
= g_strdup_printf("Default: %s",
3259 XT_DS_WARN_CERT_CHANGES
? "Enabled" : "Disabled");
3260 return (warn_cert_changes
!= XT_DS_WARN_CERT_CHANGES
);
3264 check_window_height(char **tt
)
3266 *tt
= g_strdup_printf("Default: %d", 768);
3267 return (window_height
!= 768);
3271 check_window_maximize(char **tt
)
3273 *tt
= g_strdup("Default: Disabled");
3274 return (window_maximize
!= 0);
3278 check_window_width(char **tt
)
3280 *tt
= g_strdup_printf("Default: %d", 768);
3281 return (window_width
!= 1024);
3285 check_work_dir(char **tt
)
3290 if ((pwd
= getpwuid(getuid())) == NULL
)
3292 snprintf(buf
, sizeof buf
, "%s" PS
".xombrero", pwd
->pw_dir
);
3293 *tt
= g_strdup_printf("Default: %s", buf
);
3294 return (g_strcmp0(work_dir
, buf
));
3298 get_edit_mode(struct settings
*s
)
3300 if (edit_mode
== XT_EM_HYBRID
)
3301 return (g_strdup("hybrid"));
3303 return (g_strdup("vi"));
3307 set_edit_mode(struct settings
*s
, char *val
)
3309 if (!strcmp(val
, "hybrid"))
3310 edit_mode
= XT_EM_HYBRID
;
3311 else if (!strcmp(val
, "vi"))
3312 edit_mode
= XT_EM_VI
;
3320 check_edit_mode(char **tt
)
3322 *tt
= g_strdup("Default: hybrid");
3323 return (edit_mode
!= XT_EM_HYBRID
);
3327 get_download_mode(struct settings
*s
)
3329 switch (download_mode
) {
3331 return (g_strdup("start"));
3334 return (g_strdup("ask"));
3337 return (g_strdup("add"));
3340 return (g_strdup("unknown"));
3344 set_download_mode(struct settings
*s
, char *val
)
3346 if (val
== NULL
|| strlen(val
) == 0 || !strcmp(val
, "start"))
3347 download_mode
= XT_DM_START
;
3348 else if (!strcmp(val
, "ask"))
3349 download_mode
= XT_DM_ASK
;
3350 else if (!strcmp(val
, "add"))
3351 download_mode
= XT_DM_ADD
;
3359 set_download_mode_rt(char *val
)
3361 return (set_download_mode(NULL
, val
));
3365 check_download_mode(char **tt
)
3367 *tt
= g_strdup("Default: start");
3368 return (download_mode
!= XT_DM_START
);
3372 get_work_dir(struct settings
*s
)
3374 if (work_dir
[0] == '\0')
3376 return (g_strdup(work_dir
));
3380 set_work_dir(struct settings
*s
, char *val
)
3382 expand_tilde(work_dir
, sizeof work_dir
, val
);
3387 walk_cookie_wl(struct settings
*s
,
3388 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3392 if (s
== NULL
|| cb
== NULL
) {
3393 show_oops(NULL
, "walk_cookie_wl invalid parameters");
3397 RB_FOREACH_REVERSE(d
, domain_list
, &c_wl
)
3398 cb(s
, d
->d
, cb_args
);
3402 walk_js_wl(struct settings
*s
,
3403 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3407 if (s
== NULL
|| cb
== NULL
) {
3408 show_oops(NULL
, "walk_js_wl invalid parameters");
3412 RB_FOREACH_REVERSE(d
, domain_list
, &js_wl
)
3413 cb(s
, d
->d
, cb_args
);
3417 walk_pl_wl(struct settings
*s
,
3418 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3422 if (s
== NULL
|| cb
== NULL
) {
3423 show_oops(NULL
, "walk_pl_wl invalid parameters");
3427 RB_FOREACH_REVERSE(d
, domain_list
, &pl_wl
)
3428 cb(s
, d
->d
, cb_args
);
3432 walk_force_https(struct settings
*s
,
3433 void (*cb
)(struct settings
*, char *, void *), void *cb_args
)
3437 if (s
== NULL
|| cb
== NULL
) {
3438 show_oops(NULL
, "walk_force_https invalid parameters");
3442 RB_FOREACH_REVERSE(d
, domain_list
, &force_https
)
3443 cb(s
, d
->d
, cb_args
);
3447 settings_add(char *var
, char *val
)
3451 char c
[PATH_MAX
], **s
;
3454 for (i
= 0, rv
= 0; i
< LENGTH(rs
); i
++) {
3455 if (strcmp(var
, rs
[i
].name
))
3458 if (!strcmp(var
, "include_config")) {
3459 expand_tilde(c
, sizeof c
, val
);
3466 if (rs
[i
].s
->set(&rs
[i
], val
))
3467 startpage_add("invalid value for %s: %s", var
,
3472 switch (rs
[i
].type
) {
3473 case XT_S_INT
: /* FALLTHROUGH */
3482 errx(1, "invalid sval for %s",
3496 errx(1, "invalid type for %s", var
);
3505 config_parse(char *filename
, int runtime
)
3508 char *line
, *cp
, *var
, *val
;
3509 size_t len
, lineno
= 0;
3511 char file
[PATH_MAX
];
3514 DNPRINTF(XT_D_CONFIG
, "config_parse: filename %s\n", filename
);
3516 if (filename
== NULL
)
3519 if (runtime
&& runtime_settings
[0] != '\0') {
3520 snprintf(file
, sizeof file
, "%s" PS
"%s",
3521 work_dir
, runtime_settings
);
3522 if (stat(file
, &sb
)) {
3523 warnx("runtime file doesn't exist, creating it");
3524 if ((f
= fopen(file
, "w")) == NULL
)
3526 fprintf(f
, "# AUTO GENERATED, DO NOT EDIT\n");
3530 strlcpy(file
, filename
, sizeof file
);
3532 if ((config
= fopen(file
, "r")) == NULL
) {
3533 warn("config_parse: cannot open %s", filename
);
3538 if ((line
= fparseln(config
, &len
, &lineno
, NULL
, 0)) == NULL
)
3539 if (feof(config
) || ferror(config
))
3543 cp
+= (long)strspn(cp
, WS
);
3544 if (cp
[0] == '\0') {
3550 if ((var
= strsep(&cp
, WS
)) == NULL
|| cp
== NULL
)
3551 startpage_add("invalid configuration file entry: %s",
3554 cp
+= (long)strspn(cp
, WS
);
3556 if ((val
= strsep(&cp
, "\0")) == NULL
)
3559 DNPRINTF(XT_D_CONFIG
, "config_parse: %s=%s\n",
3561 handled
= settings_add(var
, val
);
3564 startpage_add("invalid configuration file entry"
3565 ": %s=%s", var
, val
);
3574 struct settings_args
{
3580 print_setting(struct settings
*s
, char *val
, void *cb_args
)
3582 char *enc_val
, *tmp
, *color
;
3583 struct settings_args
*sa
= cb_args
;
3585 if (sa
== NULL
|| s
->flags
& XT_SF_INVISIBLE
)
3588 if (s
->flags
& XT_SF_RUNTIME
)
3593 enc_val
= html_escape(val
);
3595 *sa
->body
= g_strdup_printf(
3597 "<td style='background-color: %s; width: 10%%;word-break:break-all'>%s</td>"
3598 "<td style='background-color: %s; width: 20%%;word-break:break-all'>%s</td>",
3603 enc_val
== NULL
? "" : enc_val
3612 print_runtime_setting(struct settings
*s
, char *val
, void *cb_args
)
3614 char *tmp
, *tt
= NULL
;
3615 struct settings_args
*sa
= cb_args
;
3622 if (s
== NULL
|| s
->flags
& XT_SF_INVISIBLE
|| s
->activate
== NULL
)
3627 modified
= s
->ismodified(&tt
);
3628 *sa
->body
= g_strdup_printf(
3630 "<td title=\"%s\" style='width: 240px;'><div style='width: 100%%;'>%s</div></td>"
3631 "<td title=\"%s\"><div style='width: 100%%; word-break:break-all'>",
3633 modified
? "id='modified'" : "",
3641 if (s
->type
== XT_S_STR
&& s
->s
&& s
->s
->valid_options
[0]) {
3642 *sa
->body
= g_strdup_printf("%s<select name='%s'>",
3645 for (i
= 0; s
->s
->valid_options
[i
]; ++i
) {
3648 *sa
->body
= g_strdup_printf("%s"
3649 "<option value='%s' %s>%s</option>",
3651 s
->s
->valid_options
[i
],
3652 !strcmp(s
->s
->valid_options
[i
], val
) ? "selected" : "",
3653 s
->s
->valid_options
[i
]);
3655 } else if (s
->type
== XT_S_STR
)
3656 *sa
->body
= g_strdup_printf(
3657 "%s<input style='width: 98%%' type='text' name='%s' value='%s'>"
3662 else if (s
->type
== XT_S_INT
)
3663 *sa
->body
= g_strdup_printf(
3664 "%s<input type='number' name='%s' value='%s'>"
3669 else if (s
->type
== XT_S_FLOAT
)
3670 *sa
->body
= g_strdup_printf(
3671 "%s<input type='number' step='0.000001' name='%s' value='%s'>"
3676 else if (s
->type
== XT_S_BOOL
)
3677 *sa
->body
= g_strdup_printf(
3678 "%s<input type='hidden' name='%s' value='0'>"
3679 "<input type='checkbox' name='%s' value='1''%s>"
3684 atoi(val
) ? " checked='checked'" : "");
3686 *sa
->body
= g_strdup(*sa
->body
);
3687 warnx("Did not print setting %s", s
->name
);
3694 print_set_rejects(void)
3696 struct set_reject
*sr
, *st
;
3697 char *body
= NULL
, *tmp
;
3699 if (TAILQ_EMPTY(&srl
))
3702 body
= g_strdup_printf("The following settings were invalid and could "
3703 "not be set:<br><div align='center'><table id='settings'>"
3704 "<th align='left'>Setting</th>"
3705 "<th align='left'>Value</th>");
3706 TAILQ_FOREACH_SAFE(sr
, &srl
, entry
, st
) {
3708 body
= g_strdup_printf("%s\n<tr>"
3709 "<td style='width:240px'><div>%s</div></td>"
3710 "<td><div style='word-break:break-all'>%s</div></td></tr>",
3715 TAILQ_REMOVE(&srl
, sr
, entry
);
3721 body
= g_strdup_printf("%s</table></div><br>", body
);
3727 xtp_page_set(struct tab
*t
, struct karg
*args
)
3729 char *body
, *page
, *tmp
;
3731 struct settings_args sa
;
3733 bzero(&sa
, sizeof sa
);
3737 body
= g_strdup_printf("<div align='center'><table><tr>"
3738 "<th align='left'>Setting</th>"
3739 "<th align='left'>Value</th></tr>\n");
3741 settings_walk(print_setting
, &sa
);
3744 /* small message if there are none */
3747 body
= g_strdup_printf("%s\n<tr><td style='text-align:center'"
3748 "colspan='2'>No settings</td></tr>\n", body
);
3753 body
= g_strdup_printf("%s</table></div>", body
);
3756 page
= get_html_page("Settings", body
, "", 0);
3760 load_webkit_string(t
, page
, XT_URI_ABOUT_SET
);
3764 return (XT_CB_PASSTHROUGH
);
3768 xtp_page_rt(struct tab
*t
, struct karg
*args
)
3770 char *body
= NULL
, *page
, *tmp
;
3772 struct settings_args sa
;
3774 generate_xtp_session_key(&t
->session_key
);
3776 bzero(&sa
, sizeof sa
);
3780 body
= print_set_rejects();
3783 body
= g_strdup_printf("%s<div align='center'>"
3784 "<form method='GET' action='%s%d/%s/%d'>"
3785 "<input type='submit' value='Save Settings'>"
3786 "<table id='settings'>"
3787 "<th align='left'>Setting</th>"
3788 "<th align='left'>Value</th>\n",
3796 settings_walk(print_runtime_setting
, &sa
);
3799 /* small message if there are none */
3802 body
= g_strdup_printf("%s\n<tr><td style='text-align:center'"
3803 "colspan='2'>No settings</td></tr>\n", body
);
3808 body
= g_strdup_printf("%s</table>"
3809 "<input type='submit' value='Save Settings'></form></div>", body
);
3812 page
= get_html_page("Runtime Settings", body
, "", 1);
3816 load_webkit_string(t
, page
, XT_URI_ABOUT_RUNTIME
);
3820 return (XT_CB_PASSTHROUGH
);
3824 set(struct tab
*t
, struct karg
*args
)
3829 if (args
== NULL
|| args
->s
== NULL
)
3830 return (xtp_page_set(t
, args
));
3833 p
= g_strstrip(args
->s
);
3836 return (xtp_page_set(t
, args
));
3838 /* we got some sort of string */
3839 val
= g_strstr_len(p
, strlen(p
), "=");
3842 val
= g_strstrip(val
);
3845 for (i
= 0; i
< get_settings_size(); i
++) {
3846 if (strcmp(rs
[i
].name
, p
))
3849 if (rs
[i
].activate
) {
3850 if (rs
[i
].activate(val
))
3851 show_oops(t
, "%s invalid value %s",
3854 show_oops(t
, ":set %s = %s", p
, val
);
3857 show_oops(t
, "not a runtime option: %s", p
);
3861 show_oops(t
, "unknown option: %s", p
);
3865 for (i
= 0; i
< get_settings_size(); i
++) {
3866 if (strcmp(rs
[i
].name
, p
))
3869 /* XXX this could use some cleanup */
3870 switch (rs
[i
].type
) {
3871 case XT_S_INT
: /* FALLTHROUGH */
3874 show_oops(t
, "%s = %d",
3875 rs
[i
].name
, *rs
[i
].ival
);
3876 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3877 show_oops(t
, "%s = %s",
3879 rs
[i
].s
->get(&rs
[i
]));
3880 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3881 show_oops(t
, "%s = ...", rs
[i
].name
);
3883 show_oops(t
, "%s = ", rs
[i
].name
);
3887 show_oops(t
, "%s = %f",
3888 rs
[i
].name
, *rs
[i
].fval
);
3889 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3890 show_oops(t
, "%s = %s",
3892 rs
[i
].s
->get(&rs
[i
]));
3893 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3894 show_oops(t
, "%s = ...", rs
[i
].name
);
3896 show_oops(t
, "%s = ", rs
[i
].name
);
3899 if (rs
[i
].sval
&& *rs
[i
].sval
)
3900 show_oops(t
, "%s = %s",
3901 rs
[i
].name
, *rs
[i
].sval
);
3902 else if (rs
[i
].s
&& rs
[i
].s
->get
)
3903 show_oops(t
, "%s = %s",
3905 rs
[i
].s
->get(&rs
[i
]));
3906 else if (rs
[i
].s
&& rs
[i
].s
->get
== NULL
)
3907 show_oops(t
, "%s = ...", rs
[i
].name
);
3909 show_oops(t
, "%s = ", rs
[i
].name
);
3912 show_oops(t
, "unknown type for %s", rs
[i
].name
);
3918 show_oops(t
, "unknown option: %s", p
);
3921 return (XT_CB_PASSTHROUGH
);