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