summaryrefslogtreecommitdiff
path: root/apps/plugins/searchengine
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-05-10 23:44:22 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-05-10 23:44:22 +0000
commitf5eae08361c4b1c9d7c846c7b4b54fabf7467e31 (patch)
treeca9d05970a00e34d93f6651c2e8d27a9fe3caacd /apps/plugins/searchengine
parent09d82dbed8ebbefb2dfb248cd2d6191e917e9797 (diff)
downloadrockbox-f5eae08361c4b1c9d7c846c7b4b54fabf7467e31.tar.gz
rockbox-f5eae08361c4b1c9d7c846c7b4b54fabf7467e31.zip
Starts with and ends with support (for strings), as requested.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6454 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/searchengine')
-rw-r--r--apps/plugins/searchengine/parser.c35
-rw-r--r--apps/plugins/searchengine/token.c3
-rw-r--r--apps/plugins/searchengine/token.h57
3 files changed, 54 insertions, 41 deletions
diff --git a/apps/plugins/searchengine/parser.c b/apps/plugins/searchengine/parser.c
index 62423e256f..76beab49cc 100644
--- a/apps/plugins/searchengine/parser.c
+++ b/apps/plugins/searchengine/parser.c
@@ -146,7 +146,8 @@ unsigned char *parseCompareString() {
146 struct token string1,string2; 146 struct token string1,string2;
147 unsigned char *ret; 147 unsigned char *ret;
148 char *s1=NULL,*s2=NULL; 148 char *s1=NULL,*s2=NULL;
149 int i,contains; 149 int i,i2;
150 int op;
150 if(syntaxerror) return 0; 151 if(syntaxerror) return 0;
151 PUTS("parseCompareString"); 152 PUTS("parseCompareString");
152 if(currentToken->kind==TOKEN_STRING || 153 if(currentToken->kind==TOKEN_STRING ||
@@ -159,19 +160,12 @@ unsigned char *parseCompareString() {
159 rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind); 160 rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind);
160 return 0; 161 return 0;
161 } 162 }
162 if(currentToken->kind==TOKEN_CONTAINS || 163 op=currentToken->kind;
163 currentToken->kind==TOKEN_EQUALS) { 164 if(op>=TOKEN_CONTAINS&&op<=TOKEN_ENDSWITH) {
164 if(currentToken->kind==TOKEN_CONTAINS) {
165 contains=1;
166 PUTS("Contains");
167 } else {
168 contains=0;
169 PUTS("Equals");
170 }
171 parser_acceptIt(); 165 parser_acceptIt();
172 } else { 166 } else {
173 syntaxerror=1; 167 syntaxerror=1;
174 rb->snprintf(errormsg,250,"'%d' found where CONTAINS/EQUALS expected\n",currentToken->kind); 168 rb->snprintf(errormsg,250,"'%d' found where STROP expected\n",op);
175 return 0; 169 return 0;
176 } 170 }
177 if(currentToken->kind==TOKEN_STRING || 171 if(currentToken->kind==TOKEN_STRING ||
@@ -196,10 +190,21 @@ unsigned char *parseCompareString() {
196 s1=getstring(&string1); 190 s1=getstring(&string1);
197 if(string2.kind==TOKEN_STRINGIDENTIFIER) 191 if(string2.kind==TOKEN_STRINGIDENTIFIER)
198 s2=getstring(&string2); 192 s2=getstring(&string2);
199 if(contains) 193 switch(op) {
200 ret[i]=rb->strcasestr(s1,s2)!=0; 194 case TOKEN_CONTAINS:
201 else 195 ret[i]=rb->strcasestr(s1,s2)!=0;
202 ret[i]=rb->strcasecmp(s1,s2)==0; 196 break;
197 case TOKEN_EQUALS:
198 ret[i]=rb->strcasecmp(s1,s2)==0;
199 break;
200 case TOKEN_STARTSWITH:
201 ret[i]=rb->strncasecmp(s1,s2,rb->strlen(s2))==0;
202 break;
203 case TOKEN_ENDSWITH:
204 i2=rb->strlen(s2);
205 ret[i]=rb->strncasecmp(s1+rb->strlen(s1)-i2,s2,i2)==0;
206 break;
207 }
203 } 208 }
204 return ret; 209 return ret;
205} 210}
diff --git a/apps/plugins/searchengine/token.c b/apps/plugins/searchengine/token.c
index fa1f84eb7d..d8cd64072f 100644
--- a/apps/plugins/searchengine/token.c
+++ b/apps/plugins/searchengine/token.c
@@ -71,6 +71,9 @@ int getvalue(struct token *token) {
71 case INTVALUE_PLAYCOUNT: 71 case INTVALUE_PLAYCOUNT:
72 loadrundbdata(); 72 loadrundbdata();
73 return currententry->playcount; 73 return currententry->playcount;
74 case INTVALUE_AUTORATING:
75 // todo.
76 return 0;
74 default: 77 default:
75 rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue); 78 rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue);
76 rb->splash(HZ*2,true,buf); 79 rb->splash(HZ*2,true,buf);
diff --git a/apps/plugins/searchengine/token.h b/apps/plugins/searchengine/token.h
index 183f365c59..12065511ac 100644
--- a/apps/plugins/searchengine/token.h
+++ b/apps/plugins/searchengine/token.h
@@ -16,34 +16,39 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#define TOKEN_INVALID -1 19#define TOKEN_INVALID -1
20#define TOKEN_EOF 0 // EOF 20#define TOKEN_EOF 0 // EOF
21#define TOKEN_NOT 1 // "not" 21#define TOKEN_NOT 1 // "not"
22#define TOKEN_AND 2 // "and" 22#define TOKEN_AND 2 // "and"
23#define TOKEN_OR 3 // "or" 23#define TOKEN_OR 3 // "or"
24#define TOKEN_GT 4 // '>' 24#define TOKEN_GT 4 // '>'
25#define TOKEN_GTE 5 // '>=' 25#define TOKEN_GTE 5 // '>='
26#define TOKEN_LT 6 // '<' 26#define TOKEN_LT 6 // '<'
27#define TOKEN_LTE 7 // '<=' 27#define TOKEN_LTE 7 // '<='
28#define TOKEN_EQ 8 // '==' 28#define TOKEN_EQ 8 // '=='
29#define TOKEN_NE 9 // '!=' 29#define TOKEN_NE 9 // '!='
30#define TOKEN_CONTAINS 10 // "contains" 30#define TOKEN_CONTAINS 10 // "contains"
31#define TOKEN_EQUALS 11 // "equals" 31#define TOKEN_EQUALS 11 // "equals"
32#define TOKEN_LPAREN 12 // '(' 32#define TOKEN_STARTSWITH 12
33#define TOKEN_RPAREN 13 // ')' 33#define TOKEN_ENDSWITH 13
34#define TOKEN_NUM 14 // (0..9)+ 34#define TOKEN_LPAREN 14 // '('
35#define TOKEN_NUMIDENTIFIER 15 // year, trackid, bpm, etc. 35#define TOKEN_RPAREN 15 // ')'
36#define TOKEN_STRING 16 // (?)+ 36#define TOKEN_NUM 16 // (0..9)+
37#define TOKEN_STRINGIDENTIFIER 17 // album, artist, title, genre ... 37#define TOKEN_NUMIDENTIFIER 17 // year, trackid, bpm, etc.
38#define TOKEN_STRING 18 // (?)+
39#define TOKEN_STRINGIDENTIFIER 19 // album, artist, title, genre ...
40#define TOKEN_SHUFFLE 20
41#define TOKEN_PLAYTIMELIMIT 21
38 42
39#define INTVALUE_YEAR 1 43#define INTVALUE_YEAR 1
40#define INTVALUE_RATING 2 44#define INTVALUE_RATING 2
41#define INTVALUE_PLAYCOUNT 3 45#define INTVALUE_PLAYCOUNT 3
42#define INTVALUE_TITLE 4 46#define INTVALUE_AUTORATING 4
43#define INTVALUE_ARTIST 5 47#define INTVALUE_TITLE 14
44#define INTVALUE_ALBUM 6 48#define INTVALUE_ARTIST 15
45#define INTVALUE_GENRE 7 49#define INTVALUE_ALBUM 16
46#define INTVALUE_FILENAME 8 50#define INTVALUE_GENRE 17
51#define INTVALUE_FILENAME 18
47 52
48/* static char *spelling[] = { "not", "and", "or",">",">=","<", "<=","==","!=", 53/* static char *spelling[] = { "not", "and", "or",">",">=","<", "<=","==","!=",
49 "contains","(",")" }; */ 54 "contains","(",")" }; */