summaryrefslogtreecommitdiff
path: root/apps/plugins/shortcuts/shortcuts.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/shortcuts/shortcuts.h')
-rw-r--r--apps/plugins/shortcuts/shortcuts.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h
new file mode 100644
index 0000000000..6ccb320a36
--- /dev/null
+++ b/apps/plugins/shortcuts/shortcuts.h
@@ -0,0 +1,90 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Bryan Childs
11 * Copyright (c) 2007 Alexander Levin
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#ifndef _SHORTCUTS_H
22#define _SHORTCUTS_H
23
24#include "plugin.h"
25
26#define PATH_SEPARATOR "/"
27#define PATH_SEPARATOR_LEN 1 /* strlen(PATH_SEPARATOR) */
28
29#if defined(DEBUG) || defined(SIMULATOR)
30#define SC_DEBUG
31#endif
32
33#define SHORTCUTS_FILENAME "/shortcuts.link"
34
35extern struct plugin_api* rb;
36
37typedef struct sc_entry_s
38{
39 char path[MAX_PATH+1];
40 char disp[MAX_PATH+1];
41 bool explicit_disp;
42} sc_entry_t;
43
44typedef struct sc_file_s
45{
46 sc_entry_t *entries;
47 int max_entries; /* Max allowed number of entries */
48 int entry_cnt; /* Current number of entries */
49 int show_last_segments;
50} sc_file_t;
51
52
53extern void *memory_buf;
54extern long memory_bufsize;
55
56
57extern sc_file_t sc_file;
58
59
60/* Allocates a chunk of memory (as much as possible) */
61void allocate_memory(void **buf, size_t *bufsize);
62
63/* Initializes the file */
64void init_sc_file(sc_file_t *file, void *buf, size_t bufsize);
65
66/* Loads shortcuts from the file. Returns true iff succeeded */
67bool load_sc_file(sc_file_t *file, char* filename, bool must_exist,
68 void *entry_buf, size_t entry_bufsize);
69
70/* Writes contents to the file. File is overwritten. */
71bool dump_sc_file(sc_file_t *file, char *filename);
72
73/* Appends the entry to the file. Entry is copied. Returns true iff succeded. */
74bool append_entry(sc_file_t *file, sc_entry_t *entry);
75
76/* Removes the specified entry (0-based index). Returns true iff succeded. */
77bool remove_entry(sc_file_t *file, int entry_idx);
78
79/* Checks whether the index is a valid one for the file. */
80bool is_valid_index(sc_file_t *file, int entry_idx);
81
82bool file_exists(char *filename); /* Does the specified file exist? */
83bool dir_exists(char *path); /* Does the specified dir exist? */
84
85
86#ifdef SC_DEBUG
87void print_file(sc_file_t *file);
88#endif
89
90#endif