libexplain  1.4.D001
Data Structures | Typedefs | Enumerations | Functions | Variables
libexplain/option.c File Reference
#include <libexplain/ac/errno.h>
#include <libexplain/ac/ctype.h>
#include <libexplain/ac/stdlib.h>
#include <libexplain/ac/string.h>
#include <libexplain/fstrcmp.h>
#include <libexplain/option.h>
#include <libexplain/output.h>
#include <libexplain/parse_bits.h>
#include <libexplain/program_name.h>
#include <libexplain/sizeof.h>
#include <libexplain/string_buffer.h>
#include <libexplain/wrap_and_print.h>

Go to the source code of this file.

Data Structures

struct  option_t
struct  table_t

Typedefs

typedef enum option_level_t option_level_t
typedef int option_value_t
typedef enum option_type_t option_type_t
typedef struct option_t option_t
typedef char value_t
typedef struct table_t table_t

Enumerations

enum  option_level_t { option_level_default, option_level_something_or_die, option_level_environment_variable, option_level_client }
enum  option_type_t { option_type_bool, option_type_int }

Functions

static void process (char *name, option_level_t level)
static void initialise (void)
int explain_option_debug (void)
int explain_option_numeric_errno (void)
int explain_option_dialect_specific (void)
int explain_option_assemble_program_name (void)
void explain_program_name_assemble (int yesno)
int explain_option_symbolic_mode_bits (void)
int explain_option_internal_strerror (void)
int explain_option_hanging_indent (int width)
void explain_option_hanging_indent_set (int columns)
int explain_option_extra_device_info (void)

Variables

static int initialised
static option_t debug
static option_t numeric_errno
static option_t dialect_specific
static option_t assemble_program_name
static option_t symbolic_mode_bits
static option_t internal_strerror
static option_t hanging_indent
static option_t extra_device_info
static const table_t table []
static const
explain_parse_bits_table_t 
bool_table []

Typedef Documentation

Definition at line 35 of file option.c.

typedef struct option_t option_t

Definition at line 53 of file option.c.

Definition at line 46 of file option.c.

typedef int option_value_t

Definition at line 44 of file option.c.

typedef struct table_t table_t

Definition at line 81 of file option.c.

typedef char value_t

Definition at line 61 of file option.c.


Enumeration Type Documentation

Enumerator:
option_level_default 
option_level_something_or_die 
option_level_environment_variable 
option_level_client 

Definition at line 36 of file option.c.

Enumerator:
option_type_bool 
option_type_int 

Definition at line 47 of file option.c.


Function Documentation

The explain_option_assemble_program_name option is used to determine whether or not the explain_output_error, explain_output_error_and_die and explain_output_warning functions should include the program name at the start the messages.

Returns:
int; true (non-zero) is shall include program name, zero (false) if shall not include program name.

Definition at line 276 of file option.c.

int explain_option_debug ( void  )

The explain_option_debug function may be used to obtain the EXPLAIN_OPTIONS (no-)debug flag, used to control whether or not debug behaviour is enabled. Defaults to off.

Returns:
int; true (non-zero) if additional dialect specific text is to be displayed (this is the default), false (zero) if it is not to be dislayed.

Definition at line 249 of file option.c.

The explain_option_dialect_specific function may be used to obtain the EXPLAIN_OPTIONS (no-)dialect-specific flag, used to control whether or not informative text that is specific to a given UNIX dialect is to be displayed. This is commonly turned off for the test suite.

Returns:
int; true (non-zero) if additional dialect specific text is to be displayed (this is the default), false (zero) if it is not to be dislayed.

Definition at line 267 of file option.c.

Definition at line 374 of file option.c.

int explain_option_hanging_indent ( int  width)

The explain_option_hanging_indent function may be used to obtain the "hanging-indent" option value.

Parameters:
widthThe width of the output line. The hanging indent must be less than 10% of this.

Definition at line 339 of file option.c.

void explain_option_hanging_indent_set ( int  columns)

The explain_option_hanging_indent_set function is used to cause the output wrapping to use hanging indents. By default no hanging indent is used, but this can sometimes obfuscate the end of one error message and the beginning of another. A hanging indent results in continuation lines starting with white spoace, similar to RFC822 headers.

This can be set using the "hanging-indent=N" string in the EXPLAIN_OPTIONS environment variable.

Using this function will override any environment variable setting.

Parameters:
columnsThe number of columns of hanging indent to be used. A value of 0 means no hanging indent (all lines flush with left margin). A common value to use is 4: it doesn't consume to much of each line, and it is a clear indent.

Definition at line 359 of file option.c.

The explain_option_internal_strerror function may be used to obtain the "(no-)internal-strerror" flag. Defaults to false, meaning use the system strerror. Useful for avoiding false negatives in the automatic test suite.

Returns:
true (non-zero) if are to use internal strerror strings, false (zero) if are to use system strerror.

Definition at line 330 of file option.c.

The explain_option_numeric_errno function may be used to obtain the EXPLAIN_OPTIONS (no-)numeric-errno flag, used to control whether or not the numeric value of errno is displayed. This is commonly turned off for the test suite, to cope with capricious errno numbering on different UNIX dialects.

Returns:
int; true (non-zero) if numeric errno values are to be displayed (this is the default), false (zero) if they are not to be dislayed.

Definition at line 258 of file option.c.

The explain_option_symbolic_mode_bits function may be used to obtain the EXPLAIN_OPTIONS (no-)symbolic-mode-bits flag, used to control whether or not symbolic mode bits are to be used. Default to false, meaning print octal mode bits.

Returns:
true (non-zero) if symbolic mode bits are to be printed (e.g. S_IRUSR), false (zero) if octal mode bits are to be printed.

Definition at line 321 of file option.c.

void explain_program_name_assemble ( int  yesno)

The explain_option_assemble_program_name_set option is used to override any EXPLAIN_OPTIONS or default setting as to whether or not the explain_output_error, explain_output_error_and_die and explain_output_warning functions should include the program name at the start the messages.

Parameters:
yesnotrue (non-zero) to include the program name, zero (false) to omit the program name.

Definition at line 285 of file option.c.

static void initialise ( void  ) [static]

Definition at line 195 of file option.c.

static void process ( char *  name,
option_level_t  level 
) [static]

Definition at line 112 of file option.c.


Variable Documentation

Initial value:

Definition at line 70 of file option.c.

Initial value:
{
    { "yes", 1 },
    { "no", 0 },
    { "true", 1 },
    { "false", 0 },
}

Definition at line 102 of file option.c.

option_t debug [static]
Initial value:

Definition at line 64 of file option.c.

Initial value:

Definition at line 68 of file option.c.

Initial value:

Definition at line 78 of file option.c.

Initial value:

Definition at line 76 of file option.c.

int initialised [static]

Definition at line 63 of file option.c.

Initial value:

Definition at line 74 of file option.c.

Initial value:

Definition at line 66 of file option.c.

Initial value:

Definition at line 72 of file option.c.

const table_t table[] [static]
Initial value:
{
    { "assemble-program-name", &assemble_program_name },
    { "debug", &debug },
    { "dialect-specific", &dialect_specific },
    { "hanging-indent", &hanging_indent },
    { "internal-strerror", &internal_strerror },
    { "numeric-errno", &numeric_errno },
    { "program-name", &assemble_program_name },
    { "symbolic-mode-bits", &symbolic_mode_bits },
    { "extra-device-info", &extra_device_info },
}

Definition at line 88 of file option.c.