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-2005 Kern Sibbald
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,
32 #undef _POSIX_C_SOURCE
44 /* =======================================================
48 * =======================================================
50 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
53 #include "../lib/winapi.h"
57 BF_READ, /* BackupRead */
58 BF_WRITE /* BackupWrite */
63 /* Basic Win32 low level I/O file packet */
65 int use_backup_api; /* set if using BackupRead/Write */
66 int mode; /* set if file is open */
67 HANDLE fh; /* Win32 file handle */
68 int fid; /* fd if doing Unix style */
69 LPVOID lpContext; /* BackupRead/Write context */
70 POOLMEM *errmsg; /* error message buffer */
71 DWORD rw_bytes; /* Bytes read or written */
72 DWORD lerror; /* Last error code */
73 int berrno; /* errno */
74 char *prog; /* reader/writer program if any */
75 JCR *jcr; /* jcr for editing job codes */
76 Python_IO pio; /* Python I/O routines */
79 HANDLE bget_handle(BFILE *bfd);
81 #else /* Linux/Unix systems */
83 /* =======================================================
87 * =======================================================
90 /* Basic Unix low level I/O file packet */
92 int fid; /* file id on Unix */
94 char *prog; /* reader/writer program if any */
95 JCR *jcr; /* jcr for editing job codes */
96 Python_IO pio; /* Python I/O routines */
101 void binit(BFILE *bfd);
102 bool is_bopen(BFILE *bfd);
103 bool set_win32_backup(BFILE *bfd);
104 bool set_portable_backup(BFILE *bfd);
105 bool set_prog(BFILE *bfd, char *prog, JCR *jcr);
106 bool have_win32_api();
107 bool is_portable_backup(BFILE *bfd);
108 bool is_stream_supported(int stream);
109 bool is_win32_stream(int stream);
110 char *xberror(BFILE *bfd); /* DO NOT USE -- use berrno class */
111 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
112 #ifdef HAVE_DARWIN_OS
113 int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode);
115 int bclose(BFILE *bfd);
116 ssize_t bread(BFILE *bfd, void *buf, size_t count);
117 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
118 off_t blseek(BFILE *bfd, off_t offset, int whence);
119 const char *stream_to_ascii(int stream);
121 #endif /* __BFILE_H */