コード例 #1
0
ファイル: lmc.c プロジェクト: L0op/RuneAudioNext
static char *
connection_settings_name(const struct mpd_connection *connection)
{
#if LIBMPDCLIENT_CHECK_VERSION(2,4,0)
	const struct mpd_settings *settings =
		mpd_connection_get_settings(connection);
	if (settings == NULL)
		return g_strdup("unknown");

	return settings_name(settings);
#else
	(void)connection;
	return g_strdup(g_host);
#endif
}
コード例 #2
0
ファイル: main.c プロジェクト: djrtl/ncmpc-dj
static char *
default_settings_name(void)
{
#if LIBMPDCLIENT_CHECK_VERSION(2,4,0)
	struct mpd_settings *settings =
		mpd_settings_new(options.host, options.port, 0,
				 NULL, options.password);
	if (settings == NULL)
		return g_strdup(_("unknown"));

	char *name = settings_name(settings);
	mpd_settings_free(settings);

	return name;
#else
	/*
	 * localhost is actually not correct, we only know that
	 * mpd_connection_new() has connected to the "default host".
	 */
	const char *name = options.host ?: "localhost";
	return g_strdup(name);
#endif
}