diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 1 | ||||
-rw-r--r-- | lib/types/types.c | 51 | ||||
-rw-r--r-- | lib/types/types.h | 15 |
3 files changed, 67 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index fbf2ee2..b39cc9b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -38,6 +38,7 @@ lib_libpbcore_la_SOURCES = \ lib/pb-config/pb-config.h \ lib/process/process.c \ lib/process/process.h \ + lib/types/types.c \ lib/types/types.h \ lib/talloc/talloc.c \ lib/talloc/talloc.h \ diff --git a/lib/types/types.c b/lib/types/types.c new file mode 100644 index 0000000..059e52a --- /dev/null +++ b/lib/types/types.c @@ -0,0 +1,51 @@ +#include <string.h> +#include <types/types.h> +#include <i18n/i18n.h> + +const char *device_type_display_name(enum device_type type) +{ + switch (type) { + case DEVICE_TYPE_DISK: + return _("Disk"); + case DEVICE_TYPE_OPTICAL: + return _("Optical"); + case DEVICE_TYPE_NETWORK: + return _("Network"); + case DEVICE_TYPE_ANY: + return _("Any"); + case DEVICE_TYPE_UNKNOWN: + default: + return _("Unknown"); + } +} + +const char *device_type_name(enum device_type type) +{ + switch (type) { + case DEVICE_TYPE_DISK: + return "disk"; + case DEVICE_TYPE_OPTICAL: + return "optical"; + case DEVICE_TYPE_NETWORK: + return "network"; + case DEVICE_TYPE_ANY: + return "any"; + case DEVICE_TYPE_UNKNOWN: + default: + return "unknown"; + } +} + +enum device_type find_device_type(const char *str) +{ + if (!strncmp(str, "disk", strlen("disk"))) + return DEVICE_TYPE_DISK; + if (!strncmp(str, "optical", strlen("optical"))) + return DEVICE_TYPE_OPTICAL; + if (!strncmp(str, "network", strlen("network"))) + return DEVICE_TYPE_NETWORK; + if (!strncmp(str, "any", strlen("any"))) + return DEVICE_TYPE_ANY; + + return DEVICE_TYPE_UNKNOWN; +} diff --git a/lib/types/types.h b/lib/types/types.h index f543b7f..e22dbc3 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -13,6 +13,10 @@ enum device_type { DEVICE_TYPE_UNKNOWN, }; +const char *device_type_display_name(enum device_type type); +const char *device_type_name(enum device_type type); +enum device_type find_device_type(const char *str); + struct device { char *id; enum device_type type; @@ -118,6 +122,17 @@ struct boot_priority { enum device_type type; }; +struct autoboot_option { + enum { + BOOT_DEVICE_TYPE, + BOOT_DEVICE_UUID + } boot_type; + union { + enum device_type type; + char *uuid; + }; +}; + struct config { bool autoboot_enabled; unsigned int autoboot_timeout_sec; |