diff options
Diffstat (limited to 'apps/plugins/databox/edittoken.c')
-rw-r--r-- | apps/plugins/databox/edittoken.c | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/apps/plugins/databox/edittoken.c b/apps/plugins/databox/edittoken.c deleted file mode 100644 index e2e1c91818..0000000000 --- a/apps/plugins/databox/edittoken.c +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Michiel van der Kolk | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "databox.h" | ||
20 | #include "edittoken.h" | ||
21 | |||
22 | char *tokentypetostring(int tokentype) { | ||
23 | switch(tokentype) { | ||
24 | case TOKEN_EOF: return "<END>"; | ||
25 | case TOKEN_NOT: return "not"; | ||
26 | case TOKEN_AND: return "and"; | ||
27 | case TOKEN_OR: return "or"; | ||
28 | case TOKEN_GT: return ">"; | ||
29 | case TOKEN_GTE: return ">="; | ||
30 | case TOKEN_LT: return "<"; | ||
31 | case TOKEN_LTE: return "<="; | ||
32 | case TOKEN_EQ: return "=="; | ||
33 | case TOKEN_NE: return "!="; | ||
34 | case TOKEN_LPAREN: return "("; | ||
35 | case TOKEN_RPAREN: return ")"; | ||
36 | case TOKEN_CONTAINS: return "contains"; | ||
37 | case TOKEN_EQUALS: return "equals"; | ||
38 | case TOKEN_STARTSWITH: return "starts with"; | ||
39 | case TOKEN_ENDSWITH: return "ends with"; | ||
40 | case TOKEN_NUM: return "<number>"; | ||
41 | case TOKEN_NUMIDENTIFIER: return "<numberproperty>"; | ||
42 | case TOKEN_STRING: return "<string>"; | ||
43 | case TOKEN_STRINGIDENTIFIER: return "<stringproperty>"; | ||
44 | case TOKEN_INVALID: return "<INVALID>"; | ||
45 | case TOKEN_EDIT: return tokentostring(&editing.old_token); | ||
46 | case TOKEN_YEAR: return "year"; | ||
47 | case TOKEN_RATING: return "rating"; | ||
48 | case TOKEN_PLAYCOUNT: return "playcount"; | ||
49 | case TOKEN_AUTORATING: return "autorating"; | ||
50 | case TOKEN_TITLE: return "title"; | ||
51 | case TOKEN_ARTIST: return "artist"; | ||
52 | case TOKEN_ALBUM: return "album"; | ||
53 | case TOKEN_GENRE: return "genre"; | ||
54 | case TOKEN_FILENAME: return "filename"; | ||
55 | case TOKEN_PLAYTIME: return "playtime"; | ||
56 | case TOKEN_TRACKNUM: return "track number"; | ||
57 | case TOKEN_SAMPLERATE: return "sample rate"; | ||
58 | case TOKEN_BITRATE: return "bitrate"; | ||
59 | } | ||
60 | return "tokentypeerror"; | ||
61 | } | ||
62 | |||
63 | char *numidtostring(int numid) { | ||
64 | switch(numid) { | ||
65 | case INTVALUE_YEAR: return "<year>"; | ||
66 | case INTVALUE_RATING: return "<rating>"; | ||
67 | case INTVALUE_PLAYCOUNT: return "<playcount>"; | ||
68 | case INTVALUE_AUTORATING: return "<autorating>"; | ||
69 | case INTVALUE_PLAYTIME: return "<playtime>"; | ||
70 | case INTVALUE_TRACKNUM: return "<track number>"; | ||
71 | case INTVALUE_SAMPLERATE: return "<sample rate>"; | ||
72 | case INTVALUE_BITRATE: return "<bitrate>"; | ||
73 | } | ||
74 | return "numiderror"; | ||
75 | } | ||
76 | |||
77 | char *stridtostring(int strid) { | ||
78 | switch(strid) { | ||
79 | case INTVALUE_TITLE: return "<title>"; | ||
80 | case INTVALUE_ARTIST: return "<artist>"; | ||
81 | case INTVALUE_ALBUM: return "<album>"; | ||
82 | case INTVALUE_GENRE: return "<genre>"; | ||
83 | case INTVALUE_FILENAME: return "<filename>"; | ||
84 | } | ||
85 | return "striderror"; | ||
86 | } | ||
87 | |||
88 | char bufbla[40]; | ||
89 | |||
90 | void buildtoken(int tokentype,struct token *token) { | ||
91 | // TODO | ||
92 | char buf[200]; | ||
93 | rb->memset(token,0,sizeof(struct token)); | ||
94 | rb->memset(buf,0,200); | ||
95 | token->kind=tokentype; | ||
96 | token->intvalue=0; | ||
97 | switch(token->kind) { | ||
98 | case TOKEN_STRING: | ||
99 | do { | ||
100 | rb->splash(HZ*2,true,"Enter String."); | ||
101 | } while(rb->kbd_input(token->spelling, SPELLING_LENGTH)); | ||
102 | break; | ||
103 | case TOKEN_YEAR: | ||
104 | token->kind=TOKEN_NUMIDENTIFIER; | ||
105 | token->intvalue=INTVALUE_YEAR; | ||
106 | break; | ||
107 | case TOKEN_RATING: | ||
108 | token->kind=TOKEN_NUMIDENTIFIER; | ||
109 | token->intvalue=INTVALUE_RATING; | ||
110 | break; | ||
111 | case TOKEN_PLAYCOUNT: | ||
112 | token->kind=TOKEN_NUMIDENTIFIER; | ||
113 | token->intvalue=INTVALUE_PLAYCOUNT; | ||
114 | break; | ||
115 | case TOKEN_AUTORATING: | ||
116 | token->kind=TOKEN_NUMIDENTIFIER; | ||
117 | token->intvalue=INTVALUE_AUTORATING; | ||
118 | break; | ||
119 | case TOKEN_TITLE: | ||
120 | token->kind=TOKEN_STRINGIDENTIFIER; | ||
121 | token->intvalue=INTVALUE_TITLE; | ||
122 | break; | ||
123 | case TOKEN_ARTIST: | ||
124 | token->kind=TOKEN_STRINGIDENTIFIER; | ||
125 | token->intvalue=INTVALUE_ARTIST; | ||
126 | break; | ||
127 | case TOKEN_ALBUM: | ||
128 | token->kind=TOKEN_STRINGIDENTIFIER; | ||
129 | token->intvalue=INTVALUE_ALBUM; | ||
130 | break; | ||
131 | case TOKEN_GENRE: | ||
132 | token->kind=TOKEN_STRINGIDENTIFIER; | ||
133 | token->intvalue=INTVALUE_GENRE; | ||
134 | break; | ||
135 | case TOKEN_FILENAME: | ||
136 | token->kind=TOKEN_STRINGIDENTIFIER; | ||
137 | token->intvalue=INTVALUE_TITLE; | ||
138 | break; | ||
139 | case TOKEN_NUM: | ||
140 | do { | ||
141 | rb->splash(HZ*2,true,"Enter Number."); | ||
142 | } while(rb->kbd_input(buf, 199)); | ||
143 | token->intvalue=rb->atoi(buf); | ||
144 | break; | ||
145 | case TOKEN_EDIT: | ||
146 | rb->memcpy(token,&editing.old_token,sizeof(struct token)); | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | void removetoken(struct token *token,int index) { | ||
152 | struct token *currenttoken; | ||
153 | currenttoken=&token[index]; | ||
154 | do { | ||
155 | rb->memcpy(currenttoken,&token[++index],sizeof(struct token)); | ||
156 | currenttoken=&token[index]; | ||
157 | } while (currenttoken->kind!=TOKEN_EOF); | ||
158 | } | ||
159 | |||
160 | void inserttoken(struct token *token,int index,int tokentype) { | ||
161 | struct token *currenttoken; | ||
162 | int max,i; | ||
163 | currenttoken=&token[0]; | ||
164 | for(i=1;currenttoken->kind!=TOKEN_EOF;i++) | ||
165 | currenttoken=&token[i]; | ||
166 | max=i; | ||
167 | for(i=max;i>=index;i--) { | ||
168 | rb->memcpy(&token[i+1],&token[i],sizeof(struct token)); | ||
169 | } | ||
170 | buildtoken(tokentype,&token[index]); | ||
171 | } | ||
172 | |||
173 | |||
174 | char *tokentostring(struct token *token) { | ||
175 | switch(token->kind) { | ||
176 | case TOKEN_INVALID: | ||
177 | case TOKEN_EOF: | ||
178 | case TOKEN_NOT: | ||
179 | case TOKEN_AND: | ||
180 | case TOKEN_OR: | ||
181 | case TOKEN_GT: | ||
182 | case TOKEN_GTE: | ||
183 | case TOKEN_LT: | ||
184 | case TOKEN_LTE: | ||
185 | case TOKEN_EQ: | ||
186 | case TOKEN_NE: | ||
187 | case TOKEN_LPAREN: | ||
188 | case TOKEN_RPAREN: | ||
189 | case TOKEN_CONTAINS: | ||
190 | case TOKEN_EQUALS: | ||
191 | case TOKEN_STARTSWITH: | ||
192 | case TOKEN_ENDSWITH: | ||
193 | return tokentypetostring(token->kind); | ||
194 | case TOKEN_NUM: rb->snprintf(bufbla,40,"%d",token->intvalue); | ||
195 | return bufbla; | ||
196 | case TOKEN_NUMIDENTIFIER: | ||
197 | return numidtostring(token->intvalue); | ||
198 | case TOKEN_STRING: return token->spelling; | ||
199 | case TOKEN_STRINGIDENTIFIER: | ||
200 | return stridtostring(token->intvalue); | ||
201 | case TOKEN_EDIT: return tokentostring(&editing.old_token); | ||
202 | default: return "unknown token"; | ||
203 | } | ||
204 | } | ||