1 #ifndef __SYSTEM_INFO_TOOL_H__
2 #define __SYSTEM_INFO_TOOL_H__
8 #include <system_info.h>
9 #include <system_info_type.h>
10 #include <system_info_private.h>
12 #define BUFFER_MAX 128
16 DB_DEFAULT_RO = DB_START,
27 extern const struct db db[DB_END];
30 system_info_type_e type;
46 extern int runtime_env;
48 static inline void fclosep(FILE **fp)
53 #define __auto_fclose__ __attribute__((cleanup(fclosep)))
55 static inline void closep(int *fd)
60 #define __auto_close__ __attribute__((cleanup(closep)))
62 static inline void free_value(struct value *v)
64 if (v->type == SYSTEM_INFO_STRING)
67 #define __auto_free_value__ __attribute__((cleanup(free_value)))
69 static inline void free_dbentry(struct dbentry *entry)
71 if (entry->value.type == SYSTEM_INFO_STRING)
74 #define __auto_free_dbentry__ __attribute__((cleanup(free_dbentry)))
77 const char *type_to_string(system_info_type_e type);
78 system_info_type_e string_to_type(const char *type);
79 void print_value(struct value value);
80 int convert_raw_key(const char *key, char *buffer, int len);
82 #define SYSINFO_G_LIST_APPEND(a, b) \
83 a = g_list_append(a, (gpointer)b)
85 #define SYSINFO_G_LIST_FOREACH(head, elem, node) \
86 for (elem = head, node = NULL; \
87 elem && ((node = elem->data) != NULL); \
88 elem = elem->next, node = NULL)