2 * Bacula low level File I/O routines. This routine simulates
3 * open(), read(), write(), and close(), but using native routines.
4 * I.e. on Windows, we use Windows APIs.
6 * Kern Sibbald May MMIII
9 Copyright (C) 2000-2003 Kern Sibbald and John Walker
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of
14 the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public
22 License along with this program; if not, write to the Free
23 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 #define BF_READ 1 /* BackupRead */
38 #define BF_WRITE 2 /* BackupWrite */
42 /* Basic low level I/O file packet */
43 typedef struct s_bfile {
45 int use_win_api; /* set if using WinAPI */
47 int use_backup_api; /* set if using BackupRead/Write */
48 int mode; /* set if file is open */
49 HANDLE fh; /* Win32 file handle */
50 int fid; /* fd if doing Unix style */
51 LPVOID lpContext; /* BackupRead/Write context */
52 POOLMEM *errmsg; /* error message buffer */
53 DWORD rw_bytes; /* Bytes read or written */
54 DWORD lerror; /* Last error code */
57 HANDLE bget_handle(BFILE *bfd);
59 #else /* Linux/Unix systems */
61 /* Basic low level I/O file packet */
62 typedef struct s_bfile {
63 int fid; /* file id on Unix */
69 void binit(BFILE *bfd);
70 int is_bopen(BFILE *bfd);
71 int set_win32_backup(BFILE *bfd, int enable);
72 int is_win32_backup();
73 int is_stream_supported(int stream);
74 char *berror(BFILE *bfd);
75 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
76 int bclose(BFILE *bfd);
77 ssize_t bread(BFILE *bfd, void *buf, size_t count);
78 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
79 off_t blseek(BFILE *bfd, off_t offset, int whence);
81 #endif /* __BFILE_H */