aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-11-13 11:42:15 +0000
committerNils Gillmann <ng0@n0.is>2018-11-13 11:42:15 +0000
commit9d1e77b9331acb9bd8b6c99aa942f62b9759e650 (patch)
tree85475b117fff75b563a6f9512d3ead476a830f7d /src/util/configuration.c
parente8a1a082555f98af40f98fd3a20ccd803ad478f8 (diff)
parent98288a7b26344294a3668101b9c2b502dfc19e12 (diff)
downloadgnunet-9d1e77b9331acb9bd8b6c99aa942f62b9759e650.tar.gz
gnunet-9d1e77b9331acb9bd8b6c99aa942f62b9759e650.zip
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 312e0acd3..197c664db 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -138,6 +138,41 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
138 138
139 139
140/** 140/**
141 * Parse a configuration file @a filename and run the function
142 * @a cb with the resulting configuration object. Then free the
143 * configuration object and return the status value from @a cb.
144 *
145 * @param filename configuration to parse, NULL for "default"
146 * @param cb function to run
147 * @param cb_cls closure for @a cb
148 * @return #GNUNET_SYSERR if parsing the configuration failed,
149 * otherwise return value from @a cb.
150 */
151int
152GNUNET_CONFIGURATION_parse_and_run (const char *filename,
153 GNUNET_CONFIGURATION_Callback cb,
154 void *cb_cls)
155{
156 struct GNUNET_CONFIGURATION_Handle *cfg;
157 int ret;
158
159 cfg = GNUNET_CONFIGURATION_create ();
160 if (GNUNET_OK !=
161 GNUNET_CONFIGURATION_load (cfg,
162 filename))
163 {
164 GNUNET_break (0);
165 GNUNET_CONFIGURATION_destroy (cfg);
166 return GNUNET_SYSERR;
167 }
168 ret = cb (cb_cls,
169 cfg);
170 GNUNET_CONFIGURATION_destroy (cfg);
171 return ret;
172}
173
174
175/**
141 * De-serializes configuration 176 * De-serializes configuration
142 * 177 *
143 * @param cfg configuration to update 178 * @param cfg configuration to update