Code policy...
Removed tokentool for now since this is not the proper place, but what is?
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6383 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/plugins/searchengine/dbinterface.c b/apps/plugins/searchengine/dbinterface.c
index c9bbc12..7cded01 100644
--- a/apps/plugins/searchengine/dbinterface.c
+++ b/apps/plugins/searchengine/dbinterface.c
@@ -44,7 +44,7 @@
p=(char *)entryarray;
// zero all entries.
for(i=0;i<sizeof(struct entry)*rb->tagdbheader->filecount;i++)
- *(p++)=0;
+ *(p++)=0;
if(*rb->tagdb_initialized!=1) {
if(!rb->tagdb_init()) {
// failed loading db
@@ -55,21 +55,21 @@
}
long readlong(int fd) {
- long num;
- rb->read(fd,&num,4);
+ long num;
+ rb->read(fd,&num,4);
#ifdef ROCKBOX_LITTLE_ENDIAN
- num=BE32(num);
+ num=BE32(num);
#endif
- return num;
+ return num;
}
short readshort(int fd) {
- short num;
- rb->read(fd,&num,2);
+ short num;
+ rb->read(fd,&num,2);
#ifdef ROCKBOX_LITTLE_ENDIAN
- num=BE16(num);
+ num=BE16(num);
#endif
- return num;
+ return num;
}
@@ -77,11 +77,11 @@
if(entryarray[filerecord].loadedfiledata==0) {
rb->lseek(*rb->tagdb_fd,FILERECORD2OFFSET(filerecord),SEEK_SET);
entryarray[filerecord].filename=(char *)my_malloc(rb->tagdbheader->filelen);
- rb->read(*rb->tagdb_fd,entryarray[filerecord].filename,rb->tagdbheader->filelen);
- entryarray[filerecord].hash=readlong(*rb->tagdb_fd);
- entryarray[filerecord].songentry=readlong(*rb->tagdb_fd);
- entryarray[filerecord].rundbentry=readlong(*rb->tagdb_fd);
- entryarray[filerecord].loadedfiledata=1;
+ rb->read(*rb->tagdb_fd,entryarray[filerecord].filename,rb->tagdbheader->filelen);
+ entryarray[filerecord].hash=readlong(*rb->tagdb_fd);
+ entryarray[filerecord].songentry=readlong(*rb->tagdb_fd);
+ entryarray[filerecord].rundbentry=readlong(*rb->tagdb_fd);
+ entryarray[filerecord].loadedfiledata=1;
}
currententry=&entryarray[filerecord];
}
@@ -103,7 +103,7 @@
}
void loadrundbdata() {
- // we don't do this yet.
+ // we don't do this yet.
currententry->loadedrundbdata=1;
}
@@ -112,7 +112,7 @@
* write that pointer to the entrys using it.
*/
if(currententry->loadedartistname)
- return;
+ return;
loadsongdata();
currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen);
rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET);
@@ -123,7 +123,7 @@
void loadalbumname() {
/* see the note at loadartistname */
if(currententry->loadedalbumname)
- return;
+ return;
loadsongdata();
currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen);
rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET);
@@ -133,7 +133,7 @@
char *getfilename(int entry) {
if(entryarray[entry].loadedfiledata==0)
- return "error O.o;;;";
+ return "error O.o;;;";
else
- return entryarray[entry].filename;
+ return entryarray[entry].filename;
}
diff --git a/apps/plugins/searchengine/parser.c b/apps/plugins/searchengine/parser.c
index 834c0d4..62423e2 100644
--- a/apps/plugins/searchengine/parser.c
+++ b/apps/plugins/searchengine/parser.c
@@ -29,264 +29,260 @@
char errormsg[250];
unsigned char *parse(int fd) {
- unsigned char *ret=0;
- int i;
- syntaxerror=0;
- parse_fd=fd;
- currentlevel=0;
- if(nofilter==0) {
- nofilter=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
- rb->memset(nofilter,1,rb->tagdbheader->filecount);
- }
- for(i=0;i<20;i++)
- filter[i]=nofilter;
- database_init();
- parser_acceptIt();
- currentToken=&curtoken;
- PUTS("parse");
- ret=parseMExpr();
- if(syntaxerror) {
- PUTS("Syntaxerror");
- rb->splash(HZ*3,true,errormsg);
- }
- parser_accept(TOKEN_EOF);
- return ret;
+ unsigned char *ret=0;
+ int i;
+ syntaxerror=0;
+ parse_fd=fd;
+ currentlevel=0;
+ if(nofilter==0) {
+ nofilter=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
+ rb->memset(nofilter,1,rb->tagdbheader->filecount);
+ }
+ for(i=0;i<20;i++)
+ filter[i]=nofilter;
+ database_init();
+ parser_acceptIt();
+ currentToken=&curtoken;
+ PUTS("parse");
+ ret=parseMExpr();
+ if(syntaxerror) {
+ PUTS("Syntaxerror");
+ rb->splash(HZ*3,true,errormsg);
+ }
+ parser_accept(TOKEN_EOF);
+ return ret;
}
void parser_acceptIt(void) {
- if(syntaxerror) return;
- rb->read(parse_fd,&curtoken,sizeof(struct token));
+ if(syntaxerror) return;
+ rb->read(parse_fd,&curtoken,sizeof(struct token));
}
int parser_accept(unsigned char kind) {
- if(currentToken->kind!=kind) {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where '%d' expected\n",currentToken->kind,kind);
- return 0;
- }
- else {
- parser_acceptIt();
- return 1;
- }
+ if(currentToken->kind!=kind) {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where '%d' expected\n",currentToken->kind,kind);
+ return 0;
+ }
+ else {
+ parser_acceptIt();
+ return 1;
+ }
}
unsigned char *parseCompareNum() {
- struct token number1,number2;
- unsigned char *ret;
- int i,n1=-1,n2=-1;
- int op;
- if(syntaxerror) return 0;
- PUTS("parseCompareNum");
- if(currentToken->kind==TOKEN_NUM ||
- currentToken->kind==TOKEN_NUMIDENTIFIER) {
- rb->memcpy(&number1,currentToken,sizeof(struct token));
- parser_acceptIt();
- }
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where NUM/NUMID expected\n",currentToken->kind);
- return 0;
- }
- if(currentToken->kind>=TOKEN_GT && currentToken->kind <= TOKEN_NE) {
- op=currentToken->kind;
- parser_acceptIt();
- }
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where NUMOP expected\n",currentToken->kind);
- return 0;
- }
- if(currentToken->kind==TOKEN_NUM ||
- currentToken->kind==TOKEN_NUMIDENTIFIER) {
- rb->memcpy(&number2,currentToken,sizeof(struct token));
- parser_acceptIt();
+ struct token number1,number2;
+ unsigned char *ret;
+ int i,n1=-1,n2=-1;
+ int op;
+ if(syntaxerror) return 0;
+ PUTS("parseCompareNum");
+ if(currentToken->kind==TOKEN_NUM ||
+ currentToken->kind==TOKEN_NUMIDENTIFIER) {
+ rb->memcpy(&number1,currentToken,sizeof(struct token));
+ parser_acceptIt();
+ }
+ else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where NUM/NUMID expected\n",currentToken->kind);
+ return 0;
+ }
+ if(currentToken->kind>=TOKEN_GT && currentToken->kind <= TOKEN_NE) {
+ op=currentToken->kind;
+ parser_acceptIt();
+ }
+ else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where NUMOP expected\n",currentToken->kind);
+ return 0;
+ }
+ if(currentToken->kind==TOKEN_NUM ||
+ currentToken->kind==TOKEN_NUMIDENTIFIER) {
+ rb->memcpy(&number2,currentToken,sizeof(struct token));
+ parser_acceptIt();
+ }
+ else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where NUM/NUMID expected\n",currentToken->kind);
+ return 0;
+ }
+ ret=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
+ if(number1.kind==TOKEN_NUM)
+ n1=getvalue(&number1);
+ if(number2.kind==TOKEN_NUM)
+ n2=getvalue(&number2);
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ if(filter[currentlevel][i]) {
+ loadentry(i);
+ if(number1.kind==TOKEN_NUMIDENTIFIER)
+ n1=getvalue(&number1);
+ if(number2.kind==TOKEN_NUMIDENTIFIER)
+ n2=getvalue(&number2);
+ switch(op) {
+ case TOKEN_GT:
+ ret[i]=n1 > n2;
+ break;
+ case TOKEN_GTE:
+ ret[i]=n1 >= n2;
+ break;
+ case TOKEN_LT:
+ ret[i]=n1 < n2;
+ break;
+ case TOKEN_LTE:
+ ret[i]=n1 <= n2;
+ break;
+ case TOKEN_EQ:
+ ret[i]=n1 == n2;
+ break;
+ case TOKEN_NE:
+ ret[i]=n1 != n2;
+ break;
+ }
}
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where NUM/NUMID expected\n",currentToken->kind);
- return 0;
- }
- ret=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
- if(number1.kind==TOKEN_NUM)
- n1=getvalue(&number1);
- if(number2.kind==TOKEN_NUM)
- n2=getvalue(&number2);
- for(i=0;i<rb->tagdbheader->filecount;i++)
- if(filter[currentlevel][i]) {
- loadentry(i);
- if(number1.kind==TOKEN_NUMIDENTIFIER)
- n1=getvalue(&number1);
- if(number2.kind==TOKEN_NUMIDENTIFIER)
- n2=getvalue(&number2);
- switch(op) {
- case TOKEN_GT:
- ret[i]=n1 > n2;
- break;
- case TOKEN_GTE:
- ret[i]=n1 >= n2;
- break;
- case TOKEN_LT:
- ret[i]=n1 < n2;
- break;
- case TOKEN_LTE:
- ret[i]=n1 <= n2;
- break;
- case TOKEN_EQ:
- ret[i]=n1 == n2;
- break;
- case TOKEN_NE:
- ret[i]=n1 != n2;
- break;
- }
- }
- return ret;
+ return ret;
}
unsigned char *parseCompareString() {
- struct token string1,string2;
- unsigned char *ret;
- char *s1=NULL,*s2=NULL;
- int i,contains;
- if(syntaxerror) return 0;
- PUTS("parseCompareString");
- if(currentToken->kind==TOKEN_STRING ||
- currentToken->kind==TOKEN_STRINGIDENTIFIER) {
- rb->memcpy(&string1,currentToken,sizeof(struct token));
- parser_acceptIt();
+ struct token string1,string2;
+ unsigned char *ret;
+ char *s1=NULL,*s2=NULL;
+ int i,contains;
+ if(syntaxerror) return 0;
+ PUTS("parseCompareString");
+ if(currentToken->kind==TOKEN_STRING ||
+ currentToken->kind==TOKEN_STRINGIDENTIFIER) {
+ rb->memcpy(&string1,currentToken,sizeof(struct token));
+ parser_acceptIt();
+ }
+ else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind);
+ return 0;
+ }
+ if(currentToken->kind==TOKEN_CONTAINS ||
+ currentToken->kind==TOKEN_EQUALS) {
+ if(currentToken->kind==TOKEN_CONTAINS) {
+ contains=1;
+ PUTS("Contains");
+ } else {
+ contains=0;
+ PUTS("Equals");
}
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind);
- return 0;
+ parser_acceptIt();
+ } else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where CONTAINS/EQUALS expected\n",currentToken->kind);
+ return 0;
+ }
+ if(currentToken->kind==TOKEN_STRING ||
+ currentToken->kind==TOKEN_STRINGIDENTIFIER) {
+ rb->memcpy(&string2,currentToken,sizeof(struct token));
+ parser_acceptIt();
+ }
+ else {
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind);
+ return 0;
+ }
+ ret=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
+ if(string1.kind==TOKEN_STRING)
+ s1=getstring(&string1);
+ if(string2.kind==TOKEN_STRING)
+ s2=getstring(&string2);
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ if(filter[currentlevel][i]) {
+ loadentry(i);
+ if(string1.kind==TOKEN_STRINGIDENTIFIER)
+ s1=getstring(&string1);
+ if(string2.kind==TOKEN_STRINGIDENTIFIER)
+ s2=getstring(&string2);
+ if(contains)
+ ret[i]=rb->strcasestr(s1,s2)!=0;
+ else
+ ret[i]=rb->strcasecmp(s1,s2)==0;
}
-
- if(currentToken->kind==TOKEN_CONTAINS ||
- currentToken->kind==TOKEN_EQUALS) {
- if(currentToken->kind==TOKEN_CONTAINS) {
- contains=1;
- PUTS("Contains");
- }
- else {
- contains=0;
- PUTS("Equals");
- }
- parser_acceptIt();
- }
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where CONTAINS/EQUALS expected\n",currentToken->kind);
- return 0;
- }
-
- if(currentToken->kind==TOKEN_STRING ||
- currentToken->kind==TOKEN_STRINGIDENTIFIER) {
- rb->memcpy(&string2,currentToken,sizeof(struct token));
- parser_acceptIt();
- }
- else {
- syntaxerror=1;
- rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind);
- return 0;
- }
- ret=my_malloc(sizeof(unsigned char)*rb->tagdbheader->filecount);
- if(string1.kind==TOKEN_STRING)
- s1=getstring(&string1);
- if(string2.kind==TOKEN_STRING)
- s2=getstring(&string2);
- for(i=0;i<rb->tagdbheader->filecount;i++)
- if(filter[currentlevel][i]) {
- loadentry(i);
- if(string1.kind==TOKEN_STRINGIDENTIFIER)
- s1=getstring(&string1);
- if(string2.kind==TOKEN_STRINGIDENTIFIER)
- s2=getstring(&string2);
- if(contains)
- ret[i]=rb->strcasestr(s1,s2)!=0;
- else
- ret[i]=rb->strcasecmp(s1,s2)==0;
- }
- return ret;
+ return ret;
}
unsigned char *parseExpr() {
- unsigned char *ret;
- int i;
- if(syntaxerror) return 0;
- PUTS("parseExpr");
- switch(currentToken->kind) {
- case TOKEN_NOT:
- parser_accept(TOKEN_NOT);
- PUTS("parseNot");
- ret = parseExpr();
- if(ret==NULL) return 0;
- for(i=0;i<rb->tagdbheader->filecount;i++)
- if(filter[currentlevel][i])
- ret[i]=!ret[i];
- break;
- case TOKEN_LPAREN:
- parser_accept(TOKEN_LPAREN);
- currentlevel++;
- ret = parseMExpr();
- currentlevel--;
- if(ret==NULL) return 0;
- parser_accept(TOKEN_RPAREN);
- break;
- case TOKEN_NUM:
- case TOKEN_NUMIDENTIFIER:
- ret = parseCompareNum();
- if(ret==NULL) return 0;
- break;
- case TOKEN_STRING:
- case TOKEN_STRINGIDENTIFIER:
- ret = parseCompareString();
- if(ret==NULL) return 0;
- break;
- default:
- // error, unexpected symbol
- syntaxerror=1;
- rb->snprintf(errormsg,250,"unexpected '%d' found at parseExpr\n",currentToken->kind);
- ret=0;
- break;
- }
- return ret;
+ unsigned char *ret;
+ int i;
+ if(syntaxerror) return 0;
+ PUTS("parseExpr");
+ switch(currentToken->kind) {
+ case TOKEN_NOT:
+ parser_accept(TOKEN_NOT);
+ PUTS("parseNot");
+ ret = parseExpr();
+ if(ret==NULL) return 0;
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ if(filter[currentlevel][i])
+ ret[i]=!ret[i];
+ break;
+ case TOKEN_LPAREN:
+ parser_accept(TOKEN_LPAREN);
+ currentlevel++;
+ ret = parseMExpr();
+ currentlevel--;
+ if(ret==NULL) return 0;
+ parser_accept(TOKEN_RPAREN);
+ break;
+ case TOKEN_NUM:
+ case TOKEN_NUMIDENTIFIER:
+ ret = parseCompareNum();
+ if(ret==NULL) return 0;
+ break;
+ case TOKEN_STRING:
+ case TOKEN_STRINGIDENTIFIER:
+ ret = parseCompareString();
+ if(ret==NULL) return 0;
+ break;
+ default:
+ // error, unexpected symbol
+ syntaxerror=1;
+ rb->snprintf(errormsg,250,"unexpected '%d' found at parseExpr\n",currentToken->kind);
+ ret=0;
+ break;
+ }
+ return ret;
}
unsigned char *parseMExpr() {
- unsigned char *ret,*ret2;
- int i;
- if(syntaxerror) return 0;
- PUTS("parseMExpr");
- ret=parseLExpr();
- while(currentToken->kind==TOKEN_OR) {
- parser_accept(TOKEN_OR);
- PUTS("parseOr");
- ret2 = parseLExpr();
- if(ret2==NULL) return 0;
- for(i=0;i<rb->tagdbheader->filecount;i++)
- if(filter[currentlevel][i]) // this should always be true
- ret[i]=ret[i] || ret2[i];
- else
- rb->splash(HZ*2,true,"An or is having a filter, bad.");
- }
- return ret;
+ unsigned char *ret,*ret2;
+ int i;
+ if(syntaxerror) return 0;
+ PUTS("parseMExpr");
+ ret=parseLExpr();
+ while(currentToken->kind==TOKEN_OR) {
+ parser_accept(TOKEN_OR);
+ PUTS("parseOr");
+ ret2 = parseLExpr();
+ if(ret2==NULL) return 0;
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ if(filter[currentlevel][i]) // this should always be true
+ ret[i]=ret[i] || ret2[i];
+ else
+ rb->splash(HZ*2,true,"An or is having a filter, bad.");
+ }
+ return ret;
}
unsigned char *parseLExpr() {
- unsigned char *ret,*ret2;
- int i;
- if(syntaxerror) return 0;
- PUTS("parseLExpr");
- filter[currentlevel]=nofilter;
- ret=parseExpr();
- filter[currentlevel]=ret;
- while(currentToken->kind==TOKEN_AND) {
- parser_accept(TOKEN_AND);
- PUTS("parseAnd");
- ret2 = parseExpr();
- if(ret2==NULL) return 0;
- for(i=0;i<rb->tagdbheader->filecount;i++)
- ret[i]=ret[i] && ret2[i];
- }
- filter[currentlevel]=nofilter;
- return ret;
+ unsigned char *ret,*ret2;
+ int i;
+ if(syntaxerror) return 0;
+ PUTS("parseLExpr");
+ filter[currentlevel]=nofilter;
+ ret=parseExpr();
+ filter[currentlevel]=ret;
+ while(currentToken->kind==TOKEN_AND) {
+ parser_accept(TOKEN_AND);
+ PUTS("parseAnd");
+ ret2 = parseExpr();
+ if(ret2==NULL) return 0;
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ ret[i]=ret[i] && ret2[i];
+ }
+ filter[currentlevel]=nofilter;
+ return ret;
}
diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c
index 16b9236..5a85af5 100644
--- a/apps/plugins/searchengine/searchengine.c
+++ b/apps/plugins/searchengine/searchengine.c
@@ -72,7 +72,7 @@
parsefd=rb->open(parameter,O_RDONLY);
if(parsefd<0) {
rb->splash(2*HZ,true,"Unable to open search tokenstream");
- return PLUGIN_ERROR;
+ return PLUGIN_ERROR;
}
result=parse(parsefd);
rb->snprintf(buf,250,"Retval: 0x%x",result);
@@ -80,15 +80,14 @@
rb->close(parsefd);
hits=0;
if(result!=0) {
- int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC);
- int i;
- for(i=0;i<rb->tagdbheader->filecount;i++)
- if(result[i]) {
- hits++;
- rb->fdprintf(fd,"%s\n",getfilename(i));
- }
-/* rb->write(fd,result,rb->tagdbheader->filecount);*/
- rb->close(fd);
+ int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC);
+ int i;
+ for(i=0;i<rb->tagdbheader->filecount;i++)
+ if(result[i]) {
+ hits++;
+ rb->fdprintf(fd,"%s\n",getfilename(i));
+ }
+ rb->close(fd);
}
rb->snprintf(buf,250,"Hits: %d",hits);
rb->splash(HZ*3,true,buf);
diff --git a/apps/plugins/searchengine/searchengine.h b/apps/plugins/searchengine/searchengine.h
index d89c9c2..18b68a8 100644
--- a/apps/plugins/searchengine/searchengine.h
+++ b/apps/plugins/searchengine/searchengine.h
@@ -25,15 +25,15 @@
extern int w, h, y;
#ifdef HAVE_LCD_BITMAP
#define PUTS(str) do { \
- rb->lcd_putsxy(1, y, str); \
- rb->lcd_getstringsize(str, &w, &h); \
- y += h + 1; \
+ rb->lcd_putsxy(1, y, str); \
+ rb->lcd_getstringsize(str, &w, &h); \
+ y += h + 1; \
} while (0); \
rb->lcd_update()
#else
#define PUTS(str) do { \
- rb->lcd_puts(0, y, str); \
- y = (y + 1) % 2; \
+ rb->lcd_puts(0, y, str); \
+ y = (y + 1) % 2; \
} while (0);
#endif
diff --git a/apps/plugins/searchengine/token.c b/apps/plugins/searchengine/token.c
index 84ce21d..a98fae4 100644
--- a/apps/plugins/searchengine/token.c
+++ b/apps/plugins/searchengine/token.c
@@ -21,59 +21,59 @@
#include "dbinterface.h"
char *getstring(struct token *token) {
- 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->splash(HZ*2,true,"unknown stringid intvalue");
- return 0;
- }
- break;
- default:
- // report error
- rb->splash(HZ*2,true,"unknown token...");
- return 0;
- }
+ 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->splash(HZ*2,true,"unknown stringid intvalue");
+ return 0;
+ }
+ break;
+ default:
+ // report error
+ rb->splash(HZ*2,true,"unknown token...");
+ return 0;
+ }
}
int getvalue(struct token *token) {
- 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;
- default:
- rb->splash(HZ*2,true,"unknown numid intvalue");
- // report error.
- return 0;
- }
- default:
- rb->splash(HZ*2,true,"unknown token...");
- return 0;
- }
+ 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;
+ default:
+ rb->splash(HZ*2,true,"unknown numid intvalue");
+ // report error.
+ return 0;
+ }
+ default:
+ rb->splash(HZ*2,true,"unknown token...");
+ return 0;
+ }
}
diff --git a/apps/plugins/searchengine/token.h b/apps/plugins/searchengine/token.h
index 0df4a6e..75a88c3 100644
--- a/apps/plugins/searchengine/token.h
+++ b/apps/plugins/searchengine/token.h
@@ -16,8 +16,8 @@
* KIND, either express or implied.
*
****************************************************************************/
-#define TOKEN_INVALID -1
-#define TOKEN_EOF 0 // EOF
+#define TOKEN_INVALID -1
+#define TOKEN_EOF 0 // EOF
#define TOKEN_NOT 1 // "not"
#define TOKEN_AND 2 // "and"
#define TOKEN_OR 3 // "or"
@@ -28,7 +28,7 @@
#define TOKEN_EQ 8 // '=='
#define TOKEN_NE 9 // '!='
#define TOKEN_CONTAINS 10 // "contains"
-#define TOKEN_EQUALS 11 // "equals"
+#define TOKEN_EQUALS 11 // "equals"
#define TOKEN_LPAREN 12 // '('
#define TOKEN_RPAREN 13 // ')'
#define TOKEN_NUM 14 // (0..9)+
@@ -36,17 +36,17 @@
#define TOKEN_STRING 16 // (?)+
#define TOKEN_STRINGIDENTIFIER 17 // album, artist, title, genre ...
-#define INTVALUE_YEAR 1
-#define INTVALUE_RATING 2
-#define INTVALUE_PLAYCOUNT 3
-#define INTVALUE_TITLE 4
-#define INTVALUE_ARTIST 5
-#define INTVALUE_ALBUM 6
-#define INTVALUE_GENRE 7
-#define INTVALUE_FILENAME 8
+#define INTVALUE_YEAR 1
+#define INTVALUE_RATING 2
+#define INTVALUE_PLAYCOUNT 3
+#define INTVALUE_TITLE 4
+#define INTVALUE_ARTIST 5
+#define INTVALUE_ALBUM 6
+#define INTVALUE_GENRE 7
+#define INTVALUE_FILENAME 8
/* static char *spelling[] = { "not", "and", "or",">",">=","<", "<=","==","!=",
- "contains","(",")" }; */
+ "contains","(",")" }; */
struct token {
unsigned char kind;
diff --git a/apps/plugins/searchengine/tokentool.c b/apps/plugins/searchengine/tokentool.c
deleted file mode 100644
index 6cca98e..0000000
--- a/apps/plugins/searchengine/tokentool.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * 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 <stdlib.h>
-#include <stdio.h>
-#include "token.h"
-
-
-#ifdef LITTLE_ENDIAN
-#define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \
- ((_x_ & 0x00ff0000) >> 8) | \
- ((_x_ & 0x0000ff00) << 8) | \
- ((_x_ & 0x000000ff) << 24))
-#else
-#define BE32(_x_) _x_
-#endif
-
-
-struct token token;
-char buf[500];
-long num;
-FILE *fp;
-main() {
- int done=0;
- printf("Output filename? ");
- fflush(stdout);
- fgets(buf,254,stdin);
- buf[strlen(buf)-1]=0;
- fp=fopen(buf,"w");
- if(fp<0) {
- printf("Error opening outputfile.\n");
- return -1;
- }
- do {
- printf("EOF=0 NOT=1 AND=2 OR=3 GT=4 GTE=5 LT=6 LTE=7 EQ=8 NE=9\n");
- printf("(strings:) CONTAINS=10 EQUALS=11\n");
- printf("'('=12 ')'=13\n");
- printf("(arguments:) NUMBER=14 NUMBERFIELD=15 STRING=16 STRINGFIELD=17\n");
- printf("Token kind? ");
- fflush(stdout);
- fgets(buf,254,stdin);
- token.kind=strtol(buf,0,10);
- memset(&token.spelling,0,256);
- if(token.kind==TOKEN_STRING) {
- printf("Token spelling? ");
- fflush(stdout);
- fgets(token.spelling,254,stdin);
- token.spelling[strlen(token.spelling)-1]=0;
- }
- if(token.kind==TOKEN_STRINGIDENTIFIER)
- printf("TITLE=4 ARTIST=5 ALBUM=6 GENRE=7 FILENAME=8\n");
- else if(token.kind==TOKEN_NUMIDENTIFIER)
- printf("YEAR=1 RATING=2 PLAYCOUNT=3\n");
- token.intvalue=0;
- if(token.kind==TOKEN_STRINGIDENTIFIER ||
- token.kind==TOKEN_NUMIDENTIFIER ||
- token.kind==TOKEN_NUM) {
- printf("Token intvalue? ");
- fflush(stdout);
- fgets(buf,254,stdin);
- token.intvalue=BE32(strtol(buf,0,10));
- }
- fwrite(&token,sizeof(struct token),1,fp);
- done=token.kind==0;
- } while(!done);
- fclose(fp);
- printf("Successfully wrote tokenfile\n");
-}