コード例 #1
0
ファイル: test_missing_name.c プロジェクト: loki42/Carla
int
main(int argc, char** argv)
{
	if (argc != 2) {
		fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
		return 1;
	}

	const char* bundle_path = argv[1];
	LilvWorld*  world       = lilv_world_new();

	// Load test plugin bundle
	uint8_t*  abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
	SerdNode  bundle     = serd_node_new_file_uri(abs_bundle, 0, 0, true);
	LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
	lilv_world_load_bundle(world, bundle_uri);
	free(abs_bundle);
	serd_node_free(&bundle);

	LilvNode*          plugin_uri = lilv_new_uri(world, PLUGIN_URI);
	const LilvPlugins* plugins    = lilv_world_get_all_plugins(world);
	const LilvPlugin*  plugin     = lilv_plugins_get_by_uri(plugins, plugin_uri);
	TEST_ASSERT(plugin);

	LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
	TEST_ASSERT(instance);

	lilv_world_free(world);

	return 0;
}
コード例 #2
0
ファイル: state.c プロジェクト: dmlloyd/Carla
static char*
absolute_dir(const char* path)
{
	char* abs_path = lilv_path_absolute(path);
	char* base     = lilv_path_join(abs_path, NULL);
	free(abs_path);
	return base;
}
コード例 #3
0
ファイル: node.c プロジェクト: falkTX/Carla
LILV_API LilvNode*
lilv_new_file_uri(LilvWorld* world, const char* host, const char* path)
{
	char*    abs_path = lilv_path_absolute(path);
	SerdNode s        = serd_node_new_file_uri(
		(const uint8_t*)abs_path, (const uint8_t*)host, NULL, true);

	LilvNode* ret = lilv_node_new(world, LILV_VALUE_URI, (const char*)s.buf);
	serd_node_free(&s);
	free(abs_path);
	return ret;
}
コード例 #4
0
ファイル: state.c プロジェクト: dmlloyd/Carla
LILV_API
LilvState*
lilv_state_new_from_file(LilvWorld*          world,
                         const LV2_URID_Map* map,
                         const LilvNode*     subject,
                         const char*         path)
{
	if (subject && !lilv_node_is_uri(subject)
	    && !lilv_node_is_blank(subject)) {
		LILV_ERRORF("Subject `%s' is not a URI or blank node.\n",
		            lilv_node_as_string(subject));
		return NULL;
	}

	uint8_t*    abs_path = (uint8_t*)lilv_path_absolute(path);
	SerdNode    node     = serd_node_new_file_uri(abs_path, NULL, NULL, 0);
	SerdEnv*    env      = serd_env_new(&node);
	SordModel*  model    = sord_new(world->world, SORD_SPO, false);
	SerdReader* reader   = sord_new_reader(model, env, SERD_TURTLE, NULL);

	serd_reader_read_file(reader, node.buf);

	SordNode* subject_node = (subject)
		? subject->node
		: sord_node_from_serd_node(world->world, env, &node, NULL, NULL);

	char* dirname   = lilv_dirname(path);
	char* real_path = lilv_realpath(dirname);
	LilvState* state = new_state_from_model(
		world, map, model, subject_node, real_path);
	free(dirname);
	free(real_path);

	serd_node_free(&node);
	free(abs_path);
	serd_reader_free(reader);
	sord_free(model);
	serd_env_free(env);
	return state;
}