libhd 5.0

hwclass_names.h

Go to the documentation of this file.
00001 typedef struct {
00002   int key;
00003   char *value;
00004 } hash_t;
00005 
00006 static char *key2value(hash_t *hash, int id);
00007 static int value2key(hash_t *hash, char *str);
00008 
00009 /* corresponds to hd_hw_item_t */
00010 static hash_t hw_items[] = {
00011   { hw_sys,           "system"              },
00012   { hw_cpu,           "cpu"                 },
00013   { hw_keyboard,      "keyboard"            },
00014   { hw_braille,       "braille"             },
00015   { hw_mouse,         "mouse"               },
00016   { hw_joystick,      "joystick"            },
00017   { hw_printer,       "printer"             },
00018   { hw_scanner,       "scanner"             },
00019   { hw_chipcard,      "chipcard"            },
00020   { hw_monitor,       "monitor"             },
00021   { hw_tv,            "tv card"             },
00022   { hw_display,       "graphics card"       },
00023   { hw_framebuffer,   "framebuffer"         },
00024   { hw_camera,        "camera"              },
00025   { hw_sound,         "sound"               },
00026   { hw_storage_ctrl,  "storage"             },
00027   { hw_network_ctrl,  "network"             },
00028   { hw_isdn,          "isdn adapter"        },
00029   { hw_modem,         "modem"               },
00030   { hw_network,       "network interface"   },
00031   { hw_disk,          "disk"                },
00032   { hw_partition,     "partition"           },
00033   { hw_cdrom,         "cdrom"               },
00034   { hw_floppy,        "floppy"              },
00035   { hw_manual,        "manual"              },
00036   { hw_usb_ctrl,      "usb controller"      },
00037   { hw_usb,           "usb"                 },
00038   { hw_bios,          "bios"                },
00039   { hw_pci,           "pci"                 },
00040   { hw_isapnp,        "isapnp"              },
00041   { hw_bridge,        "bridge"              },
00042   { hw_hub,           "hub"                 },
00043   { hw_scsi,          "scsi"                },
00044   { hw_ide,           "ide"                 },
00045   { hw_memory,        "memory"              },
00046   { hw_dvb,           "dvb card"            },
00047   { hw_pcmcia,        "pcmcia"              },
00048   { hw_pcmcia_ctrl,   "pcmcia controller"   },
00049   { hw_ieee1394,      "firewire"            },
00050   { hw_ieee1394_ctrl, "firewire controller" },
00051   { hw_hotplug,       "hotplug"             },
00052   { hw_hotplug_ctrl,  "hotplug controller"  },
00053   { hw_zip,           "zip"                 },
00054   { hw_pppoe,         "pppoe"               },
00055   { hw_wlan,          "wlan card"           },
00056   { hw_redasd,        "redasd"              },
00057   { hw_dsl,           "dsl adapter"         },
00058   { hw_block,         "block device"        },
00059   { hw_tape,          "tape"                },
00060   { hw_vbe,           "vesa bios"           },
00061   { hw_bluetooth,     "bluetooth"           },
00062   { hw_unknown,       "unknown"             },
00063   { 0,                NULL                  }
00064 };
00065 
00066 int value2key(hash_t *hash, char *str)
00067 {
00068   for(; hash->value; hash++) {
00069     if(!strcmp(hash->value, str)) break;
00070   }
00071 
00072   return hash->key;
00073 }
00074 
00075 char *key2value(hash_t *hash, int id)
00076 {
00077   for(; hash->value; hash++) {
00078     if(hash->key == id) break;
00079   }
00080 
00081   return hash->value;
00082 }
00083 
00084 
00085 char *hd_hw_item_name(hd_hw_item_t item)
00086 {
00087   return key2value(hw_items, item);
00088 }
00089 
00090 
00091 hd_hw_item_t hd_hw_item_type(char *name)
00092 {
00093   return name ? value2key(hw_items, name) : hw_none;
00094 }
00095 
00096