Packard Bell Vibe 500: change a not so lucky keymap for the bookmark delete.
[kugel-rb.git] / apps / plugins / searchengine / searchengine.c
blobddcd0ead0d35a42203403c67c7ff252bb6ae89ae
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Michiel van der Kolk
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "searchengine.h"
22 #include "parser.h"
23 #include "token.h"
24 #include "dbinterface.h"
26 PLUGIN_HEADER
28 void *audio_bufferbase;
29 void *audio_bufferpointer;
30 size_t audio_buffer_free;
31 int w, h, y;
33 void *my_malloc(size_t size)
35 void *alloc;
37 if (!audio_bufferbase)
39 audio_bufferbase = audio_bufferpointer
40 = rb->plugin_get_audio_buffer(&audio_buffer_free);
41 audio_bufferpointer+=3;
42 audio_bufferpointer=(void *)(((long)audio_bufferpointer)&~3);
43 audio_buffer_free-=audio_bufferpointer-audio_bufferbase;
45 if (size + 4 > audio_buffer_free)
46 return 0;
47 alloc = audio_bufferpointer;
48 audio_bufferpointer +=(size+3)&~3; // alignment
49 audio_buffer_free -= (size+3)&~3;
50 return alloc;
53 void setmallocpos(void *pointer)
55 audio_bufferpointer = pointer;
56 audio_buffer_free = audio_bufferpointer - audio_bufferbase;
59 /* this is the plugin entry point */
60 enum plugin_status plugin_start(const void* parameter)
62 unsigned char *result,buf[500];
63 int parsefd,hits;
65 audio_bufferbase=audio_bufferpointer=0;
66 audio_buffer_free=0;
68 /* now go ahead and have fun! */
69 PUTS("SearchEngine v0.1");
70 parsefd=rb->open(parameter,O_RDONLY);
71 if(parsefd<0) {
72 rb->splash(2*HZ,"Unable to open search tokenstream");
73 return PLUGIN_ERROR;
75 result=parse(parsefd);
76 rb->snprintf(buf,250,"Retval: 0x%x",result);
77 PUTS(buf);
78 rb->close(parsefd);
79 hits=0;
80 if(result!=0) {
81 int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC);
82 int i;
83 for(i=0;i<rb->tagdbheader->filecount;i++)
84 if(result[i]) {
85 hits++;
86 rb->fdprintf(fd,"%s\n",getfilename(i));
88 rb->close(fd);
90 rb->snprintf(buf,250,"Hits: %d",hits);
91 rb->splash(HZ*3,buf);
92 if (result!=0) {
93 /* Return PLUGIN_USB_CONNECTED to force a file-tree refresh */
94 return PLUGIN_USB_CONNECTED;
96 return PLUGIN_OK;