2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
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
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.
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
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.
30 * Kern Sibbald, January MM
34 struct RES_ITEM; /* Declare forward referenced structure */
35 struct RES_ITEM2; /* Declare forward referenced structure */
36 class RES; /* Declare forware referenced structure */
37 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
38 typedef void (INC_RES_HANDLER)(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude);
42 /* This is the structure that defines
43 * the record types (items) permitted within each
44 * resource. It is used to define the configuration
48 const char *name; /* Resource name i.e. Director, ... */
49 MSG_RES_HANDLER *handler; /* Routine storing the resource item */
51 char **value; /* Where to store the item */
62 int32_t code; /* item code/additional info */
63 uint32_t flags; /* flags: default, required, ... */
64 int32_t default_value; /* default value */
68 const char *name; /* Resource name i.e. Director, ... */
69 INC_RES_HANDLER *handler; /* Routine storing the resource item */
71 char **value; /* Where to store the item */
82 int32_t code; /* item code/additional info */
83 uint32_t flags; /* flags: default, required, ... */
84 int32_t default_value; /* default value */
88 /* For storing name_addr items in res_items table */
89 #define ITEM(x) {(char **)&res_all.x}
91 #define MAX_RES_ITEMS 80 /* maximum resource items per RES */
93 /* This is the universal header that is
94 * at the beginning of every resource
99 RES *next; /* pointer to next resource of this type */
100 char *name; /* resource name */
101 char *desc; /* resource description */
102 uint32_t rcode; /* resource id or type */
103 int32_t refcnt; /* reference count for releasing */
104 char item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
109 * Master Resource configuration structure definition
110 * This is the structure that defines the
111 * resources that are available to this daemon.
114 const char *name; /* resource name */
115 RES_ITEM *items; /* list of resource keywords */
116 uint32_t rcode; /* code if needed */
121 /* Common Resource definitions */
123 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */
125 #define ITEM_REQUIRED 0x1 /* item required */
126 #define ITEM_DEFAULT 0x2 /* default supplied */
127 #define ITEM_NO_EQUALS 0x4 /* Don't scan = after name */
129 /* Message Resource */
133 char *mail_cmd; /* mail command */
134 char *operator_cmd; /* Operator command */
135 DEST *dest_chain; /* chain of destinations */
136 char send_msg[nbytes_for_bits(M_MAX+1)]; /* bit array of types */
139 bool m_in_use; /* set when using to send a message */
140 bool m_closing; /* set when closing message resource */
145 void clear_in_use() { lock(); m_in_use=false; unlock(); }
146 void set_in_use() { wait_not_in_use(); m_in_use=true; unlock(); }
147 void set_closing() { m_closing=true; }
148 void clear_closing() { lock(); m_closing=false; unlock(); }
149 bool is_closing() { lock(); bool rtn=m_closing; unlock(); return rtn; }
151 void wait_not_in_use(); /* in message.c */
152 void lock(); /* in message.c */
153 void unlock(); /* in message.c */
156 inline char *MSGS::name() const { return hdr.name; }
159 * Old C style configuration routines -- deprecated do not use.
161 //int parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
162 void free_config_resources(void);
163 RES **save_config_resources(void);
164 RES **new_res_head();
167 * New C++ configuration routines
172 const char *m_cf; /* config file */
173 LEX_ERROR_HANDLER *m_scan_error; /* error handler if non-null */
174 int32_t m_err_type; /* the way to terminate on failure */
175 void *m_res_all; /* pointer to res_all buffer */
176 int32_t m_res_all_size; /* length of buffer */
178 /* The below are not yet implemented */
179 int32_t m_r_first; /* first daemon resource type */
180 int32_t m_r_last; /* last daemon resource type */
181 RES_TABLE *m_resources; /* pointer to table of permitted resources */
182 RES **m_res_head; /* pointer to defined resources */
183 brwlock_t m_res_lock; /* resource lock */
188 LEX_ERROR_HANDLER *scan_error,
191 int32_t res_all_size,
194 RES_TABLE *resources,
198 void free_resources();
199 RES **save_resources();
200 RES **new_res_head();
203 CONFIG *new_config_parser();
206 /* Resource routines */
207 RES *GetResWithName(int rcode, const char *name);
208 RES *GetNextRes(int rcode, RES *res);
209 void b_LockRes(const char *file, int line);
210 void b_UnlockRes(const char *file, int line);
211 void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
212 void free_resource(RES *res, int type);
213 void init_resource(int type, RES_ITEM *item);
214 void save_resource(int type, RES_ITEM *item, int pass);
215 const char *res_to_str(int rcode);
217 /* Loop through each resource of type, returning in var */
219 #define foreach_res(var, type) \
220 for((var)=NULL; ((var)=(typeof(var))GetNextRes((type), (RES *)var));)
222 #define foreach_res(var, type) \
223 for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
228 * Standard global parsers defined in parse_config.c
230 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
231 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
232 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
233 void store_name(LEX *lc, RES_ITEM *item, int index, int pass);
234 void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
235 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
236 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass);
237 void store_alist_str(LEX *lc, RES_ITEM *item, int index, int pass);
238 void store_int32(LEX *lc, RES_ITEM *item, int index, int pass);
239 void store_pint32(LEX *lc, RES_ITEM *item, int index, int pass);
240 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
241 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
242 void store_bit(LEX *lc, RES_ITEM *item, int index, int pass);
243 void store_bool(LEX *lc, RES_ITEM *item, int index, int pass);
244 void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
245 void store_size64(LEX *lc, RES_ITEM *item, int index, int pass);
246 void store_size32(LEX *lc, RES_ITEM *item, int index, int pass);
247 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
248 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);
250 /* ***FIXME*** eliminate these globals */
251 extern int32_t r_first;
252 extern int32_t r_last;
253 extern RES_TABLE resources[];
254 extern RES **res_head;
255 extern int32_t res_all_size;