5 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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.
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.
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,
24 struct RES_ITEM; /* Declare forward referenced structure */
25 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
27 /* This is the structure that defines
28 * the record types (items) permitted within each
29 * resource. It is used to define the configuration
33 const 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 */
41 /* For storing name_addr items in res_items table */
42 #define ITEM(x) ((void **)&res_all.x)
44 #define MAX_RES_ITEMS 50 /* maximum resource items per RES */
46 /* This is the universal header that is
47 * at the beginning of every resource
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 */
61 * Master Resource configuration structure definition
62 * This is the structure that defines the
63 * resources that are available to this daemon.
66 const char *name; /* resource name */
67 RES_ITEM *items; /* list of resource keywords */
68 int rcode; /* code if needed */
71 /* Common Resource definitions */
73 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */
75 #define ITEM_REQUIRED 0x1 /* item required */
76 #define ITEM_DEFAULT 0x2 /* default supplied */
77 #define ITEM_NO_EQUALS 0x4 /* Don't scan = after name */
79 /* Message Resource */
82 char *mail_cmd; /* mail command */
83 char *operator_cmd; /* Operator command */
84 DEST *dest_chain; /* chain of destinations */
85 char send_msg[nbytes_for_bits(M_MAX+1)]; /* bit array of types */
89 /* Define the Union of all the above common
90 * resource structure definitions.
98 /* Configuration routines */
99 int parse_config(const char *cf, int exit_on_error = 1);
100 void free_config_resources(void);
101 RES **save_config_resources(void);
102 RES **new_res_head();
105 /* Resource routines */
106 RES *GetResWithName(int rcode, char *name);
107 RES *GetNextRes(int rcode, RES *res);
108 void b_LockRes(const char *file, int line);
109 void b_UnlockRes(const char *file, int line);
110 void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
111 void free_resource(RES *res, int type);
112 void init_resource(int type, RES_ITEM *item);
113 void save_resource(int type, RES_ITEM *item, int pass);
114 const char *res_to_str(int rcode);
116 /* Loop through each resource of type, returning in var */
117 #define foreach_res(var, type) \
118 for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
121 #define foreach_res(var, type) \
122 for((var)=NULL; (((void *)(var))=GetNextRes((type), (RES *)var));)
126 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
127 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
128 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
129 void store_name(LEX *lc, RES_ITEM *item, int index, int pass);
130 void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
131 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
132 void store_int(LEX *lc, RES_ITEM *item, int index, int pass);
133 void store_pint(LEX *lc, RES_ITEM *item, int index, int pass);
134 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
135 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
136 void store_yesno(LEX *lc, RES_ITEM *item, int index, int pass);
137 void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
138 void store_size(LEX *lc, RES_ITEM *item, int index, int pass);
139 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);