From b86570f63e533abcbcb97c2572e0e5732a96307b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 11:40:31 +0200 Subject: Adding upstream version 1.20.13. Signed-off-by: Daniel Baumann --- utils/update-alternatives.c | 3145 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3145 insertions(+) create mode 100644 utils/update-alternatives.c (limited to 'utils/update-alternatives.c') diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c new file mode 100644 index 0000000..89264d3 --- /dev/null +++ b/utils/update-alternatives.c @@ -0,0 +1,3145 @@ +/* + * update-alternatives + * + * Copyright © 1995 Ian Jackson + * Copyright © 2000-2002 Wichert Akkerman + * Copyright © 2006-2017 Guillem Jover + * Copyright © 2008 Pierre Habouzit + * Copyright © 2009-2010 Raphaël Hertzog + * + * 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 2 of the License, 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* Global variables: */ + +#define PROGNAME "update-alternatives" + +static const char *altdir = SYSCONFDIR "/alternatives"; +static char *admdir = NULL; +static const char *instdir = ""; +static size_t instdir_len; + +static const char *prog_path = "update-alternatives"; + +enum action { + ACTION_NONE, + ACTION_INSTALL, + ACTION_SET, + ACTION_SET_SELECTIONS, + ACTION_GET_SELECTIONS, + ACTION_AUTO, + ACTION_CONFIG, + ACTION_CONFIG_ALL, + ACTION_REMOVE, + ACTION_REMOVE_ALL, + ACTION_LIST, + ACTION_QUERY, + ACTION_DISPLAY, +}; + +static struct action_name { + enum action action; + const char *name; +} action_names[] = { + { ACTION_NONE, "" }, + { ACTION_INSTALL, "install" }, + { ACTION_SET, "set" }, + { ACTION_SET_SELECTIONS, "set-selections" }, + { ACTION_GET_SELECTIONS, "get-selections" }, + { ACTION_AUTO, "auto" }, + { ACTION_CONFIG, "config" }, + { ACTION_CONFIG_ALL, "all" }, + { ACTION_REMOVE, "remove" }, + { ACTION_REMOVE_ALL, "remove-all" }, + { ACTION_LIST, "list" }, + { ACTION_QUERY, "query" }, + { ACTION_DISPLAY, "display" }, +}; + +enum output_mode { + OUTPUT_QUIET = -1, + OUTPUT_NORMAL = 0, + OUTPUT_VERBOSE = 1, + OUTPUT_DEBUG = 2, +}; + +/* Action to perform */ +static enum action action = ACTION_NONE; +static char *log_file = NULL; +static FILE *fh_log = NULL; +/* Skip alternatives properly configured in auto mode (for --config) */ +static int opt_skip_auto = 0; +static int opt_verbose = OUTPUT_NORMAL; +static int opt_force = 0; + +/* + * Functions. + */ + +static void +version(void) +{ + printf(_("Debian %s version %s.\n"), PROGNAME, VERSION); + printf("\n"); + + printf(_( +"This is free software; see the GNU General Public License version 2 or\n" +"later for copying conditions. There is NO warranty.\n")); +} + +static void +usage(void) +{ + printf(_( +"Usage: %s [