ELinks 0.18.0
option Struct Reference

#include <options.h>

Collaboration diagram for option:

Public Member Functions

 LIST_HEAD_EL (struct option)
 

Data Fields

struct elinks_object object
 
union { 
 
   const char *   name 
 
   char *   aname 
 
};  
 
option_flags_T flags
 
enum option_type type
 
long min
 
long max
 
union option_value value
 
const char * desc
 
const char * capt
 
unsigned int node_number
 
struct optionroot
 
change_hook_T change_hook
 To be called when the option (or sub-option if it's a tree) is changed.
 
struct listbox_itembox_item
 

Related Symbols

(Note that these are not member symbols.)

static void debug_check_option_syntax (struct option *option)
 
struct optionget_opt_rec (struct option *tree, const char *name_)
 Get record of option of given name, or NULL if there's no such option.
 
struct optionget_opt_rec_real (struct option *tree, const char *name)
 Get record of option of given name, or NULL if there's no such option.
 
struct optionindirect_option (struct option *alias)
 If opt is an alias, return the option to which it refers.
 
union option_valueget_opt_ (char *file, int line, enum option_type option_type, struct option *tree, const char *name, struct session *ses)
 Fetch pointer to value of certain option.
 
static void add_opt_sort (struct option *tree, struct option *option, int abi)
 
static void add_opt_rec (struct option *tree, const char *path, struct option *option)
 Add option to tree.
 
static struct listbox_iteminit_option_listbox_item (struct option *option)
 
struct optionadd_opt (struct option *tree, const char *path, const char *capt, const char *name, option_flags_T flags, enum option_type type, long min, long max, intptr_t value, const char *desc)
 
static void done_option (struct option *option)
 
static void delete_option_do (struct option *option, int recursive)
 
void mark_option_as_deleted (struct option *option)
 
void delete_option (struct option *option)
 
struct optioncopy_option (struct option *template_, int flags)
 
struct option list * init_options_tree (void)
 
static void update_visibility (struct option list *tree, int show)
 Make option templates visible or invisible in the option manager.
 
static void free_options_tree (struct option list *tree, int recursive)
 
void prepare_mustsave_flags (struct option list *tree, int set_all)
 Set or clear the OPT_MUST_SAVE flag in all descendants of tree.
 
void untouch_options (struct option list *tree)
 Clear the OPT_TOUCHED flag in all descendants of tree.
 
static int check_nonempty_tree (struct option list *options)
 
void smart_config_string (struct string *str, int print_comment, int i18n, struct option list *options, char *path, int depth, void(*fn)(struct string *, struct option *, char *, int, int, int, int))
 
#define INIT_OPTION(name, flags, type, min, max, value, desc, capt)    { NULL_LIST_HEAD_EL, INIT_OBJECT("option"), {name}, flags, type, min, max, { (LIST_OF(struct option) *) (value) }, desc, capt }
 An initializer for struct option.
 
void toggle_option (struct session *ses, struct option *option)
 Toggle the value of the given option numeric, respecting option->min and option->max.
 
void call_change_hooks (struct session *ses, struct option *current, struct option *option)
 Call the change-hooks for the given option and recur on its parent.
 
void option_changed (struct session *ses, struct option *option)
 Do proper bookkeeping after an option has changed - call this every time you change an option value.
 
#define add_opt_bool_tree(tree, path, capt, name, flags, def, desc)    add_opt(tree, path, capt, name, flags, OPT_BOOL, 0, 1, (intptr_t) def, DESC(desc))
 
#define add_opt_int_tree(tree, path, capt, name, flags, min, max, def, desc)    add_opt(tree, path, capt, name, flags, OPT_INT, min, max, (intptr_t) def, DESC(desc))
 
#define add_opt_long_tree(tree, path, capt, name, flags, min, max, def, desc)    add_opt(tree, path, capt, name, flags, OPT_LONG, min, max, (intptr_t) def, DESC(desc))
 
#define add_opt_str_tree(tree, path, capt, name, flags, def, desc)
 
#define add_opt_codepage_tree(tree, path, capt, name, flags, def, desc)    add_opt(tree, path, capt, name, flags, OPT_CODEPAGE, 0, 0, (intptr_t) get_cp_index(def), DESC(desc))
 
#define add_opt_lang_tree(tree, path, capt, name, flags, desc)    add_opt(tree, path, capt, name, flags, OPT_LANGUAGE, 0, 0, (intptr_t) 0, DESC(desc))
 
#define add_opt_color_tree(tree, path, capt, name, flags, def, desc)    add_opt(tree, path, capt, name, flags, OPT_COLOR, 0, 0, (intptr_t) def, DESC(desc))
 
#define add_opt_command_tree(tree, path, capt, name, flags, cmd, desc)    add_opt(tree, path, capt, name, flags, OPT_COMMAND, 0, 0, (intptr_t) cmd, DESC(desc));
 
#define add_opt_alias_tree(tree, path, capt, name, flags, def, desc)    add_opt(tree, path, capt, name, flags, OPT_ALIAS, 0, strlen(def), (intptr_t) def, DESC(desc))
 
#define add_opt_tree_tree(tree, path, capt, name, flags, desc)    add_opt(tree, path, capt, name, flags, OPT_TREE, 0, 0, (intptr_t) init_options_tree(), DESC(desc));
 

Member Function Documentation

◆ LIST_HEAD_EL()

option::LIST_HEAD_EL ( struct option )

Friends And Related Symbol Documentation

◆ add_opt()

struct option * add_opt ( struct option * tree,
const char * path,
const char * capt,
const char * name,
option_flags_T flags,
enum option_type type,
long min,
long max,
intptr_t value,
const char * desc )
related

◆ add_opt_alias_tree

#define add_opt_alias_tree ( tree,
path,
capt,
name,
flags,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_ALIAS, 0, strlen(def), (intptr_t) def, DESC(desc))
related

