diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/databox/databox.c | 2 | ||||
-rw-r--r-- | apps/plugins/databox/editparser.c | 2 | ||||
-rw-r--r-- | apps/plugins/databox/edittoken.c | 9 | ||||
-rw-r--r-- | apps/plugins/databox/edittoken.h | 98 | ||||
-rw-r--r-- | apps/plugins/searchengine/parser.c | 35 | ||||
-rw-r--r-- | apps/plugins/searchengine/token.c | 3 | ||||
-rw-r--r-- | apps/plugins/searchengine/token.h | 57 |
7 files changed, 120 insertions, 86 deletions
diff --git a/apps/plugins/databox/databox.c b/apps/plugins/databox/databox.c index af2bdda927..58f949ee19 100644 --- a/apps/plugins/databox/databox.c +++ b/apps/plugins/databox/databox.c | |||
@@ -145,6 +145,8 @@ void buildchoices(int mask) { | |||
145 | if(mask&ACCEPT_STROP) { | 145 | if(mask&ACCEPT_STROP) { |
146 | editing.selection_candidates[i++]=TOKEN_CONTAINS; | 146 | editing.selection_candidates[i++]=TOKEN_CONTAINS; |
147 | editing.selection_candidates[i++]=TOKEN_EQUALS; | 147 | editing.selection_candidates[i++]=TOKEN_EQUALS; |
148 | editing.selection_candidates[i++]=TOKEN_STARTSWITH; | ||
149 | editing.selection_candidates[i++]=TOKEN_ENDSWITH; | ||
148 | } | 150 | } |
149 | if(mask&ACCEPT_LPAREN) { | 151 | if(mask&ACCEPT_LPAREN) { |
150 | editing.selection_candidates[i++]=TOKEN_LPAREN; | 152 | editing.selection_candidates[i++]=TOKEN_LPAREN; |
diff --git a/apps/plugins/databox/editparser.c b/apps/plugins/databox/editparser.c index d2fcbc4e6d..5ee9ffbd56 100644 --- a/apps/plugins/databox/editparser.c +++ b/apps/plugins/databox/editparser.c | |||
@@ -100,6 +100,8 @@ void parse_checktoken() { | |||
100 | break; | 100 | break; |
101 | case TOKEN_EQUALS: | 101 | case TOKEN_EQUALS: |
102 | case TOKEN_CONTAINS: | 102 | case TOKEN_CONTAINS: |
103 | case TOKEN_STARTSWITH: | ||
104 | case TOKEN_ENDSWITH: | ||
103 | ok=acceptedmask&ACCEPT_STROP; | 105 | ok=acceptedmask&ACCEPT_STROP; |
104 | break; | 106 | break; |
105 | case TOKEN_STRING: | 107 | case TOKEN_STRING: |
diff --git a/apps/plugins/databox/edittoken.c b/apps/plugins/databox/edittoken.c index f5b869757b..71548d6ce1 100644 --- a/apps/plugins/databox/edittoken.c +++ b/apps/plugins/databox/edittoken.c | |||
@@ -35,6 +35,8 @@ char *tokentypetostring(int tokentype) { | |||
35 | case TOKEN_RPAREN: return ")"; | 35 | case TOKEN_RPAREN: return ")"; |
36 | case TOKEN_CONTAINS: return "contains"; | 36 | case TOKEN_CONTAINS: return "contains"; |
37 | case TOKEN_EQUALS: return "equals"; | 37 | case TOKEN_EQUALS: return "equals"; |
38 | case TOKEN_STARTSWITH: return "starts with"; | ||
39 | case TOKEN_ENDSWITH: return "ends with"; | ||
38 | case TOKEN_NUM: return "<number>"; | 40 | case TOKEN_NUM: return "<number>"; |
39 | case TOKEN_NUMIDENTIFIER: return "<numberproperty>"; | 41 | case TOKEN_NUMIDENTIFIER: return "<numberproperty>"; |
40 | case TOKEN_STRING: return "<string>"; | 42 | case TOKEN_STRING: return "<string>"; |
@@ -58,6 +60,7 @@ char *numidtostring(int numid) { | |||
58 | case INTVALUE_YEAR: return "<year>"; | 60 | case INTVALUE_YEAR: return "<year>"; |
59 | case INTVALUE_RATING: return "<rating>"; | 61 | case INTVALUE_RATING: return "<rating>"; |
60 | case INTVALUE_PLAYCOUNT: return "<playcount>"; | 62 | case INTVALUE_PLAYCOUNT: return "<playcount>"; |
63 | case INTVALUE_AUTORATING: return "<autorating>"; | ||
61 | } | 64 | } |
62 | return "numiderror"; | 65 | return "numiderror"; |
63 | } | 66 | } |
@@ -100,6 +103,10 @@ void buildtoken(int tokentype,struct token *token) { | |||
100 | token->kind=TOKEN_NUMIDENTIFIER; | 103 | token->kind=TOKEN_NUMIDENTIFIER; |
101 | token->intvalue=INTVALUE_PLAYCOUNT; | 104 | token->intvalue=INTVALUE_PLAYCOUNT; |
102 | break; | 105 | break; |
106 | case TOKEN_AUTORATING: | ||
107 | token->kind=TOKEN_NUMIDENTIFIER; | ||
108 | token->intvalue=INTVALUE_AUTORATING; | ||
109 | break; | ||
103 | case TOKEN_TITLE: | 110 | case TOKEN_TITLE: |
104 | token->kind=TOKEN_STRINGIDENTIFIER; | 111 | token->kind=TOKEN_STRINGIDENTIFIER; |
105 | token->intvalue=INTVALUE_TITLE; | 112 | token->intvalue=INTVALUE_TITLE; |
@@ -172,6 +179,8 @@ char *tokentostring(struct token *token) { | |||
172 | case TOKEN_RPAREN: | 179 | case TOKEN_RPAREN: |
173 | case TOKEN_CONTAINS: | 180 | case TOKEN_CONTAINS: |
174 | case TOKEN_EQUALS: | 181 | case TOKEN_EQUALS: |
182 | case TOKEN_STARTSWITH: | ||
183 | case TOKEN_ENDSWITH: | ||
175 | return tokentypetostring(token->kind); | 184 | return tokentypetostring(token->kind); |
176 | case TOKEN_NUM: rb->snprintf(bufbla,40,"%d",token->intvalue); | 185 | case TOKEN_NUM: rb->snprintf(bufbla,40,"%d",token->intvalue); |
177 | return bufbla; | 186 | return bufbla; |
diff --git a/apps/plugins/databox/edittoken.h b/apps/plugins/databox/edittoken.h index a5c8d472e1..4c9f535448 100644 --- a/apps/plugins/databox/edittoken.h +++ b/apps/plugins/databox/edittoken.h | |||
@@ -19,54 +19,62 @@ | |||
19 | #ifndef EDITTOKEN_H | 19 | #ifndef EDITTOKEN_H |
20 | #define EDITTOKEN_H | 20 | #define EDITTOKEN_H |
21 | 21 | ||
22 | #define TOKEN_INVALID -1 | 22 | #define TOKEN_INVALID -1 |
23 | #define TOKEN_EOF 0 // EOF | 23 | #define TOKEN_EOF 0 // EOF |
24 | #define TOKEN_NOT 1 // "not" | 24 | #define TOKEN_NOT 1 // "not" |
25 | #define TOKEN_AND 2 // "and" | 25 | #define TOKEN_AND 2 // "and" |
26 | #define TOKEN_OR 3 // "or" | 26 | #define TOKEN_OR 3 // "or" |
27 | #define TOKEN_GT 4 // '>' | 27 | #define TOKEN_GT 4 // '>' |
28 | #define TOKEN_GTE 5 // '>=' | 28 | #define TOKEN_GTE 5 // '>=' |
29 | #define TOKEN_LT 6 // '<' | 29 | #define TOKEN_LT 6 // '<' |
30 | #define TOKEN_LTE 7 // '<=' | 30 | #define TOKEN_LTE 7 // '<=' |
31 | #define TOKEN_EQ 8 // '==' | 31 | #define TOKEN_EQ 8 // '==' |
32 | #define TOKEN_NE 9 // '!=' | 32 | #define TOKEN_NE 9 // '!=' |
33 | #define TOKEN_CONTAINS 10 // "contains" | 33 | #define TOKEN_CONTAINS 10 // "contains" |
34 | #define TOKEN_EQUALS 11 // "equals" | 34 | #define TOKEN_EQUALS 11 // "equals" |
35 | #define TOKEN_LPAREN 12 // '(' | 35 | #define TOKEN_STARTSWITH 12 |
36 | #define TOKEN_RPAREN 13 // ')' | 36 | #define TOKEN_ENDSWITH 13 |
37 | #define TOKEN_NUM 14 // (0..9)+ | 37 | #define TOKEN_LPAREN 14 // '(' |
38 | #define TOKEN_NUMIDENTIFIER 15 // year, trackid, bpm, etc. | 38 | #define TOKEN_RPAREN 15 // ')' |
39 | #define TOKEN_STRING 16 // (?)+ | 39 | #define TOKEN_NUM 16 // (0..9)+ |
40 | #define TOKEN_STRINGIDENTIFIER 17 // album, artist, title, genre ... | 40 | #define TOKEN_NUMIDENTIFIER 17 // year, trackid, bpm, etc. |
41 | #define TOKEN_YEAR 18 | 41 | #define TOKEN_STRING 18 // (?)+ |
42 | #define TOKEN_RATING 19 | 42 | #define TOKEN_STRINGIDENTIFIER 19 // album, artist, title, genre ... |
43 | #define TOKEN_PLAYCOUNT 20 | 43 | #define TOKEN_SHUFFLE 20 |
44 | #define TOKEN_TITLE 21 | 44 | #define TOKEN_PLAYTIMELIMIT 21 |
45 | #define TOKEN_ARTIST 22 | ||
46 | #define TOKEN_ALBUM 23 | ||
47 | #define TOKEN_GENRE 24 | ||
48 | #define TOKEN_FILENAME 25 | ||
49 | #define TOKEN_EDIT 26 | ||
50 | 45 | ||
51 | #define ACCEPT_EOF 0x1 | 46 | // pseudotokens.. |
52 | #define ACCEPT_BOOLOP 0x2 | 47 | #define TOKEN_YEAR 118 |
53 | #define ACCEPT_NUMOP 0x4 | 48 | #define TOKEN_RATING 119 |
54 | #define ACCEPT_STROP 0x8 | 49 | #define TOKEN_PLAYCOUNT 120 |
55 | #define ACCEPT_LPAREN 0x10 | 50 | #define TOKEN_TITLE 121 |
56 | #define ACCEPT_RPAREN 0x20 | 51 | #define TOKEN_ARTIST 122 |
57 | #define ACCEPT_NUMARG 0x40 | 52 | #define TOKEN_ALBUM 123 |
58 | #define ACCEPT_STRARG 0x80 | 53 | #define TOKEN_GENRE 124 |
59 | #define ACCEPT_NOT 0x100 | 54 | #define TOKEN_FILENAME 125 |
60 | #define ACCEPT_DELETE 0x200 | 55 | #define TOKEN_EDIT 126 |
56 | #define TOKEN_AUTORATING 127 | ||
61 | 57 | ||
62 | #define INTVALUE_YEAR 1 | 58 | #define ACCEPT_EOF 0x1 |
59 | #define ACCEPT_BOOLOP 0x2 | ||
60 | #define ACCEPT_NUMOP 0x4 | ||
61 | #define ACCEPT_STROP 0x8 | ||
62 | #define ACCEPT_LPAREN 0x10 | ||
63 | #define ACCEPT_RPAREN 0x20 | ||
64 | #define ACCEPT_NUMARG 0x40 | ||
65 | #define ACCEPT_STRARG 0x80 | ||
66 | #define ACCEPT_NOT 0x100 | ||
67 | #define ACCEPT_DELETE 0x200 | ||
68 | |||
69 | #define INTVALUE_YEAR 1 | ||
63 | #define INTVALUE_RATING 2 | 70 | #define INTVALUE_RATING 2 |
64 | #define INTVALUE_PLAYCOUNT 3 | 71 | #define INTVALUE_PLAYCOUNT 3 |
65 | #define INTVALUE_TITLE 4 | 72 | #define INTVALUE_AUTORATING 4 |
66 | #define INTVALUE_ARTIST 5 | 73 | #define INTVALUE_TITLE 14 |
67 | #define INTVALUE_ALBUM 6 | 74 | #define INTVALUE_ARTIST 15 |
68 | #define INTVALUE_GENRE 7 | 75 | #define INTVALUE_ALBUM 16 |
69 | #define INTVALUE_FILENAME 8 | 76 | #define INTVALUE_GENRE 17 |
77 | #define INTVALUE_FILENAME 18 | ||
70 | 78 | ||
71 | struct token { | 79 | struct token { |
72 | char kind; | 80 | char kind; |
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","(",")" }; */ |