]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/parse_conf.h
This commit was manufactured by cvs2svn to create tag
[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 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
21
22 /* This is the structure that defines
23  * the record types (items) permitted within each
24  * resource. It is used to define the configuration
25  * tables.
26  */
27 struct RES_ITEM {
28    const char *name;                  /* Resource name i.e. Director, ... */
29    MSG_RES_HANDLER *handler;          /* Routine storing the resource item */
30    char **value;                      /* Where to store the item */
31    int  code;                         /* item code/additional info */
32    int  flags;                        /* flags: default, required, ... */
33    int  default_value;                /* default value */
34 };
35
36 /* For storing name_addr items in res_items table */
37 #define ITEM(x) ((char **)&res_all.x)
38
39 #define MAX_RES_ITEMS 70              /* maximum resource items per RES */
40
41 /* This is the universal header that is
42  * at the beginning of every resource
43  * record.
44  */
45 struct RES {
46    RES *next;                         /* pointer to next resource of this type */
47    char *name;                        /* resource name */
48    char *desc;                        /* resource description */
49    int   rcode;                       /* resource id or type */
50    int   refcnt;                      /* reference count for releasing */
51    char  item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
52 };
53
54
55 /*
56  * Master Resource configuration structure definition
57  * This is the structure that defines the
58  * resources that are available to this daemon.
59  */
60 struct RES_TABLE {
61    const char *name;                  /* resource name */
62    RES_ITEM *items;                   /* list of resource keywords */
63    int rcode;                         /* code if needed */
64 };
65
66 /* Common Resource definitions */
67
68 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
69
70 #define ITEM_REQUIRED    0x1          /* item required */
71 #define ITEM_DEFAULT     0x2          /* default supplied */
72 #define ITEM_NO_EQUALS   0x4          /* Don't scan = after name */
73
74 /* Message Resource */
75 struct MSGS {
76    RES   hdr;
77    char *mail_cmd;                    /* mail command */
78    char *operator_cmd;                /* Operator command */
79    DEST *dest_chain;                  /* chain of destinations */
80    char send_msg[nbytes_for_bits(M_MAX+1)];  /* bit array of types */
81 };
82
83
84 /* Define the Union of all the above common
85  * resource structure definitions.
86  */
87 union CURES {
88    MSGS  res_msgs;
89    RES hdr;
90 };
91
92
93 /* Configuration routines */
94 int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL);
95 void    free_config_resources(void);
96 RES   **save_config_resources(void);
97 RES   **new_res_head();
98
99
100 /* Resource routines */
101 RES *GetResWithName(int rcode, char *name);
102 RES *GetNextRes(int rcode, RES *res);
103 void b_LockRes(const char *file, int line);
104 void b_UnlockRes(const char *file, int line);
105 void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
106 void free_resource(RES *res, int type);
107 void init_resource(int type, RES_ITEM *item);
108 void save_resource(int type, RES_ITEM *item, int pass);
109 const char *res_to_str(int rcode);
110
111 /* Loop through each resource of type, returning in var */
112 #ifdef HAVE_GCC
113 #define foreach_res(var, type) \
114         for((var)=NULL; ((var)=(typeof(var))GetNextRes((type), (RES *)var));)
115 #else 
116 #define foreach_res(var, type) \
117     for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
118 #endif
119
120
121
122 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
123 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
124 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
125 void store_name(LEX *lc, RES_ITEM *item, int index, int pass);
126 void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
127 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
128 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass);
129 void store_alist_str(LEX *lc, RES_ITEM *item, int index, int pass);
130 void store_int(LEX *lc, RES_ITEM *item, int index, int pass);
131 void store_pint(LEX *lc, RES_ITEM *item, int index, int pass);
132 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
133 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
134 void store_yesno(LEX *lc, RES_ITEM *item, int index, int pass);
135 void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
136 void store_size(LEX *lc, RES_ITEM *item, int index, int pass);
137 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
138 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);