automotive-dlt
|
#include "dlt_config_file_parser.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <syslog.h>
#include "dlt_common.h"
#include "dlt-daemon_cfg.h"
Go to the source code of this file.
Macros | |
#define | DLT_CONFIG_FILE_NEW_SECTION 0x0a |
#define | DLT_CONFIG_FILE_NEW_DATA 0x0b |
Functions | |
static void | dlt_config_file_trim_line (char *line) |
static int | dlt_config_file_ignore_line (char *line) |
static int | dlt_config_file_is_section_name (DltConfigFile *file, char *name) |
static int | dlt_config_file_set_section (DltConfigFile *file, char *name) |
static int | dlt_config_file_set_section_data (DltConfigFile *file, char *str1, char *str2) |
static int | dlt_config_file_line_has_section (char *line) |
static int | dlt_config_file_get_section_name_from_string (char *line, char *name) |
static int | dlt_config_file_get_key_value (char *line, char *str1, char *str2) |
static int | dlt_config_file_read_line (char *line, char *str1, char *str2) |
static void | dlt_config_file_read_file (DltConfigFile *file, FILE *hdl) |
static int | dlt_config_file_find_section (const DltConfigFile *file, const char *section) |
DltConfigFile * | dlt_config_file_init (char *file_name) |
void | dlt_config_file_release (DltConfigFile *file) |
int | dlt_config_file_get_section_name (const DltConfigFile *file, int num, char *name) |
int | dlt_config_file_get_num_sections (const DltConfigFile *file, int *num) |
int | dlt_config_file_get_value (const DltConfigFile *file, const char *section, const char *key, char *value) |
Definition in file dlt_config_file_parser.c.
#define DLT_CONFIG_FILE_NEW_DATA 0x0b |
Definition at line 41 of file dlt_config_file_parser.c.
Referenced by dlt_config_file_read_file(), and dlt_config_file_read_line().
#define DLT_CONFIG_FILE_NEW_SECTION 0x0a |
Definition at line 40 of file dlt_config_file_parser.c.
Referenced by dlt_config_file_read_file(), and dlt_config_file_read_line().
|
static |
dlt_config_file_find_section
Find a section
file | DltConfigFile |
section | Name of section |
Definition at line 419 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, dlt_log(), DltConfigFileSection::name, NULL, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_config_file_get_value().
|
static |
dlt_config_file_get_key_value
Get key and value from a line of configuration file
line | Line on configuration file | |
[out] | str1 | String to be used as key |
[out] | str2 | String to be used as value |
Definition at line 293 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, and NULL.
Referenced by dlt_config_file_read_line().
int dlt_config_file_get_num_sections | ( | const DltConfigFile * | file, |
int * | num | ||
) |
dlt_config_file_get_num_sections
Get the number of sections inside configuration file
[in] | file | DltConfigFile |
[out] | num | Number of sections inside configuration file |
Definition at line 524 of file dlt_config_file_parser.c.
References NULL, and DltConfigFile::num_sections.
Referenced by dlt_gateway_configure(), and dlt_logstorage_store_filters().
int dlt_config_file_get_section_name | ( | const DltConfigFile * | file, |
int | num, | ||
char * | name | ||
) |
dlt_config_file_get_section_name
Get name of section number.
[in] | file | DltConfigFile |
[in] | num | Number of section |
[out] | section | Section name |
Definition at line 512 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, NULL, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_gateway_configure(), and dlt_logstorage_store_filters().
|
static |
dlt_config_file_get_section_name_from_string
Extract section name from line
line | Line in configuration file containing a section header |
Definition at line 262 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, and NULL.
Referenced by dlt_config_file_read_line().
int dlt_config_file_get_value | ( | const DltConfigFile * | file, |
const char * | section, | ||
const char * | key, | ||
char * | value | ||
) |
dlt_config_file_get_value
Get value of key in specified section.
[in] | file | DltConfigFile |
[in] | section | Name of section |
[in] | key | Key |
[out] | value | Value |
Definition at line 534 of file dlt_config_file_parser.c.
References DltConfigFileSection::data, DLT_CONFIG_FILE_ENTRY_MAX_LEN, dlt_config_file_find_section(), dlt_log(), NULL, and DltConfigFile::sections.
Referenced by dlt_daemon_setup_filter_properties(), and dlt_gateway_configure().
|
static |
dlt_config_file_ignore_line
Check if a line has to be ignored, because it contains a comment or is empty
line | Line of configuration file |
Definition at line 78 of file dlt_config_file_parser.c.
Referenced by dlt_config_file_read_file().
DltConfigFile* dlt_config_file_init | ( | char * | file_name | ) |
dlt_config_file_init
Load the configuration file and stores all data in internal data structures.
file_name | File to be opened |
Definition at line 441 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_PATH_MAX_LEN, dlt_config_file_read_file(), DLT_CONFIG_FILE_SECTIONS_MAX, dlt_log(), NULL, and DltConfigFile::sections.
Referenced by dlt_gateway_configure(), and dlt_logstorage_store_filters().
|
static |
dlt_config_file_is_section_name
Check if section name already used
file | DltConfigFile |
name | Name of section |
Definition at line 103 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, DltConfigFileSection::name, NULL, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_config_file_set_section().
|
static |
dlt_config_file_has_section
Check if a certain line in config file is a section header
line | Line in configuration file |
Definition at line 245 of file dlt_config_file_parser.c.
Referenced by dlt_config_file_read_line().
|
static |
dlt_config_file_read_file
Read configuration file line by line and fill internal structures
file | DltConfigFile |
hdl | FILE handle of opened configuration file |
Definition at line 363 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, dlt_config_file_ignore_line(), DLT_CONFIG_FILE_LINE_MAX_LEN, DLT_CONFIG_FILE_NEW_DATA, DLT_CONFIG_FILE_NEW_SECTION, dlt_config_file_read_line(), dlt_config_file_set_section(), dlt_config_file_set_section_data(), dlt_config_file_trim_line(), DLT_DAEMON_TEXTBUFSIZE, dlt_log(), and NULL.
Referenced by dlt_config_file_init().
|
static |
dlt_config_file_read_line
Read line from configuration file
line | Line from configuration file | |
[out] | str1 | String contains section header or key |
[out] | str2 | String contains value or is empty |
Definition at line 329 of file dlt_config_file_parser.c.
References DLT_CONFIG_FILE_ENTRY_MAX_LEN, dlt_config_file_get_key_value(), dlt_config_file_get_section_name_from_string(), dlt_config_file_line_has_section(), DLT_CONFIG_FILE_NEW_DATA, DLT_CONFIG_FILE_NEW_SECTION, and NULL.
Referenced by dlt_config_file_read_file().
void dlt_config_file_release | ( | DltConfigFile * | file | ) |
dlt_config_file_release
Release config file and frees all internal data. Has to be called after after all data is read.
file | DltConfigFile |
Definition at line 477 of file dlt_config_file_parser.c.
References DltConfigFileSection::data, DLT_CONFIG_FILE_ENTRY_MAX_LEN, DltConfigFileSection::keys, DltConfigFileSection::name, NULL, DltConfigFileSection::num_entries, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_gateway_configure(), and dlt_logstorage_store_filters().
|
static |
dlt_config_file_set_section
Store section in internal data structure
file | DltConfigFile |
name | Name of section |
Definition at line 130 of file dlt_config_file_parser.c.
References DltConfigFileSection::data, DLT_CONFIG_FILE_ENTRY_MAX_LEN, dlt_config_file_is_section_name(), DLT_CONFIG_FILE_KEYS_MAX, DLT_CONFIG_FILE_SECTIONS_MAX, dlt_log(), DltConfigFileSection::keys, DltConfigFileSection::name, NULL, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_config_file_read_file().
|
static |
dlt_config_file_set_section_data
Store data pair of a section
file | DltConfigFile |
str1 | string used for key |
str2 | string used for value |
Definition at line 189 of file dlt_config_file_parser.c.
References DltConfigFileSection::data, DLT_CONFIG_FILE_ENTRY_MAX_LEN, DLT_CONFIG_FILE_KEYS_MAX, DLT_DAEMON_TEXTBUFSIZE, dlt_log(), DltConfigFileSection::keys, NULL, DltConfigFileSection::num_entries, DltConfigFile::num_sections, and DltConfigFile::sections.
Referenced by dlt_config_file_read_file().
|
static |
dlt_config_file_trim_line
Trim all whitespace from a string
line | String to remove whitespace from |
Definition at line 53 of file dlt_config_file_parser.c.
References NULL.
Referenced by dlt_config_file_read_file().