From c099300c8da48d4f61c6bcb97d1d4e0a0bcf282d Mon Sep 17 00:00:00 2001 From: Michiel Van Der Kolk Date: Thu, 28 Apr 2005 16:39:41 +0000 Subject: Count hits... string searches appear to be broken for now, unsure why, maybe something goes wrong when allocating ram for the strings.. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6373 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/searchengine/parser.c | 14 +++++++++++--- apps/plugins/searchengine/searchengine.c | 10 ++++++++-- apps/plugins/searchengine/token.h | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/plugins/searchengine/parser.c b/apps/plugins/searchengine/parser.c index cbedeb3041..ad2e4ee538 100644 --- a/apps/plugins/searchengine/parser.c +++ b/apps/plugins/searchengine/parser.c @@ -148,11 +148,19 @@ unsigned char *parseCompareString() { rb->snprintf(errormsg,250,"'%d' found where STRING/STRINGID expected\n",currentToken->kind); return 0; } - - contains=currentToken->kind==TOKEN_CONTAINS; + if(currentToken->kind==TOKEN_CONTAINS || - currentToken->kind==TOKEN_EQUALS) + 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); diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c index 0cb090e141..3926b15eac 100644 --- a/apps/plugins/searchengine/searchengine.c +++ b/apps/plugins/searchengine/searchengine.c @@ -54,7 +54,7 @@ void setmallocpos(void *pointer) enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { unsigned char *result,buf[500]; - int parsefd; + int parsefd,hits; /* this macro should be called as the first thing you do in the plugin. it test that the api version and model the plugin was compiled for matches the machine it is running on */ @@ -78,14 +78,20 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->snprintf(buf,250,"Retval: 0x%x",result); PUTS(buf); 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;itagdbheader->filecount;i++) - if(result[i]) + if(result[i]) { + hits++; rb->fdprintf(fd,"%s\n",getfilename(i)); + } /* rb->write(fd,result,rb->tagdbheader->filecount);*/ rb->close(fd); } + rb->snprintf(buf,250,"Hits: %d",hits); + PUTS(buf); + rb->sleep(HZ*3); return PLUGIN_OK; } diff --git a/apps/plugins/searchengine/token.h b/apps/plugins/searchengine/token.h index 0ce27162d3..0df4a6ec5f 100644 --- a/apps/plugins/searchengine/token.h +++ b/apps/plugins/searchengine/token.h @@ -51,7 +51,7 @@ struct token { unsigned char kind; char spelling[256]; - int intvalue; + long intvalue; }; char *getstring(struct token *token); -- cgit v1.2.3