Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add three new pkg_printf() formats:
Matthew Seaman committed 12 years ago
commit 6abc372e540b2074484b1b2f5477dfdd07af1ca5
parent c4d29d0
2 files changed +75 -5
modified libpkg/pkg_printf.c
@@ -95,8 +95,8 @@
 *
 * P
 * Q
-
 * R
 *
+
 * R  pkg          Repopath
 * S  char*        Arbitrary character string
 *
 * T
@@ -105,7 +105,7 @@
 * Un pkg_user     User name
 * Uu pkg_user     uidstr (parse this using pw_scan()?)
 *
-
 * V
+
 * V  pkg          old version
 * W
 * X
 * Y
@@ -147,9 +147,7 @@
 *
 * s  pkg          flatsize
 * t  pkg          install timestamp
-
 *
-
 * u
-
 *
+
 * u  pkg          checksum
 * v  pkg          version
 * w  pkg          home page URL
 *
@@ -453,6 +451,15 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_PKG,
		&format_options,
	},
+
	[PP_PKG_REPO_PATH] =
+
	{
+
		'R',
+
		'\0',
+
		false,
+
		true,
+
		PP_ALL,
+
		&format_repo_path,
+
	},
	[PP_PKG_CHAR_STRING] =
	{
		'S',
@@ -489,6 +496,15 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_PKG,
		&format_users,
	},
+
	[PP_PKG_OLD_VERSION] =
+
	{
+
		'V',
+
		'\0',
+
		false,
+
		true,
+
		PP_ALL,
+
		&format_old_version,
+
	},
	[PP_PKG_AUTOREMOVE] =
	{
		'a',
@@ -704,6 +720,15 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_ALL,
		&format_install_tstamp,
	},
+
	[PP_PKG_CHECKSUM] =
+
	{
+
		'u',
+
		'\0',
+
		false,
+
		true,
+
		PP_ALL,
+
		&format_checksum,
+
	},
	[PP_PKG_VERSION] =
	{
		'v',
@@ -1285,6 +1310,19 @@ format_option_value(struct sbuf *sbuf, const void *data, struct percent_esc *p)
}

/*
+
 * %R -- Repo path. string.
+
 */
+
struct sbuf *
+
format_repo_path(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
{
+
	const struct pkg	*pkg = data;
+
	const char		*repo_path;
+

+
	pkg_get(pkg, PKG_REPOPATH, &repo_path);
+
	return (string_val(sbuf, repo_path, p));
+
}
+

+
/*
 * %S -- Character string.
 */
struct sbuf *
@@ -1351,6 +1389,19 @@ format_user_uidstr(struct sbuf *sbuf, const void *data, struct percent_esc *p)
}

/*
+
 * %V -- Old package version. string. Accepts field width, left align
+
 */
+
struct sbuf *
+
format_old_version(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
{
+
	const struct pkg	*pkg = data;
+
	const char		*old_version;
+

+
	pkg_get(pkg, PKG_OLD_VERSION, &old_version);
+
	return (string_val(sbuf, old_version, p));
+
}
+

+
/*
 * %a -- Autoremove flag. boolean.  Accepts field-width, left-align.
 * Standard form: 0, 1.  Alternate form1: no, yes.  Alternate form2:
 * false, true
@@ -1688,6 +1739,19 @@ format_version(struct sbuf *sbuf, const void *data, struct percent_esc *p)
}

/*
+
 * %u -- Package checksum. string. Accepts field width, left align
+
 */
+
struct sbuf *
+
format_checksum(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
{
+
	const struct pkg	*pkg = data;
+
	const char		*checksum;
+

+
	pkg_get(pkg, PKG_CKSUM, &checksum);
+
	return (string_val(sbuf, checksum, p));
+
}
+

+
/*
 * %w -- Home page URL.  string.  Accepts field width, left align
 */
struct sbuf *
modified libpkg/private/pkg_printf.h
@@ -105,10 +105,12 @@ typedef enum _fmt_code_t {
	PP_PKG_OPTION_NAME,
	PP_PKG_OPTION_VALUE,
	PP_PKG_OPTIONS,
+
	PP_PKG_REPO_PATH,
	PP_PKG_CHAR_STRING,
	PP_PKG_USER_NAME,
	PP_PKG_USER_UIDSTR,
	PP_PKG_USERS,
+
	PP_PKG_OLD_VERSION,
	PP_PKG_AUTOREMOVE,
	PP_PKG_SHLIB_PROVIDED_NAME,
	PP_PKG_SHLIBS_PROVIDED,
@@ -133,6 +135,7 @@ typedef enum _fmt_code_t {
	PP_PKG_REQUIREMENTS,
	PP_PKG_FLATSIZE,
	PP_PKG_INSTALL_TIMESTAMP,
+
	PP_PKG_CHECKSUM,
	PP_PKG_VERSION,
	PP_PKG_HOME_PAGE,
	PP_LAST_FORMAT = PP_PKG_HOME_PAGE,
@@ -186,10 +189,12 @@ _static struct sbuf *format_message(struct sbuf *, const void *, struct percent_
_static struct sbuf *format_options(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_name(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_value(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_repo_path(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_char_string(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_users(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_user_name(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_user_uidstr(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_old_version(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_autoremove(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_shlibs_provided(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_comment(struct sbuf *, const void *, struct percent_esc *);
@@ -209,6 +214,7 @@ _static struct sbuf *format_architecture(struct sbuf *, const void *, struct per
_static struct sbuf *format_requirements(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_flatsize(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_install_tstamp(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_checksum(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_version(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_home_url(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_literal_percent(struct sbuf *, __unused const void *, __unused struct percent_esc *);