1 #ifndef __BFILE_H 2 #define __BFILE_H 3 4 #include "burp.h" 5 #include "conf.h" 6 7 struct asfd; 8 9 enum bf_mode 10 { 11 BF_CLOSED=0, 12 BF_READ, /* BackupRead */ 13 BF_WRITE /* BackupWrite */ 14 }; 15 16 struct mysid 17 { 18 struct bsid sid; 19 size_t needed_s; 20 size_t needed_d; 21 }; 22 23 struct BFILE 24 { 25 enum bf_mode mode; /* set if file is open */ 26 uint64_t winattr; /* needed for deciding to open with 27 encrypted functions or not */ 28 struct stat statp; 29 char *path; 30 struct cntr *cntr; 31 // Windows VSS headers tell us how much file data to expect. 32 // Protocol1 only for now. 33 size_t datalen; 34 #ifdef HAVE_WIN32 35 uint8_t use_backup_api; /* set if using BackupRead/Write */ 36 HANDLE fh; /* Win32 file handle */ 37 LPVOID lpContext; /* BackupRead/Write context */ 38 DWORD rw_bytes; /* Bytes read or written */ 39 DWORD lerror; /* Last error code */ 40 PVOID pvContext; /* also for the encrypted functions */ 41 int berrno; /* errno */ 42 #else 43 int fd; 44 #endif 45 struct mysid mysid; 46 int vss_strip; 47 int set_attribs_on_close; 48 49 // Let us try using function pointers. 50 int (*open)(struct BFILE *bfd, struct asfd *asfd, 51 const char *fname, int flags, mode_t mode); 52 int (*close)(struct BFILE *bfd, struct asfd *asfd); 53 ssize_t (*read)(struct BFILE *bfd, void *buf, size_t count); 54 ssize_t (*write)(struct BFILE *bfd, void *buf, size_t count); 55 int (*open_for_send)(struct BFILE *bfd, struct asfd *asfd, 56 const char *fname, int64_t winattr, 57 int atime, struct cntr *cntr, enum protocol protocol); 58 #ifdef HAVE_WIN32 59 void (*set_win32_api)(struct BFILE *bfd, int on); 60 #endif 61 void (*set_vss_strip)(struct BFILE *bfd, int on); 62 }; 63 64 extern struct BFILE *bfile_alloc(void); 65 extern void bfile_free(struct BFILE **bfd); 66 // FIX THIS: should be possible to have this as a function pointer too. 67 // Need to sort out the bfd in sbuf. 68 extern void bfile_init(struct BFILE *bfd, int64_t winattr, struct cntr *cntr); 69 extern void bfile_setup_funcs(struct BFILE *bfd); 70 71 #ifdef HAVE_WIN32 72 extern int have_win32_api(void); 73 #endif 74 75 #endif 76