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 #ifdef USE_WIN32STREAMEXTRACTION
45 typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT {
46 LONGLONG liNextHeader;
48 WIN32_STREAM_ID header_stream;
49 } PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT;
52 /* =======================================================
56 * =======================================================
58 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
61 #include "../lib/winapi.h"
65 BF_READ, /* BackupRead */
66 BF_WRITE /* BackupWrite */
71 /* Basic Win32 low level I/O file packet */
73 int use_backup_api; /* set if using BackupRead/Write */
74 int mode; /* set if file is open */
75 HANDLE fh; /* Win32 file handle */
76 int fid; /* fd if doing Unix style */
77 LPVOID lpContext; /* BackupRead/Write context */
78 POOLMEM *errmsg; /* error message buffer */
79 DWORD rw_bytes; /* Bytes read or written */
80 DWORD lerror; /* Last error code */
81 int berrno; /* errno */
82 char *prog; /* reader/writer program if any */
83 JCR *jcr; /* jcr for editing job codes */
84 Python_IO pio; /* Python I/O routines */
85 #ifdef USE_WIN32STREAMEXTRACTION
86 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
87 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
91 HANDLE bget_handle(BFILE *bfd);
93 #else /* Linux/Unix systems */
95 /* =======================================================
99 * =======================================================
102 /* Basic Unix low level I/O file packet */
104 int fid; /* file id on Unix */
106 char *prog; /* reader/writer program if any */
107 JCR *jcr; /* jcr for editing job codes */
108 Python_IO pio; /* Python I/O routines */
109 #ifdef USE_WIN32STREAMEXTRACTION
110 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
111 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
117 void binit(BFILE *bfd);
118 bool is_bopen(BFILE *bfd);
119 bool set_win32_backup(BFILE *bfd);
120 bool set_portable_backup(BFILE *bfd);
121 bool set_prog(BFILE *bfd, char *prog, JCR *jcr);
122 bool have_win32_api();
123 bool is_portable_backup(BFILE *bfd);
124 bool is_stream_supported(int stream);
125 bool is_win32_stream(int stream);
126 char *xberror(BFILE *bfd); /* DO NOT USE -- use berrno class */
127 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
128 #ifdef HAVE_DARWIN_OS
129 int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode);
131 int bclose(BFILE *bfd);
132 ssize_t bread(BFILE *bfd, void *buf, size_t count);
133 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
134 off_t blseek(BFILE *bfd, off_t offset, int whence);
135 const char *stream_to_ascii(int stream);
137 #ifdef USE_WIN32STREAMEXTRACTION
138 BOOL processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, size_t dwSize);
141 #endif /* __BFILE_H */