![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Example of using the librnr config module. More...
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include "rnr/rnrconfig.h"#include "rnr/log.h"#include "rnr/config.h"Go to the source code of this file.
Classes | |
| struct | Cmd_T |
| command structure type More... | |
Macros | |
| #define | CHKARGS(argc, min) |
| Check argument count against minimum required. More... | |
| #define | CHKCFG() |
| Check that the configuration db exists. More... | |
| #define | CHKNOCFG() |
| Check that the configuration db does not exist. More... | |
Typedefs | |
| typedef void(* | CmdExec_T) (int, char *[]) |
| command execution function type | |
Functions | |
| static void | CmdHelp (int argc, char *argv[]) |
| Print command help. More... | |
| static void | CmdQuit (int argc, char *argv[]) |
| Quit this example program. More... | |
| static void | CmdLog (int argc, char *argv[]) |
| Set diagnotics logging level. More... | |
| static void | CmdDbDelete (int argc, char *argv[]) |
| Delete configuration db. More... | |
| static void | CmdDbNew (int argc, char *argv[]) |
| Create new, empty configuration db. More... | |
| static void | CmdDbPrint (int argc, char *argv[]) |
| Print out entire configuration db. More... | |
| static void | CmdDbRead (int argc, char *argv[]) |
| Create new configuration db from file. More... | |
| static void | CmdDelete (int argc, char *argv[]) |
| Delete configuration key. More... | |
| static void | CmdFind (int argc, char *argv[]) |
| Find configuration key=values matching substring. More... | |
| static void | CmdGetd (int argc, char *argv[]) |
| Get configuration value string converting to double. More... | |
| static void | CmdGeti (int argc, char *argv[]) |
| Get configuration value string converting to int. More... | |
| static void | CmdGets (int argc, char *argv[]) |
| Get configuration value string. More... | |
| static void | CmdSectDelete (int argc, char *argv[]) |
| Delete entier configuration db section. More... | |
| static void | CmdSectNew (int argc, char *argv[]) |
| Create new, empty configuration db section. More... | |
| static void | CmdSetd (int argc, char *argv[]) |
| Set or create key=<double> entry in section. More... | |
| static void | CmdSeti (int argc, char *argv[]) |
| Set or create key=<int> entry in section. More... | |
| static void | CmdSets (int argc, char *argv[]) |
| Set or create key=<string> entry in section. More... | |
| static int | Tokenize (char *string, char *tokv[], size_t tokmax) |
| Tokenize input. More... | |
| static Cmd_T * | MatchCmd (const char *sPattern, Cmd_T tblCmds[]) |
| Match command. More... | |
| int | main (int argc, char *argv[]) |
| Example main. More... | |
Variables | |
| static Config_T * | TheConfig = NULL |
| the configuration db | |
| static Cmd_T | CmdTbl [] |
| The command set. | |
Example of using the librnr config module.
Definition in file example_config.c.
| #define CHKARGS | ( | argc, | |
| min | |||
| ) |
Check argument count against minimum required.
| argc | Argument count. |
| min | Required minimum count. |
Definition at line 77 of file example_config.c.
Referenced by CmdDbRead(), CmdDelete(), CmdFind(), CmdGetd(), CmdGeti(), CmdGets(), CmdLog(), CmdSectDelete(), CmdSectNew(), CmdSetd(), CmdSeti(), and CmdSets().
| #define CHKCFG | ( | ) |
Check that the configuration db exists.
Definition at line 88 of file example_config.c.
Referenced by CmdDbDelete(), CmdDbPrint(), CmdDelete(), CmdFind(), CmdGetd(), CmdGeti(), CmdGets(), CmdSectDelete(), CmdSectNew(), CmdSetd(), CmdSeti(), and CmdSets().
| #define CHKNOCFG | ( | ) |
Check that the configuration db does not exist.
Definition at line 100 of file example_config.c.
Referenced by CmdDbNew(), and CmdDbRead().
|
static |
Delete configuration db.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 147 of file example_config.c.
References CHKCFG, ConfigDbDelete(), and NULL.
|
static |
Create new, empty configuration db.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 161 of file example_config.c.
References CHKNOCFG, ConfigDbNew(), and NULL.
|
static |
Print out entire configuration db.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 174 of file example_config.c.
References CHKCFG, and ConfigDbPrint().
|
static |
Create new configuration db from file.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 187 of file example_config.c.
References CHKARGS, CHKNOCFG, and ConfigDbRead().
|
static |
Delete configuration key.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 201 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigDelete(), and OK.
|
static |
Find configuration key=values matching substring.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 223 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigDbIterNew(), ConfigGetStr(), ConfigIterDelete(), ConfigIterNext(), ConfigSectionIterNew(), and NULL.
|
static |
Get configuration value string converting to double.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 267 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigGetDouble(), and OK.
|
static |
Get configuration value string converting to int.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 291 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigGetInt(), and OK.
|
static |
Get configuration value string.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 315 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigGetStr(), and NULL.
|
static |
Print command help.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 524 of file example_config.c.
References Cmd_T::m_sCmdHelpArgs, Cmd_T::m_sCmdHelpDesc, Cmd_T::m_sCmdName, and NULL.
|
static |
Set diagnotics logging level.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 130 of file example_config.c.
References CHKARGS, and LOG_SET_THRESHOLD().
|
static |
Quit this example program.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 119 of file example_config.c.
|
static |
Delete entier configuration db section.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 339 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigSectionDelete(), ConfigSectionGet(), and NULL.
|
static |
Create new, empty configuration db section.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 363 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigSectionNew(), and NULL.
|
static |
Set or create key=<double> entry in section.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 384 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigSetDouble(), and OK.
|
static |
Set or create key=<int> entry in section.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 410 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigSetInt(), and OK.
|
static |
Set or create key=<string> entry in section.
| argc | Command argument count. |
| argv | Array of arguments. |
Definition at line 436 of file example_config.c.
References CHKARGS, CHKCFG, ConfigDbGetName(), ConfigSetStr(), and OK.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Example main.
| argc | Command-line argument count. |
| argv | Command-line argument list. |
Definition at line 654 of file example_config.c.
References arraysize, Cmd_T::m_fnCmdExec, MatchCmd(), NULL, and Tokenize().
Match command.
| sPattern | (Partial) command string. |
| tblCmds | Table of commands. |
Definition at line 581 of file example_config.c.
References Cmd_T::m_sCmdName, and NULL.
Referenced by main().
|
static |
Tokenize input.
| string | Input string | |
| [out] | tokv | Array of tokens. |
| tokmax | Maximum number of tokens. |
Definition at line 545 of file example_config.c.
Referenced by main().