ef6c165da3400fa0c534501fac36c2db2c0feaac
[debian/amanda] / server-src / conffile.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-2000 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: James da Silva, Systems Design and Analysis Group
24  *                         Computer Science Department
25  *                         University of Maryland at College Park
26  */
27 /*
28  * $Id: conffile.h,v 1.60 2005/12/21 19:07:50 paddy_s Exp $
29  *
30  * interface for config file reading code
31  */
32 #ifndef CONFFILE_H
33 #define CONFFILE_H
34
35 #include "amanda.h"
36 #include "sl.h"
37
38 #define CONFFILE_NAME "amanda.conf"
39
40 typedef enum conf_e {
41     CNF_ORG,
42     CNF_MAILTO,
43     CNF_DUMPUSER,
44     CNF_TAPEDEV,
45     CNF_CHNGRDEV,
46     CNF_CHNGRFILE,
47     CNF_LABELSTR,
48     CNF_TAPELIST,
49     CNF_DISKFILE,
50     CNF_INFOFILE,
51     CNF_LOGDIR,
52     CNF_DISKDIR,
53     CNF_INDEXDIR,
54     CNF_TAPETYPE,
55     CNF_DUMPCYCLE,
56     CNF_RUNSPERCYCLE,
57     CNF_MAXCYCLE,
58     CNF_TAPECYCLE,
59     CNF_DISKSIZE,
60     CNF_NETUSAGE,
61     CNF_INPARALLEL,
62     CNF_DUMPORDER,
63     CNF_TIMEOUT,
64     CNF_BUMPPERCENT,
65     CNF_BUMPSIZE,
66     CNF_BUMPMULT,
67     CNF_BUMPDAYS,
68     CNF_TPCHANGER,
69     CNF_RUNTAPES,
70     CNF_MAXDUMPS,
71     CNF_ETIMEOUT,
72     CNF_DTIMEOUT,
73     CNF_CTIMEOUT,
74     CNF_TAPEBUFS,
75     CNF_RAWTAPEDEV,
76     CNF_PRINTER,
77     CNF_AUTOFLUSH,
78     CNF_RESERVE,
79     CNF_MAXDUMPSIZE,
80     CNF_COLUMNSPEC,
81     CNF_AMRECOVER_DO_FSF,
82     CNF_AMRECOVER_CHECK_LABEL,
83     CNF_AMRECOVER_CHANGER,
84     CNF_TAPERALGO,
85     CNF_DISPLAYUNIT,
86     CNF_KRB5KEYTAB,
87     CNF_KRB5PRINCIPAL,
88     CNF_LABEL_NEW_TAPES
89 } confparm_t;
90
91 typedef struct tapetype_s {
92     struct tapetype_s *next;
93     int seen;
94     char *name;
95
96     char *comment;
97     char *lbl_templ;
98     long blocksize;
99     unsigned long length;
100     unsigned long filemark;
101     int speed;
102     int file_pad;
103
104     /* seen flags */
105     int s_comment;
106     int s_lbl_templ;
107     int s_blocksize;
108     int s_file_pad;
109     int s_length;
110     int s_filemark;
111     int s_speed;
112 } tapetype_t;
113
114 /* Dump strategies */
115 #define DS_SKIP         0       /* Don't do any dumps at all */
116 #define DS_STANDARD     1       /* Standard (0 1 1 1 1 2 2 2 ...) */
117 #define DS_NOFULL       2       /* No full's (1 1 1 ...) */
118 #define DS_NOINC        3       /* No inc's (0 0 0 ...) */
119 #define DS_4            4       /* ? (0 1 2 3 4 5 6 7 8 9 10 11 ...) */
120 #define DS_5            5       /* ? (0 1 1 1 1 1 1 1 1 1 1 1 ...) */
121 #define DS_HANOI        6       /* Tower of Hanoi (? ? ? ? ? ...) */
122 #define DS_INCRONLY     7       /* Forced fulls (0 1 1 2 2 FORCE0 1 1 ...) */
123
124 /* Estimate strategies */
125 #define ES_CLIENT       0       /* client estimate */
126 #define ES_SERVER       1       /* server estimate */
127 #define ES_CALCSIZE     2       /* calcsize estimate */
128
129 /* Compression types */
130 typedef enum {
131     COMP_NONE,          /* No compression */
132     COMP_FAST,          /* Fast compression on client */
133     COMP_BEST,          /* Best compression on client */
134     COMP_CUST,          /* Custom compression on client */
135     COMP_SERV_FAST,     /* Fast compression on server */
136     COMP_SERV_BEST,     /* Best compression on server */
137     COMP_SERV_CUST      /* Custom compression on server */
138 } comp_t;
139
140 /* Encryption types */
141 typedef enum {
142     ENCRYPT_NONE,               /* No encryption */
143     ENCRYPT_CUST,               /* Custom encryption on client */
144     ENCRYPT_SERV_CUST,          /* Custom encryption on server */
145 } encrypt_t;
146
147 #define ALGO_FIRST      0
148 #define ALGO_FIRSTFIT   1
149 #define ALGO_LARGEST    2
150 #define ALGO_LARGESTFIT 3
151 #define ALGO_SMALLEST   4
152 #define ALGO_LAST       5
153
154 typedef struct dumptype_s {
155     struct dumptype_s *next;
156     int seen;
157     char *name;
158
159     char *comment;
160     char *program;
161     char *srvcompprog;
162     char *clntcompprog;
163     char *srv_encrypt;
164     char *clnt_encrypt;
165     sl_t *exclude_file;
166     sl_t *exclude_list;
167     sl_t *include_file;
168     sl_t *include_list;
169     int exclude_optional;
170     int include_optional;
171     int priority;
172     int dumpcycle;
173     int maxcycle;
174     int frequency;
175     char *security_driver;
176     int maxdumps;
177     int maxpromoteday;
178     int bumppercent;
179     int bumpsize;
180     int bumpdays;
181     double bumpmult;
182     time_t start_t;
183     int strategy;
184     int estimate;
185     comp_t compress;
186     encrypt_t encrypt;
187     char *srv_decrypt_opt;
188     char *clnt_decrypt_opt;
189     float comprate[2]; /* first is full, second is incremental */
190     long tape_splitsize;
191     char *split_diskbuffer;
192     long fallback_splitsize;
193     /* flag options */
194     unsigned int record:1;
195     unsigned int skip_incr:1;
196     unsigned int skip_full:1;
197     unsigned int no_hold:1;
198     unsigned int kencrypt:1;
199     unsigned int ignore:1;
200     unsigned int index:1;
201
202     /* seen flags */
203     int s_comment;
204     int s_program;
205     int s_srvcompprog;
206     int s_clntcompprog;
207     int s_srv_encrypt;
208     int s_clnt_encrypt;
209     int s_exclude_file;
210     int s_exclude_list;
211     int s_include_file;
212     int s_include_list;
213     int s_exclude_optional;
214     int s_include_optional;
215     int s_priority;
216     int s_dumpcycle;
217     int s_maxcycle;
218     int s_frequency;
219     int s_security_driver;
220     int s_maxdumps;
221     int s_maxpromoteday;
222     int s_bumppercent;
223     int s_bumpsize;
224     int s_bumpdays;
225     int s_bumpmult;
226     int s_start_t;
227     int s_strategy;
228     int s_estimate;
229     int s_compress;
230     int s_encrypt;
231     int s_srv_decrypt_opt;
232     int s_clnt_decrypt_opt;
233     int s_comprate;
234     int s_record;
235     int s_skip_incr;
236     int s_skip_full;
237     int s_no_hold;
238     int s_kencrypt;
239     int s_ignore;
240     int s_index;
241     int s_tape_splitsize;
242     int s_split_diskbuffer;
243     int s_fallback_splitsize;
244 } dumptype_t;
245
246 /* A network interface */
247 typedef struct interface_s {
248     struct interface_s *next;
249     int seen;
250     char *name;
251
252     char *comment;
253     int maxusage;               /* bandwidth we can consume [kb/s] */
254
255     /* seen flags */
256     int s_comment;
257     int s_maxusage;
258
259     int curusage;               /* current usage */
260 } interface_t;
261
262 /* A holding disk */
263 typedef struct holdingdisk_s {
264     struct holdingdisk_s *next;
265     int seen;
266     char *name;
267
268     char *comment;
269     char *diskdir;
270     long disksize;
271     long chunksize;
272
273     int s_comment;
274     int s_disk;
275     int s_size;
276     int s_csize;
277
278     void *up;                   /* generic user pointer */
279 } holdingdisk_t;
280
281 /* for each column we define some values on how to
282  * format this column element
283  */
284 typedef struct {
285     char *Name;         /* column name */
286     char PrefixSpace;   /* the blank space to print before this
287                          * column. It is used to get the space
288                          * between the colums
289                          */
290     char Width;         /* the widht of the column itself */
291     char Precision;     /* the precision if its a float */
292     char MaxWidth;      /* if set, Width will be recalculated
293                          * to the space needed */
294     char *Format;       /* the printf format string for this
295                          * column element
296                          */
297     char *Title;        /* the title to use for this column */
298 } ColumnInfo;
299
300 /* this corresponds to the normal output of amanda, but may
301  * be adapted to any spacing as you like.
302  */
303 extern ColumnInfo ColumnData[];
304
305 extern char *config_name;
306 extern char *config_dir;
307
308 extern holdingdisk_t *holdingdisks;
309 extern int num_holdingdisks;
310
311 int read_conffile P((char *filename));
312 int getconf_seen P((confparm_t parameter));
313 int getconf_int P((confparm_t parameter));
314 am64_t getconf_am64 P((confparm_t parameter));
315 double getconf_real P((confparm_t parameter));
316 char *getconf_str P((confparm_t parameter));
317 char *getconf_byname P((char *confname));
318 dumptype_t *lookup_dumptype P((char *identifier));
319 dumptype_t *read_dumptype P((char *name, FILE *from, char *fname, int *linenum));
320 tapetype_t *lookup_tapetype P((char *identifier));
321 interface_t *lookup_interface P((char *identifier));
322 holdingdisk_t *getconf_holdingdisks P((void));
323 long int getconf_unit_divisor P((void));
324
325 int ColumnDataCount P((void));
326 int StringToColumn P((char *s));
327 char LastChar P((char *s));
328 int SetColumDataFromString P((ColumnInfo* ci, char *s, char **errstr));
329
330 char *taperalgo2str P((int taperalgo));
331
332 /* this is in securityconf.h */
333 char *generic_get_security_conf P((char *, void *));
334 #endif /* ! CONFFILE_H */