1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
13 * Szabo, Janos Zoltan – initial implementation
15 ******************************************************************************/
16 #ifndef _Common_config_preproc_H
17 #define _Common_config_preproc_H
23 extern void config_preproc_error(const char *error_str
, ...)
24 __attribute__ ((__format__ (__printf__
, 1, 2)));
30 extern void path_error(const char *fmt
, ...)
31 __attribute__ ((__format__ (__printf__
, 1, 2)));
37 extern std::string
get_cfg_preproc_current_file();
38 extern int config_preproc_yylineno
;
40 /** this struct is used to maintain a list of config files */
41 typedef struct string_chain_t
{
43 struct string_chain_t
*next
;
46 /** adds a new string to the end of chain (reference), if it is not
47 * contained by the chain */
48 void string_chain_add(string_chain_t
**ec
, char *s
);
49 /** cuts the head of the chain (reference!) and returns that
51 char* string_chain_cut(string_chain_t
**ec
);
53 /** struct to store string key-value pairs. the value can contain
54 * null-characters so we store also the length. */
55 typedef struct string_keyvalue_t
{
61 /** an array. keep it sorted */
62 typedef struct string_map_t
{
64 string_keyvalue_t
**data
;
67 /** adds a new key-value pair. if the key exists, it will be
68 * overwritten, and the return value is the (old) key. */
69 const char* string_map_add(string_map_t
*map
, char *key
,
70 char *value
, size_t value_len
);
72 /** returns NULL if no such key. the length of value is returned in
74 const char* string_map_get_bykey(const string_map_t
*map
, const char *key
,
78 string_map_t
* string_map_new(void);
80 void string_map_free(string_map_t
*map
);
82 /** Parses out and returns the macro identifier from macro reference \a str.
83 * The input shall be in format "${<macro_id>,something}", NULL pointer is
84 * returned otherwise. Whitespaces are allowed anywhere within the braces.
85 * The returned string shall be deallocated by the caller using Free(). */
86 char *get_macro_id_from_ref(const char *str
);
88 /** Entry point for preprocessing config files.
90 * @param [in] filename the main config file
91 * @param [out] filenames main config plus all the included files
92 * @param [out] defines the macro definitions
93 * @return 1 if there were errors, 0 otherwise.
95 int preproc_parse_file(const char *filename
, string_chain_t
**filenames
,
96 string_map_t
**defines
);
98 int string_is_int(const char *str
, size_t len
);
99 int string_is_float(const char *str
, size_t len
);
100 int string_is_id(const char *str
, size_t len
);
101 int string_is_bstr(const char *str
, size_t len
);
102 int string_is_hstr(const char *str
, size_t len
);
103 int string_is_ostr(const char *str
, size_t len
);
104 int string_is_hostname(const char *str
, size_t len
);
106 #endif /* _Common_config_preproc_H */
This page took 0.032589 seconds and 5 git commands to generate.