1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Michiel van der Kolk
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "searchengine.h"
22 #include "dbinterface.h"
26 void *audio_bufferbase
;
27 void *audio_bufferpointer
;
28 size_t audio_buffer_free
;
29 struct plugin_api
* rb
;
32 void *my_malloc(size_t size
)
36 if (!audio_bufferbase
)
38 audio_bufferbase
= audio_bufferpointer
39 = rb
->plugin_get_audio_buffer(&audio_buffer_free
);
40 audio_bufferpointer
+=3;
41 audio_bufferpointer
=(void *)(((long)audio_bufferpointer
)&~3);
42 audio_buffer_free
-=audio_bufferpointer
-audio_bufferbase
;
44 if (size
+ 4 > audio_buffer_free
)
46 alloc
= audio_bufferpointer
;
47 audio_bufferpointer
+=(size
+3)&~3; // alignment
48 audio_buffer_free
-= (size
+3)&~3;
52 void setmallocpos(void *pointer
)
54 audio_bufferpointer
= pointer
;
55 audio_buffer_free
= audio_bufferpointer
- audio_bufferbase
;
58 /* this is the plugin entry point */
59 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
61 unsigned char *result
,buf
[500];
63 /* if you are using a global api pointer, don't forget to copy it!
64 otherwise you will get lovely "I04: IllInstr" errors... :-) */
67 audio_bufferbase
=audio_bufferpointer
=0;
70 /* now go ahead and have fun! */
71 PUTS("SearchEngine v0.1");
72 parsefd
=rb
->open(parameter
,O_RDONLY
);
74 rb
->splash(2*HZ
,"Unable to open search tokenstream");
77 result
=parse(parsefd
);
78 rb
->snprintf(buf
,250,"Retval: 0x%x",result
);
83 int fd
=rb
->open("/search.m3u", O_WRONLY
|O_CREAT
|O_TRUNC
);
85 for(i
=0;i
<rb
->tagdbheader
->filecount
;i
++)
88 rb
->fdprintf(fd
,"%s\n",getfilename(i
));
92 rb
->snprintf(buf
,250,"Hits: %d",hits
);
95 /* Return PLUGIN_USB_CONNECTED to force a file-tree refresh */
96 return PLUGIN_USB_CONNECTED
;