]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/parse_conf.h
kes Add code in catreq.c to reject volumes not marked Enabled.
[bacula/bacula] / bacula / src / lib / parse_conf.h
1 /*
2  *   Version $Id$
3  */
4 /*
5    Bacula® - The Network Backup Solution
6
7    Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
8
9    The main author of Bacula is Kern Sibbald, with contributions from
10    many others, a complete list can be found in the file AUTHORS.
11    This program is Free Software; you can redistribute it and/or
12    modify it under the terms of version two of the GNU General Public
13    License as published by the Free Software Foundation plus additions
14    that are listed in the file LICENSE.
15
16    This program is distributed in the hope that it will be useful, but
17    WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24    02110-1301, USA.
25
26    Bacula® is a registered trademark of John Walker.
27    The licensor of Bacula is the Free Software Foundation Europe
28    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
29    Switzerland, email:ftf@fsfeurope.org.
30 */
31
32 struct RES_ITEM;                    /* Declare forward referenced structure */
33 struct RES;                         /* Declare forware referenced structure */
34 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
35
36 /* This is the structure that defines
37  * the record types (items) permitted within each
38  * resource. It is used to define the configuration
39  * tables.
40  */
41 struct RES_ITEM {
42    const char *name;                  /* Resource name i.e. Director, ... */
43    MSG_RES_HANDLER *handler;          /* Routine storing the resource item */
44    union {
45       char **value;                   /* Where to store the item */
46       char **charvalue;
47       uint32_t ui32value;
48       int32_t i32value;
49       uint64_t ui64value;
50       int64_t i64value;
51       bool boolvalue;
52       utime_t utimevalue;
53       RES *resvalue;
54       RES **presvalue;
55    };
56    int  code;                         /* item code/additional info */
57    int  flags;                        /* flags: default, required, ... */
58    int  default_value;                /* default value */
59 };
60
61 /* For storing name_addr items in res_items table */
62 #define ITEM(x) {(char **)&res_all.x}
63
64 #define MAX_RES_ITEMS 70              /* maximum resource items per RES */
65
66 /* This is the universal header that is
67  * at the beginning of every resource
68  * record.
69  */
70 class RES {
71 public:
72    RES *next;                         /* pointer to next resource of this type */
73    char *name;                        /* resource name */
74    char *desc;                        /* resource description */
75    int   rcode;                       /* resource id or type */
76    int   refcnt;                      /* reference count for releasing */
77    char  item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
78 };
79
80
81 /*
82  * Master Resource configuration structure definition
83  * This is the structure that defines the
84  * resources that are available to this daemon.
85  */
86 struct RES_TABLE {
87    const char *name;                  /* resource name */
88    RES_ITEM *items;                   /* list of resource keywords */
89    int rcode;                         /* code if needed */
90 };
91
92 /* Common Resource definitions */
93
94 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
95
96 #define ITEM_REQUIRED    0x1          /* item required */
97 #define ITEM_DEFAULT     0x2          /* default supplied */
98 #define ITEM_NO_EQUALS   0x4          /* Don't scan = after name */
99
100 /* Message Resource */
101 class MSGS {
102 public:
103    RES   hdr;
104    char *mail_cmd;                    /* mail command */
105    char *operator_cmd;                /* Operator command */
106    DEST *dest_chain;                  /* chain of destinations */
107    char send_msg[nbytes_for_bits(M_MAX+1)];  /* bit array of types */
108
109    /* Methods */
110    char *name() const;
111 };
112
113 inline char *MSGS::name() const { return hdr.name; }
114
115
116 /* Define the Union of all the above common
117  * resource structure definitions.
118  */
119 union CURES {
120    MSGS  res_msgs;
121    RES hdr;
122 };
123
124
125 /* Configuration routines */
126 int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
127 void    free_config_resources(void);
128 RES   **save_config_resources(void);
129 RES   **new_res_head();
130
131
132 /* Resource routines */
133 RES *GetResWithName(int rcode, char *name);
134 RES *GetNextRes(int rcode, RES *res);
135 void b_LockRes(const char *file, int line);
136 void b_UnlockRes(const char *file, int line);
137 void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
138 void free_resource(RES *res, int type);
139 void init_resource(int type, RES_ITEM *item);
140 void save_resource(int type, RES_ITEM *item, int pass);
141 const char *res_to_str(int rcode);
142
143 /* Loop through each resource of type, returning in var */
144 #ifdef HAVE_TYPEOF
145 #define foreach_res(var, type) \
146         for((var)=NULL; ((var)=(typeof(var))GetNextRes((type), (RES *)var));)
147 #else 
148 #define foreach_res(var, type) \
149     for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
150 #endif
151
152
153
154 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
155 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
156 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
157 void store_name(LEX *lc, RES_ITEM *item, int index, int pass);
158 void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
159 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
160 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass);
161 void store_alist_str(LEX *lc, RES_ITEM *item, int index, int pass);
162 void store_int(LEX *lc, RES_ITEM *item, int index, int pass);
163 void store_pint(LEX *lc, RES_ITEM *item, int index, int pass);
164 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
165 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
166 void store_bit(LEX *lc, RES_ITEM *item, int index, int pass);
167 void store_bool(LEX *lc, RES_ITEM *item, int index, int pass);
168 void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
169 void store_size(LEX *lc, RES_ITEM *item, int index, int pass);
170 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
171 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);