1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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"
24 #include "dbinterface.h"
28 void *audio_bufferbase
;
29 void *audio_bufferpointer
;
30 size_t audio_buffer_free
;
33 void *my_malloc(size_t size
)
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
)
47 alloc
= audio_bufferpointer
;
48 audio_bufferpointer
+=(size
+3)&~3; // alignment
49 audio_buffer_free
-= (size
+3)&~3;
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];
65 audio_bufferbase
=audio_bufferpointer
=0;
68 /* now go ahead and have fun! */
69 PUTS("SearchEngine v0.1");
70 parsefd
=rb
->open(parameter
,O_RDONLY
);
72 rb
->splash(2*HZ
,"Unable to open search tokenstream");
75 result
=parse(parsefd
);
76 rb
->snprintf(buf
,250,"Retval: 0x%x",result
);
81 int fd
=rb
->open("/search.m3u", O_WRONLY
|O_CREAT
|O_TRUNC
, 0666);
83 for(i
=0;i
<rb
->tagdbheader
->filecount
;i
++)
86 rb
->fdprintf(fd
,"%s\n",getfilename(i
));
90 rb
->snprintf(buf
,250,"Hits: %d",hits
);
93 /* Return PLUGIN_USB_CONNECTED to force a file-tree refresh */
94 return PLUGIN_USB_CONNECTED
;