libhd  5.0
hwclass_names.h
Go to the documentation of this file.
1 #ifndef API_SYM
2 #define API_SYM __attribute__((visibility("default")))
3 #endif
4 
5 typedef struct {
6  int key;
7  char *value;
8 } hash_t;
9 
10 static char *key2value(hash_t *hash, int id);
11 static int value2key(hash_t *hash, char *str);
12 
13 /* corresponds to hd_hw_item_t */
14 static hash_t hw_items[] = {
15  { hw_sys, "system" },
16  { hw_cpu, "cpu" },
17  { hw_keyboard, "keyboard" },
18  { hw_braille, "braille" },
19  { hw_mouse, "mouse" },
20  { hw_joystick, "joystick" },
21  { hw_printer, "printer" },
22  { hw_scanner, "scanner" },
23  { hw_chipcard, "chipcard" },
24  { hw_monitor, "monitor" },
25  { hw_tv, "tv card" },
26  { hw_display, "graphics card" },
27  { hw_framebuffer, "framebuffer" },
28  { hw_camera, "camera" },
29  { hw_sound, "sound" },
30  { hw_storage_ctrl, "storage" },
31  { hw_network_ctrl, "network" },
32  { hw_isdn, "isdn adapter" },
33  { hw_modem, "modem" },
34  { hw_network, "network interface" },
35  { hw_disk, "disk" },
36  { hw_partition, "partition" },
37  { hw_cdrom, "cdrom" },
38  { hw_floppy, "floppy" },
39  { hw_manual, "manual" },
40  { hw_usb_ctrl, "usb controller" },
41  { hw_usb, "usb" },
42  { hw_bios, "bios" },
43  { hw_pci, "pci" },
44  { hw_isapnp, "isapnp" },
45  { hw_bridge, "bridge" },
46  { hw_hub, "hub" },
47  { hw_scsi, "scsi" },
48  { hw_ide, "ide" },
49  { hw_memory, "memory" },
50  { hw_dvb, "dvb card" },
51  { hw_pcmcia, "pcmcia" },
52  { hw_pcmcia_ctrl, "pcmcia controller" },
53  { hw_ieee1394, "firewire" },
54  { hw_ieee1394_ctrl, "firewire controller" },
55  { hw_hotplug, "hotplug" },
56  { hw_hotplug_ctrl, "hotplug controller" },
57  { hw_zip, "zip" },
58  { hw_pppoe, "pppoe" },
59  { hw_wlan, "wlan card" },
60  { hw_redasd, "redasd" },
61  { hw_dsl, "dsl adapter" },
62  { hw_block, "block device" },
63  { hw_tape, "tape" },
64  { hw_vbe, "vesa bios" },
65  { hw_bluetooth, "bluetooth" },
66  { hw_nvme, "nvme" },
67  { hw_unknown, "unknown" },
68  { 0, NULL }
69 };
70 
71 int value2key(hash_t *hash, char *str)
72 {
73  for(; hash->value; hash++) {
74  if(!strcmp(hash->value, str)) break;
75  }
76 
77  return hash->key;
78 }
79 
80 char *key2value(hash_t *hash, int id)
81 {
82  for(; hash->value; hash++) {
83  if(hash->key == id) break;
84  }
85 
86  return hash->value;
87 }
88 
89 
91 {
92  return key2value(hw_items, item);
93 }
94 
95 
97 {
98  return name ? value2key(hw_items, name) : hw_none;
99 }
100 
101 
Definition: hd.h:147
Definition: hd.h:145
Definition: hd.h:140
Definition: hd.h:145
Definition: hd.h:144
Definition: hd.h:147
Definition: hd.h:147
Definition: hd.h:143
Definition: hd.h:146
Definition: hd.h:147
Definition: hd.h:143
Definition: hd.h:143
Definition: hd.h:143
Definition: hd.h:145
Definition: hd.h:143
enum hw_item hd_hw_item_t
list types for hd_list()
char * value
Definition: hwclass_names.h:7
Definition: hd.h:145
Definition: hd.h:144
Definition: hd.h:147
Definition: hd.h:144
Definition: hd.h:145
static hash_t hw_items[]
Definition: hwclass_names.h:14
Definition: hd.h:141
Definition: hd.h:143
Definition: hd.h:141
Definition: hd.h:146
Definition: hd.h:148
Definition: hd.h:140
Definition: hd.h:145
Definition: hd.h:141
Definition: hd.h:142
Definition: hd.h:144
append new entries here
Definition: hd.h:150
Definition: hd.h:140
API_SYM hd_hw_item_t hd_hw_item_type(char *name)
Definition: hwclass_names.h:96
static char * key2value(hash_t *hash, int id)
Definition: hwclass_names.h:80
static int value2key(hash_t *hash, char *str)
Definition: hwclass_names.h:71
Definition: hd.h:142
Definition: hd.h:146
Definition: hd.h:140
Definition: hd.h:140
Definition: hd.h:141
Definition: hd.h:145
Definition: hd.h:148
Definition: hd.h:142
int key
Definition: hwclass_names.h:6
Definition: hd.h:142
Definition: hd.h:148
Definition: hd.h:144
#define API_SYM
Definition: hwclass_names.h:2
Definition: hd.h:140
Definition: hd.h:146
Definition: hd.h:146
Definition: hd.h:142
Definition: hd.h:141
Definition: hwclass_names.h:5
API_SYM char * hd_hw_item_name(hd_hw_item_t item)
Definition: hwclass_names.h:90
Definition: hd.h:144
Definition: hd.h:141
Definition: hd.h:148
Definition: hd.h:147
Definition: hd.h:147
Definition: hd.h:144