summaryrefslogtreecommitdiff
path: root/src/warning.c
blob: 4374a88c870a28c35e96e22cf8410628b20979a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* This file is part of GNU tar.

   Copyright (C) 2009 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 3, or (at your option) any later
   version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
   Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <system.h>
#include <argmatch.h>

#include "common.h"

static char const *const warning_args[] = {
  "all",
  "alone-zero-block",
  "bad-dumpdir",
  "cachedir",
  "contiguous-cast",
  "file-changed",
  "file-ignored",
  "file-removed",
  "file-shrank",
  "file-unchanged",
  "filename-with-nuls",
  "ignore-archive",
  "ignore-newer",
  "new-directory",
  "rename-directory",
  "symlink-cast",
  "timestamp",
  "unknown-cast",
  "unknown-keyword",
  "xdev",
  NULL
};

static int warning_types[] = {
  WARN_ALL,
  WARN_ALONE_ZERO_BLOCK,
  WARN_BAD_DUMPDIR,
  WARN_CACHEDIR,
  WARN_CONTIGUOUS_CAST,
  WARN_FILE_CHANGED,
  WARN_FILE_IGNORED,
  WARN_FILE_REMOVED,
  WARN_FILE_SHRANK,
  WARN_FILE_UNCHANGED,
  WARN_FILENAME_WITH_NULS,
  WARN_IGNORE_ARCHIVE,
  WARN_IGNORE_NEWER,
  WARN_NEW_DIRECTORY,
  WARN_RENAME_DIRECTORY,
  WARN_SYMLINK_CAST,
  WARN_TIMESTAMP,
  WARN_UNKNOWN_CAST,
  WARN_UNKNOWN_KEYWORD,
  WARN_XDEV
};

ARGMATCH_VERIFY (warning_args, warning_types);

int warning_option = WARN_ALL;

void
set_warning_option (const char *arg)
{
  int negate = 0;
  int option;

  if (strcmp (arg, "none") == 0)
    {
      warning_option = 0;
      return;
    }
  if (strlen (arg) > 2 && memcmp (arg, "no-", 3) == 0)
    {
      negate = 1;
      arg += 3;
    }

  option = XARGMATCH ("--warning", arg,
		      warning_args, warning_types);
  if (negate)
    warning_option &= ~option;
  else
    warning_option |= option;
}