Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

cfg_parser.h File Reference

#include "str.h"
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  cfg_token
 Structure representing a lexical token. More...
struct  cfg_option
 Token mapping structure. More...
struct  cfg_parser

Defines

#define MAX_TOKEN_LEN   512
 Token names cannot be longer than this value.

Typedefs

typedef enum cfg_flags cfg_flags_t
typedef cfg_token cfg_token_t
 Structure representing a lexical token.
typedef int(* cfg_func_f )(void *param, struct cfg_parser *st, unsigned int flags)
typedef cfg_option cfg_option_t
 Token mapping structure.
typedef cfg_parser cfg_parser_t

Enumerations

enum  cfg_flags {
  CFG_EXTENDED_ALPHA = (1 << 0), CFG_CASE_SENSITIVE = (1 << 1), CFG_DEFAULT = (1 << 2), CFG_PREFIX = (1 << 3),
  CFG_STR_PKGMEM = (1 << 4), CFG_STR_SHMMEM = (1 << 5), CFG_STR_MALLOC = (1 << 6), CFG_STR_STATIC = (1 << 7)
}
enum  cfg_token_type { CFG_TOKEN_EOF = -1, CFG_TOKEN_ALPHA = -2, CFG_TOKEN_STRING = -3 }

Functions

cfg_parsercfg_parser_init (str *filename)
void cfg_section_parser (struct cfg_parser *st, cfg_func_f parser, void *param)
void cfg_set_options (struct cfg_parser *st, struct cfg_option *options)
int cfg_parse (struct cfg_parser *st)
void cfg_parser_close (struct cfg_parser *st)
cfg_optioncfg_lookup_token (struct cfg_option *options, str *token)
int cfg_get_token (struct cfg_token *token, struct cfg_parser *st, unsigned int flags)
 Interface to the lexical scanner.
