kb_config.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  kb_section_config_s
struct  kb_device_config_s
struct  kb_register_config_s
struct  kb_alias_config_s

Defines

#define KB_CONFIG_DIR_INTERNAL   KB_CONFIG_DIRECTORY "/"
#define KB_DEVICE_CLASS_ANY   -1
#define KB_DEVICE_CLASS_I2C   0
#define KB_DEVICE_CLASS_SPI   1
#define KB_DEVICE_CLASS_MODULE   2
#define KB_DEVICE_CLASS_RS232   3
#define KB_DEVICE_MAX_CLASS   4

Typedefs

typedef struct kb_section_config_s kb_section_config_t
typedef struct kb_device_config_s kb_device_config_t
typedef struct kb_register_config_s kb_register_config_t
typedef struct kb_alias_config_s kb_alias_config_t

Functions

int kb_config_init (int argc, char *argv[])
void kb_config_exit (void)
kb_device_config_tkb_lookup_device (const char *name)
kb_register_config_tkb_lookup_register (const char *name)
int kb_parse_config_file (const char *file)
int kb_enum_section (int(*func)(const char *name, kb_section_config_t *section, void *context), void *context)
int kb_enum_alias (const char *section, int(*func)(const char *name, kb_alias_config_t *alias, void *context), void *context)
int kb_enum_device (const char *section, int(*func)(const char *name, kb_device_config_t *device, void *context), void *context)
int kb_enum_register (const char *section, int(*func)(const char *name, kb_register_config_t *reg, void *context), void *context)


Define Documentation

#define KB_CONFIG_DIR_INTERNAL   KB_CONFIG_DIRECTORY "/"

Define the location for libkorebot configuration files. Can be modified in the top level Makefile editing KB_CONFIG_DIRECTORY.

Definition at line 18 of file kb_config.h.

Referenced by kb_config_init().

#define KB_DEVICE_CLASS_ANY   -1

Any device class

Definition at line 25 of file kb_config.h.

#define KB_DEVICE_CLASS_I2C   0

IC Device

Definition at line 28 of file kb_config.h.

Referenced by kb_parse_device(), and knet_open().

#define KB_DEVICE_CLASS_MODULE   2

Module

Definition at line 34 of file kb_config.h.

Referenced by kb_parse_device(), and knet_open().

#define KB_DEVICE_CLASS_RS232   3

RS-232 Device

Definition at line 37 of file kb_config.h.

Referenced by kb_parse_device(), and knet_open().

#define KB_DEVICE_CLASS_SPI   1

SPI Device

Definition at line 31 of file kb_config.h.

Referenced by kb_parse_device(), and knet_open().

#define KB_DEVICE_MAX_CLASS   4

Maximum number of device classes

Definition at line 40 of file kb_config.h.


Typedef Documentation


Function Documentation

void kb_config_exit ( void   ) 

This function should be called on exit by 'kb_init' and free all memory used in this module.

Remarks:
Never call this function !

Definition at line 123 of file kb_config.c.

References kb_destroy_symbol_table().

Referenced by kb_exit(), and main().

Here is the call graph for this function:

int kb_config_init ( int  argc,
char *  argv[] 
)

This function initializes the configuration tables and variables

Parameters:
argc Number of element in the array of arguments
argv Array of string containing all arguments
Returns:
an error code
  • <0 error code
  • 0 no error

Definition at line 78 of file kb_config.c.

References KB_CONFIG_DIR_INTERNAL, kb_create_symbol_table(), kb_parse_config_file(), KB_WARN_CONFIG_FILE, KB_WARN_OPENDIR, and kb_warning().

Referenced by kb_init(), and main().

Here is the call graph for this function:

int kb_enum_alias ( const char *  section_name,
int(*)(const char *name, kb_alias_config_t *alias, void *context)  func,
void *  context 
)

This function enumerates all aliases of a given section.

Parameters:
section_name A string containing the name of the section
func A function called for each alias found.
context A Pointer or a value passed as parameter to function 'func'.
Returns:
an error code:
  • <0 on error
  • >= number of aliases in a given section

Definition at line 934 of file kb_config.c.

