diff options
author | Michiel Van Der Kolk <not.valid@email.address> | 2005-04-28 18:49:23 +0000 |
---|---|---|
committer | Michiel Van Der Kolk <not.valid@email.address> | 2005-04-28 18:49:23 +0000 |
commit | 238bea737050f22007a06035cdd78c96beb50f06 (patch) | |
tree | 5d3cd2ddd30d2bc5846dd3b7c9188db95d6305c8 /apps | |
parent | 6752d1310d2ad37018c8b78614a2496d43c49301 (diff) |
dumb dumb dumb dumb dumb.....
some rearrangements of code..
bugs were in the tokentool tokenstream generator X.x..
dumb :/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6380 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/searchengine/dbinterface.c | 9 | ||||
-rw-r--r-- | apps/plugins/searchengine/parser.c | 6 | ||||
-rw-r--r-- | apps/plugins/searchengine/searchengine.c | 3 | ||||
-rw-r--r-- | apps/plugins/searchengine/token.c | 24 | ||||
-rw-r--r-- | apps/plugins/searchengine/tokentool.c | 13 |
5 files changed, 35 insertions, 20 deletions
diff --git a/apps/plugins/searchengine/dbinterface.c b/apps/plugins/searchengine/dbinterface.c index 778a7adb3b..c9bbc12c02 100644 --- a/apps/plugins/searchengine/dbinterface.c +++ b/apps/plugins/searchengine/dbinterface.c @@ -87,8 +87,7 @@ void loadentry(int filerecord) { } void loadsongdata() { - if(currententry->loadedsongdata || - !currententry->loadedfiledata) + if(currententry->loadedsongdata) return; currententry->title=(char *)my_malloc(rb->tagdbheader->songlen); currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen); @@ -112,6 +111,9 @@ void loadartistname() { /* memory optimization possible, only malloc for an album name once, then * write that pointer to the entrys using it. */ + if(currententry->loadedartistname) + return; + loadsongdata(); currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen); rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET); rb->read(*rb->tagdb_fd,currententry->artistname,rb->tagdbheader->artistlen); @@ -120,6 +122,9 @@ void loadartistname() { void loadalbumname() { /* see the note at loadartistname */ + if(currententry->loadedalbumname) + return; + loadsongdata(); currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen); rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET); rb->read(*rb->tagdb_fd,currententry->albumname,rb->tagdbheader->albumlen); diff --git a/apps/plugins/searchengine/parser.c b/apps/plugins/searchengine/parser.c index ad2e4ee538..32849b19e3 100644 --- a/apps/plugins/searchengine/parser.c +++ b/apps/plugins/searchengine/parser.c @@ -188,10 +188,10 @@ unsigned char *parseCompareString() { s1=getstring(&string1); if(string2.kind==TOKEN_STRINGIDENTIFIER) s2=getstring(&string2); - if(contains) - ret[i]=rb->strcasestr(s1,s2)!=0; + if(contains) + ret[i]=rb->strcasestr(s1,s2)!=0; else - ret[i]=rb->strcasecmp(s1,s2)==0; + ret[i]=rb->strcasecmp(s1,s2)==0; } return ret; } diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c index 3926b15eac..16b92369f1 100644 --- a/apps/plugins/searchengine/searchengine.c +++ b/apps/plugins/searchengine/searchengine.c @@ -91,7 +91,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->close(fd); } rb->snprintf(buf,250,"Hits: %d",hits); - PUTS(buf); - rb->sleep(HZ*3); + rb->splash(HZ*3,true,buf); return PLUGIN_OK; } diff --git a/apps/plugins/searchengine/token.c b/apps/plugins/searchengine/token.c index cc4f5b3224..84ce21daeb 100644 --- a/apps/plugins/searchengine/token.c +++ b/apps/plugins/searchengine/token.c @@ -16,14 +16,10 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "searchengine.h" #include "token.h" #include "dbinterface.h" -#define REQUIRESONGDATA() if(!currententry->loadedsongdata) loadsongdata(); -#define REQUIRERUNDBDATA() if(!currententry->loadedrundbdata) loadrundbdata(); -#define REQUIREALBUMNAME() if(!currententry->loadedalbumname) { REQUIRESONGDATA(); loadalbumname(); } -#define REQUIREARTISTNAME() if(!currententry->loadedartistname) { REQUIRESONGDATA(); loadartistname(); } - char *getstring(struct token *token) { switch(token->kind) { case TOKEN_STRING: @@ -31,25 +27,27 @@ char *getstring(struct token *token) { case TOKEN_STRINGIDENTIFIER: switch(token->intvalue) { case INTVALUE_TITLE: - REQUIRESONGDATA(); + loadsongdata(); return currententry->title; case INTVALUE_ARTIST: - REQUIREARTISTNAME(); + loadartistname(); return currententry->artistname; case INTVALUE_ALBUM: - REQUIREALBUMNAME(); + loadalbumname(); return currententry->albumname; case INTVALUE_GENRE: - REQUIRESONGDATA(); + 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; } } @@ -61,19 +59,21 @@ int getvalue(struct token *token) { case TOKEN_NUMIDENTIFIER: switch(token->intvalue) { case INTVALUE_YEAR: - REQUIRESONGDATA(); + loadsongdata(); return currententry->year; case INTVALUE_RATING: - REQUIRERUNDBDATA(); + loadrundbdata(); return currententry->rating; case INTVALUE_PLAYCOUNT: - REQUIRERUNDBDATA(); + 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/tokentool.c b/apps/plugins/searchengine/tokentool.c index 0967192e98..6cca98ecd4 100644 --- a/apps/plugins/searchengine/tokentool.c +++ b/apps/plugins/searchengine/tokentool.c @@ -20,6 +20,17 @@ #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; @@ -62,7 +73,7 @@ main() { printf("Token intvalue? "); fflush(stdout); fgets(buf,254,stdin); - token.intvalue=strtol(buf,0,10); + token.intvalue=BE32(strtol(buf,0,10)); } fwrite(&token,sizeof(struct token),1,fp); done=token.kind==0; |