Imported Upstream version 2.4.5
[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.24.2.8.4.4.2.9.2.5 2005/03/29 16:35:11 martinea 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 } confparm_t;
87
88 typedef enum auth_e {
89     AUTH_BSD, AUTH_KRB4
90 } auth_t;
91
92
93 typedef struct tapetype_s {
94     struct tapetype_s *next;
95     int seen;
96     char *name;
97
98     char *comment;
99     char *lbl_templ;
100     long blocksize;
101     unsigned long length;
102     unsigned long filemark;
103     int speed;
104     int file_pad;
105
106     /* seen flags */
107     int s_comment;
108     int s_lbl_templ;
109     int s_blocksize;
110     int s_file_pad;
111     int s_length;
112     int s_filemark;
113     int s_speed;
114 } tapetype_t;
115
116 /* Dump strategies */
117 #define DS_SKIP         0       /* Don't do any dumps at all */
118 #define DS_STANDARD     1       /* Standard (0 1 1 1 1 2 2 2 ...) */
119 #define DS_NOFULL       2       /* No full's (1 1 1 ...) */
120 #define DS_NOINC        3       /* No inc's (0 0 0 ...) */
121 #define DS_4            4       /* ? (0 1 2 3 4 5 6 7 8 9 10 11 ...) */
122 #define DS_5            5       /* ? (0 1 1 1 1 1 1 1 1 1 1 1 ...) */
123 #define DS_HANOI        6       /* Tower of Hanoi (? ? ? ? ? ...) */
124 #define DS_INCRONLY     7       /* Forced fulls (0 1 1 2 2 FORCE0 1 1 ...) */
125
126 /* Estimate strategies */
127 #define ES_CLIENT       0       /* client estimate */
128 #define ES_SERVER       1       /* server estimate */
129 #define ES_CALCSIZE     2       /* calcsize estimate */
130
131 /* Compression types */
132 #define COMP_NONE       0       /* No compression */
133 #define COMP_FAST       1       /* Fast compression on client */
134 #define COMP_BEST       2       /* Best compression on client */
135 #define COMP_SERV_FAST  3       /* Fast compression on server */
136 #define COMP_SERV_BEST  4       /* Best compression on server */
137
138 #define ALGO_FIRST      0
139 #define ALGO_FIRSTFIT   1
140 #define ALGO_LARGEST    2
141 #define ALGO_LARGESTFIT 3
142 #define ALGO_SMALLEST   4
143 #define ALGO_LAST       5
144
145 typedef struct dumptype_s {
146     struct dumptype_s *next;
147     int seen;
148     char *name;
149
150     char *comment;
151     char *program;
152     sl_t *exclude_file;
153     sl_t *exclude_list;
154     sl_t *include_file;
155     sl_t *include_list;
156     int exclude_optional;
157     int include_optional;
158     int priority;
159     int dumpcycle;
160     int maxcycle;
161     int frequency;
162     int maxpromoteday;
163     int bumppercent;
164     int bumpsize;
165     int bumpdays;
166     double bumpmult;
167     auth_t auth;
168     int maxdumps;
169     time_t start_t;
170     int strategy;
171     int estimate;
172     int compress;
173     float comprate[2]; /* first is full, second is incremental */
174     /* flag options */
175     unsigned int record:1;
176     unsigned int skip_incr:1;
177     unsigned int skip_full:1;
178     unsigned int no_hold:1;
179     unsigned int kencrypt:1;
180     unsigned int ignore:1;
181     unsigned int index:1;
182
183     /* seen flags */
184     int s_comment;
185     int s_program;
186     int s_exclude_file;
187     int s_exclude_list;
188     int s_include_file;
189     int s_include_list;
190     int s_exclude_optional;
191     int s_include_optional;
192     int s_priority;
193     int s_dumpcycle;
194     int s_maxcycle;
195     int s_frequency;
196     int s_auth;
197     int s_maxdumps;
198     int s_maxpromoteday;
199     int s_bumppercent;
200     int s_bumpsize;
201     int s_bumpdays;
202     int s_bumpmult;
203     int s_start_t;
204     int s_strategy;
205     int s_estimate;
206     int s_compress;
207     int s_comprate;
208     int s_record;
209     int s_skip_incr;
210     int s_skip_full;
211     int s_no_hold;
212     int s_kencrypt;
213     int s_ignore;
214     int s_index;
215 } dumptype_t;
216
217 /* A network interface */
218 typedef struct interface_s {
219     struct interface_s *next;
220     int seen;
221     char *name;
222
223     char *comment;
224     int maxusage;               /* bandwidth we can consume [kb/s] */
225
226     /* seen flags */
227     int s_comment;
228     int s_maxusage;
229
230     int curusage;               /* current usage */
231 } interface_t;
232
233 /* A holding disk */
234 typedef struct holdingdisk_s {
235     struct holdingdisk_s *next;
236     int seen;
237     char *name;
238
239     char *comment;
240     char *diskdir;
241     long disksize;
242     long chunksize;
243
244     int s_comment;
245     int s_disk;
246     int s_size;
247     int s_csize;
248
249     void *up;                   /* generic user pointer */
250 } holdingdisk_t;
251
252 /* for each column we define some values on how to
253  * format this column element
254  */
255 typedef struct {
256     char *Name;         /* column name */
257     char PrefixSpace;   /* the blank space to print before this
258                          * column. It is used to get the space
259                          * between the colums
260                          */
261     char Width;         /* the widht of the column itself */
262     char Precision;     /* the precision if its a float */
263     char MaxWidth;      /* if set, Width will be recalculated
264                          * to the space needed */
265     char *Format;       /* the printf format string for this
266                          * column element
267                          */
268     char *Title;        /* the title to use for this column */
269 } ColumnInfo;
270
271 /* this corresponds to the normal output of amanda, but may
272  * be adapted to any spacing as you like.
273  */
274 extern ColumnInfo ColumnData[];
275
276 extern char *config_name;
277 extern char *config_dir;
278
279 extern holdingdisk_t *holdingdisks;
280 extern int num_holdingdisks;
281
282 int read_conffile P((char *filename));
283 int getconf_seen P((confparm_t parameter));
284 int getconf_int P((confparm_t parameter));
285 double getconf_real P((confparm_t parameter));
286 char *getconf_str P((confparm_t parameter));
287 char *getconf_byname P((char *confname));
288 dumptype_t *lookup_dumptype P((char *identifier));
289 dumptype_t *read_dumptype P((char *name, FILE *from, char *fname, int *linenum));
290 tapetype_t *lookup_tapetype P((char *identifier));
291 interface_t *lookup_interface P((char *identifier));
292 holdingdisk_t *getconf_holdingdisks P((void));
293 long int getconf_unit_divisor P((void));
294
295 int ColumnDataCount P((void));
296 int StringToColumn P((char *s));
297 char LastChar P((char *s));
298 int SetColumDataFromString P((ColumnInfo* ci, char *s, char **errstr));
299
300 char *taperalgo2str P((int taperalgo));
301
302 #endif /* ! CONFFILE_H */