5 Copyright (C) 2000-2006 Kern Sibbald
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.
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.
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);
23 /* This is the structure that defines
24 * the record types (items) permitted within each
25 * resource. It is used to define the configuration
29 const char *name; /* Resource name i.e. Director, ... */
30 MSG_RES_HANDLER *handler; /* Routine storing the resource item */
32 char **value; /* Where to store the item */
43 int code; /* item code/additional info */
44 int flags; /* flags: default, required, ... */
45 int default_value; /* default value */
48 /* For storing name_addr items in res_items table */
49 #define ITEM(x) {(char **)&res_all.x}
51 #define MAX_RES_ITEMS 70 /* maximum resource items per RES */
53 /* This is the universal header that is
54 * at the beginning of every resource
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 */
68 * Master Resource configuration structure definition
69 * This is the structure that defines the
70 * resources that are available to this daemon.
73 const char *name; /* resource name */
74 RES_ITEM *items; /* list of resource keywords */
75 int rcode; /* code if needed */
78 /* Common Resource definitions */
80 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */
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 */
86 /* Message Resource */
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 */
96 /* Define the Union of all the above common
97 * resource structure definitions.
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();
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);
123 /* Loop through each resource of type, returning in var */
125 #define foreach_res(var, type) \
126 for((var)=NULL; ((var)=(typeof(var))GetNextRes((type), (RES *)var));)
128 #define foreach_res(var, type) \
129 for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
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);