2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-2000 University of Maryland at College Park
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.
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.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * Originally living in conffile.c, this stuff supports columnar output in amreport.
35 ColumnInfo ColumnData[] = {
36 { "HostName", 0, 12, 12, 0, "%-*.*s", "HOSTNAME" },
37 { "Disk", 1, 11, 11, 0, "%-*.*s", "DISK" },
38 { "Level", 1, 1, 1, 0, "%*.*d", "L" },
39 { "OrigKB", 1, 7, 0, 0, "%*.*lf", "ORIG-KB" },
40 { "OutKB", 1, 7, 0, 0, "%*.*lf", "OUT-KB" },
41 { "Compress", 1, 6, 1, 0, "%*.*lf", "COMP%" },
42 { "DumpTime", 1, 7, 7, 0, "%*.*s", "MMM:SS" },
43 { "DumpRate", 1, 6, 1, 0, "%*.*lf", "KB/s" },
44 { "TapeTime", 1, 6, 6, 0, "%*.*s", "MMM:SS" },
45 { "TapeRate", 1, 6, 1, 0, "%*.*lf", "KB/s" },
46 { NULL, 0, 0, 0, 0, NULL, NULL }
51 ColumnDataCount(void )
53 return (int)(SIZEOF(ColumnData) / SIZEOF(ColumnData[0]));
56 /* conversion from string to table index
64 for (cn=0; ColumnData[cn].Name != NULL; cn++) {
65 if (strcasecmp(s, ColumnData[cn].Name) == 0) {
76 return s[strlen(s)-1];
80 SetColumnDataFromString(
87 /* Convert from a Columnspec string to our internal format
88 * of columspec. The purpose is to provide this string
89 * as configuration paramter in the amanda.conf file or
90 * (maybe) as environment variable.
92 * This text should go as comment into the sample amanda.conf
94 * The format for such a ColumnSpec string s is a ',' seperated
95 * list of triples. Each triple consists of
96 * -the name of the column (as in ColumnData.Name)
97 * -prefix before the column
98 * -the width of the column
99 * if set to -1 it will be recalculated
100 * to the maximum length of a line to print.
102 * "Disk=1:17,HostName=1:10,OutKB=1:7"
104 * "Disk=1:-1,HostName=1:10,OutKB=1:7"
106 * You need only specify those colums that should be changed from
107 * the default. If nothing is specified in the configfile, the
108 * above compiled in values will be in effect, resulting in an
109 * output as it was all the time.
116 char *eon= strchr(s, '=');
119 *errstr = stralloc2(_("invalid columnspec: "), s);
123 cn=StringToColumn(s);
124 if (ColumnData[cn].Name == NULL) {
125 *errstr = stralloc2(_("invalid column name: "), s);
128 if (sscanf(eon+1, "%d:%d", &Space, &Width) != 2) {
129 *errstr = stralloc2(_("invalid format: "), eon + 1);
132 ColumnData[cn].Width= Width;
133 ColumnData[cn].PrefixSpace = Space;
134 if (LastChar(ColumnData[cn].Format) == 's') {
136 ColumnData[cn].MaxWidth= 1;
138 if (Width > ColumnData[cn].Precision)
139 ColumnData[cn].Precision= Width;
143 ColumnData[cn].MaxWidth= 1;
145 else if (Width < ColumnData[cn].Precision)
146 ColumnData[cn].Precision = Width;
148 s= strchr(eon+1, ',');