1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Michiel van der Kolk
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "searchengine.h"
21 #include "dbinterface.h"
23 char *getstring(struct token
*token
) {
27 return token
->spelling
;
28 case TOKEN_STRINGIDENTIFIER
:
29 switch(token
->intvalue
) {
32 return currententry
->title
;
35 return currententry
->artistname
;
38 return currententry
->albumname
;
41 return currententry
->genre
;
42 case INTVALUE_FILENAME
:
43 return currententry
->filename
;
45 rb
->snprintf(buf
,199,"unknown stringid intvalue %d",token
->intvalue
);
52 rb
->snprintf(buf
,199,"unknown token %d in getstring..",token
->kind
);
58 int getvalue(struct token
*token
) {
63 return token
->intvalue
;
64 case TOKEN_NUMIDENTIFIER
:
65 switch(token
->intvalue
) {
68 return currententry
->year
;
71 return currententry
->rating
;
72 case INTVALUE_PLAYCOUNT
:
74 return currententry
->playcount
;
75 case INTVALUE_PLAYTIME
:
77 return currententry
->playtime
;
78 case INTVALUE_TRACKNUM
:
80 return currententry
->track
;
81 case INTVALUE_BITRATE
:
83 return currententry
->bitrate
;
84 case INTVALUE_SAMPLERATE
:
86 return currententry
->samplerate
;
87 case INTVALUE_AUTORATING
:
88 if(!dbglobal
.gotplaycountlimits
) {
89 index
=dbglobal
.currententryindex
;
90 dbglobal
.playcountmax
=0;
91 dbglobal
.playcountmin
=0xFFFFFFFF;
92 for(i
=0;i
<rb
->tagdbheader
->filecount
;i
++) {
95 if(currententry
->playcount
>dbglobal
.playcountmax
)
96 dbglobal
.playcountmax
=currententry
->playcount
;
97 if(currententry
->playcount
<dbglobal
.playcountmin
)
98 dbglobal
.playcountmin
=currententry
->playcount
;
100 dbglobal
.gotplaycountlimits
=1;
104 return (currententry
->playcount
-dbglobal
.playcountmin
)*10/(dbglobal
.playcountmax
-dbglobal
.playcountmin
);
106 rb
->snprintf(buf
,199,"unknown numid intvalue %d",token
->intvalue
);
107 rb
->splash(HZ
*2,buf
);
112 rb
->snprintf(buf
,199,"unknown token %d in getvalue..",token
->kind
);
113 rb
->splash(HZ
*2,buf
);