Context flags

libcfg+ 0.7.0: command line and configuration file parsing library
Prev | Chapter 2. Usage | Next

# 2.3. Context flags

The following functions can be used to set various context flags:

    #include <cfg+.h>

``void cfg_set_context_flag`(const CFG_CONTEXT con, int flag);`

``void cfg_clear_context_flag`(const CFG_CONTEXT con, int flag);`

``int cfg_get_context_flag`(const CFG_CONTEXT con, int flag);`

``void cfg_set_context_flags`(const CFG_CONTEXT con, int flags);`

``int cfg_get_context_flags`(const CFG_CONTEXT con, int flags);`

You can set a context flag with `cfg_set_context_flag()`. You can clear a flag with `cfg_clear_context_flag()`. To see whether a flag is set, use `cfg_get_context_flag()`. It has a macro alias `cfg_is_context_flag()`, which is identical in every way.

The functions `cfg_set_context_flags()` and `cfg_get_context_flags()` can set and retrieve the value of all flags in one call.

A list of all settable context flags is provided in the following table.

Context flags

`CFG_IGNORE_MULTI`

  Ignore multiple arguments for a single option. The first argument will be used to store the option value. The others are skipped.

  By default, multiple arguments for an option that has not allowed them, cause the `CFG_ERROR_MULTI` error.

`CFG_IGNORE_UNKNOWN`

  Ignore all unknown options.

  The default behaviour is to produce the `CFG_ERROR_UNKNOWN` error when an unknown option is encountered.

`CFG_SKIP_FIRST`

  Setting this flag will cause the first argument on the command line to be skipped. This flag affects only command line contexts.

  The default behaviour is to parse all command line arguments.

`CFG_ADVANCED_LEFTOVERS`

  Advanced leftover arguments. Setting this flag will drop the requirement of the leftover arguments to conform to the POSIX standard.

  The default behaviour is to require the leftover arguments to conform to POSIX. According to POSIX, all option arguments must precede any non-option (leftover) arguments. Once a non-option argument is found, all remaining arguments are also interpreted as non-option.

`CFG_FILE_LINE_POS_USAGE`

  Setting this flag will cause the parsing of configuration file to become line- instead of byte-oriented. This will also change the meaning of the values stored in `begin_pos` and `size`.

  By default, parsing is byte-oriented.

You can use the `cfg_clear_context_flag()` function to restore the value of a flag to its default value.

Prev | Home | Next
Context manipulation | Up | Parsing