summaryrefslogtreecommitdiff
path: root/apps/plugins/searchengine/searchengine.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/searchengine/searchengine.c')
-rw-r--r--apps/plugins/searchengine/searchengine.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c
new file mode 100644
index 0000000000..4b14836ddc
--- /dev/null
+++ b/apps/plugins/searchengine/searchengine.c
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id
9 *
10 * Copyright (C) 2005 by Michiel van der Kolk
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "searchengine.h"
20#include "parser.h"
21#include "token.h"
22#include "dbinterface.h"
23
24void *audio_bufferbase;
25void *audio_bufferpointer;
26unsigned int audio_buffer_free;
27struct plugin_api* rb;
28int w, h, y;
29
30void *my_malloc(size_t size)
31{
32 void *alloc;
33
34 if (!audio_bufferbase)
35 {
36 audio_bufferbase = audio_bufferpointer
37 = rb->plugin_get_audio_buffer(&audio_buffer_free);
38 }
39 if (size + 4 > audio_buffer_free)
40 return 0;
41 alloc = audio_bufferpointer;
42 audio_bufferpointer += size + 4;
43 audio_buffer_free -= size + 4;
44 return alloc;
45}
46
47void setmallocpos(void *pointer)
48{
49 audio_bufferpointer = pointer;
50 audio_buffer_free = audio_bufferpointer - audio_bufferbase;
51}
52
53struct token tokenstream[10];
54
55/* this is the plugin entry point */
56enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
57{
58 unsigned char *result,buf[500];
59 /* this macro should be called as the first thing you do in the plugin.
60 it test that the api version and model the plugin was compiled for
61 matches the machine it is running on */
62 TEST_PLUGIN_API(api);
63
64 (void)parameter;
65
66 /* if you are using a global api pointer, don't forget to copy it!
67 otherwise you will get lovely "I04: IllInstr" errors... :-) */
68 rb = api;
69
70 audio_bufferbase=audio_bufferpointer=0;
71 audio_buffer_free=0;
72
73 /* now go ahead and have fun! */
74 rb->splash(HZ*2, true, "SearchEngine v0.1");
75 tokenstream[0].kind=TOKEN_NUMIDENTIFIER;
76 tokenstream[0].intvalue=INTVALUE_YEAR;
77 tokenstream[1].kind=TOKEN_GTE;
78 tokenstream[2].kind=TOKEN_NUM;
79 tokenstream[2].intvalue=1980;
80 tokenstream[3].kind=TOKEN_AND;
81 tokenstream[4].kind=TOKEN_NUMIDENTIFIER;
82 tokenstream[4].intvalue=INTVALUE_YEAR;
83 tokenstream[5].kind=TOKEN_LT;
84 tokenstream[6].kind=TOKEN_NUM;
85 tokenstream[6].intvalue=1990;
86 tokenstream[7].kind=TOKEN_EOF;
87 result=parse(tokenstream);
88 rb->snprintf(buf,250,"Retval: 0x%x",result);
89 PUTS(buf);
90 if(result!=0) {
91 int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC);
92 int i;
93 for(i=0;i<rb->tagdbheader->filecount;i++)
94 if(result[i])
95 rb->fdprintf(fd,"%s\n",getfilename(i));
96/* rb->write(fd,result,rb->tagdbheader->filecount);*/
97 rb->close(fd);
98 }
99 rb->sleep(HZ*10);
100 return PLUGIN_OK;
101}