Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Turn pkg_emit_manifest into a stub that calls pkg_emit_manuifest2
Baptiste Daroussin committed 13 years ago
commit b275896b279db7e1a5512b7c59b96d41f594864f
parent e3b979d
2 files changed +23 -4
modified libpkg/pkg_manifest.c
@@ -722,6 +722,26 @@ manifest_append_seqval(yaml_document_t *doc, int parent, int *seq,
int
pkg_emit_manifest(struct pkg *pkg, char **dest, bool compact)
{
+
	struct sbuf *b = sbuf_new_auto();
+
	int rc;
+

+
	rc = pkg_emit_manifest2(pkg, b, compact);
+

+
	if (rc != EPKG_OK) {
+
		sbuf_delete(b);
+
		return (rc);
+
	}
+

+
	sbuf_finish(b);
+
	*dest = strdup(sbuf_get(b));
+
	sbuf_delete(b);
+

+
	return (rc);
+
}
+

+
int
+
pkg_emit_manifest2(struct pkg *pkg, struct sbuf *destbuf, bool compact)
+
{
	yaml_emitter_t emitter;
	yaml_document_t doc;
	char tmpbuf[BUFSIZ];
@@ -743,13 +763,13 @@ pkg_emit_manifest(struct pkg *pkg, char **dest, bool compact)
	int i;
/*	int users = -1;
	int groups = -1;*/
-
	struct sbuf *destbuf = sbuf_new_auto();
	const char *comment, *desc, *infos, *message, *name, *pkgarch;
	const char *pkgmaintainer, *pkgorigin, *prefix, *version, *www;
	const char *script_types = NULL;
	lic_t licenselogic;
	int64_t flatsize;

+
	sbuf_reset(destbuf);
	yaml_emitter_initialize(&emitter);
	yaml_emitter_set_unicode(&emitter, 1);
	yaml_emitter_set_output(&emitter, yaml_write_buf, destbuf);
@@ -933,9 +953,6 @@ pkg_emit_manifest(struct pkg *pkg, char **dest, bool compact)
		rc = EPKG_FATAL;

	sbuf_free(tmpsbuf);
-
	sbuf_finish(destbuf);
-
	*dest = strdup(sbuf_get(destbuf));
-
	sbuf_delete(destbuf);

	yaml_emitter_delete(&emitter);
	return (rc);
modified libpkg/private/pkg.h
@@ -383,4 +383,6 @@ int pkg_register_shlibs(struct pkg *pkg);

void pkg_config_parse(yaml_document_t *doc, yaml_node_t *node, struct pkg_config *conf_by_key);

+
int pkg_emit_manifest2(struct pkg*, struct sbuf *, bool);
+

#endif