Imported Upstream version 2.4.4p3
[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 2003/01/04 03:35:54 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_BUMPSIZE,
65     CNF_BUMPMULT,
66     CNF_BUMPDAYS,
67     CNF_TPCHANGER,
68     CNF_RUNTAPES,
69     CNF_MAXDUMPS,
70     CNF_ETIMEOUT,
71     CNF_DTIMEOUT,
72     CNF_CTIMEOUT,
73     CNF_TAPEBUFS,
74     CNF_RAWTAPEDEV,
75     CNF_PRINTER,
76     CNF_AUTOFLUSH,
77     CNF_RESERVE,
78     CNF_MAXDUMPSIZE,
79     CNF_COLUMNSPEC,
80     CNF_AMRECOVER_DO_FSF,
81     CNF_AMRECOVER_CHECK_LABEL,
82     CNF_AMRECOVER_CHANGER,
83     CNF_TAPERALGO
84 } confparm_t;
85
86 typedef enum auth_e {
87     AUTH_BSD, AUTH_KRB4
88 } auth_t;
89
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 /* Compression types */
125 #define COMP_NONE       0       /* No compression */
126 #define COMP_FAST       1       /* Fast compression on client */
127 #define COMP_BEST       2       /* Best compression on client */
128 #define COMP_SERV_FAST  3       /* Fast compression on server */
129 #define COMP_SERV_BEST  4       /* Best compression on server */
130
131 #define ALGO_FIRST      0
132 #define ALGO_FIRSTFIT   1
133 #define ALGO_LARGEST    2
134 #define ALGO_LARGESTFIT 3
135 #define ALGO_SMALLEST   4
136 #define ALGO_LAST       5
137
138 typedef struct dumptype_s {
139     struct dumptype_s *next;
140     int seen;
141     char *name;
142
143     char *comment;
144     char *program;
145     sl_t *exclude_file;
146     sl_t *exclude_list;
147     sl_t *include_file;
148     sl_t *include_list;
149     int exclude_optional;
150     int include_optional;
151     int priority;
152     int dumpcycle;
153     int maxcycle;
154     int frequency;
155     int maxpromoteday;
156     auth_t auth;
157     int maxdumps;
158     time_t start_t;
159     int strategy;
160     int compress;
161     float comprate[2]; /* first is full, second is incremental */
162     /* flag options */
163     unsigned int record:1;
164     unsigned int skip_incr:1;
165     unsigned int skip_full:1;
166     unsigned int no_hold:1;
167     unsigned int kencrypt:1;
168     unsigned int ignore:1;
169     unsigned int index:1;
170
171     /* seen flags */
172     int s_comment;
173     int s_program;
174     int s_exclude_file;
175     int s_exclude_list;
176     int s_include_file;
177     int s_include_list;
178     int s_exclude_optional;
179     int s_include_optional;
180     int s_priority;
181     int s_dumpcycle;
182     int s_maxcycle;
183     int s_frequency;
184     int s_auth;
185     int s_maxdumps;
186     int s_maxpromoteday;
187     int s_start_t;
188     int s_strategy;
189     int s_compress;
190     int s_comprate;
191     int s_record;
192     int s_skip_incr;
193     int s_skip_full;
194     int s_no_hold;
195     int s_kencrypt;
196     int s_ignore;
197     int s_index;
198 } dumptype_t;
199
200 /* A network interface */
201 typedef struct interface_s {
202     struct interface_s *next;
203     int seen;
204     char *name;
205
206     char *comment;
207     int maxusage;               /* bandwidth we can consume [kb/s] */
208
209     /* seen flags */
210     int s_comment;
211     int s_maxusage;
212
213     int curusage;               /* current usage */
214 } interface_t;
215
216 /* A holding disk */
217 typedef struct holdingdisk_s {
218     struct holdingdisk_s *next;
219     int seen;
220     char *name;
221
222     char *comment;
223     char *diskdir;
224     long disksize;
225     long chunksize;
226
227     int s_comment;
228     int s_disk;
229     int s_size;
230     int s_csize;
231
232     void *up;                   /* generic user pointer */
233 } holdingdisk_t;
234
235 /* for each column we define some values on how to
236  * format this column element
237  */
238 typedef struct {
239     char *Name;         /* column name */
240     char PrefixSpace;   /* the blank space to print before this
241                          * column. It is used to get the space
242                          * between the colums
243                          */
244     char Width;         /* the widht of the column itself */
245     char Precision;     /* the precision if its a float */
246     char MaxWidth;      /* if set, Width will be recalculated
247                          * to the space needed */
248     char *Format;       /* the printf format string for this
249                          * column element
250                          */
251     char *Title;        /* the title to use for this column */
252 } ColumnInfo;
253
254 /* this corresponds to the normal output of amanda, but may
255  * be adapted to any spacing as you like.
256  */
257 extern ColumnInfo ColumnData[];
258
259 extern char *config_name;
260 extern char *config_dir;
261
262 extern holdingdisk_t *holdingdisks;
263 extern int num_holdingdisks;
264
265 int read_conffile P((char *filename));
266 int getconf_seen P((confparm_t parameter));
267 int getconf_int P((confparm_t parameter));
268 double getconf_real P((confparm_t parameter));
269 char *getconf_str P((confparm_t parameter));
270 char *getconf_byname P((char *confname));
271 dumptype_t *lookup_dumptype P((char *identifier));
272 dumptype_t *read_dumptype P((char *name, FILE *from, char *fname, int *linenum));
273 tapetype_t *lookup_tapetype P((char *identifier));
274 interface_t *lookup_interface P((char *identifier));
275 holdingdisk_t *getconf_holdingdisks P((void));
276
277 int ColumnDataCount P((void));
278 int StringToColumn P((char *s));
279 char LastChar P((char *s));
280 int SetColumDataFromString P((ColumnInfo* ci, char *s, char **errstr));
281
282 char *taperalgo2str P((int taperalgo));
283
284 #endif /* ! CONFFILE_H */