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