1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #ifndef _omi_conf_h
26 #define _omi_conf_h
27
28 #include <common.h>
29
30 /*
31 **==============================================================================
32 **
33 ** Conf
34 **
35 ** Provides processing of configuration files. Configuration files contain
36 ** options expressed KEY=VALUE pairs. For example:
37 **
38 ** # My Configuration File
39 ** port=1234
40 ** prefix=/usr/local/bin
41 ** libdir=/usr/local/lib
42 ** trace=3
43 mike 1.1 **
44 ** The following example shows how to read key-value pairs form a
45 ** configuration file.
46 **
47 ** Conf* conf = Conf_Open("/etc/mine.conf");
48 **
49 ** if (!conf)
50 ** {
51 ** fprintf(stderr, "error: failed to open file\n");
52 ** exit(1);
53 ** }
54 **
55 ** for (;;)
56 ** {
57 ** const char* key;
58 ** const char* value;
59 ** int r;
60 **
61 ** r = Conf_Read(conf, &key, &value);
62 ** if (r == -1)
63 ** {
64 mike 1.1 ** fprintf(stderr, "error: %s\n", Conf_Error(conf));
65 ** exit(1);
66 ** }
67 **
68 ** printf("key{%s}, value{%s}\n", key, value);
69 ** }
70 **
71 ** Conf_Close(conf);
72 **
73 **==============================================================================
74 */
75
76 BEGIN_EXTERNC
77
78 typedef struct _Conf Conf;
79
80 Conf* Conf_Open(const char* path);
81
82 int Conf_Read(Conf* self, const char** key, const char** value);
83
84 const char* Conf_Error(Conf* self);
85 mike 1.1
86 unsigned int Conf_Line(Conf* self);
87
88 void Conf_Close(Conf* self);
89
90 END_EXTERNC
91
92 #endif /* _omi_conf_h */
|