libyang  6.4.7
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
utils.h
Go to the documentation of this file.
1 
15 #ifndef LY_UTILS_H_
16 #define LY_UTILS_H_
17 
18 #include <stdint.h>
19 #include <time.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 struct ly_ctx;
26 struct timespec;
27 
39 #define LY_LIST_FOR(START, ELEM) \
40  for ((ELEM) = (START); \
41  (ELEM); \
42  (ELEM) = (ELEM)->next)
43 
53 #define LY_LIST_FOR_SAFE(START, NEXT, ELEM) \
54  for ((ELEM) = (START); \
55  (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \
56  (ELEM) = (NEXT))
57 
61 typedef enum {
82 } LY_DATA_TYPE;
83 #define LY_DATA_TYPE_COUNT 20
88 extern const char *ly_data_type2str[LY_DATA_TYPE_COUNT];
89 
93 typedef enum {
103 
117 LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
118  uint32_t str_len, void **pat_comp);
119 
129 LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp);
130 
136 LIBYANG_API_DECL void ly_pattern_free(void *pat_comp);
137 
143 LIBYANG_API_DECL int ly_time_tz_offset(void);
144 
151 LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
152 
161 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
162 
171 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
172 
180 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
181 
189 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif /* LY_UTILS_H_ */
LIBYANG_API_DECL void ly_pattern_free(void *pat_comp)
Free a compiled XML Schema regex pattern.
LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str)
Convert UNIX timestamp and fractions of a second into canonical date-and-time string value...
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:255
LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time)
Get UTC (GMT) timezone offset in seconds at a specific timestamp (including DST setting).
LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s)
Convert date-and-time from string to UNIX timestamp and fractions of a second.
LIBYANG_API_DECL int ly_time_tz_offset(void)
Get current timezone (including DST setting) UTC (GMT) time offset in seconds.
LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, void **pat_comp)
Check a string matches an XML Schema regex used in YANG.
LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts)
Convert date-and-time from string to timespec.
LY_DATA_TYPE
YANG built-in types.
Definition: utils.h:61
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp)
Compile an XML Schema regex pattern prior to matching.
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: utils.h:93
libyang context handler.