locate: renamed LocateTagItem to "struct locate_item"

No CamelCase and no typedefs.
This commit is contained in:
Max Kellermann 2009-01-24 14:52:05 +01:00
parent 627d590ce5
commit 53e712aca4
7 changed files with 70 additions and 60 deletions

View File

@ -34,6 +34,7 @@
#include "stored_playlist.h" #include "stored_playlist.h"
#include "ack.h" #include "ack.h"
#include "audio.h" #include "audio.h"
#include "locate.h"
#include "dbUtils.h" #include "dbUtils.h"
#include "tag.h" #include "tag.h"
#include "client.h" #include "client.h"
@ -832,8 +833,7 @@ static enum command_return
handle_find(struct client *client, int argc, char *argv[]) handle_find(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
struct locate_item *items;
LocateTagItem *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1, argc - 1,
&items); &items);
@ -857,8 +857,7 @@ static enum command_return
handle_search(struct client *client, int argc, char *argv[]) handle_search(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
struct locate_item *items;
LocateTagItem *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1, argc - 1,
&items); &items);
@ -882,8 +881,7 @@ static enum command_return
handle_count(struct client *client, int argc, char *argv[]) handle_count(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
struct locate_item *items;
LocateTagItem *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1, argc - 1,
&items); &items);
@ -906,7 +904,7 @@ handle_count(struct client *client, int argc, char *argv[])
static enum command_return static enum command_return
handle_playlistfind(struct client *client, int argc, char *argv[]) handle_playlistfind(struct client *client, int argc, char *argv[])
{ {
LocateTagItem *items; struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1, argc - 1,
&items); &items);
@ -926,7 +924,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
static enum command_return static enum command_return
handle_playlistsearch(struct client *client, int argc, char *argv[]) handle_playlistsearch(struct client *client, int argc, char *argv[])
{ {
LocateTagItem *items; struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1, argc - 1,
&items); &items);
@ -1114,7 +1112,7 @@ static enum command_return
handle_list(struct client *client, int argc, char *argv[]) handle_list(struct client *client, int argc, char *argv[])
{ {
int numConditionals; int numConditionals;
LocateTagItem *conditionals = NULL; struct locate_item *conditionals = NULL;
int tagType = getLocateTagItemType(argv[1]); int tagType = getLocateTagItemType(argv[1]);
int ret; int ret;

View File

@ -17,7 +17,7 @@
*/ */
#include "dbUtils.h" #include "dbUtils.h"
#include "locate.h"
#include "directory.h" #include "directory.h"
#include "database.h" #include "database.h"
#include "client.h" #include "client.h"
@ -36,12 +36,12 @@
typedef struct _ListCommandItem { typedef struct _ListCommandItem {
int8_t tagType; int8_t tagType;
int numConditionals; int numConditionals;
const LocateTagItem *conditionals; const struct locate_item *conditionals;
} ListCommandItem; } ListCommandItem;
typedef struct _LocateTagItemArray { typedef struct _LocateTagItemArray {
int numItems; int numItems;
const LocateTagItem *items; const struct locate_item *items;
} LocateTagItemArray; } LocateTagItemArray;
typedef struct _SearchStats { typedef struct _SearchStats {
@ -86,13 +86,14 @@ searchInDirectory(struct song *song, void *_data)
return 0; return 0;
} }
int searchForSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items) searchForSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item *items)
{ {
int ret; int ret;
int i; int i;
LocateTagItem *new_items = struct locate_item *new_items =
g_memdup(items, sizeof(LocateTagItem) * numItems); g_memdup(items, sizeof(items[0]) * numItems);
struct search_data data; struct search_data data;
for (i = 0; i < numItems; i++) for (i = 0; i < numItems; i++)
@ -121,8 +122,9 @@ findInDirectory(struct song *song, void *_data)
return 0; return 0;
} }
int findSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items) findSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item *items)
{ {
struct search_data data; struct search_data data;
@ -154,8 +156,9 @@ searchStatsInDirectory(struct song *song, void *data)
return 0; return 0;
} }
int searchStatsForSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items) searchStatsForSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item *items)
{ {
SearchStats stats; SearchStats stats;
int ret; int ret;
@ -226,8 +229,9 @@ int printInfoForAllIn(struct client *client, const char *name)
printDirectoryInDirectory, client); printDirectoryInDirectory, client);
} }
static ListCommandItem *newListCommandItem(int tagType, int numConditionals, static ListCommandItem *
const LocateTagItem * conditionals) newListCommandItem(int tagType, int numConditionals,
const struct locate_item *conditionals)
{ {
ListCommandItem *item = g_new(ListCommandItem, 1); ListCommandItem *item = g_new(ListCommandItem, 1);
@ -288,7 +292,7 @@ listUniqueTagsInDirectory(struct song *song, void *_data)
} }
int listAllUniqueTags(struct client *client, int type, int numConditionals, int listAllUniqueTags(struct client *client, int type, int numConditionals,
const LocateTagItem *conditionals) const struct locate_item *conditionals)
{ {
int ret; int ret;
ListCommandItem *item = newListCommandItem(type, numConditionals, ListCommandItem *item = newListCommandItem(type, numConditionals,

View File

@ -19,9 +19,8 @@
#ifndef MPD_DB_UTILS_H #ifndef MPD_DB_UTILS_H
#define MPD_DB_UTILS_H #define MPD_DB_UTILS_H
#include "locate.h"
struct client; struct client;
struct locate_item;
int printAllIn(struct client *client, const char *name); int printAllIn(struct client *client, const char *name);
@ -31,19 +30,23 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file);
int printInfoForAllIn(struct client *client, const char *name); int printInfoForAllIn(struct client *client, const char *name);
int searchForSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items); searchForSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item * items);
int findSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items); findSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item * items);
int searchStatsForSongsIn(struct client *client, const char *name, int
int numItems, const LocateTagItem * items); searchStatsForSongsIn(struct client *client, const char *name,
int numItems, const struct locate_item * items);
unsigned long sumSongTimesIn(const char *name); unsigned long sumSongTimesIn(const char *name);
int listAllUniqueTags(struct client *client, int type, int numConditiionals, int
const LocateTagItem *conditionals); listAllUniqueTags(struct client *client, int type, int numConditiionals,
const struct locate_item *conditionals);
void printSavedMemoryFromFilenames(void); void printSavedMemoryFromFilenames(void);

