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() {
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);

View file

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

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;