Imported Upstream version 3.3.3
[debian/amanda] / server-src / infofile.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
5  * All Rights Reserved.
6  *
7  * Permission to use, copy, modify, distribute, and sell this software and its
8  * documentation for any purpose is hereby granted without fee, provided that
9  * the above copyright notice appear in all copies and that both that
10  * copyright notice and this permission notice appear in supporting
11  * documentation, and that the name of U.M. not be used in advertising or
12  * publicity pertaining to distribution of the software without specific,
13  * written prior permission.  U.M. makes no representations about the
14  * suitability of this software for any purpose.  It is provided "as is"
15  * without express or implied warranty.
16  *
17  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: James da Silva, Systems Design and Analysis Group
25  *                         Computer Science Department
26  *                         University of Maryland at College Park
27  */
28 /*
29  * $Id: infofile.h,v 1.14 2006/05/25 01:47:20 johnfranks Exp $
30  *
31  * interface for current info file reading code
32  */
33 #ifndef INFOFILE_H
34 #define INFOFILE_H
35
36 #include "amanda.h"
37
38 #define MAX_LABEL       80
39 #define EPOCH           ((time_t)0)
40
41 #define AVG_COUNT       3
42 #define NB_HISTORY      100
43 #define newperf(ary,f)  ( ary[2]=ary[1], ary[1]=ary[0], ary[0]=(f) )
44
45 typedef struct stats_s {
46     /* fields updated by dumper */
47     off_t size;                 /* original size of dump in kbytes */
48     off_t csize;                /* compressed size of dump in kbytes */
49     time_t secs;                /* time of dump in secs */
50     time_t date;                /* end time of dump */
51     /* fields updated by taper */
52     off_t filenum;              /* file number on tape */
53     char label[MAX_LABEL];      /* tape label */
54 } stats_t;
55
56 typedef struct history_s {
57     int level;                  /* level of dump */
58     off_t size;                 /* original size of dump in kbytes */
59     off_t csize;                /* compressed size of dump in kbytes */
60     time_t date;                /* time of dump */
61     time_t secs;                /* time of dump in secs */
62 } history_t;
63
64 typedef struct perf_s {
65     double rate[AVG_COUNT];
66     double comp[AVG_COUNT];
67 } perf_t;
68
69 typedef struct info_s {
70     unsigned int  command;              /* command word */
71 #       define NO_COMMAND       0       /* no outstanding commands */
72 #       define FORCE_FULL       1       /* force level 0 at next run */
73 #       define FORCE_BUMP       2       /* force bump at next run */
74 #       define FORCE_NO_BUMP    4       /* force no-bump at next run */
75     perf_t  full;
76     perf_t  incr;
77     stats_t inf[DUMP_LEVELS];
78     int last_level, consecutive_runs;
79     history_t history[NB_HISTORY+1];
80 } info_t;
81
82
83 int open_infofile(char *infofile);
84 void close_infofile(void);
85
86 char *get_dumpdate(info_t *info, int level);
87 double perf_average(double *array, double def);
88 int get_info(char *hostname, char *diskname, info_t *info);
89 int put_info(char *hostname, char *diskname, info_t *info);
90 int del_info(char *hostname, char *diskname);
91
92 #endif /* ! INFOFILE_H */