fb3644dcd9cd98dfb1fdc5460f455d777ae67bd9
[gnokii.git] / include / cfgreader.h
1 /*
2
3   $Id$
4   
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
10
11   Released under the terms of the GNU GPL, see file COPYING for more details.
12
13   Header file for config file reader.
14
15   $Log$
16   Revision 1.1.1.1.8.1  2001/11/25 23:10:58  short
17       * ... - new cfgreader.c/CFG_GetForeach()
18   some "const" keywords written - they are missing almost everywhere in Gnokii!
19   "CFG_info" is now global public symbol
20    * Global symbols became IMO obsolete: {model,port,initlength,connection,bindir}
21   stdout/stderr are de-buffered (cfgreading is upon startup)
22    * I know that it doesn't belong here but currently there is now generic
23      application init function anywhere.
24    * stdout/stderr de-buffering is already donw at various weird places all
25      through the project
26
27   Revision 1.1.1.1  2001/11/25 21:59:19  short
28   :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
29
30   Revision 1.4  2000/12/19 16:18:19  pkot
31   configure script updates and added shared function for configfile reading
32
33   
34 */
35
36 #ifndef _CFGREADER_H
37 #define _CFGREADER_H
38
39 #include "config.h"
40
41 /* Structure definitions */
42
43 /* A linked list of key/value pairs */
44
45 struct CFG_Entry {
46         struct CFG_Entry *next, *prev;
47         char *key;
48         char *value;
49 };
50
51 struct CFG_Header {
52         struct CFG_Header *next, *prev;
53         struct CFG_Entry *entries;
54         char *section;
55 };
56
57 /* Global variables */
58
59 extern struct CFG_Header *CFG_Info;
60
61 /* Function prototypes */
62
63 struct CFG_Header *CFG_ReadFile(char *filename);
64 char              *CFG_Get(struct CFG_Header *cfg, const char *section, const char *key);
65 typedef void (*CFG_GetForeach_func)(const char *section,const char *key,const char *value);
66 void               CFG_GetForeach(struct CFG_Header *cfg, const char *section, CFG_GetForeach_func func);
67 char              *CFG_Set(struct CFG_Header *cfg, char *section, char *key, 
68                            char *value);
69 int                CFG_WriteFile(struct CFG_Header *cfg, char *filename);
70 int                readconfig(char **model, char **port, char **initlength, char **connection, char **bindir);
71
72 #endif /* _CFGREADER_H */