lib/system: Add vgscan, vgchange utilities
[petitboot] / discover / parser-utils.h
index fe28b7bd74d7adfd100f011649fdbf27f17aca24..9096b311ce6ecc00b4fd0d3f0c851fe8f588a4c5 100644 (file)
@@ -1,19 +1,24 @@
 #ifndef PARSER_UTILS_H
 #define PARSER_UTILS_H
 
-#include "pb-protocol/pb-protocol.h"
+#include "types/types.h"
 #include "parser.h"
 
 #define streq(a,b) (!strcasecmp((a),(b)))
 
 #define artwork_pathname(file) (PKG_SHARE_DIR "/artwork/" file)
 
-#define define_parser(__name, __parse_fn)                      \
-       struct parser                                                   \
-       __ ## __name ## _parser = {                                     \
-               .name           = #__name,                              \
-               .parse          = __parse_fn,                           \
-       };
+#define __parser_funcname(_n) __register_parser ## _ ## _n
+#define  _parser_funcname(_n) __parser_funcname(_n)
+
+#define register_parser(_parser)                                       \
+       static  __attribute__((constructor))                            \
+               void _parser_funcname(__COUNTER__)(void)                \
+       {                                                               \
+               __register_parser(&_parser);                            \
+       }
+
+void __register_parser(struct parser *parser);
 
 void device_add_boot_option(struct device *device,
                struct boot_option *boot_option);