Beispiel #1
0
static int
parse_sequence(struct pkg * pkg, yaml_node_t *node, yaml_document_t *doc, int attr)
{
	yaml_node_item_t *item;
	yaml_node_t *val;

	item = node->data.sequence.items.start;
	while (item < node->data.sequence.items.top) {
		val = yaml_document_get_node(doc, *item);
		switch (attr) {
			case PKG_CONFLICTS:
				if (val->type != YAML_SCALAR_NODE || val->data.scalar.length <= 0)
					pkg_emit_error("Skipping malformed conflict");
				else
					pkg_addconflict(pkg, val->data.scalar.value);
				break;
			case PKG_CATEGORIES:
				if (val->type != YAML_SCALAR_NODE || val->data.scalar.length <= 0)
					pkg_emit_error("Skipping malformed category");
				else
					pkg_addcategory(pkg, val->data.scalar.value);
				break;
			case PKG_LICENSES:
				if (val->type != YAML_SCALAR_NODE || val->data.scalar.length <= 0)
					pkg_emit_error("Skipping malformed license");
				else
					pkg_addlicense(pkg, val->data.scalar.value);
				break;
			case PKG_USERS:
				if (val->type != YAML_SCALAR_NODE || val->data.scalar.length <= 0)
					pkg_emit_error("Skipping malformed license");
				else
					pkg_adduser(pkg, val->data.scalar.value);
				break;
			case PKG_GROUPS:
				if (val->type != YAML_SCALAR_NODE || val->data.scalar.length <= 0)
					pkg_emit_error("Skipping malformed license");
				else
					pkg_addgroup(pkg, val->data.scalar.value);
				break;
			case PKG_DIRS:
				if (val->type == YAML_SCALAR_NODE && val->data.scalar.length > 0)
					pkg_adddir(pkg, val->data.scalar.value, 1);
				else if (val->type == YAML_MAPPING_NODE)
					parse_mapping(pkg, val, doc, attr);
				else
					pkg_emit_error("Skipping malformed dirs");
		}
		++item;
	}
	return (EPKG_OK);
}
Beispiel #2
0
static int
pkg_array(struct pkg *pkg, ucl_object_t *obj, int attr)
{
	ucl_object_t *cur;
	ucl_object_iter_t it = NULL;

	pkg_debug(3, "%s", "Manifest: parsing array");
	while ((cur = ucl_iterate_object(obj, &it, true))) {
		switch (attr) {
		case PKG_CATEGORIES:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed category");
			else
				pkg_addcategory(pkg, ucl_object_tostring(cur));
			break;
		case PKG_LICENSES:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed license");
			else
				pkg_addlicense(pkg, ucl_object_tostring(cur));
			break;
		case PKG_USERS:
			if (cur->type == UCL_STRING)
				pkg_adduser(pkg, ucl_object_tostring(cur));
			else if (cur->type == UCL_OBJECT)
				pkg_object(pkg, cur, attr);
			else
				pkg_emit_error("Skipping malformed license");
			break;
		case PKG_GROUPS:
			if (cur->type == UCL_STRING)
				pkg_addgroup(pkg, ucl_object_tostring(cur));
			else if (cur->type == UCL_OBJECT)
				pkg_object(pkg, cur, attr);
			else
				pkg_emit_error("Skipping malformed license");
			break;
		case PKG_DIRS:
			if (cur->type == UCL_STRING)
				pkg_adddir(pkg, ucl_object_tostring(cur), 1, false);
			else if (cur->type == UCL_OBJECT)
				pkg_object(pkg, cur, attr);
			else
				pkg_emit_error("Skipping malformed dirs");
			break;
		case PKG_SHLIBS_REQUIRED:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed required shared library");
			else
				pkg_addshlib_required(pkg, ucl_object_tostring(cur));
			break;
		case PKG_SHLIBS_PROVIDED:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed provided shared library");
			else
				pkg_addshlib_provided(pkg, ucl_object_tostring(cur));
			break;
		case PKG_CONFLICTS:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed conflict name");
			else
				pkg_addconflict(pkg, ucl_object_tostring(cur));
			break;
		case PKG_PROVIDES:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed provide name");
			else
				pkg_addprovide(pkg, ucl_object_tostring(cur));
			break;
		}
	}

	return (EPKG_OK);
}
Beispiel #3
0
static int
parse_sequence(struct pkg * pkg, yaml_node_t *node, yaml_document_t *doc,
    int attr)
{
	yaml_node_item_t *item;
	yaml_node_t *val;

	item = node->data.sequence.items.start;
	while (item < node->data.sequence.items.top) {
		val = yaml_document_get_node(doc, *item);
		switch (attr) {
		case PKG_CATEGORIES:
			if (!is_valid_yaml_scalar(val))
				pkg_emit_error("Skipping malformed category");
			else
				pkg_addcategory(pkg, val->data.scalar.value);
			break;
		case PKG_LICENSES:
			if (!is_valid_yaml_scalar(val))
				pkg_emit_error("Skipping malformed license");
			else
				pkg_addlicense(pkg, val->data.scalar.value);
			break;
		case PKG_USERS:
			if (is_valid_yaml_scalar(val))
				pkg_adduser(pkg, val->data.scalar.value);
			else if (val->type == YAML_MAPPING_NODE)
				parse_mapping(pkg, val, doc, attr);
			else
				pkg_emit_error("Skipping malformed license");
			break;
		case PKG_GROUPS:
			if (is_valid_yaml_scalar(val))
				pkg_addgroup(pkg, val->data.scalar.value);
			else if (val->type == YAML_MAPPING_NODE)
				parse_mapping(pkg, val, doc, attr);
			else
				pkg_emit_error("Skipping malformed license");
			break;
		case PKG_DIRS:
			if (is_valid_yaml_scalar(val))
				pkg_adddir(pkg, val->data.scalar.value, 1, false);
			else if (val->type == YAML_MAPPING_NODE)
				parse_mapping(pkg, val, doc, attr);
			else
				pkg_emit_error("Skipping malformed dirs");
			break;
		case PKG_SHLIBS_REQUIRED:
			if (!is_valid_yaml_scalar(val))
				pkg_emit_error("Skipping malformed required shared library");
			else
				pkg_addshlib_required(pkg, val->data.scalar.value);
			break;
		case PKG_SHLIBS_PROVIDED:
			if (!is_valid_yaml_scalar(val))
				pkg_emit_error("Skipping malformed provided shared library");
			else
				pkg_addshlib_provided(pkg, val->data.scalar.value);
			break;
		}
		++item;
	}
	return (EPKG_OK);
}