    {-# LINE 1 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    -- |H5FDmulti Implements a file driver which dispatches I/O requests to
    -- other file drivers depending on the purpose of the address
    -- region being accessed. For instance, all meta-data could be
    -- placed in one file while all raw data goes to some other file.
    module Bindings.HDF5.Raw.H5FD.Multi where

    import Foreign.C.String
    import Foreign.Ptr
    import System.IO.Unsafe (unsafePerformIO)

    import Bindings.HDF5.Raw.H5
    import Bindings.HDF5.Raw.H5I
    import Bindings.HDF5.Raw.H5FD
    import Foreign.Ptr.Conventions

    h5fd_MULTI
    {-# LINE 20 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}
      :: HId_t
    h5fd_MULTI :: HId_t
    h5fd_MULTI
    {-# LINE 22 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}
        = unsafePerformIO (h5fd_multi_init)
    {-# LINE 23 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    -- |Initialize this driver by registering the driver with the library.
    --
    -- On success, returns the driver ID for the multi driver.  On failure,
    -- returns a negative value.
    --
    -- > hid_t H5FD_multi_init(void);
    foreign import ccall "H5FD_multi_init" h5fd_multi_init
      :: IO HId_t
    foreign import ccall "&H5FD_multi_init" p_H5FD_multi_init
      :: FunPtr (IO HId_t)

    {-# LINE 31 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    {-# LINE 38 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    -- TODO: find out whether input arrays need to be static... Probably not, since H5Pget_fapl_multi copies them out.
    -- |Sets the file access property list 'fapl_id' to use the multi
    -- driver. The 'memb_map' array maps memory usage types to other
    -- memory usage types and is the mechanism which allows the
    -- caller to specify how many files are created. The array
    -- contains 'h5fd_MEM_NTYPES' entries which are either the value
    -- 'h5fd_MEM_DEFAULT' or a memory usage type and the number of
    -- unique values determines the number of files which are
    -- opened.  For each memory usage type which will be associated
    -- with a file the 'memb_fapl' array should have a property list
    -- and the 'memb_name' array should be a name generator (a
    -- printf-style format with a %s which will be replaced with the
    -- name passed to 'h5fd_open', usually from 'h5f_create' or
    -- 'h5f_open').
    --
    -- If 'relax' is set then opening an existing file for read-only
    -- access will not fail if some file members are missing.  This
    -- allows a file to be accessed in a limited sense if just the
    -- meta data is available.
    --
    -- Default values for each of the optional arguments are:
    --
    -- ['memb_map']
    --      The default member map has the value
    --      'h5fd_MEM_DEFAULT' for each element.
    --
    -- ['memb_fapl']
    --      The value 'h5p_DEFAULT' for each element.
    --
    -- ['memb_name']
    --      The string \"%s-X.h5\" where \"X\" is one of the
    --         letters \"s\" ('h5fd_MEM_SUPER'),
    --         \"b\" ('h5fd_MEM_BTREE'), \"r\" ('h5fd_MEM_DRAW'),
    --         \"g\" ('h5fd_MEM_GHEAP'), \"l\" ('h5fd_MEM_LHEAP'),
    --         \"o\" ('h5fd_MEM_OHDR').
    --
    -- ['memb_addr']
    --      The value 'hADDR_UNDEF' for each element.
    --
    --
    -- Example: To set up a multi file access property list which partitions
    -- data into meta and raw files each being 1/2 of the address
    -- space one would say (TODO: translate to Haskell):
    --
    -- > H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
    -- > hid_t memb_fapl[H5FD_MEM_NTYPES];
    -- > const char *memb[H5FD_MEM_NTYPES];
    -- > haddr_t memb_addr[H5FD_MEM_NTYPES];
    -- >
    -- > // The mapping...
    -- > for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
    -- >     memb_map[mt] = H5FD_MEM_SUPER;
    -- > }
    -- > memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
    -- >
    -- > // Member information
    -- > memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT;
    -- > memb_name[H5FD_MEM_SUPER] = "%s.meta";
    -- > memb_addr[H5FD_MEM_SUPER] = 0;
    -- >
    -- > memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT;
    -- > memb_name[H5FD_MEM_DRAW] = "%s.raw";
    -- > memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2;
    -- >
    -- > hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
    -- > H5Pset_fapl_multi(fapl, memb_map, memb_fapl,
    -- >                   memb_name, memb_addr, TRUE);
    --
    --
    -- Returns non-negative on success, negative on failure.
    --
    -- > herr_t H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
    -- >        const hid_t *memb_fapl, const char * const *memb_name,
    -- >        const haddr_t *memb_addr, hbool_t relax);
    foreign import ccall "H5Pset_fapl_multi" h5p_set_fapl_multi
      :: HId_t -> InArray H5FD_mem_t -> InArray HId_t -> InArray CString -> InArray HAddr_t -> HBool_t -> IO HErr_t
    foreign import ccall "&H5Pset_fapl_multi" p_H5Pset_fapl_multi
      :: FunPtr (HId_t -> InArray H5FD_mem_t -> InArray HId_t -> InArray CString -> InArray HAddr_t -> HBool_t -> IO HErr_t)

    {-# LINE 114 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    -- |Returns information about the multi file access property
    -- list though the function arguments which are the same as for
    -- 'h5p_set_fapl_multi' above.
    --
    -- Returns non-negative on success, negative on failure.
    --
    -- > herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
    -- >        hid_t *memb_fapl/*out*/, char **memb_name/*out*/,
    -- >        haddr_t *memb_addr/*out*/, hbool_t *relax/*out*/);
    foreign import ccall "H5Pget_fapl_multi" h5p_get_fapl_multi
      :: HId_t -> OutArray H5FD_mem_t -> OutArray HId_t -> OutArray CString -> OutArray HAddr_t -> Out HBool_t -> IO HErr_t
    foreign import ccall "&H5Pget_fapl_multi" p_H5Pget_fapl_multi
      :: FunPtr (HId_t -> OutArray H5FD_mem_t -> OutArray HId_t -> OutArray CString -> OutArray HAddr_t -> Out HBool_t -> IO HErr_t)

    {-# LINE 125 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    {-# LINE 147 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}

    -- |Compatability function. Makes the multi driver act like the
    -- old split driver which stored meta data in one file and raw
    -- data in another file.
    --
    -- If the raw or meta extension string contains a \"%s\", it will
    -- be substituted by the filename given for 'h5f_open' or 'h5f_create'.
    -- If no %s is found, one is inserted at the beginning.
    --
    -- Returns non-negative on success, negative on failure.
    --
    -- > herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext,
    -- >        hid_t meta_plist_id, const char *raw_ext,
    -- >        hid_t raw_plist_id);
    foreign import ccall "H5Pset_fapl_split" h5p_set_fapl_split
      :: HId_t -> CString -> HId_t -> CString -> HId_t -> IO HErr_t
    foreign import ccall "&H5Pset_fapl_split" p_H5Pset_fapl_split
      :: FunPtr (HId_t -> CString -> HId_t -> CString -> HId_t -> IO HErr_t)

    {-# LINE 162 "src/Bindings/HDF5/Raw/H5FD/Multi.hsc" #-}