discover/pxe-parser: Recognise plugin sources
[petitboot] / discover / parser-utils.h
index 955f5f4d7e6b7c730c3f4e7a2f8313dacd71afe1..9096b311ce6ecc00b4fd0d3f0c851fe8f588a4c5 100644 (file)
@@ -1,21 +1,24 @@
 #ifndef PARSER_UTILS_H
 #define PARSER_UTILS_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, __priority, __parse_fn)                  \
-       struct parser                                                   \
-               __attribute__((unused, section("parsers")))             \
-       __ ## __name ## _parser = {                                     \
-               .name           = #__name,                              \
-               .priority       = __priority,                           \
-               .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);