diff options
| author | Michiel Van Der Kolk <not.valid@email.address> | 2005-04-28 12:33:38 +0000 |
|---|---|---|
| committer | Michiel Van Der Kolk <not.valid@email.address> | 2005-04-28 12:33:38 +0000 |
| commit | 9369d4867d3bf033e0e3bbcff05cd7f0a9bb83e8 (patch) | |
| tree | 0276c6299a3b26705b028f399ceadf3ac7867b2f /apps/plugins/searchengine/token.c | |
| parent | a7f7781dca4db172a507e7e6f73bee03fc7deb2f (diff) | |
| download | rockbox-9369d4867d3bf033e0e3bbcff05cd7f0a9bb83e8.zip rockbox-9369d4867d3bf033e0e3bbcff05cd7f0a9bb83e8.tar.gz rockbox-9369d4867d3bf033e0e3bbcff05cd7f0a9bb83e8.tar.bz2 rockbox-9369d4867d3bf033e0e3bbcff05cd7f0a9bb83e8.tar.xz | |
Search engine core for database v2, has an hardcoded "songs for year >= 1980 and year < 1990" at the moment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6367 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/searchengine/token.c')
| -rw-r--r-- | apps/plugins/searchengine/token.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/apps/plugins/searchengine/token.c b/apps/plugins/searchengine/token.c new file mode 100644 index 0000000..d2da94a --- /dev/null +++ b/apps/plugins/searchengine/token.c @@ -0,0 +1,61 @@ +#include "token.h" +#include "dbinterface.h" + +#define REQUIRESONGDATA() if(!currententry->loadedsongdata) loadsongdata(); +#define REQUIRERUNDBDATA() if(!currententry->loadedrundbdata) loadrundbdata(); +#define REQUIREALBUMNAME() if(!currententry->loadedalbumname) { REQUIRESONGDATA(); loadalbumname(); } +#define REQUIREARTISTNAME() if(!currententry->loadedartistname) { REQUIRESONGDATA(); loadartistname(); } + +char *getstring(struct token *token) { + switch(token->kind) { + case TOKEN_STRING: + return token->spelling; + case TOKEN_STRINGIDENTIFIER: + switch(token->intvalue) { + case INTVALUE_TITLE: + REQUIRESONGDATA(); + return currententry->title; + case INTVALUE_ARTIST: + REQUIREARTISTNAME(); + return currententry->artistname; + case INTVALUE_ALBUM: + REQUIREALBUMNAME(); + return currententry->albumname; + case INTVALUE_GENRE: + REQUIRESONGDATA(); + return currententry->genre; + case INTVALUE_FILENAME: + return currententry->filename; + default: + return 0; + } + break; + default: + // report error + return 0; + } +} + +int getvalue(struct token *token) { + switch(token->kind) { + case TOKEN_NUM: + return token->intvalue; + case TOKEN_NUMIDENTIFIER: + switch(token->intvalue) { + case INTVALUE_YEAR: + REQUIRESONGDATA(); + return currententry->year; + case INTVALUE_RATING: + REQUIRERUNDBDATA(); + return currententry->rating; + case INTVALUE_PLAYCOUNT: + REQUIRERUNDBDATA(); + return currententry->playcount; + default: + // report error. + return 0; + } + default: + return 0; + } +} |