]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/bfile.h
Use rentrant mysql lib, eliminate race in sql_list, Win32 streams, misc see kes-1.31
[bacula/bacula] / bacula / src / findlib / bfile.h
1 /*
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.
5  *
6  *     Kern Sibbald May MMIII
7  */
8 /*
9    Copyright (C) 2000-2003 Kern Sibbald and John Walker
10
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.
15
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.
20
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,
24    MA 02111-1307, USA.
25
26  */
27
28 #ifndef __BFILE_H
29 #define __BFILE_H
30
31 #ifdef HAVE_CYGWIN
32
33 #include <windows.h>
34 #include "winapi.h"
35
36 #define BF_CLOSED 0
37 #define BF_READ   1                   /* BackupRead */
38 #define BF_WRITE  2                   /* BackupWrite */
39
40 /* In bfile.c */
41
42 /* Basic low level I/O file packet */
43 typedef struct s_bfile {
44    int use_win_api;                   /* set if using WinAPI */
45    int use_backup_api;                /* set if using BackupRead/Write */
46    int mode;                          /* set if file is open */
47    HANDLE fh;                         /* Win32 file handle */
48    int fid;                           /* fd if doing Unix style */
49    LPVOID lpContext;                  /* BackupRead/Write context */
50    POOLMEM *errmsg;                   /* error message buffer */
51    DWORD rw_bytes;                    /* Bytes read or written */
52    DWORD lerror;                      /* Last error code */
53 } BFILE;
54
55 HANDLE bget_handle(BFILE *bfd);
56
57 #else   /* Linux/Unix systems */
58
59 /* Basic low level I/O file packet */
60 typedef struct s_bfile {
61    int fid;                           /* file id on Unix */
62    int berrno;
63 } BFILE;
64
65 #endif
66
67 void binit(BFILE *bfd);
68 int is_bopen(BFILE *bfd);
69 int is_win32_data(BFILE *bfd);
70 char *berror(BFILE *bfd);
71 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
72 int bclose(BFILE *bfd);
73 ssize_t bread(BFILE *bfd, void *buf, size_t count);
74 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
75 off_t blseek(BFILE *bfd, off_t offset, int whence);
76
77 #endif /* __BFILE_H */