1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Michiel van der Kolk
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "searchengine.h"
23 #include "dbinterface.h"
25 char *getstring(struct token
*token
) {
29 return token
->spelling
;
30 case TOKEN_STRINGIDENTIFIER
:
31 switch(token
->intvalue
) {
34 return currententry
->title
;
37 return currententry
->artistname
;
40 return currententry
->albumname
;
43 return currententry
->genre
;
44 case INTVALUE_FILENAME
:
45 return currententry
->filename
;
47 rb
->snprintf(buf
,199,"unknown stringid intvalue %d",token
->intvalue
);
54 rb
->snprintf(buf
,199,"unknown token %d in getstring..",token
->kind
);
60 int getvalue(struct token
*token
) {
65 return token
->intvalue
;
66 case TOKEN_NUMIDENTIFIER
:
67 switch(token
->intvalue
) {
70 return currententry
->year
;
73 return currententry
->rating
;
74 case INTVALUE_PLAYCOUNT
:
76 return currententry
->playcount
;
77 case INTVALUE_PLAYTIME
:
79 return currententry
->playtime
;
80 case INTVALUE_TRACKNUM
:
82 return currententry
->track
;
83 case INTVALUE_BITRATE
:
85 return currententry
->bitrate
;
86 case INTVALUE_SAMPLERATE
:
88 return currententry
->samplerate
;
89 case INTVALUE_AUTORATING
:
90 if(!dbglobal
.gotplaycountlimits
) {
91 index
=dbglobal
.currententryindex
;
92 dbglobal
.playcountmax
=0;
93 dbglobal
.playcountmin
=0xFFFFFFFF;
94 for(i
=0;i
<rb
->tagdbheader
->filecount
;i
++) {
97 if(currententry
->playcount
>dbglobal
.playcountmax
)
98 dbglobal
.playcountmax
=currententry
->playcount
;
99 if(currententry
->playcount
<dbglobal
.playcountmin
)
100 dbglobal
.playcountmin
=currententry
->playcount
;
102 dbglobal
.gotplaycountlimits
=1;
106 return (currententry
->playcount
-dbglobal
.playcountmin
)*10/(dbglobal
.playcountmax
-dbglobal
.playcountmin
);
108 rb
->snprintf(buf
,199,"unknown numid intvalue %d",token
->intvalue
);
109 rb
->splash(HZ
*2,buf
);
114 rb
->snprintf(buf
,199,"unknown token %d in getvalue..",token
->kind
);
115 rb
->splash(HZ
*2,buf
);