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 
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:3
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:10
Definition: hd.h:141
Definition: hd.h:143
Definition: hd.h:141
Definition: hd.h:146
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
hd_hw_item_t hd_hw_item_type(char *name)
Definition: hwclass_names.h:91
static char * key2value(hash_t *hash, int id)
Definition: hwclass_names.h:75
static int value2key(hash_t *hash, char *str)
Definition: hwclass_names.h:66
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:2
Definition: hd.h:142
Definition: hd.h:148
Definition: hd.h:144
Definition: hd.h:140
Definition: hd.h:146
Definition: hd.h:146
Definition: hd.h:142
Definition: hd.h:141
Definition: hwclass_names.h:1
char * hd_hw_item_name(hd_hw_item_t item)
Definition: hwclass_names.h:85
Definition: hd.h:144
Definition: hd.h:141
Definition: hd.h:148
Definition: hd.h:147
Definition: hd.h:147
Definition: hd.h:144