blob: 84ce21daeb5b18350af765df01eb156a6d4a9895 [file] [log] [blame]
Michiel Van Der Kolk4350eec2005-04-28 14:06:20 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Michiel van der Kolk
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000019#include "searchengine.h"
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000020#include "token.h"
21#include "dbinterface.h"
22
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000023char *getstring(struct token *token) {
24 switch(token->kind) {
25 case TOKEN_STRING:
26 return token->spelling;
27 case TOKEN_STRINGIDENTIFIER:
28 switch(token->intvalue) {
29 case INTVALUE_TITLE:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000030 loadsongdata();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000031 return currententry->title;
32 case INTVALUE_ARTIST:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000033 loadartistname();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000034 return currententry->artistname;
35 case INTVALUE_ALBUM:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000036 loadalbumname();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000037 return currententry->albumname;
38 case INTVALUE_GENRE:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000039 loadsongdata();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000040 return currententry->genre;
41 case INTVALUE_FILENAME:
42 return currententry->filename;
43 default:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000044 rb->splash(HZ*2,true,"unknown stringid intvalue");
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000045 return 0;
46 }
47 break;
48 default:
49 // report error
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000050 rb->splash(HZ*2,true,"unknown token...");
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000051 return 0;
52 }
53}
54
55int getvalue(struct token *token) {
56 switch(token->kind) {
57 case TOKEN_NUM:
58 return token->intvalue;
59 case TOKEN_NUMIDENTIFIER:
60 switch(token->intvalue) {
61 case INTVALUE_YEAR:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000062 loadsongdata();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000063 return currententry->year;
64 case INTVALUE_RATING:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000065 loadrundbdata();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000066 return currententry->rating;
67 case INTVALUE_PLAYCOUNT:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000068 loadrundbdata();
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000069 return currententry->playcount;
70 default:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000071 rb->splash(HZ*2,true,"unknown numid intvalue");
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000072 // report error.
73 return 0;
74 }
75 default:
Michiel Van Der Kolk238bea72005-04-28 18:49:23 +000076 rb->splash(HZ*2,true,"unknown token...");
Michiel Van Der Kolk9369d482005-04-28 12:33:38 +000077 return 0;
78 }
79}