summaryrefslogtreecommitdiffstats
path: root/lib/types/types.c
blob: 63045e1a29d2a933abd98bb8ed8826f2adea7a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <string.h>
#include <types/types.h>
#include <i18n/i18n.h>

const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev)
{
	switch (bootdev) {
	case IPMI_BOOTDEV_NONE:
		return _("None");
	case IPMI_BOOTDEV_NETWORK:
		return _("Network");
	case IPMI_BOOTDEV_DISK:
		return _("Disk");
	case IPMI_BOOTDEV_SAFE:
		return _("Safe Mode");
	case IPMI_BOOTDEV_CDROM:
		return _("Optical");
	case IPMI_BOOTDEV_SETUP:
		return _("Setup Mode");
	default:
		return _("Unknown");
	}
}

const char *device_type_display_name(enum device_type type)
{
	switch (type) {
	case DEVICE_TYPE_DISK:
		return _("Disk");
	case DEVICE_TYPE_USB:
		return _("USB");
	case DEVICE_TYPE_OPTICAL:
		return _("CD/DVD");
	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_USB:
		return "usb";
	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, "usb", strlen("usb")))
		return DEVICE_TYPE_USB;
	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;
}
OpenPOWER on IntegriCloud