Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Jan 2022 21:35:50 +0000
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        Baptiste Daroussin <bapt@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 18f20d5d967a - main - bsddialog: convert bsdinstall/distextract
Message-ID:  <41538126-67AC-4C19-9414-BD4E8B85D23B@freebsd.org>
In-Reply-To: <202201012052.201KqrhV082129@gitrepo.freebsd.org>
References:  <202201012052.201KqrhV082129@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1 Jan 2022, at 20:52, Baptiste Daroussin <bapt@FreeBSD.org> wrote:
>=20
> The branch main has been updated by bapt:
>=20
> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3D18f20d5d967ae790f121963e1fcee68d=
729a529e
>=20
> commit 18f20d5d967ae790f121963e1fcee68d729a529e
> Author:     Alfonso Siciliano <alfsiciliano@gmail.com>
> AuthorDate: 2022-01-01 20:50:44 +0000
> Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
> CommitDate: 2022-01-01 20:51:23 +0000
>=20
>    bsddialog: convert bsdinstall/distextract
>=20
>    Differential Revision:  https://reviews.freebsd.org/D33581
> ---
> usr.sbin/bsdinstall/distextract/Makefile      |   3 +-
> usr.sbin/bsdinstall/distextract/distextract.c | 180 =
+++++++++++++-------------
> 2 files changed, 92 insertions(+), 91 deletions(-)
>=20
> diff --git a/usr.sbin/bsdinstall/distextract/Makefile =
b/usr.sbin/bsdinstall/distextract/Makefile
> index 2b7180e28ea0..5e9f2b9e1473 100644
> --- a/usr.sbin/bsdinstall/distextract/Makefile
> +++ b/usr.sbin/bsdinstall/distextract/Makefile
> @@ -2,7 +2,8 @@
>=20
> BINDIR=3D ${LIBEXECDIR}/bsdinstall
> PROG=3D	distextract
> -LIBADD=3D	archive dpv dialog m
> +CFLAGS+=3D -I${SRCTOP}/contrib/bsddialog/lib
> +LIBADD=3D	archive bsddialog m
>=20
> MAN=3D
>=20
> diff --git a/usr.sbin/bsdinstall/distextract/distextract.c =
b/usr.sbin/bsdinstall/distextract/distextract.c
> index 8ad6c7b2c64b..df10c299ab7f 100644
> --- a/usr.sbin/bsdinstall/distextract/distextract.c
> +++ b/usr.sbin/bsdinstall/distextract/distextract.c
> @@ -33,11 +33,12 @@ __FBSDID("$FreeBSD$");
> #include <sys/param.h>
> #include <archive.h>
> #include <ctype.h>
> -#include <dialog.h>
> -#include <dpv.h>
> +#include <bsddialog.h>
> +#include <bsddialog_progressview.h>
> #include <err.h>
> #include <errno.h>
> #include <limits.h>
> +#include <signal.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> @@ -46,30 +47,27 @@ __FBSDID("$FreeBSD$");
> /* Data to process */
> static char *distdir =3D NULL;
> static struct archive *archive =3D NULL;
> -static struct dpv_file_node *dists =3D NULL;
>=20
> /* Function prototypes */
> static void	sig_int(int sig);
> static int	count_files(const char *file);
> -static int	extract_files(struct dpv_file_node *file, int out);
> +static int	extract_files(struct bsddialog_fileminibar *file);
>=20
> -#define _errx(...) (end_dialog(), errx(__VA_ARGS__))
> +#define _errx(...) (bsddialog_end(), errx(__VA_ARGS__))
>=20
> int
> main(void)
> {
> 	char *chrootdir;
> 	char *distributions;
> +	unsigned int i;
> 	int retval;
> -	size_t config_size =3D sizeof(struct dpv_config);
> -	size_t file_node_size =3D sizeof(struct dpv_file_node);
> +	size_t minibar_size =3D sizeof(struct bsddialog_fileminibar);
> 	size_t span;
> -	struct dpv_config *config;
> -	struct dpv_file_node *dist =3D dists;
> -	static char backtitle[] =3D "FreeBSD Installer";
> -	static char title[] =3D "Archive Extraction";
> -	static char aprompt[] =3D "\n  Overall Progress:";
> -	static char pprompt[] =3D "Extracting distribution files...\n";
> +	unsigned int nminibars;
> +	struct bsddialog_fileminibar *dists;
> +	struct bsddialog_progviewconf pvconf;
> +	struct bsddialog_conf conf;
> 	struct sigaction act;
> 	char error[PATH_MAX + 512];
>=20
> @@ -78,17 +76,17 @@ main(void)
> 	if ((distdir =3D getenv("BSDINSTALL_DISTDIR")) =3D=3D NULL)
> 		distdir =3D __DECONST(char *, "");
>=20
> -	/* Initialize dialog(3) */
> -	init_dialog(stdin, stdout);
> -	dialog_vars.backtitle =3D backtitle;
> -	dlg_put_backtitle();
> -
> -	dialog_msgbox("",
> -	    "Checking distribution archives.\nPlease wait...", 4, 35, =
FALSE);
> -
> -	/*
> -	 * Parse $DISTRIBUTIONS into dpv(3) linked-list
> -	 */
> +	if (bsddialog_init() =3D=3D BSDDIALOG_ERROR)
> +		errx(EXIT_FAILURE, "Cannot init libbsdialog");
> +	bsddialog_initconf(&conf);
> +	bsddialog_backtitle(&conf, __DECONST(char *, "FreeBSD =
Installer"));

Can all these interfaces really not just use a const char * rather than
having to scatter __DECONST everywhere if you want to pass a string
literal to functions like this? There are quite a few __DECONST=E2=80=99s =
of
string literals in this patch alone...

Jess




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41538126-67AC-4C19-9414-BD4E8B85D23B>