automotive-dlt
dlt_env_ll.c File Reference
#include "dlt_user.h"
#include <string.h>
#include <stdlib.h>
Include dependency graph for dlt_env_ll.c:

Go to the source code of this file.

Macros

#define DLT_ENV_LL_SET_INCREASE   10
 

Functions

int dlt_env_extract_id (char **const env, char *id)
 extract id out of given string More...
 
int dlt_env_helper_to_lower (char **const env, char *result, int const res_len)
 convert a given string to lower-case More...
 
int dlt_env_extract_symbolic_ll (char **const env, int8_t *ll)
 
int dlt_env_extract_ll (char **const env, int8_t *ll)
 extract log-level out of given string More...
 
int dlt_env_extract_ll_item (char **const env, dlt_env_ll_item *const item)
 extract one item out of string More...
 
int dlt_env_init_ll_set (dlt_env_ll_set *const ll_set)
 initialize ll_set More...
 
void dlt_env_free_ll_set (dlt_env_ll_set *const ll_set)
 release ll_set More...
 
int dlt_env_increase_ll_set (dlt_env_ll_set *const ll_set)
 increase size of ll_set by LL_SET_INCREASE elements More...
 
int dlt_env_extract_ll_set (char **const env, dlt_env_ll_set *const ll_set)
 extract all items out of string More...
 
int dlt_env_ids_match (char const *const a, char const *const b)
 check if two ids match More...
 
int dlt_env_ll_item_get_matching_prio (dlt_env_ll_item const *const item, char const *const apid, char const *const ctid)
 check if (and how) apid and ctid match with given item More...
 
int dlt_env_adjust_ll_from_env (dlt_env_ll_set const *const ll_set, char const *const apid, char const *const ctid, int const ll)
 adjust log-level based on values given through environment More...
 

Detailed Description

Author
Stefan Vacek stefa.nosp@m.n.va.nosp@m.cek@i.nosp@m.ntel.nosp@m..com Intel Corporation

Definition in file dlt_env_ll.c.

Macro Definition Documentation

#define DLT_ENV_LL_SET_INCREASE   10

Definition at line 31 of file dlt_env_ll.c.

Referenced by dlt_env_increase_ll_set(), and dlt_env_init_ll_set().

Function Documentation

int dlt_env_extract_id ( char **const  env,
char *  id 
)

extract id out of given string

Extract 4-byte string out of given environment string, the pointer of the environment string is moved to the next un-used character and the extracted id is copied into

Parameters
idExample: env[] = "abcd:1234:3" char res[4u]; char * tmp = &env[0]; int ret = extract_id(&tmp, res); assert(ret == 0); assert(*tmp == ':'); assert(res[3] == 'd');
Returns
0 if successful, -1 else

Definition at line 58 of file dlt_env_ll.c.

Referenced by dlt_env_extract_ll_item().

int dlt_env_extract_ll ( char **const  env,
int8_t *  ll 
)

extract log-level out of given string

A valid log-level is a numeric value in the range of -1 .. 6, with: -1: default 0: off 1: fatal 2: error 3: warning 4: info 5: debug 6: verbose During parsing, the environment string is moved to the next un-used character and the extracted log-level is written into

Parameters
llExample: env[] = "abcd:1234:6" int ll; char ** tmp = &env[10]; // tmp points to '6'! int ret = extract_ll(&tmp, &ll); assert(ret == 0); assert(*tmp == NULL); assert(ll == 6);
Returns
0 if successful, -1 else

Definition at line 228 of file dlt_env_ll.c.

References dlt_env_extract_symbolic_ll().

Referenced by dlt_env_extract_ll_item().

int dlt_env_extract_ll_item ( char **const  env,
dlt_env_ll_item *const  item 
)

extract one item out of string

Returns
0 if successful, -1 else

Definition at line 281 of file dlt_env_ll.c.

References dlt_env_ll_item::appId, dlt_env_ll_item::ctxId, dlt_env_extract_id(), dlt_env_extract_ll(), and dlt_env_ll_item::ll.

Referenced by dlt_env_extract_ll_set().

int dlt_env_extract_symbolic_ll ( char **const  env,
int8_t *  ll 
)

Definition at line 136 of file dlt_env_ll.c.

References dlt_env_helper_to_lower().

Referenced by dlt_env_extract_ll().

int dlt_env_helper_to_lower ( char **const  env,
char *  result,
int const  res_len 
)

convert a given string to lower-case

Stops end of string or if ';' is detected

Definition at line 93 of file dlt_env_ll.c.

Referenced by dlt_env_extract_symbolic_ll().

int dlt_env_ids_match ( char const *const  a,
char const *const  b 
)

check if two ids match

Returns
1 if matching, 0 if not

Definition at line 454 of file dlt_env_ll.c.

Referenced by dlt_env_ll_item_get_matching_prio().

int dlt_env_increase_ll_set ( dlt_env_ll_set *const  ll_set)

increase size of ll_set by LL_SET_INCREASE elements

Returns
-1 if memory could not be allocated
0 on success

Definition at line 370 of file dlt_env_ll.c.

References dlt_env_ll_set::array_size, DLT_ENV_LL_SET_INCREASE, and dlt_env_ll_set::item.

Referenced by dlt_env_extract_ll_set().

int dlt_env_init_ll_set ( dlt_env_ll_set *const  ll_set)

initialize ll_set

Must call release_ll_set before exit to release all memory

Returns
-1 if memory could not be allocated
0 on success

Definition at line 327 of file dlt_env_ll.c.

References dlt_env_ll_set::array_size, DLT_ENV_LL_SET_INCREASE, dlt_env_ll_set::item, and dlt_env_ll_set::num_elem.

Referenced by dlt_env_extract_ll_set().

int dlt_env_ll_item_get_matching_prio ( dlt_env_ll_item const *const  item,
char const *const  apid,
char const *const  ctid 
)

check if (and how) apid and ctid match with given item

Resulting priorities:

  • no apid, no ctid only ll given in item: use ll with prio 1
  • no apid, ctid matches: use ll with prio 2
  • no ctid, apid matches: use ll with prio 3
  • apid, ctid matches: use ll with prio 4

In case of error, -1 is returned.

Definition at line 488 of file dlt_env_ll.c.

References dlt_env_ll_item::appId, dlt_env_ll_item::ctxId, and dlt_env_ids_match().

Referenced by dlt_env_adjust_ll_from_env().