/** * \file * * * \brief KFile interface over a memory buffer. * * Convenient way to access a memory region using the KFile interface. * * * \author Francesco Sacchi * * $WIZ$ module_name = "kfilemem" * $WIZ$ module_depends = "kfile" */ #ifndef STRUCT_KFILE_MEM #define STRUCT_KFILE_MEM #include /** * Context for KFile over memory buffer. */ typedef struct KFileMem { KFile fd; ///< KFile base class void *mem; ///< Pointer to the memory buffer used. } KFileMem; /** * ID for KFile Mem. */ #define KFT_KFILEMEM MAKE_ID('M', 'E', 'M', '0') /** * Convert + ASSERT from generic KFile to KFileMem. */ INLINE KFileMem * KFILEMEM_CAST(KFile *fd) { ASSERT(fd->_type == KFT_KFILEMEM); return (KFileMem *)fd; } /** * Initialize KFileMem struct. * * \param km Interface to initialize. * \param mem Pointer to the memory buffer to operate on. * \param len Size of the buffer */ void kfilemem_init(KFileMem *km, void *mem, size_t len); #endif /* STRUCT_KFILE_MEM */