]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/exchange-fd.h
Attempt to disactivate old exchange-fd.dll if no plugin= line in FileSet
[bacula/bacula] / bacula / src / win32 / filed / plugins / exchange-fd.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2010-2011 Bacula Systems(R) SA
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 #ifndef _EXCHANGE_FD_H
33 #define _EXCHANGE_FD_H
34
35 #define BUILD_PLUGIN
36
37 #if defined(BUILDING_DLL)
38 #  define DLL_IMP_EXP   __declspec(dllexport)
39 #elif defined(USING_DLL)
40 #  define DLL_IMP_EXP   __declspec(dllimport)
41 #else
42 #  define DLL_IMP_EXP
43 #endif
44
45 #if defined(HAVE_WIN32)
46 #if defined(HAVE_MINGW)
47 #include "mingwconfig.h"
48 #else
49 #include "winconfig.h"
50 #endif
51 #else
52 #include "config.h"
53 #endif
54 #define __CONFIG_H
55
56 enum {
57    /* Keep M_ABORT=1 for dlist.h */
58    M_ABORT = 1,                       /* MUST abort immediately */
59    M_DEBUG,                           /* debug message */
60    M_FATAL,                           /* Fatal error, stopping job */
61    M_ERROR,                           /* Error, but recoverable */
62    M_WARNING,                         /* Warning message */
63    M_INFO,                            /* Informational message */
64    M_SAVED,                           /* Info on saved file */
65    M_NOTSAVED,                        /* Info on notsaved file */
66    M_SKIPPED,                         /* File skipped during backup by option setting */
67    M_MOUNT,                           /* Mount requests */
68    M_ERROR_TERM,                      /* Error termination request (no dump) */
69    M_TERM,                            /* Terminating daemon normally */
70    M_RESTORED,                        /* ls -l of restored files */
71    M_SECURITY,                        /* security violation */
72    M_ALERT,                           /* tape alert messages */
73    M_VOLMGMT                          /* Volume management messages */
74 };
75
76 #define FT_REG        3
77 #define FT_DIREND     5
78
79 #define _REENTRANT    1
80 #define _THREAD_SAFE  1
81 #define _POSIX_PTHREAD_SEMANTICS 1
82
83 #include <stdint.h>
84
85 #include <stdio.h>
86 #include <stdlib.h>
87 #include <time.h>
88 #include <sys/types.h>
89 #ifdef HAVE_SYS_BITYPES_H
90 #include <sys/bitypes.h>
91 #endif
92
93 //#include "bacula.h"
94 #include <windows.h>
95 #include "win32/compat/compat.h"
96 #include "bc_types.h"
97
98 typedef int64_t   boffset_t;
99 //#define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
100 #define bstrdup(str) strdup(str)
101
102 #include "fd_plugins.h"
103 #include "api.h"
104
105 #if defined(HAVE_WIN32)
106 #include "win32/winapi.h"
107 #include "winhost.h"
108 #else
109 #include "host.h"
110 #endif
111
112 #define EXCHANGE_PLUGIN_VERSION 1
113
114 #define JOB_TYPE_BACKUP 1
115 #define JOB_TYPE_RESTORE 2
116
117 #define JOB_LEVEL_FULL ((int)'F')
118 #define JOB_LEVEL_INCREMENTAL ((int)'I')
119 #define JOB_LEVEL_DIFFERENTIAL ((int)'D')
120
121 struct exchange_fd_context_t;
122
123 #include "node.h"
124
125 struct exchange_fd_context_t {
126    struct bpContext *bpContext;
127    WCHAR *computer_name;
128    char *path_bits[6];
129    root_node_t *root_node;
130    node_t *current_node;
131    int job_type;
132    int job_level;
133    time_t job_since;
134    bool notrunconfull_option;
135    bool truncate_logs;
136    bool accurate;
137    bool plugin_active;
138 };
139
140 static inline char *tocharstring(WCHAR *src)
141 {
142    char *tmp = new char[wcslen(src) + 1];
143    wcstombs(tmp, src, wcslen(src) + 1);
144    return tmp;
145 }
146
147 static inline WCHAR *towcharstring(char *src)
148 {
149    WCHAR *tmp = new WCHAR[strlen(src) + 1];
150    mbstowcs(tmp, src, strlen(src) + 1);
151    return tmp;
152 }
153
154
155 extern bFuncs *bfuncs;
156 extern bInfo  *binfo;
157
158 #define _DebugMessage(level, message, ...) bfuncs->DebugMessage(context->bpContext, __FILE__, __LINE__, level, message, ##__VA_ARGS__)
159 #define _JobMessage(type, message, ...) bfuncs->JobMessage(context->bpContext, __FILE__, __LINE__, type, 0, message, ##__VA_ARGS__)
160 #define _JobMessageNull(type, message, ...) bfuncs->JobMessage(NULL, __FILE__, __LINE__, type, 0, message, ##__VA_ARGS__)
161
162 #define PLUGIN_PATH_PREFIX_BASE "@EXCHANGE"
163 #define PLUGIN_PATH_PREFIX_SERVICE "Microsoft Information Store"
164 #define PLUGIN_PATH_PREFIX_SERVICE_W L"Microsoft Information Store"
165
166 #endif /* _EXCHANGE_FD_H */