playlist_print: use bool instead of int
Return true on success, instead of 0. Converted the "detail" parameter to bool.
This commit is contained in:
parent
f817285922
commit
60bec77664
|
@ -686,26 +686,30 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
static enum command_return
|
static enum command_return
|
||||||
handle_listplaylist(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
handle_listplaylist(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
bool ret;
|
||||||
|
|
||||||
ret = spl_print(client, argv[1], 0);
|
ret = spl_print(client, argv[1], false);
|
||||||
if (ret == -1)
|
if (!ret) {
|
||||||
command_error(client, ACK_ERROR_NO_EXIST, "No such playlist");
|
command_error(client, ACK_ERROR_NO_EXIST, "No such playlist");
|
||||||
|
return COMMAND_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return COMMAND_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum command_return
|
static enum command_return
|
||||||
handle_listplaylistinfo(struct client *client,
|
handle_listplaylistinfo(struct client *client,
|
||||||
G_GNUC_UNUSED int argc, char *argv[])
|
G_GNUC_UNUSED int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
bool ret;
|
||||||
|
|
||||||
ret = spl_print(client, argv[1], 1);
|
ret = spl_print(client, argv[1], true);
|
||||||
if (ret == -1)
|
if (!ret) {
|
||||||
command_error(client, ACK_ERROR_NO_EXIST, "No such playlist");
|
command_error(client, ACK_ERROR_NO_EXIST, "No such playlist");
|
||||||
|
return COMMAND_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return COMMAND_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum command_return
|
static enum command_return
|
||||||
|
|
|
@ -23,24 +23,24 @@
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
int
|
bool
|
||||||
spl_print(struct client *client, const char *name_utf8, int detail)
|
spl_print(struct client *client, const char *name_utf8, bool detail)
|
||||||
{
|
{
|
||||||
GPtrArray *list;
|
GPtrArray *list;
|
||||||
|
|
||||||
list = spl_load(name_utf8);
|
list = spl_load(name_utf8);
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return -1;
|
return false;
|
||||||
|
|
||||||
for (unsigned i = 0; i < list->len; ++i) {
|
for (unsigned i = 0; i < list->len; ++i) {
|
||||||
const char *temp = g_ptr_array_index(list, i);
|
const char *temp = g_ptr_array_index(list, i);
|
||||||
int wrote = 0;
|
bool wrote = false;
|
||||||
|
|
||||||
if (detail) {
|
if (detail) {
|
||||||
struct song *song = db_get_song(temp);
|
struct song *song = db_get_song(temp);
|
||||||
if (song) {
|
if (song) {
|
||||||
song_print_info(client, song);
|
song_print_info(client, song);
|
||||||
wrote = 1;
|
wrote = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,5 +50,5 @@ spl_print(struct client *client, const char *name_utf8, int detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_free(list);
|
spl_free(list);
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
#ifndef PLAYLIST_PRINT_H
|
#ifndef PLAYLIST_PRINT_H
|
||||||
#define PLAYLIST_PRINT_H
|
#define PLAYLIST_PRINT_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
|
|
||||||
int
|
bool
|
||||||
spl_print(struct client *client, const char *name_utf8, int detail);
|
spl_print(struct client *client, const char *name_utf8, bool detail);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue