]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/parse_conf.h
Replace explicit checks for "/" with calls to IsPathSeparator, strchr with first_path...
[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 struct RES {
71    RES *next;                         /* pointer to next resource of this type */
72    char *name;                        /* resource name */
73    char *desc;                        /* resource description */
74    int   rcode;                       /* resource id or type */
75    int   refcnt;                      /* reference count for releasing */
76    char  item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
77 };
78
79
80 /*
81  * Master Resource configuration structure definition
82  * This is the structure that defines the
83  * resources that are available to this daemon.
84  */
85 struct RES_TABLE {
86    const char *name;                  /* resource name */
87    RES_ITEM *items;                   /* list of resource keywords */
88    int rcode;                         /* code if needed */
89 };
90
91 /* Common Resource definitions */
92
93 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
94
95 #define ITEM_REQUIRED    0x1          /* item required */
96 #define ITEM_DEFAULT     0x2          /* default supplied */
97 #define ITEM_NO_EQUALS   0x4          /* Don't scan = after name */
98
99 /* Message Resource */
100 struct MSGS {
101    RES   hdr;
102    char *mail_cmd;                    /* mail command */
103    char *operator_cmd;                /* Operator command */
104    DEST *dest_chain;                  /* chain of destinations */
105    char send_msg[nbytes_for_bits(M_MAX+1)];  /* bit array of types */
106 };
107
108
109 /* Define the Union of all the above common
110  * resource structure definitions.
111  */
112 union CURES {
113    MSGS  res_msgs;
114    RES hdr;
115 };
116
117
118 /* Configuration routines */
119 int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
120 void    free_config_resources(void);
121 RES   **save_config_resources(void);
122 RES   **new_res_head();
123
124
125 /* Resource routines */
126 RES *GetResWithName(int rcode, char *name);
127 RES *GetNextRes(int rcode, RES *res);
128 void b_LockRes(const char *file, int line);
129 void b_UnlockRes(const char *file, int line);
130 void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
131 void free_resource(RES *res, int type);
132 void init_resource(int type, RES_ITEM *item);
133 void save_resource(int type, RES_ITEM *item, int pass);
134 const char *res_to_str(int rcode);
135
136 /* Loop through each resource of type, returning in var */
137 #ifdef HAVE_TYPEOF
138 #define foreach_res(var, type) \
139         for((var)=NULL; ((var)=(typeof(var))GetNextRes((type), (RES *)var));)
140 #else 
141 #define foreach_res(var, type) \
142     for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
143 #endif
144
145
146
147 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
148 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
149 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
150 void store_name(LEX *lc, RES_ITEM *item, int index, int pass);
151 void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
152 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
153 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass);
154 void store_alist_str(LEX *lc, RES_ITEM *item, int index, int pass);
155 void store_int(LEX *lc, RES_ITEM *item, int index, int pass);
156 void store_pint(LEX *lc, RES_ITEM *item, int index, int pass);
157 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
158 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
159 void store_bit(LEX *lc, RES_ITEM *item, int index, int pass);
160 void store_bool(LEX *lc, RES_ITEM *item, int index, int pass);
161 void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
162 void store_size(LEX *lc, RES_ITEM *item, int index, int pass);
163 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
164 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);