summaryrefslogtreecommitdiffstats
path: root/ignore.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:12:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:12:14 +0000
commit4b8a0f3f3dcf60dac2ce308ea08d413a535af29f (patch)
tree0f09c0ad2a4d0f535d89040a63dc3a866a6606e6 /ignore.c
parentInitial commit. (diff)
downloadreprepro-4b8a0f3f3dcf60dac2ce308ea08d413a535af29f.tar.xz
reprepro-4b8a0f3f3dcf60dac2ce308ea08d413a535af29f.zip
Adding upstream version 5.4.4.upstream/5.4.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ignore.c')
-rw-r--r--ignore.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/ignore.c b/ignore.c
new file mode 100644
index 0000000..bff54b3
--- /dev/null
+++ b/ignore.c
@@ -0,0 +1,101 @@
+/* This file is part of "reprepro"
+ * Copyright (C) 2005 Bernhard R. Link
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+#include <config.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "ignore.h"
+
+int ignored[IGN_COUNT];
+bool ignore[IGN_COUNT];
+static enum config_option_owner owner_ignore[IGN_COUNT];
+
+static const char * const ignores[] = {
+#define IGN(what) #what ,
+ VALID_IGNORES
+#undef IGN
+};
+
+bool print_ignore_type_message(bool i, enum ignore what) {
+ ignored[what]++;
+ if (ignore[what])
+ fprintf(stderr, "%s as --ignore=%s given.\n",
+ i ? "Ignoring" : "Not rejecting",
+ ignores[what]);
+ else
+ fprintf(stderr, "To ignore use --ignore=%s.\n",
+ ignores[what]);
+ return ignore[what];
+}
+
+static retvalue set(const char *given, size_t len, bool newvalue, enum config_option_owner newowner) {
+ int i;
+
+ //TODO: allow multiple values sperated by some sign here...
+
+ for (i = 0 ; i < IGN_COUNT ; i++) {
+ if (strncmp(given, ignores[i], len) == 0 &&
+ ignores[i][len] == '\0') {
+ if (owner_ignore[i] <= newowner) {
+ ignore[i] = newvalue;
+ owner_ignore[i] = newowner;
+ }
+ break;
+ }
+ }
+ if (i == IGN_COUNT) {
+ char *str = strndup(given, len);
+ if (IGNORING(ignore,
+"Unknown --ignore value: '%s'!\n", (str!=NULL)?str:given)) {
+ free(str);
+ return RET_NOTHING;
+ } else {
+ free(str);
+ return RET_ERROR;
+ }
+ } else
+ return RET_OK;
+}
+
+retvalue set_ignore(const char *given, bool newvalue, enum config_option_owner newowner) {
+ const char *g, *p;
+ retvalue r;
+
+ assert (given != NULL);
+
+ g = given;
+
+ while (true) {
+ p = g;
+ while (*p != '\0' && *p != ',')
+ p++;
+ if (p == g) {
+ fprintf(stderr,
+"Empty ignore option in --ignore='%s'!\n",
+ given);
+ return RET_ERROR_MISSING;
+ }
+ r = set(g, p - g, newvalue, newowner);
+ if (RET_WAS_ERROR(r))
+ return r;
+ if (*p == '\0')
+ return RET_OK;
+ g = p+1;
+ }
+}