◆ add_opt_bool_tree

#define add_opt_bool_tree ( tree,
path,
capt,
name,
flags,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_BOOL, 0, 1, (intptr_t) def, DESC(desc))
related

◆ add_opt_codepage_tree

#define add_opt_codepage_tree ( tree,
path,
capt,
name,
flags,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_CODEPAGE, 0, 0, (intptr_t) get_cp_index(def), DESC(desc))
related

◆ add_opt_color_tree

#define add_opt_color_tree ( tree,
path,
capt,
name,
flags,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_COLOR, 0, 0, (intptr_t) def, DESC(desc))
related

◆ add_opt_command_tree

#define add_opt_command_tree ( tree,
path,
capt,
name,
flags,
cmd,
desc )    add_opt(tree, path, capt, name, flags, OPT_COMMAND, 0, 0, (intptr_t) cmd, DESC(desc));
related

◆ add_opt_int_tree

#define add_opt_int_tree ( tree,
path,
capt,
name,
flags,
min,
max,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_INT, min, max, (intptr_t) def, DESC(desc))
related

◆ add_opt_lang_tree

#define add_opt_lang_tree ( tree,
path,
capt,
name,
flags,
desc )    add_opt(tree, path, capt, name, flags, OPT_LANGUAGE, 0, 0, (intptr_t) 0, DESC(desc))
related

◆ add_opt_long_tree

#define add_opt_long_tree ( tree,
path,
capt,
name,
flags,
min,
max,
def,
desc )    add_opt(tree, path, capt, name, flags, OPT_LONG, min, max, (intptr_t) def, DESC(desc))
related

◆ add_opt_rec()

static void add_opt_rec ( struct option * tree,
const char * path,
struct option * option )
related

Add option to tree.

◆ add_opt_sort()

static void add_opt_sort ( struct option * tree,
struct option * option,
int abi )
related

◆ add_opt_str_tree

#define add_opt_str_tree ( tree,
path,
capt,
name,
flags,
def,
desc )
related
Value:
do { \
char *ptr = (char *)mem_alloc(MAX_STR_LEN); \
safe_strncpy(ptr, def, MAX_STR_LEN); \
add_opt(tree, path, capt, name, flags, OPT_STRING, 0, MAX_STR_LEN, (intptr_t) ptr, DESC(desc)); \
} while (0)
@ OPT_STRING
Definition options.h:108
#define DESC(x)
Definition options.h:358
void * mem_alloc(size_t)
#define MAX_STR_LEN
Definition setup.h:79

◆ add_opt_tree_tree

#define add_opt_tree_tree ( tree,
path,
capt,
name,
flags,
desc )    add_opt(tree, path, capt, name, flags, OPT_TREE, 0, 0, (intptr_t) init_options_tree(), DESC(desc));
related

◆ call_change_hooks()

void call_change_hooks ( struct session * ses,
struct option * current,
struct option * option )
related

Call the change-hooks for the given option and recur on its parent.

◆ check_nonempty_tree()

static int check_nonempty_tree ( struct option list * options)
related

◆ copy_option()

struct option * copy_option ( struct option * template_,
int flags )
related

◆ debug_check_option_syntax()

static void debug_check_option_syntax ( struct option * option)
related

◆ delete_option()

void delete_option ( struct option * option)
related

◆ delete_option_do()

