]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/parse_conf.h
78c1beba24ddc6db1f105606a98a94394ae3e021
[bacula/bacula] / bacula / src / lib / parse_conf.h
1 /*
2  *   Version $Id$
3  */
4 /*
5    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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 as
9    published by the Free Software Foundation; either version 2 of
10    the License, or (at your option) any later version.
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 GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU General Public
18    License along with this program; if not, write to the Free
19    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20    MA 02111-1307, USA.
21
22  */
23
24 struct res_items;                   /* Declare forward referenced structure */ 
25 typedef void (MSG_RES_HANDLER)(LEX *lc, struct res_items *item, int index, int pass);
26
27 /* This is the structure that defines
28  * the record types (items) permitted within each
29  * resource. It is used to define the configuration
30  * tables.
31  */
32 struct res_items {
33    char *name;                        /* Resource name i.e. Director, ... */
34    MSG_RES_HANDLER *handler;          /* Routine storing the resource item */
35    void **value;                      /* Where to store the item */
36    int  code;                         /* item code/additional info */
37    int  flags;                        /* flags: default, required, ... */
38    int  default_value;                /* default value */
39 };
40
41 /* For storing name_addr items in res_items table */
42 #define ITEM(x) ((void **)&res_all.x)
43
44 #define MAX_RES_ITEMS 50              /* maximum resource items per RES */
45
46 /* This is the universal header that is
47  * at the beginning of every resource
48  * record.
49  */
50 struct RES {
51    RES *next;                         /* pointer to next resource of this type */
52    char *name;                        /* resource name */
53    char *desc;                        /* resource description */
54    int   rcode;                       /* resource id or type */
55    int   refcnt;                      /* reference count for releasing */
56    char  item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
57 };
58
59
60 /* 
61  * Master Resource configuration structure definition
62  * This is the structure that defines the
63  * resources that are available to this daemon.
64  */
65 struct s_res {       
66    char *name;                        /* resource name */
67    struct res_items *items;           /* list of resource keywords */
68    int rcode;                         /* code if needed */
69    RES *res_head;                     /* where to store it */
70 };
71
72 /* Common Resource definitions */
73
74 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
75
76 #define ITEM_REQUIRED    0x1          /* item required */
77 #define ITEM_DEFAULT     0x2          /* default supplied */
78 #define ITEM_NO_EQUALS   0x4          /* Don't scan = after name */
79
80 /* Message Resource */
81 struct MSGS {
82    RES   hdr;
83    char *mail_cmd;                    /* mail command */
84    char *operator_cmd;                /* Operator command */
85    DEST *dest_chain;                  /* chain of destinations */
86    char send_msg[nbytes_for_bits(M_MAX+1)];  /* bit array of types */
87 };
88
89
90 /* Define the Union of all the above common
91  * resource structure definitions.
92  */
93 union CURES {
94    MSGS  res_msgs;
95    RES hdr;
96 };
97
98
99 /* Configuration routines */
100 void  parse_config(char *cf);
101 void  free_config_resources(void);
102
103 /* Resource routines */
104 RES *GetResWithName(int rcode, char *name);
105 RES *GetNextRes(int rcode, RES *res);
106 void LockRes(void);
107 void UnlockRes(void);
108 void dump_resource(int type, RES *res, void sendmsg(void *sock, char *fmt, ...), void *sock);
109 void free_resource(int type);
110 void init_resource(int type, struct res_items *item);
111 void save_resource(int type, struct res_items *item, int pass);
112 char *res_to_str(int rcode);
113
114 /* Loop through each resource of type, returning in var */
115 #define foreach_res(var, type) \
116     for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));) 
117
118 #ifdef the_old_way
119 #define foreach_res(var, type) \
120         for((var)=NULL; (((void *)(var))=GetNextRes((type), (RES *)var));) 
121 #endif
122
123
124 void store_str(LEX *lc, struct res_items *item, int index, int pass);
125 void store_dir(LEX *lc, struct res_items *item, int index, int pass);
126 void store_password(LEX *lc, struct res_items *item, int index, int pass);
127 void store_name(LEX *lc, struct res_items *item, int index, int pass);
128 void store_strname(LEX *lc, struct res_items *item, int index, int pass);
129 void store_res(LEX *lc, struct res_items *item, int index, int pass);
130 void store_int(LEX *lc, struct res_items *item, int index, int pass);
131 void store_pint(LEX *lc, struct res_items *item, int index, int pass);
132 void store_msgs(LEX *lc, struct res_items *item, int index, int pass);
133 void store_int64(LEX *lc, struct res_items *item, int index, int pass);
134 void store_yesno(LEX *lc, struct res_items *item, int index, int pass);
135 void store_time(LEX *lc, struct res_items *item, int index, int pass);
136 void store_size(LEX *lc, struct res_items *item, int index, int pass);
137 void store_defs(LEX *lc, struct res_items *item, int index, int pass);