Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Two new functions to add default_value or description to a pre-existing struct pkg_option for the same option key.
Matthew Seaman committed 12 years ago
commit 206bdcace312c92c5bd94b06e5d50770014fad6b
parent a032d5f
2 files changed +56 -0
modified libpkg/pkg.c
@@ -853,6 +853,48 @@ pkg_addoption(struct pkg *pkg, const char *key, const char *value)
}

int
+
pkg_addoption_default(struct pkg *pkg, const char *key,
+
		      const char *default_value)
+
{
+
	struct pkg_option *o = NULL;
+

+
	assert(pkg != NULL);
+
	assert(key != NULL && key[0] != '\0');
+
	assert(default_value != NULL && default_value[0] != '\0');
+

+
	HASH_FIND_STR(pkg->options, __DECONST(char *, key), o);
+
	if (o == NULL) {
+
		pkg_emit_error("default value for unknown option: %s, ignoring",
+
			       key);
+
		return (EPKG_OK);
+
	}
+

+
	sbuf_set(&o->default_value, default_value);
+
}
+

+
int
+
pkg_addoption_description(struct pkg *pkg, const char *key,
+
			  const char *description)
+
{
+
	struct pkg_option *o = NULL;
+

+
	assert(pkg != NULL);
+
	assert(key != NULL && key[0] != '\0');
+
	assert(description != NULL && description[0] != '\0');
+

+
	HASH_FIND_STR(pkg->options, __DECONST(char *, key), o);
+
	if (o == NULL) {
+
		pkg_emit_error("description for unknown option: %s, ignoring",
+
			       key);
+
		return (EPKG_OK);
+
	}
+

+
	sbuf_set(&o->description, description);
+

+
	return (EPKG_OK);
+
}
+

+
int
pkg_addshlib_required(struct pkg *pkg, const char *name)
{
	struct pkg_shlib *s = NULL;
modified libpkg/pkg.h.in
@@ -785,6 +785,20 @@ int pkg_appendscript(struct pkg *pkg, const char *cmd, pkg_script type);
int pkg_addoption(struct pkg *pkg, const char *name, const char *value);

/**
+
 * Add a default value to an already exsting struct pkg_option
+
 * @return An error code.
+
 */
+
int pkg_addoption_default(struct pkg *pkg, const char *key,
+
			  const char *default_value);
+

+
/**
+
 * Add a description to an already exsting struct pkg_option
+
 * @return An error code.
+
 */
+
int pkg_addoption_description(struct pkg *pkg, const char *key,
+
			      const char *description);
+

+
/**
 * Add a shared library used by this package
 * @return An error code.
 */