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