]> Dogcows Code - chaz/tar/blob - src/warning.c
d58a575d5813fe2e7f83fc907cb4d71a47ea24e4
[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 "record-size",
50 NULL
51 };
52
53 static int warning_types[] = {
54 WARN_ALL,
55 WARN_ALONE_ZERO_BLOCK,
56 WARN_BAD_DUMPDIR,
57 WARN_CACHEDIR,
58 WARN_CONTIGUOUS_CAST,
59 WARN_FILE_CHANGED,
60 WARN_FILE_IGNORED,
61 WARN_FILE_REMOVED,
62 WARN_FILE_SHRANK,
63 WARN_FILE_UNCHANGED,
64 WARN_FILENAME_WITH_NULS,
65 WARN_IGNORE_ARCHIVE,
66 WARN_IGNORE_NEWER,
67 WARN_NEW_DIRECTORY,
68 WARN_RENAME_DIRECTORY,
69 WARN_SYMLINK_CAST,
70 WARN_TIMESTAMP,
71 WARN_UNKNOWN_CAST,
72 WARN_UNKNOWN_KEYWORD,
73 WARN_XDEV,
74 WARN_DECOMPRESS_PROGRAM,
75 WARN_EXISTING_FILE,
76 WARN_XATTR_WRITE,
77 WARN_RECORD_SIZE
78 };
79
80 ARGMATCH_VERIFY (warning_args, warning_types);
81
82 int warning_option = WARN_ALL;
83
84 void
85 set_warning_option (const char *arg)
86 {
87 int negate = 0;
88 int option;
89
90 if (strcmp (arg, "none") == 0)
91 {
92 warning_option = 0;
93 return;
94 }
95 if (strlen (arg) > 2 && memcmp (arg, "no-", 3) == 0)
96 {
97 negate = 1;
98 arg += 3;
99 }
100
101 option = XARGMATCH ("--warning", arg,
102 warning_args, warning_types);
103 if (negate)
104 warning_option &= ~option;
105 else
106 warning_option |= option;
107 }
This page took 0.034087 seconds and 3 git commands to generate.