]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/bfile.h
Add jcr to timer packets so if killed message can be sent to job.
[bacula/bacula] / bacula / src / findlib / bfile.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  *  Bacula low level File I/O routines.  This routine simulates
30  *    open(), read(), write(), and close(), but using native routines.
31  *    I.e. on Windows, we use Windows APIs.
32  *
33  *     Kern Sibbald May MMIII
34  */
35
36 #ifndef __BFILE_H
37 #define __BFILE_H
38
39 #ifdef HAVE_PYTHON
40 #undef _POSIX_C_SOURCE
41 #include <Python.h>
42 struct Python_IO {
43    PyObject *fo;
44    PyObject *fr;
45    PyObject *fc;
46 };
47 #else
48 struct Python_IO {
49 };
50 #endif
51
52
53 /* this should physically correspond to WIN32_STREAM_ID
54  * from winbase.h on Win32. We didn't inlcude cStreamName
55  * as we don't use it and don't need it for a correct struct size.
56  */
57
58 #define WIN32_BACKUP_DATA 1
59
60 typedef struct _BWIN32_STREAM_ID {
61         int32_t        dwStreamId;
62         int32_t        dwStreamAttributes;
63         int64_t        Size;
64         int32_t        dwStreamNameSize;        
65 } BWIN32_STREAM_ID, *LPBWIN32_STREAM_ID ;
66
67
68 typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT {
69         int64_t          liNextHeader;
70         bool             bIsInData;
71         BWIN32_STREAM_ID header_stream;        
72 } PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT;
73
74 /*  =======================================================
75  *
76  *   W I N D O W S
77  *
78  *  =======================================================
79  */
80 #if defined(HAVE_WIN32)
81
82 enum {
83    BF_CLOSED,
84    BF_READ,                           /* BackupRead */
85    BF_WRITE                           /* BackupWrite */
86 };
87
88 /* In bfile.c */
89
90 /* Basic Win32 low level I/O file packet */
91 struct BFILE {
92    bool use_backup_api;               /* set if using BackupRead/Write */
93    int mode;                          /* set if file is open */
94    HANDLE fh;                         /* Win32 file handle */
95    int fid;                           /* fd if doing Unix style */
96    LPVOID lpContext;                  /* BackupRead/Write context */
97    POOLMEM *errmsg;                   /* error message buffer */
98    DWORD rw_bytes;                    /* Bytes read or written */
99    DWORD lerror;                      /* Last error code */
100    int berrno;                        /* errno */
101    char *prog;                        /* reader/writer program if any */
102    JCR *jcr;                          /* jcr for editing job codes */
103    Python_IO pio;                     /* Python I/O routines */
104    PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
105    int use_backup_decomp;             /* set if using BackupRead Stream Decomposition */
106    bool reparse_point;                /* set if reparse point */ 
107 };
108
109 HANDLE bget_handle(BFILE *bfd);
110
111 #else   /* Linux/Unix systems */
112
113 /*  =======================================================
114  *
115  *   U N I X
116  *
117  *  =======================================================
118  */
119
120 /* Basic Unix low level I/O file packet */
121 struct BFILE {
122    int fid;                           /* file id on Unix */
123    int m_flags;                       /* open flags */
124    int berrno;
125    char *prog;                        /* reader/writer program if any */
126    JCR *jcr;                          /* jcr for editing job codes */
127    Python_IO pio;                     /* Python I/O routines */
128    PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
129    int use_backup_decomp;             /* set if using BackupRead Stream Decomposition */
130    bool reparse_point;                /* not used in Unix */
131 };
132
133 #endif
134
135 void    binit(BFILE *bfd);
136 bool    is_bopen(BFILE *bfd);
137 bool    set_win32_backup(BFILE *bfd);
138 bool    set_portable_backup(BFILE *bfd);
139 bool    set_prog(BFILE *bfd, char *prog, JCR *jcr);
140 bool    have_win32_api();
141 bool    is_portable_backup(BFILE *bfd);
142 bool    is_restore_stream_supported(int stream);
143 bool    is_win32_stream(int stream);
144 char   *xberror(BFILE *bfd);          /* DO NOT USE  -- use berrno class */
145 int     bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
146 #ifdef HAVE_DARWIN_OS
147 int     bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode);
148 #endif
149 int     bclose(BFILE *bfd);
150 ssize_t bread(BFILE *bfd, void *buf, size_t count);
151 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
152 boffset_t blseek(BFILE *bfd, boffset_t offset, int whence);
153 const char   *stream_to_ascii(int stream);
154
155 bool processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, ssize_t dwSize);
156
157 #endif /* __BFILE_H */