2004-02-13 19:09:12 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2005-12-01 05:59:55 +03:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-02-13 19:09:12 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Option reading and saving (implementation).
|
|
|
|
*
|
|
|
|
* Options are stored in the format key:value, one per line. For bool options,
|
|
|
|
* value is "0" or "1".
|
|
|
|
*/
|
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
#include <assert.h>
|
2004-02-13 19:09:12 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-08-11 20:44:12 +04:00
|
|
|
#include <strings.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "css/css.h"
|
|
|
|
#include "desktop/options.h"
|
2009-07-21 14:59:53 +04:00
|
|
|
#include "desktop/plot_style.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2006-07-24 02:32:33 +04:00
|
|
|
#if defined(riscos)
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/options.h"
|
2006-07-24 02:32:33 +04:00
|
|
|
#elif defined(nsgtk)
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "gtk/options.h"
|
2008-07-29 13:28:45 +04:00
|
|
|
#elif defined(nsbeos)
|
|
|
|
#include "beos/options.h"
|
2008-08-25 17:27:44 +04:00
|
|
|
#elif defined(nsamiga)
|
|
|
|
#include "amiga/options.h"
|
2009-06-28 22:32:47 +04:00
|
|
|
#elif defined(nsframebuffer)
|
|
|
|
#include "framebuffer/options.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#elif defined(nsatari)
|
|
|
|
#include "atari/options.h"
|
2011-03-12 18:08:07 +03:00
|
|
|
#elif defined(nsmonkey)
|
|
|
|
#include "monkey/options.h"
|
2004-02-13 19:09:12 +03:00
|
|
|
#else
|
|
|
|
#define EXTRA_OPTION_DEFINE
|
|
|
|
#define EXTRA_OPTION_TABLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/** An HTTP proxy should be used. */
|
|
|
|
bool option_http_proxy = false;
|
|
|
|
/** Hostname of proxy. */
|
|
|
|
char *option_http_proxy_host = 0;
|
|
|
|
/** Proxy port. */
|
|
|
|
int option_http_proxy_port = 8080;
|
2004-07-27 19:49:28 +04:00
|
|
|
/** Proxy authentication method. */
|
|
|
|
int option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE;
|
|
|
|
/** Proxy authentication user name */
|
|
|
|
char *option_http_proxy_auth_user = 0;
|
|
|
|
/** Proxy authentication password */
|
|
|
|
char *option_http_proxy_auth_pass = 0;
|
2004-02-14 02:07:42 +03:00
|
|
|
/** Default font size / 0.1pt. */
|
2007-12-09 14:13:25 +03:00
|
|
|
int option_font_size = 128;
|
2004-02-14 02:07:42 +03:00
|
|
|
/** Minimum font size. */
|
2007-12-09 14:13:25 +03:00
|
|
|
int option_font_min_size = 85;
|
2006-03-31 14:41:21 +04:00
|
|
|
/** Default sans serif font */
|
|
|
|
char *option_font_sans;
|
|
|
|
/** Default serif font */
|
|
|
|
char *option_font_serif;
|
|
|
|
/** Default monospace font */
|
|
|
|
char *option_font_mono;
|
|
|
|
/** Default cursive font */
|
|
|
|
char *option_font_cursive;
|
|
|
|
/** Default fantasy font */
|
|
|
|
char *option_font_fantasy;
|
2004-03-08 03:03:58 +03:00
|
|
|
/** Accept-Language header. */
|
|
|
|
char *option_accept_language = 0;
|
2006-12-28 03:42:14 +03:00
|
|
|
/** Accept-Charset header. */
|
|
|
|
char *option_accept_charset = 0;
|
2004-06-21 19:09:59 +04:00
|
|
|
/** Preferred maximum size of memory cache / bytes. */
|
|
|
|
int option_memory_cache_size = 2 * 1024 * 1024;
|
2006-01-07 03:39:14 +03:00
|
|
|
/** Preferred expiry age of disc cache / days. */
|
|
|
|
int option_disc_cache_age = 28;
|
2004-07-31 03:40:01 +04:00
|
|
|
/** Whether to block advertisements */
|
|
|
|
bool option_block_ads = false;
|
2004-10-05 03:54:42 +04:00
|
|
|
/** Minimum GIF animation delay */
|
|
|
|
int option_minimum_gif_delay = 10;
|
2004-10-02 01:31:55 +04:00
|
|
|
/** Whether to send the referer HTTP header */
|
|
|
|
bool option_send_referer = true;
|
2004-12-09 13:30:44 +03:00
|
|
|
/** Whether to animate images */
|
|
|
|
bool option_animate_images = true;
|
2005-12-30 02:18:17 +03:00
|
|
|
/** How many days to retain URL data for */
|
|
|
|
int option_expire_url = 28;
|
2006-01-03 02:31:29 +03:00
|
|
|
/** Default font family */
|
2009-07-21 14:59:53 +04:00
|
|
|
int option_font_default = PLOT_FONT_FAMILY_SANS_SERIF;
|
2006-01-08 04:51:33 +03:00
|
|
|
/** ca-bundle location */
|
|
|
|
char *option_ca_bundle = 0;
|
2007-06-27 19:39:56 +04:00
|
|
|
/** ca-path location */
|
|
|
|
char *option_ca_path = 0;
|
2006-01-08 04:51:33 +03:00
|
|
|
/** Cookie file location */
|
|
|
|
char *option_cookie_file = 0;
|
2009-12-18 02:55:02 +03:00
|
|
|
/** Cookie jar location */
|
2006-01-08 04:51:33 +03:00
|
|
|
char *option_cookie_jar = 0;
|
2006-03-29 19:26:54 +04:00
|
|
|
/** Home page location */
|
|
|
|
char *option_homepage_url = 0;
|
2009-12-18 02:55:02 +03:00
|
|
|
/** search web from url bar */
|
|
|
|
bool option_search_url_bar = false;
|
2006-07-28 19:52:37 +04:00
|
|
|
/** URL completion in url bar */
|
|
|
|
bool option_url_suggestion = true;
|
2009-12-18 02:55:02 +03:00
|
|
|
/** default web search provider */
|
|
|
|
int option_search_provider = 0;
|
2006-08-29 04:17:35 +04:00
|
|
|
/** default x position of new windows */
|
|
|
|
int option_window_x = 0;
|
|
|
|
/** default y position of new windows */
|
|
|
|
int option_window_y = 0;
|
|
|
|
/** default width of new windows */
|
|
|
|
int option_window_width = 0;
|
|
|
|
/** default height of new windows */
|
|
|
|
int option_window_height = 0;
|
|
|
|
/** width of screen when above options were saved */
|
|
|
|
int option_window_screen_width = 0;
|
|
|
|
/** height of screen when above options were saved */
|
|
|
|
int option_window_screen_height = 0;
|
|
|
|
/** default size of status bar vs. h scroll bar */
|
|
|
|
int option_toolbar_status_width = 6667;
|
2007-08-07 07:55:18 +04:00
|
|
|
/** default window scale */
|
|
|
|
int option_scale = 100;
|
2008-03-01 02:03:26 +03:00
|
|
|
/* Whether to reflow web pages while objects are fetching */
|
|
|
|
bool option_incremental_reflow = true;
|
|
|
|
/* Minimum time between HTML reflows while objects are fetching */
|
|
|
|
#ifdef riscos
|
2008-03-11 03:14:39 +03:00
|
|
|
unsigned int option_min_reflow_period = 100; /* time in cs */
|
2008-03-01 02:03:26 +03:00
|
|
|
#else
|
2008-03-11 03:14:39 +03:00
|
|
|
unsigned int option_min_reflow_period = 25; /* time in cs */
|
2008-03-01 02:03:26 +03:00
|
|
|
#endif
|
2009-08-14 14:37:33 +04:00
|
|
|
bool option_core_select_menu = false;
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
/** top margin of exported page*/
|
|
|
|
int option_margin_top = DEFAULT_MARGIN_TOP_MM;
|
|
|
|
/** bottom margin of exported page*/
|
|
|
|
int option_margin_bottom = DEFAULT_MARGIN_BOTTOM_MM;
|
|
|
|
/** left margin of exported page*/
|
|
|
|
int option_margin_left = DEFAULT_MARGIN_LEFT_MM;
|
|
|
|
/** right margin of exported page*/
|
|
|
|
int option_margin_right = DEFAULT_MARGIN_RIGHT_MM;
|
|
|
|
/** scale of exported content*/
|
|
|
|
int option_export_scale = DEFAULT_EXPORT_SCALE * 100;
|
|
|
|
/**suppressing images in printed content*/
|
|
|
|
bool option_suppress_images = false;
|
|
|
|
/**turning off all backgrounds for printed content*/
|
|
|
|
bool option_remove_backgrounds = false;
|
|
|
|
/**turning on content loosening for printed content*/
|
|
|
|
bool option_enable_loosening = true;
|
|
|
|
/**compression of PDF documents*/
|
|
|
|
bool option_enable_PDF_compression = true;
|
|
|
|
/**setting a password and encoding PDF documents*/
|
|
|
|
bool option_enable_PDF_password = false;
|
2006-08-29 04:17:35 +04:00
|
|
|
|
2006-03-14 17:21:01 +03:00
|
|
|
/* Fetcher configuration */
|
|
|
|
/** Maximum simultaneous active fetchers */
|
|
|
|
int option_max_fetchers = 24;
|
|
|
|
/** Maximum simultaneous active fetchers per host.
|
2008-07-18 13:52:18 +04:00
|
|
|
* (<=option_max_fetchers else it makes no sense)
|
|
|
|
* Note that rfc2616 section 8.1.4 says that there should be no more than
|
|
|
|
* two keepalive connections per host. None of the main browsers follow this
|
|
|
|
* as it slows page fetches down considerably.
|
|
|
|
* See https://bugzilla.mozilla.org/show_bug.cgi?id=423377#c4
|
2006-03-14 17:21:01 +03:00
|
|
|
*/
|
2008-07-18 13:52:18 +04:00
|
|
|
int option_max_fetchers_per_host = 5;
|
2006-03-14 17:21:01 +03:00
|
|
|
/** Maximum number of inactive fetchers cached.
|
|
|
|
* The total number of handles netsurf will therefore have open
|
|
|
|
* is this plus option_max_fetchers.
|
|
|
|
*/
|
|
|
|
int option_max_cached_fetch_handles = 6;
|
2007-06-27 20:27:52 +04:00
|
|
|
/** Suppress debug output from cURL. */
|
|
|
|
bool option_suppress_curl_debug = true;
|
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** Whether to allow target="_blank" */
|
|
|
|
bool option_target_blank = true;
|
2006-03-14 17:21:01 +03:00
|
|
|
|
2008-11-29 03:24:09 +03:00
|
|
|
/** Whether second mouse button opens in new tab */
|
|
|
|
bool option_button_2_tab = true;
|
|
|
|
|
2010-12-21 20:00:44 +03:00
|
|
|
/* Interface colours */
|
|
|
|
colour option_gui_colour_bg_1 = 0xFFCCBB; /** Background (bbggrr) */
|
|
|
|
colour option_gui_colour_fg_1 = 0x000000; /** Foreground (bbggrr) */
|
|
|
|
colour option_gui_colour_fg_2 = 0xFFFBF8; /** Foreground selected (bbggrr) */
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
/* system colours */
|
|
|
|
colour option_sys_colour_ActiveBorder = 0x00000000;
|
|
|
|
colour option_sys_colour_ActiveCaption = 0x00000000;
|
|
|
|
colour option_sys_colour_AppWorkspace = 0x00000000;
|
|
|
|
colour option_sys_colour_Background = 0x00000000;
|
|
|
|
colour option_sys_colour_ButtonFace = 0x00000000;
|
|
|
|
colour option_sys_colour_ButtonHighlight = 0x00000000;
|
|
|
|
colour option_sys_colour_ButtonShadow = 0x00000000;
|
|
|
|
colour option_sys_colour_ButtonText = 0x00000000;
|
|
|
|
colour option_sys_colour_CaptionText = 0x0000000;
|
|
|
|
colour option_sys_colour_GrayText = 0x00000000;
|
|
|
|
colour option_sys_colour_Highlight = 0x00000000;
|
|
|
|
colour option_sys_colour_HighlightText = 0x00000000;
|
|
|
|
colour option_sys_colour_InactiveBorder = 0x00000000;
|
|
|
|
colour option_sys_colour_InactiveCaption = 0x00000000;
|
|
|
|
colour option_sys_colour_InactiveCaptionText = 0x00000000;
|
|
|
|
colour option_sys_colour_InfoBackground = 0x00000000;
|
|
|
|
colour option_sys_colour_InfoText = 0x00000000;
|
|
|
|
colour option_sys_colour_Menu = 0x00000000;
|
|
|
|
colour option_sys_colour_MenuText = 0x0000000;
|
|
|
|
colour option_sys_colour_Scrollbar = 0x0000000;
|
|
|
|
colour option_sys_colour_ThreeDDarkShadow = 0x000000;
|
|
|
|
colour option_sys_colour_ThreeDFace = 0x000000;
|
|
|
|
colour option_sys_colour_ThreeDHighlight = 0x000000;
|
|
|
|
colour option_sys_colour_ThreeDLightShadow = 0x000000;
|
|
|
|
colour option_sys_colour_ThreeDShadow = 0x000000;
|
|
|
|
colour option_sys_colour_Window = 0x000000;
|
|
|
|
colour option_sys_colour_WindowFrame = 0x000000;
|
|
|
|
colour option_sys_colour_WindowText = 0x000000;
|
|
|
|
|
|
|
|
|
2004-02-13 19:09:12 +03:00
|
|
|
EXTRA_OPTION_DEFINE
|
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
enum option_type_e {
|
|
|
|
OPTION_BOOL,
|
|
|
|
OPTION_INTEGER,
|
|
|
|
OPTION_STRING,
|
|
|
|
OPTION_COLOUR
|
|
|
|
} ;
|
|
|
|
|
|
|
|
struct option_entry_s {
|
2004-02-13 19:09:12 +03:00
|
|
|
const char *key;
|
2011-02-21 00:04:53 +03:00
|
|
|
enum option_type_e type;
|
2004-02-13 19:09:12 +03:00
|
|
|
void *p;
|
2011-02-21 00:04:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct option_entry_s option_table[] = {
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "http_proxy", OPTION_BOOL, &option_http_proxy },
|
|
|
|
{ "http_proxy_host", OPTION_STRING, &option_http_proxy_host },
|
|
|
|
{ "http_proxy_port", OPTION_INTEGER, &option_http_proxy_port },
|
|
|
|
{ "http_proxy_auth", OPTION_INTEGER, &option_http_proxy_auth },
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "http_proxy_auth_user", OPTION_STRING, &option_http_proxy_auth_user },
|
|
|
|
{ "http_proxy_auth_pass", OPTION_STRING, &option_http_proxy_auth_pass },
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "font_size", OPTION_INTEGER, &option_font_size },
|
|
|
|
{ "font_min_size", OPTION_INTEGER, &option_font_min_size },
|
|
|
|
{ "font_sans", OPTION_STRING, &option_font_sans },
|
|
|
|
{ "font_serif", OPTION_STRING, &option_font_serif },
|
|
|
|
{ "font_mono", OPTION_STRING, &option_font_mono },
|
|
|
|
{ "font_cursive", OPTION_STRING, &option_font_cursive },
|
|
|
|
{ "font_fantasy", OPTION_STRING, &option_font_fantasy },
|
|
|
|
{ "accept_language", OPTION_STRING, &option_accept_language },
|
|
|
|
{ "accept_charset", OPTION_STRING, &option_accept_charset },
|
|
|
|
{ "memory_cache_size", OPTION_INTEGER, &option_memory_cache_size },
|
|
|
|
{ "disc_cache_age", OPTION_INTEGER, &option_disc_cache_age },
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "block_advertisements", OPTION_BOOL, &option_block_ads },
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay },
|
|
|
|
{ "send_referer", OPTION_BOOL, &option_send_referer },
|
|
|
|
{ "animate_images", OPTION_BOOL, &option_animate_images },
|
|
|
|
{ "expire_url", OPTION_INTEGER, &option_expire_url },
|
|
|
|
{ "font_default", OPTION_INTEGER, &option_font_default },
|
|
|
|
{ "ca_bundle", OPTION_STRING, &option_ca_bundle },
|
|
|
|
{ "ca_path", OPTION_STRING, &option_ca_path },
|
|
|
|
{ "cookie_file", OPTION_STRING, &option_cookie_file },
|
|
|
|
{ "cookie_jar", OPTION_STRING, &option_cookie_jar },
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "homepage_url", OPTION_STRING, &option_homepage_url },
|
|
|
|
{ "search_url_bar", OPTION_BOOL, &option_search_url_bar},
|
|
|
|
{ "search_provider", OPTION_INTEGER, &option_search_provider},
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "url_suggestion", OPTION_BOOL, &option_url_suggestion },
|
|
|
|
{ "window_x", OPTION_INTEGER, &option_window_x },
|
|
|
|
{ "window_y", OPTION_INTEGER, &option_window_y },
|
|
|
|
{ "window_width", OPTION_INTEGER, &option_window_width },
|
|
|
|
{ "window_height", OPTION_INTEGER, &option_window_height },
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "window_screen_width", OPTION_INTEGER, &option_window_screen_width },
|
|
|
|
{ "window_screen_height", OPTION_INTEGER, &option_window_screen_height },
|
|
|
|
{ "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width },
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "scale", OPTION_INTEGER, &option_scale },
|
|
|
|
{ "incremental_reflow", OPTION_BOOL, &option_incremental_reflow },
|
|
|
|
{ "min_reflow_period", OPTION_INTEGER, &option_min_reflow_period },
|
2009-08-14 14:37:33 +04:00
|
|
|
{ "core_select_menu", OPTION_BOOL, &option_core_select_menu },
|
2006-03-14 17:21:01 +03:00
|
|
|
/* Fetcher options */
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "max_fetchers", OPTION_INTEGER, &option_max_fetchers },
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "max_fetchers_per_host", OPTION_INTEGER, &option_max_fetchers_per_host },
|
|
|
|
{ "max_cached_fetch_handles", OPTION_INTEGER, &option_max_cached_fetch_handles },
|
2008-11-29 03:24:09 +03:00
|
|
|
{ "suppress_curl_debug",OPTION_BOOL, &option_suppress_curl_debug },
|
|
|
|
{ "target_blank", OPTION_BOOL, &option_target_blank },
|
|
|
|
{ "button_2_tab", OPTION_BOOL, &option_button_2_tab },
|
|
|
|
/* PDF / Print options*/
|
|
|
|
{ "margin_top", OPTION_INTEGER, &option_margin_top},
|
|
|
|
{ "margin_bottom", OPTION_INTEGER, &option_margin_bottom},
|
|
|
|
{ "margin_left", OPTION_INTEGER, &option_margin_left},
|
|
|
|
{ "margin_right", OPTION_INTEGER, &option_margin_right},
|
|
|
|
{ "export_scale", OPTION_INTEGER, &option_export_scale},
|
|
|
|
{ "suppress_images", OPTION_BOOL, &option_suppress_images},
|
|
|
|
{ "remove_backgrounds", OPTION_BOOL, &option_remove_backgrounds},
|
|
|
|
{ "enable_loosening", OPTION_BOOL, &option_enable_loosening},
|
2011-02-21 00:04:53 +03:00
|
|
|
{ "enable_PDF_compression", OPTION_BOOL, &option_enable_PDF_compression},
|
|
|
|
{ "enable_PDF_password", OPTION_BOOL, &option_enable_PDF_password},
|
2010-12-21 20:00:44 +03:00
|
|
|
/* Interface colours */
|
|
|
|
{ "gui_colour_bg_1", OPTION_COLOUR, &option_gui_colour_bg_1},
|
|
|
|
{ "gui_colour_fg_1", OPTION_COLOUR, &option_gui_colour_fg_1},
|
|
|
|
{ "gui_colour_fg_2", OPTION_COLOUR, &option_gui_colour_fg_2},
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
/* System colours */
|
|
|
|
{ "sys_colour_ActiveBorder",OPTION_COLOUR,&option_sys_colour_ActiveBorder },
|
|
|
|
{ "sys_colour_ActiveCaption",OPTION_COLOUR,&option_sys_colour_ActiveCaption },
|
|
|
|
{ "sys_colour_AppWorkspace",OPTION_COLOUR,&option_sys_colour_AppWorkspace },
|
|
|
|
{ "sys_colour_Background",OPTION_COLOUR,&option_sys_colour_Background },
|
|
|
|
{ "sys_colour_ButtonFace",OPTION_COLOUR,&option_sys_colour_ButtonFace },
|
|
|
|
{ "sys_colour_ButtonHighlight",OPTION_COLOUR,&option_sys_colour_ButtonHighlight },
|
|
|
|
{ "sys_colour_ButtonShadow",OPTION_COLOUR,&option_sys_colour_ButtonShadow },
|
|
|
|
{ "sys_colour_ButtonText",OPTION_COLOUR,&option_sys_colour_ButtonText },
|
|
|
|
{ "sys_colour_CaptionText",OPTION_COLOUR,&option_sys_colour_CaptionText },
|
|
|
|
{ "sys_colour_GrayText",OPTION_COLOUR,&option_sys_colour_GrayText },
|
|
|
|
{ "sys_colour_Highlight",OPTION_COLOUR,&option_sys_colour_Highlight },
|
|
|
|
{ "sys_colour_HighlightText",OPTION_COLOUR,&option_sys_colour_HighlightText },
|
|
|
|
{ "sys_colour_InactiveBorder",OPTION_COLOUR,&option_sys_colour_InactiveBorder },
|
|
|
|
{ "sys_colour_InactiveCaption",OPTION_COLOUR,&option_sys_colour_InactiveCaption },
|
|
|
|
{ "sys_colour_InactiveCaptionText",OPTION_COLOUR,&option_sys_colour_InactiveCaptionText },
|
|
|
|
{ "sys_colour_InfoBackground",OPTION_COLOUR,&option_sys_colour_InfoBackground },
|
|
|
|
{ "sys_colour_InfoText",OPTION_COLOUR,&option_sys_colour_InfoText },
|
|
|
|
{ "sys_colour_Menu",OPTION_COLOUR,&option_sys_colour_Menu },
|
|
|
|
{ "sys_colour_MenuText",OPTION_COLOUR,&option_sys_colour_MenuText },
|
|
|
|
{ "sys_colour_Scrollbar",OPTION_COLOUR,&option_sys_colour_Scrollbar },
|
|
|
|
{ "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&option_sys_colour_ThreeDDarkShadow },
|
|
|
|
{ "sys_colour_ThreeDFace",OPTION_COLOUR,&option_sys_colour_ThreeDFace },
|
|
|
|
{ "sys_colour_ThreeDHighlight",OPTION_COLOUR,&option_sys_colour_ThreeDHighlight },
|
|
|
|
{ "sys_colour_ThreeDLightShadow",OPTION_COLOUR,&option_sys_colour_ThreeDLightShadow },
|
|
|
|
{ "sys_colour_ThreeDShadow",OPTION_COLOUR,&option_sys_colour_ThreeDShadow },
|
|
|
|
{ "sys_colour_Window",OPTION_COLOUR,&option_sys_colour_Window },
|
|
|
|
{ "sys_colour_WindowFrame",OPTION_COLOUR,&option_sys_colour_WindowFrame },
|
|
|
|
{ "sys_colour_WindowText",OPTION_COLOUR,&option_sys_colour_WindowText },
|
|
|
|
|
2004-02-13 19:09:12 +03:00
|
|
|
EXTRA_OPTION_TABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
#define option_table_entries (sizeof option_table / sizeof option_table[0])
|
|
|
|
|
2011-03-19 00:58:29 +03:00
|
|
|
/**
|
|
|
|
* Set an option value based on a string
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
strtooption(const char *value, struct option_entry_s *option_entry)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
colour rgbcolour; /* RRGGBB */
|
|
|
|
|
|
|
|
switch (option_entry->type) {
|
|
|
|
case OPTION_BOOL:
|
|
|
|
*((bool *)option_entry->p) = value[0] == '1';
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_INTEGER:
|
|
|
|
*((int *)option_entry->p) = atoi(value);
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_COLOUR:
|
|
|
|
sscanf(value, "%x", &rgbcolour);
|
|
|
|
*((colour *)option_entry->p) =
|
|
|
|
((0x000000FF & rgbcolour) << 16) |
|
|
|
|
((0x0000FF00 & rgbcolour) << 0) |
|
|
|
|
((0x00FF0000 & rgbcolour) >> 16);
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_STRING:
|
|
|
|
free(*((char **)option_entry->p));
|
|
|
|
*((char **)option_entry->p) = strdup(value);
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
}
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2011-03-19 00:58:29 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
/* exported interface documented in options.h */
|
2004-02-13 19:09:12 +03:00
|
|
|
void options_read(const char *path)
|
|
|
|
{
|
|
|
|
char s[100];
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(path, "r");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("failed to open file '%s'", path));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(s, 100, fp)) {
|
|
|
|
char *colon, *value;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (s[0] == 0 || s[0] == '#')
|
|
|
|
continue;
|
|
|
|
colon = strchr(s, ':');
|
|
|
|
if (colon == 0)
|
|
|
|
continue;
|
|
|
|
s[strlen(s) - 1] = 0; /* remove \n at end */
|
|
|
|
*colon = 0; /* terminate key */
|
|
|
|
value = colon + 1;
|
|
|
|
|
|
|
|
for (i = 0; i != option_table_entries; i++) {
|
|
|
|
if (strcasecmp(s, option_table[i].key) != 0)
|
|
|
|
continue;
|
|
|
|
|
2011-03-19 00:58:29 +03:00
|
|
|
strtooption(value, option_table + i);
|
2004-02-13 19:09:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
2004-02-14 02:07:42 +03:00
|
|
|
|
|
|
|
if (option_font_size < 50)
|
|
|
|
option_font_size = 50;
|
|
|
|
if (1000 < option_font_size)
|
|
|
|
option_font_size = 1000;
|
|
|
|
if (option_font_min_size < 10)
|
|
|
|
option_font_min_size = 10;
|
|
|
|
if (500 < option_font_min_size)
|
|
|
|
option_font_min_size = 500;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
|
|
|
if (option_memory_cache_size < 0)
|
|
|
|
option_memory_cache_size = 0;
|
2004-02-13 19:09:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
/* exported interface documented in options.h */
|
2004-02-13 19:09:12 +03:00
|
|
|
void options_write(const char *path)
|
|
|
|
{
|
2011-03-17 12:21:02 +03:00
|
|
|
unsigned int entry;
|
2004-02-13 19:09:12 +03:00
|
|
|
FILE *fp;
|
2010-12-21 20:00:44 +03:00
|
|
|
colour rgbcolour; /* RRGGBB */
|
2004-02-13 19:09:12 +03:00
|
|
|
|
|
|
|
fp = fopen(path, "w");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("failed to open file '%s' for writing", path));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-17 12:21:02 +03:00
|
|
|
for (entry = 0; entry != option_table_entries; entry++) {
|
|
|
|
switch (option_table[entry].type) {
|
2011-02-21 00:04:53 +03:00
|
|
|
case OPTION_BOOL:
|
2011-03-17 12:21:02 +03:00
|
|
|
fprintf(fp, "%s:%c\n", option_table[entry].key,
|
|
|
|
*((bool *) option_table[entry].p) ? '1' : '0');
|
2011-02-21 00:04:53 +03:00
|
|
|
break;
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
case OPTION_INTEGER:
|
2011-03-17 12:21:02 +03:00
|
|
|
fprintf(fp, "%s:%i\n", option_table[entry].key,
|
|
|
|
*((int *) option_table[entry].p));
|
2011-02-21 00:04:53 +03:00
|
|
|
break;
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
case OPTION_COLOUR:
|
|
|
|
rgbcolour = ((0x000000FF & *((colour *)
|
2011-03-17 12:21:02 +03:00
|
|
|
option_table[entry].p)) << 16) |
|
2011-02-21 00:04:53 +03:00
|
|
|
((0x0000FF00 & *((colour *)
|
2011-03-17 12:21:02 +03:00
|
|
|
option_table[entry].p)) << 0) |
|
2011-02-21 00:04:53 +03:00
|
|
|
((0x00FF0000 & *((colour *)
|
2011-03-17 12:21:02 +03:00
|
|
|
option_table[entry].p)) >> 16);
|
|
|
|
fprintf(fp, "%s:%06x\n", option_table[entry].key,
|
|
|
|
rgbcolour);
|
2011-02-21 00:04:53 +03:00
|
|
|
break;
|
2010-12-21 20:00:44 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
case OPTION_STRING:
|
2011-03-17 12:21:02 +03:00
|
|
|
if (((*((char **) option_table[entry].p)) != NULL) &&
|
|
|
|
(*(*((char **) option_table[entry].p)) != 0)) {
|
|
|
|
fprintf(fp, "%s:%s\n", option_table[entry].key,
|
|
|
|
*((char **) option_table[entry].p));
|
|
|
|
}
|
2011-02-21 00:04:53 +03:00
|
|
|
break;
|
2004-02-13 19:09:12 +03:00
|
|
|
}
|
2009-04-21 00:31:13 +04:00
|
|
|
}
|
2004-02-13 19:09:12 +03:00
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2004-12-09 13:30:44 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
|
2011-02-21 02:19:18 +03:00
|
|
|
/**
|
|
|
|
* Output an option value into a string, in HTML format.
|
|
|
|
*
|
|
|
|
* \param option The option to output the value of.
|
|
|
|
* \param size The size of the string buffer.
|
|
|
|
* \param pos The current position in string
|
|
|
|
* \param string The string in which to output the value.
|
|
|
|
* \return The number of bytes written to string or -1 on error
|
|
|
|
*/
|
|
|
|
static size_t options_output_value_html(struct option_entry_s *option,
|
|
|
|
size_t size, size_t pos, char *string)
|
|
|
|
{
|
2011-02-21 02:40:42 +03:00
|
|
|
size_t slen = 0; /* length added to string */
|
2011-02-21 02:19:18 +03:00
|
|
|
colour rgbcolour; /* RRGGBB */
|
|
|
|
|
|
|
|
switch (option->type) {
|
|
|
|
case OPTION_BOOL:
|
|
|
|
slen = snprintf(string + pos, size - pos, "%s",
|
|
|
|
*((bool *)option->p) ? "true" : "false");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_INTEGER:
|
|
|
|
slen = snprintf(string + pos, size - pos, "%i",
|
|
|
|
*((int *)option->p));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_COLOUR:
|
|
|
|
rgbcolour = ((0x000000FF & *((colour *) option->p)) << 16) |
|
|
|
|
((0x0000FF00 & *((colour *) option->p)) << 0) |
|
|
|
|
((0x00FF0000 & *((colour *) option->p)) >> 16);
|
|
|
|
slen = snprintf(string + pos, size - pos,
|
|
|
|
"<span style=\"background-color: #%06x; "
|
|
|
|
"color: #%06x;\">#%06x</span>", rgbcolour,
|
|
|
|
(~rgbcolour) & 0xffffff, rgbcolour);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_STRING:
|
|
|
|
if (*((char **)option->p) != NULL) {
|
|
|
|
slen = snprintf(string + pos, size - pos, "%s",
|
|
|
|
*((char **)option->p));
|
|
|
|
} else {
|
|
|
|
slen = snprintf(string + pos, size - pos,
|
|
|
|
"<span class=\"null-content\">NULL"
|
|
|
|
"</span>");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return slen;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output an option value into a string, in plain text format.
|
|
|
|
*
|
|
|
|
* \param option The option to output the value of.
|
|
|
|
* \param size The size of the string buffer.
|
|
|
|
* \param pos The current position in string
|
|
|
|
* \param string The string in which to output the value.
|
|
|
|
* \return The number of bytes written to string or -1 on error
|
|
|
|
*/
|
|
|
|
static size_t options_output_value_text(struct option_entry_s *option,
|
|
|
|
size_t size, size_t pos, char *string)
|
|
|
|
{
|
2011-02-21 02:40:42 +03:00
|
|
|
size_t slen = 0; /* length added to string */
|
2011-02-21 02:19:18 +03:00
|
|
|
colour rgbcolour; /* RRGGBB */
|
|
|
|
|
|
|
|
switch (option->type) {
|
|
|
|
case OPTION_BOOL:
|
|
|
|
slen = snprintf(string + pos, size - pos, "%c",
|
|
|
|
*((bool *)option->p) ? '1' : '0');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_INTEGER:
|
|
|
|
slen = snprintf(string + pos, size - pos, "%i",
|
|
|
|
*((int *)option->p));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_COLOUR:
|
|
|
|
rgbcolour = ((0x000000FF & *((colour *) option->p)) << 16) |
|
|
|
|
((0x0000FF00 & *((colour *) option->p)) << 0) |
|
|
|
|
((0x00FF0000 & *((colour *) option->p)) >> 16);
|
2011-02-22 18:53:12 +03:00
|
|
|
slen = snprintf(string + pos, size - pos, "%06x", rgbcolour);
|
2011-02-21 02:19:18 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_STRING:
|
|
|
|
if (*((char **)option->p) != NULL) {
|
|
|
|
slen = snprintf(string + pos, size - pos, "%s",
|
|
|
|
*((char **)option->p));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return slen;
|
|
|
|
}
|
|
|
|
|
2011-03-19 00:58:29 +03:00
|
|
|
/* exported interface documented in options.h */
|
|
|
|
void options_commandline(int *pargc, char **argv)
|
|
|
|
{
|
|
|
|
char *arg;
|
|
|
|
char *val;
|
|
|
|
int arglen;
|
|
|
|
int idx = 1;
|
|
|
|
int mv_loop;
|
|
|
|
|
|
|
|
unsigned int entry_loop;
|
|
|
|
|
|
|
|
while (idx < *pargc) {
|
|
|
|
arg = argv[idx];
|
|
|
|
arglen = strlen(arg);
|
|
|
|
|
|
|
|
/* check we have an option */
|
|
|
|
/* option must start -- and be as long as the shortest option*/
|
|
|
|
if ((arglen < (2+5) ) || (arg[0] != '-') || (arg[1] != '-'))
|
|
|
|
break;
|
|
|
|
|
|
|
|
arg += 2; /* skip -- */
|
|
|
|
|
|
|
|
val = strchr(arg, '=');
|
|
|
|
if (val == NULL) {
|
|
|
|
/* no equals sign - next parameter is val */
|
|
|
|
idx++;
|
|
|
|
if (idx >= *pargc)
|
|
|
|
break;
|
|
|
|
val = argv[idx];
|
|
|
|
} else {
|
|
|
|
/* equals sign */
|
|
|
|
arglen = val - arg ;
|
|
|
|
val++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* arg+arglen is the option to set, val is the value */
|
|
|
|
|
|
|
|
LOG(("%.*s = %s",arglen,arg,val));
|
|
|
|
|
|
|
|
for (entry_loop = 0;
|
|
|
|
entry_loop < option_table_entries;
|
|
|
|
entry_loop++) {
|
|
|
|
if (strncmp(arg, option_table[entry_loop].key,
|
|
|
|
arglen) == 0) {
|
|
|
|
strtooption(val, option_table + entry_loop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove processed options from argv */
|
|
|
|
for (mv_loop=0;mv_loop < (*pargc - idx); mv_loop++) {
|
|
|
|
argv[mv_loop + 1] = argv[mv_loop + idx];
|
|
|
|
}
|
|
|
|
*pargc -= (idx - 1);
|
|
|
|
}
|
2011-02-21 02:19:18 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
/* exported interface documented in options.h */
|
2011-02-21 01:38:43 +03:00
|
|
|
int options_snoptionf(char *string, size_t size, unsigned int option,
|
|
|
|
const char *fmt)
|
2006-01-01 21:52:30 +03:00
|
|
|
{
|
2011-02-21 00:04:53 +03:00
|
|
|
size_t slen = 0; /* current output string length */
|
|
|
|
int fmtc = 0; /* current index into format string */
|
|
|
|
struct option_entry_s *option_entry;
|
2006-01-01 21:52:30 +03:00
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
if (option >= option_table_entries)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
option_entry = option_table + option;
|
|
|
|
|
|
|
|
while((slen < size) && (fmt[fmtc] != 0)) {
|
|
|
|
if (fmt[fmtc] == '%') {
|
|
|
|
fmtc++;
|
|
|
|
switch (fmt[fmtc]) {
|
|
|
|
case 'k':
|
2011-02-21 02:19:18 +03:00
|
|
|
slen += snprintf(string + slen, size - slen,
|
|
|
|
"%s", option_entry->key);
|
2006-01-01 21:52:30 +03:00
|
|
|
break;
|
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
case 't':
|
|
|
|
switch (option_entry->type) {
|
|
|
|
case OPTION_BOOL:
|
|
|
|
slen += snprintf(string + slen,
|
|
|
|
size - slen,
|
|
|
|
"boolean");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_INTEGER:
|
|
|
|
slen += snprintf(string + slen,
|
|
|
|
size - slen,
|
|
|
|
"integer");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_COLOUR:
|
|
|
|
slen += snprintf(string + slen,
|
|
|
|
size - slen,
|
|
|
|
"colour");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION_STRING:
|
|
|
|
slen += snprintf(string + slen,
|
|
|
|
size - slen,
|
|
|
|
"string");
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2006-01-01 21:52:30 +03:00
|
|
|
break;
|
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
|
|
|
|
case 'V':
|
2011-02-21 02:19:18 +03:00
|
|
|
slen += options_output_value_html(option_entry,
|
|
|
|
size, slen, string);
|
2010-12-21 20:00:44 +03:00
|
|
|
break;
|
2011-02-21 00:04:53 +03:00
|
|
|
case 'v':
|
2011-02-21 02:19:18 +03:00
|
|
|
slen += options_output_value_text(option_entry,
|
|
|
|
size, slen, string);
|
2006-01-01 21:52:30 +03:00
|
|
|
break;
|
2011-02-21 00:04:53 +03:00
|
|
|
}
|
|
|
|
fmtc++;
|
|
|
|
} else {
|
|
|
|
string[slen] = fmt[fmtc];
|
|
|
|
slen++;
|
|
|
|
fmtc++;
|
2006-01-01 21:52:30 +03:00
|
|
|
}
|
|
|
|
}
|
2011-02-22 00:25:47 +03:00
|
|
|
|
|
|
|
/* Ensure that we NUL-terminate the output */
|
|
|
|
string[min(slen, size - 1)] = '\0';
|
|
|
|
|
2011-02-21 00:04:53 +03:00
|
|
|
return slen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* exported interface documented in options.h */
|
|
|
|
void options_dump(FILE *outf)
|
|
|
|
{
|
|
|
|
char buffer[256];
|
|
|
|
int opt_loop = 0;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
do {
|
2011-02-21 01:38:43 +03:00
|
|
|
res = options_snoptionf(buffer, sizeof buffer, opt_loop,
|
|
|
|
"%k:%v\n");
|
2011-02-21 00:04:53 +03:00
|
|
|
if (res > 0) {
|
|
|
|
fprintf(outf, "%s", buffer);
|
|
|
|
}
|
|
|
|
opt_loop++;
|
|
|
|
} while (res > 0);
|
2006-01-01 21:52:30 +03:00
|
|
|
}
|
2011-02-21 02:19:18 +03:00
|
|
|
|