From ac5288c1ac9b4d0721b3bc7271368c11c736248e Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 5 Aug 2009 22:18:33 +0300 Subject: [PATCH] Forgotten to push src/warning.c --- src/warning.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/warning.c diff --git a/src/warning.c b/src/warning.c new file mode 100644 index 00000000..a9cbccb7 --- /dev/null +++ b/src/warning.c @@ -0,0 +1,98 @@ +/* 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 . */ + +#include +#include + +#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; +} + -- 2.11.4.GIT