discover: Ensure destroy_device is called on reinit
[petitboot] / lib / types / types.c
1 #include <string.h>
2 #include <types/types.h>
3 #include <i18n/i18n.h>
4
5 const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev)
6 {
7         switch (bootdev) {
8         case IPMI_BOOTDEV_NONE:
9                 return _("None");
10         case IPMI_BOOTDEV_NETWORK:
11                 return _("Network");
12         case IPMI_BOOTDEV_DISK:
13                 return _("Disk");
14         case IPMI_BOOTDEV_SAFE:
15                 return _("Safe Mode");
16         case IPMI_BOOTDEV_CDROM:
17                 return _("Optical");
18         case IPMI_BOOTDEV_SETUP:
19                 return _("Setup Mode");
20         default:
21                 return _("Unknown");
22         }
23 }
24
25 const char *device_type_display_name(enum device_type type)
26 {
27         switch (type) {
28         case DEVICE_TYPE_DISK:
29                 return _("Disk");
30         case DEVICE_TYPE_OPTICAL:
31                 return _("Optical");
32         case DEVICE_TYPE_NETWORK:
33                 return _("Network");
34         case DEVICE_TYPE_ANY:
35                 return _("Any");
36         case DEVICE_TYPE_UNKNOWN:
37         default:
38                 return _("Unknown");
39         }
40 }
41
42 const char *device_type_name(enum device_type type)
43 {
44         switch (type) {
45         case DEVICE_TYPE_DISK:
46                 return "disk";
47         case DEVICE_TYPE_OPTICAL:
48                 return "optical";
49         case DEVICE_TYPE_NETWORK:
50                 return "network";
51         case DEVICE_TYPE_ANY:
52                 return "any";
53         case DEVICE_TYPE_UNKNOWN:
54         default:
55                 return "unknown";
56         }
57 }
58
59 enum device_type find_device_type(const char *str)
60 {
61         if (!strncmp(str, "disk", strlen("disk")))
62                 return DEVICE_TYPE_DISK;
63         if (!strncmp(str, "optical", strlen("optical")))
64                 return DEVICE_TYPE_OPTICAL;
65         if (!strncmp(str, "network", strlen("network")))
66                 return DEVICE_TYPE_NETWORK;
67         if (!strncmp(str, "any", strlen("any")))
68                 return DEVICE_TYPE_ANY;
69
70         return DEVICE_TYPE_UNKNOWN;
71 }