FS#12756 by Marek Salaba - update Czech translation
[maemo-rb.git] / apps / plugins / lib / configfile.h
blob4a980b4e678f95de57985b11af6f4e24d9fc2890
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Linus Nielsen Feltzing
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 #ifndef CONFIGFILE_H
22 #define CONFIGFILE_H
24 #define TYPE_INT 1
25 #define TYPE_ENUM 2
26 #define TYPE_STRING 3
27 #define TYPE_BOOL 4
29 struct configdata
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
37 int *int_p;
38 bool *bool_p;
39 char *string;
40 }; /* Pointer to value, a union of the possible types */
41 char *name; /* Pointer to the name of the item */
42 char **values; /* List of strings for enums, NULL if not enum */
45 /* configfile_save - Given configdata entries this function will
46 create a config file with these entries, destroying any
47 previous config file of the same name */
48 int configfile_save(const char *filename, struct configdata *cfg,
49 int num_items, int version);
51 int configfile_load(const char *filename, struct configdata *cfg,
52 int num_items, int min_version);
54 /* configfile_get_value - Given a key name, this function will
55 return the integer value for that key.
57 Input:
58 filename = config file filename
59 name = (name/value) pair name entry
60 Return:
61 value if (name/value) pair is found
62 -1 if entry is not found
64 int configfile_get_value(const char* filename, const char* name);
66 /* configure_update_entry - Given a key name and integer value
67 this function will update the entry if found, or add it if
68 not found.
70 Input:
71 filename = config file filename
72 name = (name/value) pair name entry
73 val = new value for (name/value) pair
74 Return:
75 1 if the (name/value) pair was found and updated with the new value
76 0 if the (name/value) pair was added as a new entry
77 -1 if error
79 int configfile_update_entry(const char* filename, const char* name, int val);
81 #endif