From ee86a0bd989511319adf3467b41b5b2e1f486aa6 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 10 Apr 2013 12:19:13 +1000 Subject: [PATCH] lib/types: Create common file for type definitions The device and boot_option types are defined in pb-protocol.h, but aren't really specific to the procotol. This means a lot of non-messaging-related files are #including the protocol definitions unnecessarily. This change separates the types out into lib/types/types.h. Signed-off-by: Jeremy Kerr Signed-off-by: Geoff Levand --- discover/device-handler.c | 2 +- discover/grub2-parser.c | 2 +- discover/kboot-parser.c | 2 +- discover/parser-utils.c | 2 +- discover/parser-utils.h | 2 +- discover/parser.c | 2 +- discover/yaboot-parser.c | 2 +- lib/Makefile.am | 1 + lib/pb-protocol/pb-protocol.h | 27 +-------------------------- lib/types/types.h | 32 ++++++++++++++++++++++++++++++++ test/parser/parser-test.c | 2 +- ui/common/discover-client.h | 2 +- ui/common/ui-system.h | 4 +++- ui/ncurses/nc-ked.h | 2 +- ui/ncurses/nc-menu.h | 2 +- ui/twin/pbt-client.c | 2 ++ ui/twin/pbt-menu.h | 2 +- 17 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 lib/types/types.h diff --git a/discover/device-handler.c b/discover/device-handler.c index bda724c..0d43496 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include "device-handler.h" diff --git a/discover/grub2-parser.c b/discover/grub2-parser.c index f6cbccb..df1b755 100644 --- a/discover/grub2-parser.c +++ b/discover/grub2-parser.c @@ -27,7 +27,7 @@ #include "log/log.h" #include "talloc/talloc.h" -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "parser-conf.h" #include "parser-utils.h" #include "paths.h" diff --git a/discover/kboot-parser.c b/discover/kboot-parser.c index 29324cb..2954d89 100644 --- a/discover/kboot-parser.c +++ b/discover/kboot-parser.c @@ -6,7 +6,7 @@ #include "log/log.h" #include "talloc/talloc.h" -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "parser-conf.h" #include "parser-utils.h" #include "paths.h" diff --git a/discover/parser-utils.c b/discover/parser-utils.c index 47e30d8..5792f0a 100644 --- a/discover/parser-utils.c +++ b/discover/parser-utils.c @@ -4,7 +4,7 @@ #include #include -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "event.h" #include "udev.h" #include "device-handler.h" diff --git a/discover/parser-utils.h b/discover/parser-utils.h index fe28b7b..107f4f3 100644 --- a/discover/parser-utils.h +++ b/discover/parser-utils.h @@ -1,7 +1,7 @@ #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))) diff --git a/discover/parser.c b/discover/parser.c index beaaccc..d0b0477 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -1,7 +1,7 @@ #include -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include #include "device-handler.h" diff --git a/discover/yaboot-parser.c b/discover/yaboot-parser.c index 4306492..59e52b8 100644 --- a/discover/yaboot-parser.c +++ b/discover/yaboot-parser.c @@ -6,7 +6,7 @@ #include "log/log.h" #include "talloc/talloc.h" -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "parser-conf.h" #include "parser-utils.h" #include "paths.h" diff --git a/lib/Makefile.am b/lib/Makefile.am index 6440fe4..7847d09 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -28,6 +28,7 @@ libpbcore_la_SOURCES = \ waiter/waiter.h \ pb-protocol/pb-protocol.c \ pb-protocol/pb-protocol.h \ + types/types.h \ talloc/talloc.c \ talloc/talloc.h \ system/system.c \ diff --git a/lib/pb-protocol/pb-protocol.h b/lib/pb-protocol/pb-protocol.h index bfa9222..07ef7e1 100644 --- a/lib/pb-protocol/pb-protocol.h +++ b/lib/pb-protocol/pb-protocol.h @@ -5,6 +5,7 @@ #include #include +#include #define PB_SOCKET_PATH "/tmp/petitboot.ui" @@ -21,32 +22,6 @@ struct pb_protocol_message { char payload[]; }; -struct device { - char *id; - char *name; - char *description; - char *icon_file; - - struct list boot_options; - - int n_options; - void *ui_info; -}; - -struct boot_option { - char *id; - char *name; - char *description; - char *icon_file; - char *boot_image_file; - char *initrd_file; - char *boot_args; - - struct list_item list; - - void *ui_info; -}; - void pb_protocol_dump_device(const struct device *dev, const char *text, FILE *stream); int pb_protocol_device_len(const struct device *dev); diff --git a/lib/types/types.h b/lib/types/types.h new file mode 100644 index 0000000..acd9e3e --- /dev/null +++ b/lib/types/types.h @@ -0,0 +1,32 @@ +#ifndef _TYPES_H +#define _TYPES_H + +#include + +struct device { + char *id; + char *name; + char *description; + char *icon_file; + + int n_options; + struct list boot_options; + + void *ui_info; +}; + +struct boot_option { + char *id; + char *name; + char *description; + char *icon_file; + char *boot_image_file; + char *initrd_file; + char *boot_args; + + struct list_item list; + + void *ui_info; +}; + +#endif /* _TYPES_H */ diff --git a/test/parser/parser-test.c b/test/parser/parser-test.c index 90b3e3b..75533e3 100644 --- a/test/parser/parser-test.c +++ b/test/parser/parser-test.c @@ -7,7 +7,7 @@ #include #include -#include "pb-protocol/pb-protocol.h" +#include #include #include "discover/device-handler.h" diff --git a/ui/common/discover-client.h b/ui/common/discover-client.h index f9f74e5..4af936c 100644 --- a/ui/common/discover-client.h +++ b/ui/common/discover-client.h @@ -1,7 +1,7 @@ #ifndef _DISCOVER_CLIENT_H #define _DISCOVER_CLIENT_H -#include +#include struct discover_client; diff --git a/ui/common/ui-system.h b/ui/common/ui-system.h index 63d1a92..b75c4d1 100644 --- a/ui/common/ui-system.h +++ b/ui/common/ui-system.h @@ -19,8 +19,10 @@ #if !defined(_PB_UI_SYSTEM_H) #define _PB_UI_SYSTEM_H -#include "pb-protocol/pb-protocol.h" +#include + #include "system/system.h" +#include "types/types.h" #include "ui/common/timer.h" #include diff --git a/ui/ncurses/nc-ked.h b/ui/ncurses/nc-ked.h index 62fddd6..2f2792d 100644 --- a/ui/ncurses/nc-ked.h +++ b/ui/ncurses/nc-ked.h @@ -23,7 +23,7 @@ #include /* This must be included before ncurses.h */ #include -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "ui/common/ui-system.h" #include "nc-scr.h" diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h index 4abec6f..750bef5 100644 --- a/ui/ncurses/nc-menu.h +++ b/ui/ncurses/nc-menu.h @@ -24,7 +24,7 @@ #include #include "log/log.h" -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "nc-scr.h" struct pmenu; diff --git a/ui/twin/pbt-client.c b/ui/twin/pbt-client.c index ed12e5a..6a4d863 100644 --- a/ui/twin/pbt-client.c +++ b/ui/twin/pbt-client.c @@ -23,6 +23,8 @@ #include #include +#include + #include "pbt-client.h" #include "log/log.h" diff --git a/ui/twin/pbt-menu.h b/ui/twin/pbt-menu.h index 7547f16..cb696ea 100644 --- a/ui/twin/pbt-menu.h +++ b/ui/twin/pbt-menu.h @@ -19,7 +19,7 @@ #define _PBT_MENU_H #include "list/list.h" -#include "pb-protocol/pb-protocol.h" +#include "types/types.h" #include "pbt-scr.h" -- 2.39.2