int cfg_eat_equal (struct cfg_parser *st, unsigned int flags)
int cfg_eat_eol (struct cfg_parser *st, unsigned int flags)
int cfg_parse_section (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_str_opt (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_str (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_enum_opt (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_enum (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_int_opt (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_int (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_bool_opt (void *param, struct cfg_parser *st, unsigned int flags)
int cfg_parse_bool (void *param, struct cfg_parser *st, unsigned int flags)

Variables

cfg_option cfg_bool_values []


Define Documentation

#define MAX_TOKEN_LEN   512
 

Token names cannot be longer than this value.

Definition at line 31 of file cfg_parser.h.


Typedef Documentation

typedef enum cfg_flags cfg_flags_t
 

typedef int(* cfg_func_f)(void *param, struct cfg_parser *st, unsigned int flags)
 

Definition at line 108 of file cfg_parser.h.

typedef struct cfg_option cfg_option_t
 

Token mapping structure.

This structure is used to map tokens to values or function calls. Arrays of such structures are typically provided by the caller of the parser.

Referenced by cfg_lookup_token(), cfg_parse(), cfg_parse_bool(), cfg_parse_enum(), cfg_set_options(), parse_domain(), parse_field_map(), parse_hostport(), parse_section(), process_option(), and tls_parse_method().

typedef struct cfg_parser cfg_parser_t
 

Referenced by cfg_eat_eol(), cfg_eat_equal(), cfg_get_token(), cfg_parse(), cfg_parse_addr_port(), cfg_parse_bool(), cfg_parse_bool_opt(), cfg_parse_dummy(), cfg_parse_enum(), cfg_parse_enum_opt(), cfg_parse_int(), cfg_parse_int_opt(), cfg_parse_section(), cfg_parse_str(), cfg_parse_str_opt(), cfg_parser_close(), cfg_parser_init(), cfg_section_parser(), cfg_set_options(), ld_load_cfg(), parse_domain(), parse_field_map(), parse_hostport(), parse_iptrtpproxy_cfg(), parse_ipv4(), parse_ipv6(), parse_section(), parse_switchboard_section(), process_option(), and tls_load_config().

typedef struct cfg_token cfg_token_t
 

Structure representing a lexical token.

Referenced by cfg_eat_eol(), cfg_eat_equal(), cfg_get_token(), cfg_parse(), cfg_parse_addr_port(), cfg_parse_bool(), cfg_parse_dummy(), cfg_parse_enum(), cfg_parse_int(), cfg_parse_section(), cfg_parse_str(), parse_domain(), parse_field_map(), parse_hostport(), parse_ipv4(), parse_ipv6(), parse_section(), parse_switchboard_section(), and print_token().


Enumeration Type Documentation

enum cfg_flags
 

Enumeration values:
CFG_EXTENDED_ALPHA  Extended tokens can contain also delimiters, in addition to alpha-numeric characters, this is used on the righ side of assignments where no quotes are used.

CFG_CASE_SENSITIVE  The parser performs case-insensitive comparisons of token strings by default.

The parser will use case-sensitive comparison instead if this flag is set.

CFG_DEFAULT  This is a flag that can be set in the last element of cfg_option arrays (this is the one with 0 as token name).

When this flag is set then the value or parsing function of the element will be used for options that do not match any other element in the array.

CFG_PREFIX  When this flag is set then the name of the options is a prefix and all options that have the same prefix will be matched by this entry.

CFG_STR_PKGMEM  The result of cfg_parse_str_val will be in a buffer allocated by pkg_malloc, if the destination varaiable contains a pointer to a buffer already then it will be freed with pkg_free first.

CFG_STR_SHMMEM  The result of cfg_parse_str_val will be in a buffer allocated by shm_malloc, if the destination variable contains a pointer to a buffer already then it will be freed with shm_free first.

CFG_STR_MALLOC  The result of cfg_parse_str_val will be in a buffer allocated by malloc, if the destination variable contains a pointer to a buffer already then it will be freed with free first.

CFG_STR_STATIC  The result of cfg_parse_str_val will be copied into a pre-allocated buffer with a fixed size, a pointer to str variable which contains the buffer and its size is passed to the function in parameter 'param'.

Definition at line 34 of file cfg_parser.h.

enum cfg_token_type
 

Enumeration values:
CFG_TOKEN_EOF 
CFG_TOKEN_ALPHA 
CFG_TOKEN_STRING 

Definition at line 87 of file cfg_parser.h.


Function Documentation

int cfg_eat_eol struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_bool_opt(), cfg_parse_enum_opt(), cfg_parse_int_opt(), cfg_parse_section(), cfg_parse_str_opt(), parse_domain(), parse_field_map(), parse_section(), and parse_switchboard_section().

int cfg_eat_equal struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_bool_opt(), cfg_parse_enum_opt(), cfg_parse_int_opt(), cfg_parse_str_opt(), and parse_field_map().

int cfg_get_token struct cfg_token token,
struct cfg_parser st,
unsigned int  flags
 

Interface to the lexical scanner.

Referenced by cfg_eat_eol(), cfg_eat_equal(), cfg_parse(), cfg_parse_addr_port(), cfg_parse_bool(), cfg_parse_dummy(), cfg_parse_enum(), cfg_parse_int(), cfg_parse_section(), cfg_parse_str(), parse_domain(), parse_field_map(), parse_hostport(), parse_ipv4(), parse_ipv6(), parse_section(), and parse_switchboard_section().

struct cfg_option* cfg_lookup_token struct cfg_option options,
str token
 

Referenced by cfg_parse(), cfg_parse_bool(), cfg_parse_enum(), parse_domain(), parse_field_map(), parse_hostport(), parse_section(), and tls_parse_method().

int cfg_parse struct cfg_parser st  ) 
 

Referenced by ld_load_cfg(), parse_iptrtpproxy_cfg(), and tls_load_config().

int cfg_parse_bool void param,
struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_bool_opt().

int cfg_parse_bool_opt void param,
struct cfg_parser st,
unsigned int  flags
 

int cfg_parse_enum void param,
struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_enum_opt().

int cfg_parse_enum_opt void param,
struct cfg_parser st,
unsigned int  flags
 

int cfg_parse_int void param,
struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_addr_port(), and cfg_parse_int_opt().

int cfg_parse_int_opt void param,
struct cfg_parser st,
unsigned int  flags
 

int cfg_parse_section void param,
struct cfg_parser st,
unsigned int  flags
 

Referenced by parse_switchboard_section().

int cfg_parse_str void param,
struct cfg_parser st,
unsigned int  flags
 

Referenced by cfg_parse_addr_port(), cfg_parse_dummy(), cfg_parse_section(), cfg_parse_str_opt(), and parse_section().

int cfg_parse_str_opt void param,
struct cfg_parser st,
unsigned int  flags
 

void cfg_parser_close struct cfg_parser st  ) 
 

Referenced by ld_load_cfg(), parse_iptrtpproxy_cfg(), and tls_load_config().

struct cfg_parser* cfg_parser_init str filename  ) 
 

Definition at line 586 of file cfg_parser.c.

References cfg_parser_t, cfg_parser::col, ERR, cfg_parser::file, get_abs_pathname(), get_base_name(), cfg_parser::line, pkg_free, pkg_malloc, st, str, and STR_FMT.

Referenced by ld_load_cfg(), parse_iptrtpproxy_cfg(), and tls_load_config().

void cfg_section_parser struct cfg_parser st,
cfg_func_f  parser,
void param
 

Referenced by ld_load_cfg(), parse_iptrtpproxy_cfg(), and tls_load_config().

void cfg_set_options struct cfg_parser st,
struct cfg_option options
 

Referenced by parse_domain(), parse_iptrtpproxy_cfg(), and parse_section().


Variable Documentation

struct cfg_option cfg_bool_values[]
 

Definition at line 233 of file cfg_parser.c.

Referenced by cfg_parse_bool().


Generated on Thu Jul 29 04:15:53 2010 for SIPExpressRouter by  doxygen 1.3.9.1