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