aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-24 15:26:59 +0100
committerMax Kellermann <max@duempel.org>2009-01-24 15:26:59 +0100
commit3582977e01d19556dcc7e44a6b71628a9f0a1d02 (patch)
treeea9f7056e8cd7789c1c4ef4cad7baa515650d0ca /src
parentdaa5f5924d7406cc9d82ee893942f95e81c18cba (diff)
downloadmpd-3582977e01d19556dcc7e44a6b71628a9f0a1d02.tar.gz
mpd-3582977e01d19556dcc7e44a6b71628a9f0a1d02.tar.xz
mpd-3582977e01d19556dcc7e44a6b71628a9f0a1d02.zip
locate: no CamelCase
Renamed functions and variables.
Diffstat (limited to '')
-rw-r--r--src/command.c28
-rw-r--r--src/dbUtils.c14
-rw-r--r--src/locate.c93
-rw-r--r--src/locate.h24
-rw-r--r--src/queue_print.c6
5 files changed, 76 insertions, 89 deletions
diff --git a/src/command.c b/src/command.c
index cd47491ab..79a6fa7ba 100644
--- a/src/command.c
+++ b/src/command.c
@@ -834,7 +834,7 @@ handle_find(struct client *client, int argc, char *argv[])
{
int ret;
struct locate_item *items;
- int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
+ int numItems = locate_item_list_parse(argv + 1,
argc - 1,
&items);
@@ -848,7 +848,7 @@ handle_find(struct client *client, int argc, char *argv[])
command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found");
- freeLocateTagItemArray(numItems, items);
+ locate_item_list_free(numItems, items);
return ret;
}
@@ -858,7 +858,7 @@ handle_search(struct client *client, int argc, char *argv[])
{
int ret;
struct locate_item *items;
- int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
+ int numItems = locate_item_list_parse(argv + 1,
argc - 1,
&items);
@@ -872,7 +872,7 @@ handle_search(struct client *client, int argc, char *argv[])
command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found");
- freeLocateTagItemArray(numItems, items);
+ locate_item_list_free(numItems, items);
return ret;
}
@@ -882,7 +882,7 @@ handle_count(struct client *client, int argc, char *argv[])
{
int ret;
struct locate_item *items;
- int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
+ int numItems = locate_item_list_parse(argv + 1,
argc - 1,
&items);
@@ -896,7 +896,7 @@ handle_count(struct client *client, int argc, char *argv[])
command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found");
- freeLocateTagItemArray(numItems, items);
+ locate_item_list_free(numItems, items);
return ret;
}
@@ -905,7 +905,7 @@ static enum command_return
handle_playlistfind(struct client *client, int argc, char *argv[])
{
struct locate_item *items;
- int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
+ int numItems = locate_item_list_parse(argv + 1,
argc - 1,
&items);
@@ -916,7 +916,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
queue_find(client, playlist_get_queue(), numItems, items);
- freeLocateTagItemArray(numItems, items);
+ locate_item_list_free(numItems, items);
return COMMAND_RETURN_OK;
}
@@ -925,7 +925,7 @@ static enum command_return
handle_playlistsearch(struct client *client, int argc, char *argv[])
{
struct locate_item *items;
- int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
+ int numItems = locate_item_list_parse(argv + 1,
argc - 1,
&items);
@@ -936,7 +936,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
queue_search(client, playlist_get_queue(), numItems, items);
- freeLocateTagItemArray(numItems, items);
+ locate_item_list_free(numItems, items);
return COMMAND_RETURN_OK;
}
@@ -1113,7 +1113,7 @@ handle_list(struct client *client, int argc, char *argv[])
{
int numConditionals;
struct locate_item *conditionals = NULL;
- int tagType = getLocateTagItemType(argv[1]);
+ int tagType = locate_parse_type(argv[1]);
int ret;
if (tagType < 0) {
@@ -1135,12 +1135,12 @@ handle_list(struct client *client, int argc, char *argv[])
mpdTagItemKeys[TAG_ITEM_ALBUM]);
return COMMAND_RETURN_ERROR;
}
- conditionals = newLocateTagItem(mpdTagItemKeys[TAG_ITEM_ARTIST],
+ conditionals = locate_item_new(mpdTagItemKeys[TAG_ITEM_ARTIST],
argv[2]);
numConditionals = 1;
} else {
numConditionals =
- newLocateTagItemArrayFromArgArray(argv + 2,
+ locate_item_list_parse(argv + 2,
argc - 2, &conditionals);
if (numConditionals < 0) {
@@ -1153,7 +1153,7 @@ handle_list(struct client *client, int argc, char *argv[])
ret = listAllUniqueTags(client, tagType, numConditionals, conditionals);
if (conditionals)
- freeLocateTagItemArray(numConditionals, conditionals);
+ locate_item_list_free(numConditionals, conditionals);
if (ret == -1)
command_error(client, ACK_ERROR_NO_EXIST,
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 6bd0fe1af..bfe262b85 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -80,7 +80,7 @@ searchInDirectory(struct song *song, void *_data)
struct search_data *data = _data;
LocateTagItemArray *array = &data->array;
- if (strstrSearchTags(song, array->numItems, array->items))
+ if (locate_song_search(song, array->numItems, array->items))
return song_print_info(data->client, song);
return 0;
@@ -105,7 +105,7 @@ searchForSongsIn(struct client *client, const char *name,
ret = db_walk(name, searchInDirectory, NULL, &data);
- freeLocateTagItemArray(numItems, new_items);
+ locate_item_list_free(numItems, new_items);
return ret;
}
@@ -116,7 +116,7 @@ findInDirectory(struct song *song, void *_data)
struct search_data *data = _data;
LocateTagItemArray *array = &data->array;
- if (tagItemsFoundAndMatches(song, array->numItems, array->items))
+ if (locate_song_match(song, array->numItems, array->items))
return song_print_info(data->client, song);
return 0;
@@ -146,8 +146,8 @@ searchStatsInDirectory(struct song *song, void *data)
{
SearchStats *stats = data;
- if (tagItemsFoundAndMatches(song, stats->locateArray.numItems,
- stats->locateArray.items)) {
+ if (locate_song_match(song, stats->locateArray.numItems,
+ stats->locateArray.items)) {
stats->numberOfSongs++;
if (song->tag->time > 0)
stats->playTime += song->tag->time;
@@ -283,8 +283,8 @@ listUniqueTagsInDirectory(struct song *song, void *_data)
struct list_tags_data *data = _data;
ListCommandItem *item = data->item;
- if (tagItemsFoundAndMatches(song, item->numConditionals,
- item->conditionals)) {
+ if (locate_song_match(song, item->numConditionals,
+ item->conditionals)) {
visitTag(data->client, data->set, song, item->tagType);
}
diff --git a/src/locate.c b/src/locate.c
index dbb73a861..501153b4b 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -29,36 +29,32 @@
#define LOCATE_TAG_FILE_KEY_OLD "filename"
#define LOCATE_TAG_ANY_KEY "any"
-int getLocateTagItemType(const char *str)
+int
+locate_parse_type(const char *str)
{
int i;
if (0 == strcasecmp(str, LOCATE_TAG_FILE_KEY) ||
- 0 == strcasecmp(str, LOCATE_TAG_FILE_KEY_OLD))
- {
+ 0 == strcasecmp(str, LOCATE_TAG_FILE_KEY_OLD))
return LOCATE_TAG_FILE_TYPE;
- }
- if (0 == strcasecmp(str, LOCATE_TAG_ANY_KEY))
- {
+ if (0 == strcasecmp(str, LOCATE_TAG_ANY_KEY))
return LOCATE_TAG_ANY_TYPE;
- }
- for (i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
- {
+ for (i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (0 == strcasecmp(str, mpdTagItemKeys[i]))
return i;
- }
return -1;
}
-static int initLocateTagItem(struct locate_item *item,
- const char *typeStr, const char *needle)
+static int
+locate_item_init(struct locate_item *item,
+ const char *type_string, const char *needle)
{
- item->tagType = getLocateTagItemType(typeStr);
+ item->tag = locate_parse_type(type_string);
- if (item->tagType < 0)
+ if (item->tag < 0)
return -1;
item->needle = g_strdup(needle);
@@ -67,11 +63,11 @@ static int initLocateTagItem(struct locate_item *item,
}
struct locate_item *
-newLocateTagItem(const char *typeStr, const char *needle)
+locate_item_new(const char *type_string, const char *needle)
{
struct locate_item *ret = g_new(struct locate_item, 1);
- if (initLocateTagItem(ret, typeStr, needle) < 0) {
+ if (locate_item_init(ret, type_string, needle) < 0) {
free(ret);
ret = NULL;
}
@@ -79,7 +75,8 @@ newLocateTagItem(const char *typeStr, const char *needle)
return ret;
}
-void freeLocateTagItemArray(int count, struct locate_item *array)
+void
+locate_item_list_free(int count, struct locate_item *array)
{
int i;
@@ -90,27 +87,25 @@ void freeLocateTagItemArray(int count, struct locate_item *array)
}
int
-newLocateTagItemArrayFromArgArray(char *argArray[],
- int numArgs, struct locate_item **arrayRet)
+locate_item_list_parse(char *argv[], int argc, struct locate_item **arrayRet)
{
int i, j;
struct locate_item *item;
- if (numArgs == 0)
+ if (argc == 0)
return 0;
- if (numArgs % 2 != 0)
+ if (argc % 2 != 0)
return -1;
- *arrayRet = g_new(struct locate_item, numArgs / 2);
+ *arrayRet = g_new(struct locate_item, argc / 2);
- for (i = 0, item = *arrayRet; i < numArgs / 2; i++, item++) {
- if (initLocateTagItem
- (item, argArray[i * 2], argArray[i * 2 + 1]) < 0)
+ for (i = 0, item = *arrayRet; i < argc / 2; i++, item++) {
+ if (locate_item_init(item, argv[i * 2], argv[i * 2 + 1]) < 0)
goto fail;
}
- return numArgs / 2;
+ return argc / 2;
fail:
for (j = 0; j < i; j++) {
@@ -122,19 +117,20 @@ fail:
return -1;
}
-void freeLocateTagItem(struct locate_item *item)
+void
+locate_item_free(struct locate_item *item)
{
free(item->needle);
free(item);
}
static int
-strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
+locate_tag_search(const struct song *song, enum tag_type type, const char *str)
{
int i;
char *duplicate;
int ret = 0;
- int8_t visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 };
+ int8_t visited_types[TAG_NUM_OF_ITEM_TYPES] = { 0 };
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char *uri, *p;
@@ -154,7 +150,7 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
return 0;
for (i = 0; i < song->tag->numOfItems && !ret; i++) {
- visitedTypes[song->tag->items[i]->type] = 1;
+ visited_types[song->tag->items[i]->type] = 1;
if (type != LOCATE_TAG_ANY_TYPE &&
song->tag->items[i]->type != type) {
continue;
@@ -172,34 +168,28 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
* empty (first char is a \0), then it's a match as well and
* we should return 1.
*/
- if (!*str && !visitedTypes[type])
+ if (!*str && !visited_types[type])
return 1;
return ret;
}
int
-strstrSearchTags(const struct song *song, int numItems,
- const struct locate_item *items)
+locate_song_search(const struct song *song, int num_items,
+ const struct locate_item *items)
{
- int i;
-
- for (i = 0; i < numItems; i++) {
- if (!strstrSearchTag(song, items[i].tagType,
- items[i].needle)) {
+ for (int i = 0; i < num_items; i++)
+ if (!locate_tag_search(song, items[i].tag, items[i].needle))
return 0;
- }
- }
return 1;
}
static int
-tagItemFoundAndMatches(const struct song *song, enum tag_type type,
- const char *str)
+locate_tag_match(const struct song *song, enum tag_type type, const char *str)
{
int i;
- int8_t visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 };
+ int8_t visited_types[TAG_NUM_OF_ITEM_TYPES] = { 0 };
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char *uri = song_get_uri(song);
@@ -217,7 +207,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
return 0;
for (i = 0; i < song->tag->numOfItems; i++) {
- visitedTypes[song->tag->items[i]->type] = 1;
+ visited_types[song->tag->items[i]->type] = 1;
if (type != LOCATE_TAG_ANY_TYPE &&
song->tag->items[i]->type != type) {
continue;
@@ -233,7 +223,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
* empty (first char is a \0), then it's a match as well and
* we should return 1.
*/
- if (!*str && !visitedTypes[type])
+ if (!*str && !visited_types[type])
return 1;
return 0;
@@ -241,17 +231,12 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
int
-tagItemsFoundAndMatches(const struct song *song, int numItems,
- const struct locate_item *items)
+locate_song_match(const struct song *song, int num_items,
+ const struct locate_item *items)
{
- int i;
-
- for (i = 0; i < numItems; i++) {
- if (!tagItemFoundAndMatches(song, items[i].tagType,
- items[i].needle)) {
+ for (int i = 0; i < num_items; i++)
+ if (!locate_tag_match(song, items[i].tag, items[i].needle))
return 0;
- }
- }
return 1;
}
diff --git a/src/locate.h b/src/locate.h
index 3ae70ceab..92bedd90e 100644
--- a/src/locate.h
+++ b/src/locate.h
@@ -28,32 +28,34 @@ struct song;
/* struct used for search, find, list queries */
struct locate_item {
- int8_t tagType;
+ int8_t tag;
/* what we are looking for */
char *needle;
};
-int getLocateTagItemType(const char *str);
+int
+locate_parse_type(const char *str);
/* returns NULL if not a known type */
struct locate_item *
-newLocateTagItem(const char *typeString, const char *needle);
+locate_item_new(const char *type_string, const char *needle);
/* return number of items or -1 on error */
int
-newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
- struct locate_item **arrayRet);
+locate_item_list_parse(char *argv[], int argc, struct locate_item **arrayRet);
-void freeLocateTagItemArray(int count, struct locate_item *array);
+void
+locate_item_list_free(int count, struct locate_item *array);
-void freeLocateTagItem(struct locate_item *item);
+void
+locate_item_free(struct locate_item *item);
int
-strstrSearchTags(const struct song *song, int numItems,
- const struct locate_item *items);
+locate_song_search(const struct song *song, int numItems,
+ const struct locate_item *items);
int
-tagItemsFoundAndMatches(const struct song *song, int numItems,
- const struct locate_item *items);
+locate_song_match(const struct song *song, int numItems,
+ const struct locate_item *items);
#endif
diff --git a/src/queue_print.c b/src/queue_print.c
index b33c4f3ba..b7510a15d 100644
--- a/src/queue_print.c
+++ b/src/queue_print.c
@@ -93,11 +93,11 @@ queue_search(struct client *client, const struct queue *queue,
for (i = 0; i < queue_length(queue); i++) {
const struct song *song = queue_get(queue, i);
- if (strstrSearchTags(song, num_items, new_items))
+ if (locate_song_search(song, num_items, new_items))
queue_print_song_info(client, queue, i);
}
- freeLocateTagItemArray(num_items, new_items);
+ locate_item_list_free(num_items, new_items);
}
void
@@ -107,7 +107,7 @@ queue_find(struct client *client, const struct queue *queue,
for (unsigned i = 0; i < queue_length(queue); i++) {
const struct song *song = queue_get(queue, i);
- if (tagItemsFoundAndMatches(song, num_items, items))
+ if (locate_song_match(song, num_items, items))
queue_print_song_info(client, queue, i);
}
}