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 | |
parent | 6752d1310d2ad37018c8b78614a2496d43c49301 (diff) | |
download | rockbox-238bea737050f22007a06035cdd78c96beb50f06.tar.gz rockbox-238bea737050f22007a06035cdd78c96beb50f06.zip |
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
-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) { | |||
87 | } | 87 | } |
88 | 88 | ||
89 | void loadsongdata() { | 89 | void loadsongdata() { |
90 | if(currententry->loadedsongdata || | 90 | if(currententry->loadedsongdata) |
91 | !currententry->loadedfiledata) | ||
92 | return; | 91 | return; |
93 | currententry->title=(char *)my_malloc(rb->tagdbheader->songlen); | 92 | currententry->title=(char *)my_malloc(rb->tagdbheader->songlen); |
94 | currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen); | 93 | currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen); |
@@ -112,6 +111,9 @@ void loadartistname() { | |||
112 | /* memory optimization possible, only malloc for an album name once, then | 111 | /* memory optimization possible, only malloc for an album name once, then |
113 | * write that pointer to the entrys using it. | 112 | * write that pointer to the entrys using it. |
114 | */ | 113 | */ |
114 | if(currententry->loadedartistname) | ||
115 | return; | ||
116 | loadsongdata(); | ||
115 | currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen); | 117 | currententry->artistname=(char *)my_malloc(rb->tagdbheader->artistlen); |
116 | rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET); | 118 | rb->lseek(*rb->tagdb_fd,currententry->artistoffset,SEEK_SET); |
117 | rb->read(*rb->tagdb_fd,currententry->artistname,rb->tagdbheader->artistlen); | 119 | rb->read(*rb->tagdb_fd,currententry->artistname,rb->tagdbheader->artistlen); |
@@ -120,6 +122,9 @@ void loadartistname() { | |||
120 | 122 | ||
121 | void loadalbumname() { | 123 | void loadalbumname() { |
122 | /* see the note at loadartistname */ | 124 | /* see the note at loadartistname */ |
125 | if(currententry->loadedalbumname) | ||
126 | return; | ||
127 | loadsongdata(); | ||
123 | currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen); | 128 | currententry->albumname=(char *)my_malloc(rb->tagdbheader->albumlen); |
124 | rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET); | 129 | rb->lseek(*rb->tagdb_fd,currententry->albumoffset,SEEK_SET); |
125 | rb->read(*rb->tagdb_fd,currententry->albumname,rb->tagdbheader->albumlen); | 130 | 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() { | |||
188 | s1=getstring(&string1); | 188 | s1=getstring(&string1); |
189 | if(string2.kind==TOKEN_STRINGIDENTIFIER) | 189 | if(string2.kind==TOKEN_STRINGIDENTIFIER) |
190 | s2=getstring(&string2); | 190 | s2=getstring(&string2); |
191 | if(contains) | 191 | if(contains) |
192 | ret[i]=rb->strcasestr(s1,s2)!=0; | 192 | ret[i]=rb->strcasestr(s1,s2)!=0; |
193 | else | 193 | else |
194 | ret[i]=rb->strcasecmp(s1,s2)==0; | 194 | ret[i]=rb->strcasecmp(s1,s2)==0; |
195 | } | 195 | } |
196 | return ret; | 196 | return ret; |
197 | } | 197 | } |
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) | |||
91 | rb->close(fd); | 91 | rb->close(fd); |
92 | } | 92 | } |
93 | rb->snprintf(buf,250,"Hits: %d",hits); | 93 | rb->snprintf(buf,250,"Hits: %d",hits); |
94 | PUTS(buf); | 94 | rb->splash(HZ*3,true,buf); |
95 | rb->sleep(HZ*3); | ||
96 | return PLUGIN_OK; | 95 | return PLUGIN_OK; |
97 | } | 96 | } |
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 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "searchengine.h" | ||
19 | #include "token.h" | 20 | #include "token.h" |
20 | #include "dbinterface.h" | 21 | #include "dbinterface.h" |
21 | 22 | ||
22 | #define REQUIRESONGDATA() if(!currententry->loadedsongdata) loadsongdata(); | ||
23 | #define REQUIRERUNDBDATA() if(!currententry->loadedrundbdata) loadrundbdata(); | ||
24 | #define REQUIREALBUMNAME() if(!currententry->loadedalbumname) { REQUIRESONGDATA(); loadalbumname(); } | ||
25 | #define REQUIREARTISTNAME() if(!currententry->loadedartistname) { REQUIRESONGDATA(); loadartistname(); } | ||
26 | |||
27 | char *getstring(struct token *token) { | 23 | char *getstring(struct token *token) { |
28 | switch(token->kind) { | 24 | switch(token->kind) { |
29 | case TOKEN_STRING: | 25 | case TOKEN_STRING: |
@@ -31,25 +27,27 @@ char *getstring(struct token *token) { | |||
31 | case TOKEN_STRINGIDENTIFIER: | 27 | case TOKEN_STRINGIDENTIFIER: |
32 | switch(token->intvalue) { | 28 | switch(token->intvalue) { |
33 | case INTVALUE_TITLE: | 29 | case INTVALUE_TITLE: |
34 | REQUIRESONGDATA(); | 30 | loadsongdata(); |
35 | return currententry->title; | 31 | return currententry->title; |
36 | case INTVALUE_ARTIST: | 32 | case INTVALUE_ARTIST: |
37 | REQUIREARTISTNAME(); | 33 | loadartistname(); |
38 | return currententry->artistname; | 34 | return currententry->artistname; |
39 | case INTVALUE_ALBUM: | 35 | case INTVALUE_ALBUM: |
40 | REQUIREALBUMNAME(); | 36 | loadalbumname(); |
41 | return currententry->albumname; | 37 | return currententry->albumname; |
42 | case INTVALUE_GENRE: | 38 | case INTVALUE_GENRE: |
43 | REQUIRESONGDATA(); | 39 | loadsongdata(); |
44 | return currententry->genre; | 40 | return currententry->genre; |
45 | case INTVALUE_FILENAME: | 41 | case INTVALUE_FILENAME: |
46 | return currententry->filename; | 42 | return currententry->filename; |
47 | default: | 43 | default: |
44 | rb->splash(HZ*2,true,"unknown stringid intvalue"); | ||
48 | return 0; | 45 | return 0; |
49 | } | 46 | } |
50 | break; | 47 | break; |
51 | default: | 48 | default: |
52 | // report error | 49 | // report error |
50 | rb->splash(HZ*2,true,"unknown token..."); | ||
53 | return 0; | 51 | return 0; |
54 | } | 52 | } |
55 | } | 53 | } |
@@ -61,19 +59,21 @@ int getvalue(struct token *token) { | |||
61 | case TOKEN_NUMIDENTIFIER: | 59 | case TOKEN_NUMIDENTIFIER: |
62 | switch(token->intvalue) { | 60 | switch(token->intvalue) { |
63 | case INTVALUE_YEAR: | 61 | case INTVALUE_YEAR: |
64 | REQUIRESONGDATA(); | 62 | loadsongdata(); |
65 | return currententry->year; | 63 | return currententry->year; |
66 | case INTVALUE_RATING: | 64 | case INTVALUE_RATING: |
67 | REQUIRERUNDBDATA(); | 65 | loadrundbdata(); |
68 | return currententry->rating; | 66 | return currententry->rating; |
69 | case INTVALUE_PLAYCOUNT: | 67 | case INTVALUE_PLAYCOUNT: |
70 | REQUIRERUNDBDATA(); | 68 | loadrundbdata(); |
71 | return currententry->playcount; | 69 | return currententry->playcount; |
72 | default: | 70 | default: |
71 | rb->splash(HZ*2,true,"unknown numid intvalue"); | ||
73 | // report error. | 72 | // report error. |
74 | return 0; | 73 | return 0; |
75 | } | 74 | } |
76 | default: | 75 | default: |
76 | rb->splash(HZ*2,true,"unknown token..."); | ||
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
79 | } | 79 | } |
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 @@ | |||
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include "token.h" | 21 | #include "token.h" |
22 | 22 | ||
23 | |||
24 | #ifdef LITTLE_ENDIAN | ||
25 | #define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \ | ||
26 | ((_x_ & 0x00ff0000) >> 8) | \ | ||
27 | ((_x_ & 0x0000ff00) << 8) | \ | ||
28 | ((_x_ & 0x000000ff) << 24)) | ||
29 | #else | ||
30 | #define BE32(_x_) _x_ | ||
31 | #endif | ||
32 | |||
33 | |||
23 | struct token token; | 34 | struct token token; |
24 | char buf[500]; | 35 | char buf[500]; |
25 | long num; | 36 | long num; |
@@ -62,7 +73,7 @@ main() { | |||
62 | printf("Token intvalue? "); | 73 | printf("Token intvalue? "); |
63 | fflush(stdout); | 74 | fflush(stdout); |
64 | fgets(buf,254,stdin); | 75 | fgets(buf,254,stdin); |
65 | token.intvalue=strtol(buf,0,10); | 76 | token.intvalue=BE32(strtol(buf,0,10)); |
66 | } | 77 | } |
67 | fwrite(&token,sizeof(struct token),1,fp); | 78 | fwrite(&token,sizeof(struct token),1,fp); |
68 | done=token.kind==0; | 79 | done=token.kind==0; |