A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Linus Nielsen Feltzing
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 CONFIGFILE_H
22#define CONFIGFILE_H
23
24#define TYPE_INT 1
25#define TYPE_ENUM 2
26#define TYPE_STRING 3
27#define TYPE_BOOL 4
28
29struct configdata
30{
31 int type; /* See TYPE_ macros above */
32 int min; /* Min value for integers, should be 0 for enums */
33 int max; /* Max value for integers, value count for enums,
34 buffer size for strings */
35 union
36 {
37 int *int_p;
38 bool *bool_p;
39 char *string;
40 int32_t *int32_p;
41 }; /* Pointer to value, a union of the possible types */
42 char *name; /* Pointer to the name of the item */
43 char **values; /* List of strings for enums, NULL if not enum */
44};
45
46/* configfile_save - Given configdata entries this function will
47 create a config file with these entries, destroying any
48 previous config file of the same name */
49int configfile_save(const char *filename, const struct configdata *cfg,
50 int num_items, int version);
51
52int configfile_load(const char *filename, const struct configdata *cfg,
53 int num_items, int min_version);
54
55/* configfile_get_value - Given a key name, this function will
56 return the integer value for that key.
57
58 Input:
59 filename = config file filename
60 name = (name/value) pair name entry
61 Return:
62 value if (name/value) pair is found
63 -1 if entry is not found
64*/
65int configfile_get_value(const char* filename, const char* name);
66
67/* configure_update_entry - Given a key name and integer value
68 this function will update the entry if found, or add it if
69 not found.
70
71 Input:
72 filename = config file filename
73 name = (name/value) pair name entry
74 val = new value for (name/value) pair
75 Return:
76 1 if the (name/value) pair was found and updated with the new value
77 0 if the (name/value) pair was added as a new entry
78 -1 if error
79*/
80int configfile_update_entry(const char* filename, const char* name, int val);
81
82#endif