1 | /* $Id: conf.h 13 2011-04-20 15:41:43Z mmamonski $ */ |
---|
2 | /* |
---|
3 | * PSNC DRMAA 2.0 utilities library |
---|
4 | * Copyright (C) 2012 Poznan Supercomputing and Networking Center |
---|
5 | * |
---|
6 | * This program is free software: you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation, either version 3 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef __DRMAA_UTILS__CONF_H |
---|
21 | #define __DRMAA_UTILS__CONF_H |
---|
22 | |
---|
23 | #ifdef HAVE_CONFIG_H |
---|
24 | # include <config.h> |
---|
25 | #endif |
---|
26 | |
---|
27 | #include <drmaa_utils/common.h> |
---|
28 | |
---|
29 | typedef enum { |
---|
30 | FSD_CONF_INTEGER, |
---|
31 | FSD_CONF_STRING, |
---|
32 | FSD_CONF_DICT |
---|
33 | } fsd_conf_type_t; |
---|
34 | |
---|
35 | struct fsd_conf_option_s { |
---|
36 | fsd_conf_type_t type; |
---|
37 | union { |
---|
38 | int integer; |
---|
39 | char *string; |
---|
40 | fsd_conf_dict_t *dict; |
---|
41 | } val; |
---|
42 | }; |
---|
43 | |
---|
44 | |
---|
45 | /** |
---|
46 | * Read configuration. |
---|
47 | */ |
---|
48 | fsd_conf_dict_t * |
---|
49 | fsd_conf_read( |
---|
50 | fsd_conf_dict_t *configuration, |
---|
51 | const char *filename, bool must_exist, |
---|
52 | const char *content, size_t content_len |
---|
53 | ); |
---|
54 | |
---|
55 | |
---|
56 | fsd_conf_dict_t * |
---|
57 | fsd_conf_load( const char *filename ); |
---|
58 | |
---|
59 | fsd_conf_option_t * |
---|
60 | fsd_conf_option_create( fsd_conf_type_t type, void *value ); |
---|
61 | |
---|
62 | void |
---|
63 | fsd_conf_option_destroy( fsd_conf_option_t *option ); |
---|
64 | |
---|
65 | fsd_conf_option_t * |
---|
66 | fsd_conf_option_merge( fsd_conf_option_t *lhs, fsd_conf_option_t *rhs ); |
---|
67 | |
---|
68 | void |
---|
69 | fsd_conf_option_dump( fsd_conf_option_t *option ); |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | fsd_conf_dict_t * |
---|
74 | fsd_conf_dict_create(void); |
---|
75 | |
---|
76 | void |
---|
77 | fsd_conf_dict_destroy( fsd_conf_dict_t *dict ); |
---|
78 | |
---|
79 | fsd_conf_option_t * |
---|
80 | fsd_conf_dict_get( fsd_conf_dict_t *dict, const char *key ); |
---|
81 | |
---|
82 | void |
---|
83 | fsd_conf_dict_set( |
---|
84 | fsd_conf_dict_t *dict, const char *key, fsd_conf_option_t *value |
---|
85 | ); |
---|
86 | |
---|
87 | fsd_conf_dict_t * |
---|
88 | fsd_conf_dict_merge( fsd_conf_dict_t *lhs, fsd_conf_dict_t *rhs ); |
---|
89 | |
---|
90 | void |
---|
91 | fsd_conf_dict_dump( fsd_conf_dict_t *dict ); |
---|
92 | |
---|
93 | |
---|
94 | /* |
---|
95 | * Versions of functions above which do not raise exceptions. |
---|
96 | * Needed in conf_tab.y |
---|
97 | */ |
---|
98 | |
---|
99 | fsd_conf_option_t * |
---|
100 | fsd_conf_option_create_noraise( fsd_conf_type_t type, void *value ); |
---|
101 | |
---|
102 | fsd_conf_dict_t * |
---|
103 | fsd_conf_dict_create_noraise(void); |
---|
104 | |
---|
105 | int |
---|
106 | fsd_conf_dict_set_noraise( |
---|
107 | fsd_conf_dict_t *dict, const char *key, fsd_conf_option_t *value ); |
---|
108 | |
---|
109 | #endif /* __DRMAA_UTILS__CONF_H */ |
---|
110 | |
---|