]> Dogcows Code - chaz/tar/blob - src/warning.c
81805e106df9ba726437231ac27d2c17267f0c01
[chaz/tar] / src / warning.c
1 /* Warnings for GNU tar.
2
3 Copyright 2009, 2012-2013 Free Software Foundation, Inc.
4
5 This file is part of GNU tar.
6
7 GNU tar is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU tar is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include <system.h>
21 #include <argmatch.h>
22
23 #include "common.h"
24
25 static char const *const warning_args[] = {
26 "all",
27 "alone-zero-block",
28 "bad-dumpdir",
29 "cachedir",
30 "contiguous-cast",
31 "file-changed",
32 "file-ignored",
33 "file-removed",
34 "file-shrank",
35 "file-unchanged",
36 "filename-with-nuls",
37 "ignore-archive",
38 "ignore-newer",
39 "new-directory",
40 "rename-directory",
41 "symlink-cast",
42 "timestamp",
43 "unknown-cast",
44 "unknown-keyword",
45 "xdev",
46 "decompress-program",
47 "existing-file",
48 "xattr-write",
49 NULL
50 };
51
52 static int warning_types[] = {
53 WARN_ALL,
54 WARN_ALONE_ZERO_BLOCK,
55 WARN_BAD_DUMPDIR,
56 WARN_CACHEDIR,
57 WARN_CONTIGUOUS_CAST,
58 WARN_FILE_CHANGED,
59 WARN_FILE_IGNORED,
60 WARN_FILE_REMOVED,
61 WARN_FILE_SHRANK,
62 WARN_FILE_UNCHANGED,
63 WARN_FILENAME_WITH_NULS,
64 WARN_IGNORE_ARCHIVE,
65 WARN_IGNORE_NEWER,
66 WARN_NEW_DIRECTORY,
67 WARN_RENAME_DIRECTORY,
68 WARN_SYMLINK_CAST,
69 WARN_TIMESTAMP,
70 WARN_UNKNOWN_CAST,
71 WARN_UNKNOWN_KEYWORD,
72 WARN_XDEV,
73 WARN_DECOMPRESS_PROGRAM,
74 WARN_EXISTING_FILE,
75 WARN_XATTR_WRITE
76 };
77
78 ARGMATCH_VERIFY (warning_args, warning_types);
79
80 int warning_option = WARN_ALL;
81
82 void
83 set_warning_option (const char *arg)
84 {
85 int negate = 0;
86 int option;
87
88 if (strcmp (arg, "none") == 0)
89 {
90 warning_option = 0;
91 return;
92 }
93 if (strlen (arg) > 2 && memcmp (arg, "no-", 3) == 0)
94 {
95 negate = 1;
96 arg += 3;
97 }
98
99 option = XARGMATCH ("--warning", arg,
100 warning_args, warning_types);
101 if (negate)
102 warning_option &= ~option;
103 else
104 warning_option |= option;
105 }
This page took 0.033298 seconds and 3 git commands to generate.