1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michiel Van Der Kolk 2005-04-28 18:49:23 +00:00
parent 6752d1310d
commit 238bea7370
5 changed files with 35 additions and 20 deletions

View file

@ -87,8 +87,7 @@ void loadentry(int filerecord) {
} }
void loadsongdata() { void loadsongdata() {
if(currententry->loadedsongdata || if(currententry->loadedsongdata)
!currententry->loadedfiledata)
return; return;
currententry->title=(char *)my_malloc(rb->tagdbheader->songlen); currententry->title=(char *)my_malloc(rb->tagdbheader->songlen);
currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen); 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 /* memory optimization possible, only malloc for an album name once, then
* write that pointer to the entrys using it. * write that pointer to the entrys using it.
*/ */
if(currententry->loadedartistname)
return;
loadsongdata();
currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen); currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen);
rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET); rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET);
rb->read(*rb->tagdb_fd,currententry->artistname,rb->tagdbheader->artistlen); rb->read(*rb->tagdb_fd,currententry->artistname,rb->tagdbheader->artistlen);
@ -120,6 +122,9 @@ void loadartistname() {
void loadalbumname() { void loadalbumname() {
/* see the note at loadartistname */ /* see the note at loadartistname */
if(currententry->loadedalbumname)
return;
loadsongdata();
currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen); currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen);
rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET); rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET);
rb->read(*rb->tagdb_fd,currententry->albumname,rb->tagdbheader->albumlen); rb->read(*rb->tagdb_fd,currententry->albumname,rb->tagdbheader->albumlen);

View file

@ -188,10 +188,10 @@ unsigned char *parseCompareString() {
s1=getstring(&string1); s1=getstring(&string1);
if(string2.kind==TOKEN_STRINGIDENTIFIER) if(string2.kind==TOKEN_STRINGIDENTIFIER)
s2=getstring(&string2); s2=getstring(&string2);
if(contains) if(contains)
ret[i]=rb->strcasestr(s1,s2)!=0; ret[i]=rb->strcasestr(s1,s2)!=0;
else else
ret[i]=rb->strcasecmp(s1,s2)==0; ret[i]=rb->strcasecmp(s1,s2)==0;
} }
return ret; return ret;
} }

View file

@ -91,7 +91,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->close(fd); rb->close(fd);
} }
rb->snprintf(buf,250,"Hits: %d",hits); rb->snprintf(buf,250,"Hits: %d",hits);
PUTS(buf); rb->splash(HZ*3,true,buf);
rb->sleep(HZ*3);
return PLUGIN_OK; return PLUGIN_OK;
} }

View file

@ -16,14 +16,10 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "searchengine.h"
#include "token.h" #include "token.h"
#include "dbinterface.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) { char *getstring(struct token *token) {
switch(token->kind) { switch(token->kind) {
case TOKEN_STRING: case TOKEN_STRING:
@ -31,25 +27,27 @@ char *getstring(struct token *token) {
case TOKEN_STRINGIDENTIFIER: case TOKEN_STRINGIDENTIFIER:
switch(token->intvalue) { switch(token->intvalue) {
case INTVALUE_TITLE: case INTVALUE_TITLE:
REQUIRESONGDATA(); loadsongdata();
return currententry->title; return currententry->title;
case INTVALUE_ARTIST: case INTVALUE_ARTIST:
REQUIREARTISTNAME(); loadartistname();
return currententry->artistname; return currententry->artistname;
case INTVALUE_ALBUM: case INTVALUE_ALBUM:
REQUIREALBUMNAME(); loadalbumname();
return currententry->albumname; return currententry->albumname;
case INTVALUE_GENRE: case INTVALUE_GENRE:
REQUIRESONGDATA(); loadsongdata();
return currententry->genre; return currententry->genre;
case INTVALUE_FILENAME: case INTVALUE_FILENAME:
return currententry->filename; return currententry->filename;
default: default:
rb->splash(HZ*2,true,"unknown stringid intvalue");
return 0; return 0;
} }
break; break;
default: default:
// report error // report error
rb->splash(HZ*2,true,"unknown token...");
return 0; return 0;
} }
} }
@ -61,19 +59,21 @@ int getvalue(struct token *token) {
case TOKEN_NUMIDENTIFIER: case TOKEN_NUMIDENTIFIER:
switch(token->intvalue) { switch(token->intvalue) {
case INTVALUE_YEAR: case INTVALUE_YEAR:
REQUIRESONGDATA(); loadsongdata();
return currententry->year; return currententry->year;
case INTVALUE_RATING: case INTVALUE_RATING:
REQUIRERUNDBDATA(); loadrundbdata();
return currententry->rating; return currententry->rating;
case INTVALUE_PLAYCOUNT: case INTVALUE_PLAYCOUNT:
REQUIRERUNDBDATA(); loadrundbdata();
return currententry->playcount; return currententry->playcount;
default: default:
rb->splash(HZ*2,true,"unknown numid intvalue");
// report error. // report error.
return 0; return 0;
} }
default: default:
rb->splash(HZ*2,true,"unknown token...");
return 0; return 0;
} }
} }

View file

@ -20,6 +20,17 @@
#include <stdio.h> #include <stdio.h>
#include "token.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; struct token token;
char buf[500]; char buf[500];
long num; long num;
@ -62,7 +73,7 @@ main() {
printf("Token intvalue? "); printf("Token intvalue? ");
fflush(stdout); fflush(stdout);
fgets(buf,254,stdin); fgets(buf,254,stdin);
token.intvalue=strtol(buf,0,10); token.intvalue=BE32(strtol(buf,0,10));
} }
fwrite(&token,sizeof(struct token),1,fp); fwrite(&token,sizeof(struct token),1,fp);
done=token.kind==0; done=token.kind==0;