]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/node.h
Fix license problems in Bug #2382
[bacula/bacula] / bacula / src / win32 / filed / plugins / node.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2018 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /* 
20  *  Written by James Harper, October 2008
21  */
22
23 #define NODE_TYPE_UNKNOWN          0
24 #define NODE_TYPE_ROOT        1
25 #define NODE_TYPE_SERVICE          2
26 #define NODE_TYPE_STORAGE_GROUP    3
27 #define NODE_TYPE_STORE       4
28 #define NODE_TYPE_DATABASE_INFO    5
29 #define NODE_TYPE_FILE        6
30
31 class node_t {
32 public:
33    int type;
34    int state;
35    node_t *parent;
36    char *name;
37    char *full_path;
38    size_t size;
39    int level;
40
41    node_t(char *name, int type);
42    node_t(char *name, int type, node_t *parent_node);
43    virtual ~node_t();
44
45    char *make_full_path();
46
47    virtual bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) = 0;
48    virtual bRC endBackupFile(exchange_fd_context_t *context) = 0;
49
50    virtual bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp) = 0;
51    virtual bRC endRestoreFile(exchange_fd_context_t *context) = 0;
52
53    virtual bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
54    virtual bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
55    virtual bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
56    virtual bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
57 };
58
59 class file_node_t : public node_t {
60 public:
61    WCHAR *filename;
62    HCCX hccx;
63    VOID *backup_file_handle;
64    VOID *restore_file_handle;
65    uint64_t section_size;
66    bool restore_at_file_level;
67
68    file_node_t(char *name, node_t *parent_node);
69    virtual ~file_node_t();
70    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
71    bRC endBackupFile(exchange_fd_context_t *context);
72
73    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
74    bRC endRestoreFile(exchange_fd_context_t *context);
75
76    bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
77    bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
78    bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
79    bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
80 };
81
82 class dbi_node_t : public node_t {
83 public:
84    DATABASE_BACKUP_INFO *dbi;
85    char *buffer;
86    uint32_t buffer_size;
87    uint32_t buffer_pos;
88    WCHAR *restore_display_name;
89    GUID restore_guid;
90    WCHAR *restore_input_streams;
91    WCHAR *restore_output_streams;
92
93    dbi_node_t(char *name, node_t *parent_node);
94    virtual ~dbi_node_t();
95    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
96    bRC endBackupFile(exchange_fd_context_t *context);
97
98    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
99    bRC endRestoreFile(exchange_fd_context_t *context);
100
101    bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io);
102    bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io);
103    bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io);
104    bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io);
105 };
106
107 class store_node_t : public node_t {
108 public:
109    HCCX hccx;
110    DATABASE_BACKUP_INFO *dbi;
111    WCHAR *stream_ptr;
112    file_node_t *file_node;
113    dbi_node_t *dbi_node;
114    WCHAR *out_stream_ptr;
115
116    store_node_t(char *name, node_t *parent_node);
117    virtual ~store_node_t();
118    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
119    bRC endBackupFile(exchange_fd_context_t *context);
120
121    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
122    bRC endRestoreFile(exchange_fd_context_t *context);
123 };
124
125 class storage_group_node_t : public node_t {
126 public:
127    HCCX hccx;
128    INSTANCE_BACKUP_INFO *ibi;
129    store_node_t *store_node;
130    file_node_t *file_node;
131    uint32_t current_dbi;
132    WCHAR *logfiles;
133    WCHAR *logfile_ptr;
134    RESTORE_ENVIRONMENT *restore_environment;
135    WCHAR *service_name;
136    WCHAR *storage_group_name;
137    WCHAR *saved_log_path;
138    storage_group_node_t *next;
139
140    storage_group_node_t(char *name, node_t *parent_node);
141    virtual ~storage_group_node_t();
142    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
143    bRC endBackupFile(exchange_fd_context_t *context);
144
145    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
146    bRC endRestoreFile(exchange_fd_context_t *context);
147 };
148
149 class service_node_t : public node_t {
150 public:
151    uint32_t ibi_count;
152    INSTANCE_BACKUP_INFO *ibi;
153    HCCX hccx;
154    uint32_t current_ibi;
155    storage_group_node_t *first_storage_group_node;
156
157    service_node_t(char *name, node_t *parent_node);
158    virtual ~service_node_t();
159    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
160    bRC endBackupFile(exchange_fd_context_t *context);
161
162    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
163    bRC endRestoreFile(exchange_fd_context_t *context);
164 };
165
166 class root_node_t : public node_t {
167 public:
168    service_node_t *service_node;
169
170    root_node_t(char *name);
171    virtual ~root_node_t();
172    bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp);
173    bRC endBackupFile(exchange_fd_context_t *context);
174
175    bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp);
176    bRC endRestoreFile(exchange_fd_context_t *context);
177 };