View File

@ -53,7 +53,7 @@ int getLocateTagItemType(const char *str)
return -1; return -1;
} }
static int initLocateTagItem(LocateTagItem * item, static int initLocateTagItem(struct locate_item *item,
const char *typeStr, const char *needle) const char *typeStr, const char *needle)
{ {
item->tagType = getLocateTagItemType(typeStr); item->tagType = getLocateTagItemType(typeStr);
@ -66,9 +66,10 @@ static int initLocateTagItem(LocateTagItem * item,
return 0; return 0;
} }
LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle) struct locate_item *
newLocateTagItem(const char *typeStr, const char *needle)
{ {
LocateTagItem *ret = g_new(LocateTagItem, 1); struct locate_item *ret = g_new(struct locate_item, 1);
if (initLocateTagItem(ret, typeStr, needle) < 0) { if (initLocateTagItem(ret, typeStr, needle) < 0) {
free(ret); free(ret);
@ -78,7 +79,7 @@ LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle)
return ret; return ret;
} }
void freeLocateTagItemArray(int count, LocateTagItem * array) void freeLocateTagItemArray(int count, struct locate_item *array)
{ {
int i; int i;
@ -88,11 +89,12 @@ void freeLocateTagItemArray(int count, LocateTagItem * array)
free(array); free(array);
} }
int newLocateTagItemArrayFromArgArray(char *argArray[], int
int numArgs, LocateTagItem ** arrayRet) newLocateTagItemArrayFromArgArray(char *argArray[],
int numArgs, struct locate_item **arrayRet)
{ {
int i, j; int i, j;
LocateTagItem *item; struct locate_item *item;
if (numArgs == 0) if (numArgs == 0)
return 0; return 0;
@ -100,7 +102,7 @@ int newLocateTagItemArrayFromArgArray(char *argArray[],
if (numArgs % 2 != 0) if (numArgs % 2 != 0)
return -1; return -1;
*arrayRet = g_new(LocateTagItem, numArgs / 2); *arrayRet = g_new(struct locate_item, numArgs / 2);
for (i = 0, item = *arrayRet; i < numArgs / 2; i++, item++) { for (i = 0, item = *arrayRet; i < numArgs / 2; i++, item++) {
if (initLocateTagItem if (initLocateTagItem
@ -120,7 +122,7 @@ fail:
return -1; return -1;
} }
void freeLocateTagItem(LocateTagItem * item) void freeLocateTagItem(struct locate_item *item)
{ {
free(item->needle); free(item->needle);
free(item); free(item);
@ -178,7 +180,7 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
int int
strstrSearchTags(const struct song *song, int numItems, strstrSearchTags(const struct song *song, int numItems,
const LocateTagItem *items) const struct locate_item *items)
{ {
int i; int i;
@ -240,7 +242,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
int int
tagItemsFoundAndMatches(const struct song *song, int numItems, tagItemsFoundAndMatches(const struct song *song, int numItems,
const LocateTagItem * items) const struct locate_item *items)
{ {
int i; int i;

View File

@ -27,31 +27,33 @@
struct song; struct song;
/* struct used for search, find, list queries */ /* struct used for search, find, list queries */
typedef struct _LocateTagItem { struct locate_item {
int8_t tagType; int8_t tagType;
/* what we are looking for */ /* what we are looking for */
char *needle; char *needle;
} LocateTagItem; };
int getLocateTagItemType(const char *str); int getLocateTagItemType(const char *str);
/* returns NULL if not a known type */ /* returns NULL if not a known type */
LocateTagItem *newLocateTagItem(const char *typeString, const char *needle); struct locate_item *
newLocateTagItem(const char *typeString, const char *needle);
/* return number of items or -1 on error */ /* return number of items or -1 on error */
int newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs, int
LocateTagItem ** arrayRet); newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
struct locate_item **arrayRet);
void freeLocateTagItemArray(int count, LocateTagItem * array); void freeLocateTagItemArray(int count, struct locate_item *array);
void freeLocateTagItem(LocateTagItem * item); void freeLocateTagItem(struct locate_item *item);
int int
strstrSearchTags(const struct song *song, int numItems, strstrSearchTags(const struct song *song, int numItems,
const LocateTagItem * items); const struct locate_item *items);
int int
tagItemsFoundAndMatches(const struct song *song, int numItems, tagItemsFoundAndMatches(const struct song *song, int numItems,
const LocateTagItem * items); const struct locate_item *items);
#endif #endif

View File

@ -20,6 +20,7 @@
#include "playlist_save.h" #include "playlist_save.h"
#include "queue_print.h" #include "queue_print.h"
#include "queue_save.h" #include "queue_save.h"
#include "locate.h"
#include "player_control.h" #include "player_control.h"
#include "command.h" #include "command.h"
#include "ls.h" #include "ls.h"
@ -1178,11 +1179,11 @@ enum playlist_result loadPlaylist(const char *utf8file)
void void
searchForSongsInPlaylist(struct client *client, searchForSongsInPlaylist(struct client *client,
unsigned numItems, const LocateTagItem *items) unsigned numItems, const struct locate_item *items)
{ {
unsigned i; unsigned i;
LocateTagItem *new_items = struct locate_item *new_items =
g_memdup(items, sizeof(LocateTagItem) * numItems); g_memdup(items, sizeof(items[0]) * numItems);
for (i = 0; i < numItems; i++) for (i = 0; i < numItems; i++)
new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1); new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1);
@ -1199,7 +1200,7 @@ searchForSongsInPlaylist(struct client *client,
void void
findSongsInPlaylist(struct client *client, findSongsInPlaylist(struct client *client,
unsigned numItems, const LocateTagItem *items) unsigned numItems, const struct locate_item *items)
{ {
for (unsigned i = 0; i < queue_length(&playlist.queue); i++) { for (unsigned i = 0; i < queue_length(&playlist.queue); i++) {
const struct song *song = queue_get(&playlist.queue, i); const struct song *song = queue_get(&playlist.queue, i);

View File

@ -19,7 +19,6 @@
#ifndef MPD_PLAYLIST_H #ifndef MPD_PLAYLIST_H
#define MPD_PLAYLIST_H #define MPD_PLAYLIST_H
#include "locate.h"
#include "queue.h" #include "queue.h"
#include <stdbool.h> #include <stdbool.h>
@ -28,6 +27,7 @@
#define PLAYLIST_COMMENT '#' #define PLAYLIST_COMMENT '#'
struct client; struct client;
struct locate_item;
enum playlist_result { enum playlist_result {
PLAYLIST_RESULT_SUCCESS, PLAYLIST_RESULT_SUCCESS,
@ -177,11 +177,11 @@ void playlistVersionChange(void);
void void
searchForSongsInPlaylist(struct client *client, searchForSongsInPlaylist(struct client *client,
unsigned numItems, const LocateTagItem *items); unsigned numItems, const struct locate_item *items);
void void
findSongsInPlaylist(struct client *client, findSongsInPlaylist(struct client *client,
unsigned numItems, const LocateTagItem *items); unsigned numItems, const struct locate_item *items);
int is_valid_playlist_name(const char *utf8path); int is_valid_playlist_name(const char *utf8path);