026d09560262f0ab8471e18e50b61541f787defd
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 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
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef _Common_config_preproc_H
9 #define _Common_config_preproc_H
15 extern void config_preproc_error(const char *error_str
, ...)
16 __attribute__ ((__format__ (__printf__
, 1, 2)));
22 extern void path_error(const char *fmt
, ...)
23 __attribute__ ((__format__ (__printf__
, 1, 2)));
29 extern std::string
get_cfg_preproc_current_file();
30 extern int config_preproc_yylineno
;
32 /** this struct is used to maintain a list of config files */
33 typedef struct string_chain_t
{
35 struct string_chain_t
*next
;
38 /** adds a new string to the end of chain (reference), if it is not
39 * contained by the chain */
40 void string_chain_add(string_chain_t
**ec
, char *s
);
41 /** cuts the head of the chain (reference!) and returns that
43 char* string_chain_cut(string_chain_t
**ec
);
45 /** struct to store string key-value pairs. the value can contain
46 * null-characters so we store also the length. */
47 typedef struct string_keyvalue_t
{
53 /** an array. keep it sorted */
54 typedef struct string_map_t
{
56 string_keyvalue_t
**data
;
59 /** adds a new key-value pair. if the key exists, it will be
60 * overwritten, and the return value is the (old) key. */
61 const char* string_map_add(string_map_t
*map
, char *key
,
62 char *value
, size_t value_len
);
64 /** returns NULL if no such key. the length of value is returned in
66 const char* string_map_get_bykey(const string_map_t
*map
, const char *key
,
70 string_map_t
* string_map_new(void);
72 void string_map_free(string_map_t
*map
);
74 /** Parses out and returns the macro identifier from macro reference \a str.
75 * The input shall be in format "${<macro_id>,something}", NULL pointer is
76 * returned otherwise. Whitespaces are allowed anywhere within the braces.
77 * The returned string shall be deallocated by the caller using Free(). */
78 char *get_macro_id_from_ref(const char *str
);
80 /** Entry point for preprocessing config files.
82 * @param [in] filename the main config file
83 * @param [out] filenames main config plus all the included files
84 * @param [out] defines the macro definitions
85 * @return 1 if there were errors, 0 otherwise.
87 int preproc_parse_file(const char *filename
, string_chain_t
**filenames
,
88 string_map_t
**defines
);
90 int string_is_int(const char *str
, size_t len
);
91 int string_is_float(const char *str
, size_t len
);
92 int string_is_id(const char *str
, size_t len
);
93 int string_is_bstr(const char *str
, size_t len
);
94 int string_is_hstr(const char *str
, size_t len
);
95 int string_is_ostr(const char *str
, size_t len
);
96 int string_is_hostname(const char *str
, size_t len
);
98 #endif /* _Common_config_preproc_H */
This page took 0.033909 seconds and 5 git commands to generate.