1 #pragma once 2 #ifndef IWDLSNR_H 3 #define IWDLSNR_H 4 5 #include "basedefs.h" 6 #include <stdbool.h> 7 8 IW_EXTERN_C_START 9 10 /** 11 * @brief File data events listener. 12 */ 13 typedef struct IWDLSNR { 14 15 /** 16 * @brief Before file open event. 17 * 18 * @param path File path 19 * @param mode File open mode same as in open(2) 20 */ 21 iwrc (*onopen)(struct IWDLSNR *self, const char *path, int mode); 22 23 /** 24 * @brief Before file been closed. 25 */ 26 iwrc (*onclosing)(struct IWDLSNR *self); 27 28 /** 29 * @brief Write @a val value starting at @a off @a len bytes 30 */ 31 iwrc (*onset)(struct IWDLSNR *self, off_t off, uint8_t val, off_t len, int flags); 32 33 /** 34 * @brief Copy @a len bytes from @a off offset to @a noff offset 35 */ 36 iwrc (*oncopy)(struct IWDLSNR *self, off_t off, off_t len, off_t noff, int flags); 37 38 /** 39 * @brief Write @buf of @a len bytes at @a off 40 */ 41 iwrc (*onwrite)(struct IWDLSNR *self, off_t off, const void *buf, off_t len, int flags); 42 43 /** 44 * @brief File need to be resized. 45 * 46 * @param osize Old file size 47 * @param nsize New file size 48 * @param [out] handled File resizing handled by llistener. 49 */ 50 iwrc (*onresize)(struct IWDLSNR *self, off_t osize, off_t nsize, int flags, bool *handled); 51 52 /** 53 * @brief File sync successful 54 */ 55 iwrc (*onsynced)(struct IWDLSNR *self, int flags); 56 } IWDLSNR; 57 58 IW_EXTERN_C_END 59 60 #endif // !IWDLSNR_H 61