static void delete_option_do ( struct option * option,
int recursive )
related

◆ done_option()

static void done_option ( struct option * option)
related

◆ free_options_tree()

static void free_options_tree ( struct option list * tree,
int recursive )
related

◆ get_opt_()

union option_value * get_opt_ ( char * file,
int line,
enum option_type option_type,
struct option * tree,
const char * name,
struct session * ses )
related

Fetch pointer to value of certain option.

It is guaranteed to never return NULL. Note that you are supposed to use wrapper get_opt().

◆ get_opt_rec()

struct option * get_opt_rec ( struct option * tree,
const char * name_ )
related

Get record of option of given name, or NULL if there's no such option.

If the specified option is an OPT_ALIAS, this function returns the alias, rather than the option to which the alias refers. It must work this way because the alias may have the OPT_ALIAS_NEGATE flag. Instead, if the caller tries to read or set the value of the alias, the functions associated with OPT_ALIAS will forward the operation to the underlying option. However, see indirect_option().

◆ get_opt_rec_real()

struct option * get_opt_rec_real ( struct option * tree,
const char * name )
related

Get record of option of given name, or NULL if there's no such option.

But do not create the option if it doesn't exist and there's autocreation enabled.

◆ indirect_option()

struct option * indirect_option ( struct option * alias)
related

If opt is an alias, return the option to which it refers.

Warning
Because the alias may have the OPT_ALIAS_NEGATE flag, the caller must not access the value of the returned option as if it were also the value of the alias. However, it is safe to access flags such as OPT_MUST_SAVE and OPT_DELETED.

◆ INIT_OPTION

#define INIT_OPTION ( name,
flags,
type,
min,
max,
value,
desc,
capt )    { NULL_LIST_HEAD_EL, INIT_OBJECT("option"), {name}, flags, type, min, max, { (LIST_OF(struct option) *) (value) }, desc, capt }
related

An initializer for struct option.

This is quite rare: most places should instead initialize struct option_init, with INIT_OPT_INT or a similar macro.

◆ init_option_listbox_item()

static struct listbox_item * init_option_listbox_item ( struct option * option)
related

◆ init_options_tree()

struct option list * init_options_tree ( void )
related

◆ mark_option_as_deleted()

void mark_option_as_deleted ( struct option * option)
related

◆ option_changed()

void option_changed ( struct session * ses,
struct option * option )
related

Do proper bookkeeping after an option has changed - call this every time you change an option value.

◆ prepare_mustsave_flags()

void prepare_mustsave_flags ( struct option list * tree,
int set_all )
related

Set or clear the OPT_MUST_SAVE flag in all descendants of tree.

Parameters
treeThe option tree in which this function recursively sets or clears the flag.
set_allIf true, set OPT_MUST_SAVE in all options of the tree. If false, set it only in touched or deleted options, and clear in others.

◆ smart_config_string()

void smart_config_string ( struct string * str,
int print_comment,
int i18n,
struct option list * options,
char * path,
int depth,
void(* fn )(struct string *, struct option *, char *, int, int, int, int) )
related

◆ toggle_option()

void toggle_option ( struct session * ses,
struct option * option )
related

Toggle the value of the given option numeric, respecting option->min and option->max.

◆ untouch_options()

void untouch_options ( struct option list * tree)
related

Clear the OPT_TOUCHED flag in all descendants of tree.

◆ update_visibility()

static void update_visibility ( struct option list * tree,
int show )
related

Make option templates visible or invisible in the option manager.

This is called once on startup, and then each time the value of the "config.show_template" option is changed.

Parameters
treeThe option tree whose children should be affected.
showA set of bits:
  • The 0x01 bit means templates should be made visible. If the bit is clear, templates become invisible instead.
  • The 0x02 bit means tree is itself part of a template, and so all of its children should be affected, regardless of whether they are templates of their own.

Deleted options are never visible.

Field Documentation

◆ [union]

union { ... } option

◆ aname

char* option::aname

◆ box_item

struct listbox_item* option::box_item

◆ capt

const char* option::capt

◆ change_hook

change_hook_T option::change_hook

To be called when the option (or sub-option if it's a tree) is changed.

If it returns zero, we will continue descending the options tree checking for change handlers.

◆ desc

const char* option::desc

◆ flags

option_flags_T option::flags

◆ max

long option::max

◆ min

long option::min

◆ name

const char* option::name

◆ node_number

unsigned int option::node_number

◆ object

struct elinks_object option::object

◆ root

struct option* option::root

◆ type

enum option_type option::type

◆ value

union option_value option::value

The documentation for this struct was generated from the following files: