-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A database of USB identifiers -- -- Functions to find the names associated with numerical vendor and -- product identifiers. @package usb-id-database @version 0.2 module System.USB.IDDB.LinuxUsbIdRepo -- | Construct a database from a string in the format used by -- http://linux-usb.org. parseDb :: UTF8 ByteString -> Maybe IDDB staticDb :: IO IDDB fromFile :: FilePath -> IO (Maybe IDDB) -- | Construct a database from the data available at -- http://linux-usb.org/usb.ids. fromWeb :: IO (Maybe IDDB) module System.USB.IDDB.UsbDotOrg -- | Construct a database from a string in the format used by usb.org. parseDb :: UTF8 ByteString -> Maybe IDDB -- | Load a database from a snapshot of the usb.org database which is -- supplied with the package. staticDb :: IO IDDB -- | Load a vendor database from file. If the file can not be read for some -- reason an error will be thrown. fromFile :: FilePath -> IO (Maybe IDDB) -- | Construct a database from the list of companies available at -- http://www.usb.org/developers/tools/comp_dump. The website -- informs us that: "Remember this list changes almost daily, be -- sure to get a fresh copy when you use the tools". However, the -- list seems to be quite stable. Using this function more than once a -- day is probably overkill. fromWeb :: IO (Maybe IDDB) -- | A database of USB identifiers. -- -- Databases with vendor names and identifiers can be loaded from string, -- file or directly from http://www.usb.org or -- http://linux-usb.sourceforge.net. -- -- Example usage: -- --
-- import Data.ByteString.Char8 (pack, unpack) -- import System.USB.IDDB -- import System.USB.IDDB.LinuxUsbIdRepo -- import Text.Printf -- -- main :: IO () -- main = do -- Load a snapshot from the linux-usb.sourceforget.net database. -- db <- staticDb -- -- Print the name of vendor 0x1d6b -- putStrLn $ maybe "unknown VID!" unpack -- $ vendorName db 0x1d6b ---- --
-- -- Print the ID of "Linux Foundation" -- putStrLn $ maybe "unknown vendor name!" (printf "0x%04x") -- $ vendorId db (pack Linux Foundation) ---- --
-- -- Print the name of the product with ID 0x0101 from the -- -- vendor with ID 0x1d6b. -- putStrLn $ maybe "unknown PID!" unpack -- $ productName db 0x1d6b 0x0101 ---- --
-- -- Print the ID of the product with the name "Audio Gadget" -- -- from the vendor with ID 0x1d6b. -- putStrLn $ maybe "unknown product name!" (printf "0x%04x") -- $ productId db 0x1d6b (pack "Audio Gadget") --module System.USB.IDDB -- | A database of USB identifiers. Contains both vendor identifiers and -- product identifiers. data IDDB type VendorID = Int type VendorName = ByteString type ProductID = Int type ProductName = ByteString -- | An empty database. emptyDb :: IDDB vendorName :: IDDB -> VendorID -> Maybe VendorName vendorId :: IDDB -> VendorName -> Maybe VendorID productName :: IDDB -> VendorID -> ProductID -> Maybe ProductName productId :: IDDB -> VendorID -> ProductName -> Maybe ProductID