1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Michiel van der Kolk
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "searchengine.h"
#include "token.h"
#include "dbinterface.h"
char *getstring(struct token *token) {
char buf[200];
switch(token->kind) {
case TOKEN_STRING:
return token->spelling;
case TOKEN_STRINGIDENTIFIER:
switch(token->intvalue) {
case INTVALUE_TITLE:
loadsongdata();
return currententry->title;
case INTVALUE_ARTIST:
loadartistname();
return currententry->artistname;
case INTVALUE_ALBUM:
loadalbumname();
return currententry->albumname;
case INTVALUE_GENRE:
loadsongdata();
return currententry->genre;
case INTVALUE_FILENAME:
return currententry->filename;
default:
rb->snprintf(buf,199,"unknown stringid intvalue %d",token->intvalue);
rb->splash(HZ*2,buf);
return "";
}
break;
default:
// report error
rb->snprintf(buf,199,"unknown token %d in getstring..",token->kind);
rb->splash(HZ*2,buf);
return "";
}
}
int getvalue(struct token *token) {
char buf[200];
int index,i;
switch(token->kind) {
case TOKEN_NUM:
return token->intvalue;
case TOKEN_NUMIDENTIFIER:
switch(token->intvalue) {
case INTVALUE_YEAR:
loadsongdata();
return currententry->year;
case INTVALUE_RATING:
loadrundbdata();
return currententry->rating;
case INTVALUE_PLAYCOUNT:
loadrundbdata();
return currententry->playcount;
case INTVALUE_PLAYTIME:
loadsongdata();
return currententry->playtime;
case INTVALUE_TRACKNUM:
loadsongdata();
return currententry->track;
case INTVALUE_BITRATE:
loadsongdata();
return currententry->bitrate;
case INTVALUE_SAMPLERATE:
loadsongdata();
return currententry->samplerate;
case INTVALUE_AUTORATING:
if(!dbglobal.gotplaycountlimits) {
index=dbglobal.currententryindex;
dbglobal.playcountmax=0;
dbglobal.playcountmin=0xFFFFFFFF;
for(i=0;i<rb->tagdbheader->filecount;i++) {
loadentry(i);
loadrundbdata();
if(currententry->playcount>dbglobal.playcountmax)
dbglobal.playcountmax=currententry->playcount;
if(currententry->playcount<dbglobal.playcountmin)
dbglobal.playcountmin=currententry->playcount;
}
dbglobal.gotplaycountlimits=1;
loadentry(index);
}
loadrundbdata();
return (currententry->playcount-dbglobal.playcountmin)*10/(dbglobal.playcountmax-dbglobal.playcountmin);
default:
rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue);
rb->splash(HZ*2,buf);
// report error.
return 0;
}
default:
rb->snprintf(buf,199,"unknown token %d in getvalue..",token->kind);
rb->splash(HZ*2,buf);
return 0;
}
}
|