From dadf1339b57d76057b7a66dce7d3b7b2f7d796f6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 5 Sep 2011 23:12:33 +0200 Subject: [PATCH] dbUtils: pass player_control to findAddIn() Allow calling findAddIn() without a client object. --- src/command.c | 2 +- src/dbUtils.c | 19 ++++++++++++------- src/dbUtils.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/command.c b/src/command.c index 3e60e0ac3..dfa3688e0 100644 --- a/src/command.c +++ b/src/command.c @@ -956,7 +956,7 @@ handle_findadd(struct client *client, int argc, char *argv[]) return COMMAND_RETURN_ERROR; } - ret = findAddIn(client, NULL, list); + ret = findAddIn(client->player_control, NULL, list); if (ret == -1) command_error(client, ACK_ERROR_NO_EXIST, "directory or file not found"); diff --git a/src/dbUtils.c b/src/dbUtils.c index 9a44b314b..6ef1f6aa9 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -203,25 +203,30 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file) return db_walk(name, directoryAddSongToStoredPlaylist, NULL, &data); } +struct find_add_data { + struct player_control *pc; + const struct locate_item_list *criteria; +}; + static int findAddInDirectory(struct song *song, void *_data) { - struct search_data *data = _data; + struct find_add_data *data = _data; if (locate_song_match(song, data->criteria)) return playlist_append_song(&g_playlist, - data->client->player_control, + data->pc, song, NULL); return 0; } -int findAddIn(struct client *client, const char *name, - const struct locate_item_list *criteria) +int +findAddIn(struct player_control *pc, const char *name, + const struct locate_item_list *criteria) { - struct search_data data; - - data.client = client; + struct find_add_data data; + data.pc = pc; data.criteria = criteria; return db_walk(name, findAddInDirectory, NULL, &data); diff --git a/src/dbUtils.h b/src/dbUtils.h index 5de8af5c9..96ea2095d 100644 --- a/src/dbUtils.h +++ b/src/dbUtils.h @@ -42,7 +42,7 @@ findSongsIn(struct client *client, const char *name, const struct locate_item_list *criteria); int -findAddIn(struct client *client, const char *name, +findAddIn(struct player_control *pc, const char *name, const struct locate_item_list *criteria); int