References kb_section_config_s::alias_count, kb_section_config_s::aliases, kb_lookup_symbol(), KB_SYMBOL_TYPE_SECTION, kb_symbol_s::name, kb_alias_config_s::next, kb_symbol_s::type, and kb_symbol_s::value.

Here is the call graph for this function:

int kb_enum_device ( const char *  section_name,
int(*)(const char *name, kb_device_config_t *device, void *context)  func,
void *  context 
)

This function enumerates all devices of a given section.

Parameters:
section_name A string containing the name of the section
func A function called for each device found.
context A Pointer or a value passed as parameter to function 'func'.
Returns:
an error code:
  • <0 on error
  • >= number of devices in a given section

Definition at line 985 of file kb_config.c.

References kb_section_config_s::device_count, kb_section_config_s::devices, kb_lookup_symbol(), KB_SYMBOL_TYPE_SECTION, kb_symbol_s::name, kb_device_config_s::next, kb_symbol_s::type, and kb_symbol_s::value.

Referenced by print_section().

Here is the call graph for this function:

int kb_enum_register ( const char *  section_name,
int(*)(const char *name, kb_register_config_t *reg, void *context)  func,
void *  context 
)

This function enumerate all registers of a given section

Parameters:
section_name A string containing the name of the section
func A function called for each register found.
context A Pointer or a value passed as parameter to function 'func'.
Returns:
an error code:
  • <0 on error
  • >= number of registers in a given section

Definition at line 1035 of file kb_config.c.

References kb_lookup_symbol(), KB_SYMBOL_TYPE_SECTION, kb_symbol_s::name, kb_register_config_s::next, kb_section_config_s::register_count, kb_section_config_s::registers, kb_symbol_s::type, and kb_symbol_s::value.

Referenced by print_section().

Here is the call graph for this function:

int kb_enum_section ( int(*)(const char *name, kb_section_config_t *section, void *context)  func,
void *  context 
)

This function enumerates all sections.

Parameters:
func A Pointer to a function called for each section found.
context A Pointer or a value passed as parameter to the function 'func'
Returns:
an error code:
  • <0 on error
  • >=0 the number of sections

Definition at line 897 of file kb_config.c.

References kb_symbol_s::name, kb_section_config_s::next, and kb_symbol_s::value.

Referenced by main().

kb_device_config_t* kb_lookup_device ( const char *  name  ) 

This function try to find a device configuration descriptor given its name.

Parameters:
name A string containing the name of the device to find.
Returns:
A pointer to the device configuration descriptor or NULL if no device is found.

Definition at line 137 of file kb_config.c.

References kb_lookup_symbol(), KB_SYMBOL_TYPE_ALIAS, KB_SYMBOL_TYPE_DEVICE, kb_alias_config_s::name, kb_alias_config_s::ptr, kb_symbol_s::type, and kb_symbol_s::value.

Referenced by knet_open(), and main().

Here is the call graph for this function:

kb_register_config_t* kb_lookup_register ( const char *  name  ) 

This function try to find a register configuration descriptor given its name.

Parameters:
name A string containing the name of the register to find.
Returns:
A pointer to the register configuration descriptor or NULL if no register is found.

Definition at line 175 of file kb_config.c.

References kb_lookup_symbol(), KB_SYMBOL_TYPE_ALIAS, KB_SYMBOL_TYPE_REGISTER, kb_alias_config_s::name, kb_alias_config_s::ptr, kb_symbol_s::type, and kb_symbol_s::value.

Here is the call graph for this function:

int kb_parse_config_file ( const char *  file  ) 

This function parses a configuration file, builds and stores configuration information in memory.

Parameters:
file configuration file to parse
Returns:
an error code:
  • <0 on error
  • 0 on success

Definition at line 836 of file kb_config.c.

References buf, KB_ALLOC, kb_config_error(), kb_config_file, kb_config_line, kb_error(), KB_ERROR_FILEOPEN, KB_ERROR_UNKCMD, kb_free, kb_parse_command(), and kb_set_error_handler().

Referenced by kb_config_init().

Here is the call graph for this function:


Generated on Wed Dec 15 11:49:27 2010 for KoreBot Library by  doxygen 1.5.5