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