summaryrefslogtreecommitdiff
path: root/apps/open_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/open_plugin.h')
-rw-r--r--apps/open_plugin.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/apps/open_plugin.h b/apps/open_plugin.h
new file mode 100644
index 0000000000..2d8a527073
--- /dev/null
+++ b/apps/open_plugin.h
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2020 by William Wilgus
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef OPEN_PLUGIN_H
22#define OPEN_PLUGIN_H
23
24/* Open_plugin module
25 * OP stores and retrieves plugin path and parameters by key
26 * from a dictionary file
27 *
28 * plugins can load other plugins
29 * return rb->plugin_open(path, parameter);
30 */
31
32#ifndef __PCTOOL__
33/* open_plugin path lookup */
34#define OPEN_PLUGIN_DAT PLUGIN_DIR "/plugin.dat"
35#define OPEN_PLUGIN_BUFSZ MAX_PATH
36#define OPEN_PLUGIN_NAMESZ 32
37struct open_plugin_entry_t
38{
39 uint32_t hash;
40 int32_t lang_id;
41 char name[OPEN_PLUGIN_NAMESZ+1];
42 /*char key[OPEN_PLUGIN_BUFSZ+1];*/
43 char path[OPEN_PLUGIN_BUFSZ+1];
44 char param[OPEN_PLUGIN_BUFSZ+1];
45};
46
47inline static void open_plugin_get_hash(const char *key, uint32_t *hash)
48{
49 /* Calculate modified FNV1a hash of string */
50 const uint32_t p = 16777619;
51 *hash = 0x811C9DC5; //seed, 2166136261;
52 while(*key)
53 *hash = (*key++ ^ *hash) * p;
54}
55
56#ifndef PLUGIN
57extern struct open_plugin_entry_t open_plugin_entry;
58uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter);
59int open_plugin_get_entry(const char *key, struct open_plugin_entry_t *entry);
60void open_plugin_browse(const char *key);
61void open_plugin_remove(const char *key);
62int open_plugin_run(const char *key);
63#endif
64
65#endif /*ndef __PCTOOL__ */
66#endif /* OPEN_PLUGIN_H */