]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/node.h
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / win32 / filed / plugins / node.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2008-2008 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 three of the GNU Affero General Public
10    License as published by the Free Software Foundation, which is 
11    listed 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 Affero 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 Kern Sibbald.
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  *  Written by James Harper, October 2008
30  */
31
32 #define NODE_TYPE_UNKNOWN          0
33 #define NODE_TYPE_ROOT        1
34 #define NODE_TYPE_SERVICE          2
35 #define NODE_TYPE_STORAGE_GROUP    3
36 #define NODE_TYPE_STORE       4
37 #define NODE_TYPE_DATABASE_INFO    5
38 #define NODE_TYPE_FILE        6
39
40 class node_t {
41 public:
42    int type;
43    int state;
44    node_t *parent;
45    char *name;
46    char *full_path;
47    size_t size;
48    int level;
49
50    node_t(char *name, int type);
51    node_t(char *name, int type, node_t *parent_node);
52    virtual ~node_t();
53
54    char *make_full_path();
55
56    virtual bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) = 0;
57    virtual bRC endBackupFile(exchange_fd_context_t *context) = 0;
58
59    virtual bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp) = 0;
60    virtual bRC endRestoreFile(exchange_fd_context_t *context) = 0;
61
62    virtual bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
63    virtual bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
64    virtual bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
65    virtual bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
66 };
67
68 class file_node_t : public node_t {
69 public:
70    WCHAR *filename;
71    HCCX hccx;
72    VOID *backup_file_handle;
73    VOID *restore_file_handle;
74    uint64_t section_size;
75    bool restore_at_file_level;
76
77    file_node_t(char *name, node_t *parent_node);
78    virtual ~file_node_t();
79    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
80    bRC endBackupFile(exchange_fd_context_t *context);
81
82    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
83    bRC endRestoreFile(exchange_fd_context_t *context);
84
85    bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
86    bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
87    bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
88    bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
89 };
90
91 class dbi_node_t : public node_t {
92 public:
93    DATABASE_BACKUP_INFO *dbi;
94    char *buffer;
95    uint32_t buffer_size;
96    uint32_t buffer_pos;
97    WCHAR *restore_display_name;
98    GUID restore_guid;
99    WCHAR *restore_input_streams;
100    WCHAR *restore_output_streams;
101
102    dbi_node_t(char *name, node_t *parent_node);
103    virtual ~dbi_node_t();
104    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
105    bRC endBackupFile(exchange_fd_context_t *context);
106
107    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
108    bRC endRestoreFile(exchange_fd_context_t *context);
109
110    bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
111    bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
112    bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
113    bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
114 };
115
116 class store_node_t : public node_t {
117 public:
118    HCCX hccx;
119    DATABASE_BACKUP_INFO *dbi;
120    WCHAR *stream_ptr;
121    file_node_t *file_node;
122    dbi_node_t *dbi_node;
123    WCHAR *out_stream_ptr;
124
125    store_node_t(char *name, node_t *parent_node);
126    virtual ~store_node_t();
127    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
128    bRC endBackupFile(exchange_fd_context_t *context);
129
130    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
131    bRC endRestoreFile(exchange_fd_context_t *context);
132 };
133
134 class storage_group_node_t : public node_t {
135 public:
136    HCCX hccx;
137    INSTANCE_BACKUP_INFO *ibi;
138    store_node_t *store_node;
139    file_node_t *file_node;
140    uint32_t current_dbi;
141    WCHAR *logfiles;
142    WCHAR *logfile_ptr;
143    RESTORE_ENVIRONMENT *restore_environment;
144    WCHAR *service_name;
145    WCHAR *storage_group_name;
146    WCHAR *saved_log_path;
147    storage_group_node_t *next;
148
149    storage_group_node_t(char *name, node_t *parent_node);
150    virtual ~storage_group_node_t();
151    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
152    bRC endBackupFile(exchange_fd_context_t *context);
153
154    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
155    bRC endRestoreFile(exchange_fd_context_t *context);
156 };
157
158 class service_node_t : public node_t {
159 public:
160    uint32_t ibi_count;
161    INSTANCE_BACKUP_INFO *ibi;
162    HCCX hccx;
163    uint32_t current_ibi;
164    storage_group_node_t *first_storage_group_node;
165
166    service_node_t(char *name, node_t *parent_node);
167    virtual ~service_node_t();
168    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
169    bRC endBackupFile(exchange_fd_context_t *context);
170
171    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
172    bRC endRestoreFile(exchange_fd_context_t *context);
173 };
174
175 class root_node_t : public node_t {
176 public:
177    service_node_t *service_node;
178
179    root_node_t(char *name);
180    virtual ~root_node_t();
181    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
182    bRC endBackupFile(exchange_fd_context_t *context);
183
184    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
185    bRC endRestoreFile(exchange_fd_context_t *context);
186 };