diff options
Diffstat (limited to 'src')
75 files changed, 243 insertions, 223 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 42a668c756..d533b758c7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,13 +11,13 @@ SUBDIRS = \ include $(INTLEMU_SUBDIRS) \ util \ arm \ - datacache \ - datastore \ fragmentation \ hello \ peerinfo \ resolver \ statistics \ + datacache \ + datastore \ template \ transport \ core \ diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 7f120e6a6a..7ae3e9513d 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -39,7 +39,7 @@ struct ArmContext void *cls; char *service_name; struct GNUNET_CLIENT_Connection *client; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_TIME_Absolute timeout; uint16_t type; }; @@ -195,7 +195,7 @@ send_service_msg (void *cls, size_t size, void *buf) */ static void change_service (const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls, uint16_t type) @@ -266,7 +266,7 @@ change_service (const char *service_name, */ void GNUNET_ARM_start_service (const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls) @@ -308,7 +308,7 @@ GNUNET_ARM_start_service (const char *service_name, */ void GNUNET_ARM_stop_service (const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls) diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index f8f5bc20f1..740fd25338 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -111,7 +111,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (term != NULL) { diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index a844452711..32674117c7 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -124,7 +124,7 @@ static struct ServiceList *running; /** * Our configuration */ -static struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -562,7 +562,7 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_SCHEDULER_NO_TASK, - MAINT_FREQUENCY, &maint, cfg); + MAINT_FREQUENCY, &maint, NULL); /* check for services that died (WAITPID) */ prev = NULL; @@ -675,7 +675,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *c) + const struct GNUNET_CONFIGURATION_Handle *c) { char *defaultservices; char *pos; diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 89f63d3ec5..fbd90583ee 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c @@ -38,7 +38,7 @@ static struct GNUNET_SCHEDULER_Handle *sched; -static struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; static int ok = 1; @@ -84,7 +84,8 @@ static void task (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *c) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; sched = s; diff --git a/src/core/core_api.c b/src/core/core_api.c index 67b21ca266..f3e30eb9a7 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -43,7 +43,7 @@ struct GNUNET_CORE_Handle /** * Configuration we're using. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Closure for the various callbacks. @@ -777,7 +777,7 @@ transmit_start (void *cls, size_t size, void *buf) */ void GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, void *cls, GNUNET_CORE_StartupCallback init, diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 0a96d82880..6f6129f77c 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -617,7 +617,7 @@ struct GNUNET_SCHEDULER_Handle *sched; /** * Our configuration. */ -struct GNUNET_CONFIGURATION_Handle *cfg; +const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our server. @@ -3121,7 +3121,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, - struct GNUNET_SERVER_Handle *serv, struct GNUNET_CONFIGURATION_Handle *c) + struct GNUNET_SERVER_Handle *serv, + const struct GNUNET_CONFIGURATION_Handle *c) { #if 0 unsigned long long qin; @@ -3206,7 +3207,8 @@ run (void *cls, * Function called during shutdown. Clean up our state. */ static void -cleanup (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +cleanup (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (my_private_key != NULL) GNUNET_CRYPTO_rsa_key_free (my_private_key); diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index f2095025ff..89aa9b13eb 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -48,7 +48,7 @@ struct PeerContext { - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CORE_Handle *ch; struct GNUNET_PeerIdentity id; struct GNUNET_TRANSPORT_Handle *th; @@ -313,7 +313,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index c3ea855932..f1993325c2 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -45,7 +45,7 @@ struct PeerContext { - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CORE_Handle *ch; struct GNUNET_PeerIdentity id; #if START_ARM @@ -176,7 +176,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; diff --git a/src/datacache/datacache_api.c b/src/datacache/datacache_api.c index 0958c1d2c5..421acac0ff 100644 --- a/src/datacache/datacache_api.c +++ b/src/datacache/datacache_api.c @@ -47,7 +47,7 @@ struct GNUNET_DATACACHE_Handle /** * Our configuration. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Configuration section to use. @@ -118,7 +118,7 @@ env_delete_notify (void *cls, */ struct GNUNET_DATACACHE_Handle * GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) { int fd; diff --git a/src/datacache/perf_datacache_api.c b/src/datacache/perf_datacache_api.c index b1c8d4ba64..aa008a3322 100644 --- a/src/datacache/perf_datacache_api.c +++ b/src/datacache/perf_datacache_api.c @@ -54,7 +54,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h index e099cd31d4..39119339dd 100644 --- a/src/datacache/plugin_datacache.h +++ b/src/datacache/plugin_datacache.h @@ -66,7 +66,7 @@ struct GNUNET_DATACACHE_PluginEnvironment /** * Configuration to use. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Configuration section to use. diff --git a/src/datacache/test_datacache_api.c b/src/datacache/test_datacache_api.c index 0b36e0ef22..5207fa2a5d 100644 --- a/src/datacache/test_datacache_api.c +++ b/src/datacache/test_datacache_api.c @@ -58,7 +58,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; diff --git a/src/datacache/test_datacache_api_quota.c b/src/datacache/test_datacache_api_quota.c index fda5d425b3..c912c49276 100644 --- a/src/datacache/test_datacache_api_quota.c +++ b/src/datacache/test_datacache_api_quota.c @@ -42,7 +42,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 361f76e4a0..73783cfb8b 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -37,7 +37,7 @@ struct GNUNET_DATASTORE_Handle /** * Our configuration. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -82,7 +82,7 @@ struct GNUNET_DATASTORE_Handle * @param sched scheduler to use * @return handle to use to access the service */ -struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct +struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index b0719b69bc..26e894bf4b 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -156,7 +156,7 @@ static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; /** * Our configuration. */ -struct GNUNET_CONFIGURATION_Handle *cfg; +const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -1248,7 +1248,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *c) + const struct GNUNET_CONFIGURATION_Handle *c) { char *fn; unsigned int bf_size; diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 5a966358db..5fdf74f229 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -93,7 +93,7 @@ enum RunPhase struct CpsRunContext { struct GNUNET_SCHEDULER_Handle *sched; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; enum RunPhase phase; int j; unsigned long long size; @@ -318,7 +318,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index dae8e74320..26299830a6 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -71,7 +71,7 @@ struct CpsRunContext struct GNUNET_TIME_Absolute start; struct GNUNET_TIME_Absolute end; struct GNUNET_SCHEDULER_Handle *sched; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_DATASTORE_PluginFunctions * api; const char *msg; enum RunPhase phase; @@ -195,7 +195,7 @@ iterateDummy (void *cls, */ static void unload_plugin (struct GNUNET_DATASTORE_PluginFunctions * api, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *name; char *libname; @@ -315,7 +315,7 @@ test (void *cls, * Load the datastore plugin. */ static struct GNUNET_DATASTORE_PluginFunctions * -load_plugin (struct GNUNET_CONFIGURATION_Handle *cfg, +load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched) { static struct GNUNET_DATASTORE_PluginEnvironment env; @@ -350,7 +350,7 @@ run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, - struct GNUNET_CONFIGURATION_Handle *c) + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_DATASTORE_PluginFunctions *api; struct CpsRunContext *crc; diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h index 849188ce1f..2fefa2eca0 100644 --- a/src/datastore/plugin_datastore.h +++ b/src/datastore/plugin_datastore.h @@ -52,7 +52,7 @@ struct GNUNET_DATASTORE_PluginEnvironment /** * Configuration to use. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Scheduler to use. diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index af4dcc3229..e76b21cb2f 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -208,7 +208,7 @@ create_indices (sqlite3 * dbh) * @return GNUNET_OK on success */ static int -database_setup (struct GNUNET_CONFIGURATION_Handle *cfg, +database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, struct Plugin *plugin) { sqlite3_stmt *stmt; diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 005c11a586..3a9f8a235f 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -120,7 +120,7 @@ struct CpsRunContext int rid; int *iptr; struct GNUNET_SCHEDULER_Handle *sched; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; void *data; size_t size; enum RunPhase phase; @@ -527,7 +527,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index f5dfa8a07f..cbefe9d096 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -109,7 +109,7 @@ struct CpsRunContext int i; int found; struct GNUNET_SCHEDULER_Handle *sched; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; void *data; size_t size; enum RunPhase phase; @@ -298,7 +298,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 281459b759..7d075cf808 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -135,7 +135,7 @@ run (void *cls, struct GNUNET_SCHEDULER_Handle * sched, char *const *args, const char *cfgfile, - struct GNUNET_CONFIGURATION_Handle * cfg) + const struct GNUNET_CONFIGURATION_Handle * cfg) { GNUNET_CORE_ClientEventHandler ch = NULL; GNUNET_CORE_ClientEventHandler dh = NULL; diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 785e189ab5..bc98a2bcfe 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -40,7 +40,7 @@ /** * Our configuration. */ -static struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -611,7 +611,7 @@ process_stat (void *cls, * Start downloading hostlists from hostlist servers as necessary. */ int -GNUNET_HOSTLIST_client_start (struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ClientEventHandler *ch, diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/hostlist-client.h index a17e1383f1..8adf67af97 100644 --- a/src/hostlist/hostlist-client.h +++ b/src/hostlist/hostlist-client.h @@ -40,7 +40,7 @@ * @return GNUNET_OK on success */ int -GNUNET_HOSTLIST_client_start (struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ClientEventHandler *ch, diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 6139283ed7..34e9310e44 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -43,7 +43,7 @@ static struct MHD_Daemon *daemon_handle; /** * Our configuration. */ -static struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -259,7 +259,7 @@ prepare_daemon () * @return GNUNET_OK on success */ int -GNUNET_HOSTLIST_server_start (struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st) { diff --git a/src/hostlist/hostlist-server.h b/src/hostlist/hostlist-server.h index 16f6848a50..c6c6337e7d 100644 --- a/src/hostlist/hostlist-server.h +++ b/src/hostlist/hostlist-server.h @@ -38,7 +38,7 @@ * @return GNUNET_OK on success */ int -GNUNET_HOSTLIST_server_start (struct GNUNET_CONFIGURATION_Handle *c, +GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_STATISTICS_Handle *st); diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index 5a929a37e3..bbb8cb0f6a 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h @@ -71,7 +71,7 @@ typedef void (*GNUNET_ARM_Callback) (void *cls, int success); */ void GNUNET_ARM_start_service (const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls); @@ -91,7 +91,7 @@ GNUNET_ARM_start_service (const char *service_name, */ void GNUNET_ARM_stop_service (const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls); diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index 6a77aa391c..eb8e1d127e 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h @@ -59,7 +59,7 @@ struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (struct *sched, const char *service_name, - struct + const struct GNUNET_CONFIGURATION_Handle *cfg); @@ -143,7 +143,7 @@ void GNUNET_CLIENT_service_shutdown (struct GNUNET_CLIENT_Connection *sock); */ void GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, const char *service, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task task, void *task_cls); diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index 3f7d099ce3..abbfe2eec0 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h @@ -88,13 +88,13 @@ int GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, * changed since the last save. * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed) */ -int GNUNET_CONFIGURATION_is_dirty (struct GNUNET_CONFIGURATION_Handle *cfg); +int GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg); /** * Get a configuration value that should be a number. * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle +int GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number); @@ -105,7 +105,7 @@ int GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle * @param time set to the time value stored in the configuration * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle +int GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time); @@ -114,7 +114,7 @@ int GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle * Test if we have a value for a particular option * @return GNUNET_YES if so, GNUNET_NO if not. */ -int GNUNET_CONFIGURATION_have_value (struct GNUNET_CONFIGURATION_Handle *cfg, +int GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option); /** @@ -123,7 +123,7 @@ int GNUNET_CONFIGURATION_have_value (struct GNUNET_CONFIGURATION_Handle *cfg, * value, or NULL if option is not specified * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle +int GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value); @@ -135,7 +135,7 @@ int GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle * value, or NULL if option is not specified * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_CONFIGURATION_get_value_filename (struct +int GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, @@ -146,7 +146,7 @@ int GNUNET_CONFIGURATION_get_value_filename (struct * * @return number of filenames iterated over, -1 on error */ -int GNUNET_CONFIGURATION_iterate_value_filenames (struct +int GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, @@ -163,7 +163,7 @@ int GNUNET_CONFIGURATION_iterate_value_filenames (struct * or NULL if option is not specified and no default given * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_CONFIGURATION_get_value_choice (struct GNUNET_CONFIGURATION_Handle +int GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char **choices, @@ -175,7 +175,7 @@ int GNUNET_CONFIGURATION_get_value_choice (struct GNUNET_CONFIGURATION_Handle * * @return GNUNET_YES, GNUNET_NO or if option has no valid value, GNUNET_SYSERR */ -int GNUNET_CONFIGURATION_get_value_yesno (struct GNUNET_CONFIGURATION_Handle +int GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option); @@ -187,7 +187,7 @@ int GNUNET_CONFIGURATION_get_value_yesno (struct GNUNET_CONFIGURATION_Handle * @param old string to $-expand (will be freed!) * @return $-expanded string */ -char *GNUNET_CONFIGURATION_expand_dollar (struct GNUNET_CONFIGURATION_Handle +char *GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *old); /** diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index a096569ef0..a772813365 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -171,7 +171,7 @@ typedef void */ void GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, void *cls, GNUNET_CORE_StartupCallback init, diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index c913a64628..8eb724bfa2 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h @@ -58,7 +58,7 @@ struct GNUNET_DATACACHE_Handle; */ struct GNUNET_DATACACHE_Handle * GNUNET_DATACACHE_create (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section); diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index ccbe4e0765..28419126fd 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -55,7 +55,7 @@ struct GNUNET_DATASTORE_Handle; * @param sched scheduler to use * @return handle to use to access the service */ -struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct +struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, struct diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index a8a51ab787..7f463b83e9 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h @@ -359,7 +359,7 @@ int GNUNET_DISK_file_change_owner (const char *filename, const char *user); * private directory name. * @return the constructed filename */ -char *GNUNET_DISK_get_home_filename (struct GNUNET_CONFIGURATION_Handle *cfg, +char *GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *serviceName, ...); diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 0f61bc764c..e45a46ef45 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -1368,7 +1368,7 @@ struct GNUNET_FS_Handle; */ struct GNUNET_FS_Handle * GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls); diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 7221555688..e7063d3d0a 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h @@ -60,11 +60,6 @@ struct GNUNET_GETOPT_CommandLineProcessorContext const struct GNUNET_GETOPT_CommandLineOption *allOptions; /** - * For configuration - */ - struct GNUNET_CONFIGURATION_Handle *cfg; - - /** * Original command line */ char *const *argv; @@ -192,7 +187,6 @@ struct GNUNET_GETOPT_CommandLineOption * Parse the command line. * * @param binaryName name of the binary / application with options - * @param cfg for storing/accessing configuration data * @param allOptions defined options and handlers * @param argc number of arguments * @param argv actual arguments @@ -200,7 +194,6 @@ struct GNUNET_GETOPT_CommandLineOption * argument, or GNUNET_SYSERR on error */ int GNUNET_GETOPT_run (const char *binaryName, - struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv); diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 1d4d474417..cce805ba09 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h @@ -115,7 +115,8 @@ void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor * @return -1 on error, otherwise load value (between 0 and 100, * (100 is equivalent to full load for one CPU) */ -int GNUNET_OS_load_cpu_get (struct GNUNET_CONFIGURATION_Handle *cfg); +int GNUNET_OS_load_cpu_get (const struct GNUNET_CONFIGURATION_Handle *cfg); + /** * Get the current IO load. @@ -125,7 +126,7 @@ int GNUNET_OS_load_cpu_get (struct GNUNET_CONFIGURATION_Handle *cfg); * 100 means that we spend all of our cycles waiting for * the disk) */ -int GNUNET_OS_load_disk_get (struct GNUNET_CONFIGURATION_Handle *cfg); +int GNUNET_OS_load_disk_get (const struct GNUNET_CONFIGURATION_Handle *cfg); /** diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h index 45c52c447a..54fc680336 100644 --- a/src/include/gnunet_peerinfo_service.h +++ b/src/include/gnunet_peerinfo_service.h @@ -51,7 +51,7 @@ extern "C" * @param hello the verified (!) HELLO message */ void -GNUNET_PEERINFO_add_peer (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello); @@ -90,7 +90,7 @@ typedef void * @param callback_cls closure for callback */ void -GNUNET_PEERINFO_for_all (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, const struct GNUNET_PeerIdentity *peer, int trust_delta, diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h index fcd00b8ef6..a44f4f11e7 100644 --- a/src/include/gnunet_program_lib.h +++ b/src/include/gnunet_program_lib.h @@ -52,7 +52,7 @@ typedef void (*GNUNET_PROGRAM_Main) (void *cls, struct GNUNET_SCHEDULER_Handle * sched, char *const *args, const char *cfgfile, - struct GNUNET_CONFIGURATION_Handle * + const struct GNUNET_CONFIGURATION_Handle * cfg); diff --git a/src/include/gnunet_pseudonym_lib.h b/src/include/gnunet_pseudonym_lib.h index 0ee9ce7ac8..ced9bf387d 100644 --- a/src/include/gnunet_pseudonym_lib.h +++ b/src/include/gnunet_pseudonym_lib.h @@ -59,7 +59,7 @@ typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls, * @param delta by how much should the rating be changed? * @return new rating of the namespace */ -int GNUNET_PSEUDONYM_rank (struct GNUNET_CONFIGURATION_Handle *cfg, +int GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * pseudonym, int delta); /** @@ -67,7 +67,7 @@ int GNUNET_PSEUDONYM_rank (struct GNUNET_CONFIGURATION_Handle *cfg, * * @param pseudonym the pseudonym's identifier */ -void GNUNET_PSEUDONYM_add (struct GNUNET_CONFIGURATION_Handle *cfg, +void GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * pseudo, const struct GNUNET_CONTAINER_MetaData *meta); @@ -75,7 +75,7 @@ void GNUNET_PSEUDONYM_add (struct GNUNET_CONFIGURATION_Handle *cfg, /** * List all known pseudonyms. */ -int GNUNET_PSEUDONYM_list_all (struct GNUNET_CONFIGURATION_Handle *cfg, +int GNUNET_PSEUDONYM_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PSEUDONYM_Iterator iterator, void *closure); @@ -83,7 +83,7 @@ int GNUNET_PSEUDONYM_list_all (struct GNUNET_CONFIGURATION_Handle *cfg, * Register callback to be invoked whenever we discover * a new pseudonym. */ -int GNUNET_PSEUDONYM_discovery_callback_register (struct +int GNUNET_PSEUDONYM_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PSEUDONYM_Iterator @@ -101,7 +101,7 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator * * @return NULL on failure (should never happen) */ -char *GNUNET_PSEUDONYM_id_to_name (struct GNUNET_CONFIGURATION_Handle *cfg, +char *GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * pseudo); /** @@ -109,7 +109,7 @@ char *GNUNET_PSEUDONYM_id_to_name (struct GNUNET_CONFIGURATION_Handle *cfg, * * @return GNUNET_OK on success */ -int GNUNET_PSEUDONYM_name_to_id (struct GNUNET_CONFIGURATION_Handle *cfg, +int GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hname, GNUNET_HashCode * psid); diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h index ac7aebcc7e..6d96cc56f8 100644 --- a/src/include/gnunet_resolver_service.h +++ b/src/include/gnunet_resolver_service.h @@ -65,7 +65,7 @@ typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls, */ void GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, int domain, struct GNUNET_TIME_Relative timeout, @@ -84,7 +84,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, */ void GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, int domain, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, @@ -115,7 +115,7 @@ typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls, * @param cls closure for callback */ void GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const struct sockaddr *sa, socklen_t salen, int do_resolve, diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index dbfb2588bd..4d0eefb989 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h @@ -50,7 +50,7 @@ extern "C" typedef void (*GNUNET_SERVICE_Main) (void *cls, struct GNUNET_SCHEDULER_Handle * sched, struct GNUNET_SERVER_Handle * server, - struct GNUNET_CONFIGURATION_Handle * + const struct GNUNET_CONFIGURATION_Handle * cfg); @@ -62,7 +62,7 @@ typedef void (*GNUNET_SERVICE_Main) (void *cls, * @param cfg configuration to use */ typedef void (*GNUNET_SERVICE_Term) (void *cls, - struct GNUNET_CONFIGURATION_Handle * + const struct GNUNET_CONFIGURATION_Handle * cfg); @@ -103,7 +103,7 @@ struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, struct GNUNET_SCHEDULER_Handle *sched, - struct + const struct GNUNET_CONFIGURATION_Handle *cfg); diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index 8dd11094c8..2496f4091f 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h @@ -78,7 +78,7 @@ typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, struct GNUNET_STATISTICS_Handle *GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, const char *subsystem, - struct GNUNET_CONFIGURATION_Handle *cfg); + const struct GNUNET_CONFIGURATION_Handle *cfg); /** diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 41dc21f75c..3a18a17c3b 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -58,16 +58,21 @@ struct GNUNET_TESTING_Daemon; * * @param cls closure * @param id identifier for the daemon, NULL on error - * @param d handle to the daemon, NULL if starting the daemon failed + * @param d handle for the daemon + * @param emsg error message (NULL on success) */ typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls, const struct GNUNET_PeerIdentity *id, - struct GNUNET_TESTING_Daemon *d); + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_TESTING_Daemon *d, + const char *emsg); /** * Starts a GNUnet daemon. * + * @param sched scheduler to use + * @param cfg configuration to use * @param service_home directory to use as the service home directory * @param transports transport services that should be loaded * @param applications application services and daemons that should be started @@ -76,8 +81,9 @@ typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls, * (use NULL for localhost). * @param cb function to call with the result * @param cb_cls closure for cb + * @return handle to the daemon (actual start will be completed asynchronously) */ -void +struct GNUNET_TESTING_Daemon * GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_home, @@ -94,10 +100,10 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, * particular operation was completed the testing library. * * @param cls closure - * @param success GNUNET_YES on success + * @param emsg NULL on success */ typedef void (*GNUNET_TESTING_NotifyCompletion)(void *cls, - int success); + const char *emsg); /** @@ -112,17 +118,34 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, void * cb_cls); +/** + * Changes the configuration of a GNUnet daemon. + * + * @param d the daemon that should be modified + * @param cfg the new configuration for the daemon + * @param cb function called once the configuration was changed + * @param cb_cls closure for cb + */ +void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, + struct GNUNET_CONFIGURATION_Handle *cfg, + GNUNET_TESTING_NotifyCompletion cb, + void * cb_cls); + + /** * Establish a connection between two GNUnet daemons. * * @param d1 handle for the first daemon * @param d2 handle for the second daemon + * @param timeout how long is the connection attempt + * allowed to take? * @param cb function to call at the end * @param cb_cls closure for cb */ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, struct GNUNET_TESTING_Daemon *d2, + struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyCompletion cb, void *cb_cls); @@ -134,11 +157,13 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, * be computed by adding delta each time (zero * times for the first peer). * + * @param sched scheduler to use + * @param cfg configuration to use * @param total number of daemons to start - * @param service_home_prefix path to use as the prefix for the home of the services + * @param service_home_prefix path to use as the prefix for the home of the services; + * a number will be added for the different peers * @param transports which transports should all peers use * @param applications which applications should be used? - * @param timeout how long is this allowed to take? * @param cb function to call on each daemon that was started * @param cb_cls closure for cb * @param cbe function to call at the end diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 391a87e9de..037a247a2b 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -111,7 +111,7 @@ typedef void struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct + const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_TRANSPORT_ReceiveCallback diff --git a/src/peerinfo/gnunet-peerinfo.c b/src/peerinfo/gnunet-peerinfo.c index 6c737c88a0..3ade1468f4 100644 --- a/src/peerinfo/gnunet-peerinfo.c +++ b/src/peerinfo/gnunet-peerinfo.c @@ -70,7 +70,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CRYPTO_RsaPrivateKey *priv; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 6b709e84aa..3a6030fdac 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -652,7 +652,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index ba5ade199b..28865edc6d 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -79,7 +79,7 @@ copy_and_free (void *cls, size_t size, void *buf) * @param expiration when the HELLO will expire */ void -GNUNET_PEERINFO_add_peer (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello) @@ -251,7 +251,7 @@ copy_then_receive (void *cls, size_t size, void *buf) * @param callback_cls closure for callback */ void -GNUNET_PEERINFO_for_all (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SCHEDULER_Handle *sched, const struct GNUNET_PeerIdentity *peer, int trust_delta, diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index c0b6847b6b..b912419793 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c @@ -103,7 +103,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_HELLO_Message *hello; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; diff --git a/src/resolver/gnunet-service-resolver.c b/src/resolver/gnunet-service-resolver.c index ad62424a51..ed7cbbe8fa 100644 --- a/src/resolver/gnunet-service-resolver.c +++ b/src/resolver/gnunet-service-resolver.c @@ -450,7 +450,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_SERVER_add_handlers (server, handlers); } diff --git a/src/resolver/resolver_api.c b/src/resolver/resolver_api.c index 27358996ac..16debff6aa 100644 --- a/src/resolver/resolver_api.c +++ b/src/resolver/resolver_api.c @@ -187,7 +187,7 @@ transmit_get_ip (void *cls, size_t size, void *buf) */ void GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, int domain, struct GNUNET_TIME_Relative timeout, @@ -349,7 +349,7 @@ transmit_get_hostname (void *cls, size_t size, void *buf) */ void GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, const struct sockaddr *sa, socklen_t salen, int do_resolve, @@ -439,7 +439,7 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, */ void GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, int domain, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, diff --git a/src/resolver/test_resolver_api.c b/src/resolver/test_resolver_api.c index b28dd0ca48..295217c30f 100644 --- a/src/resolver/test_resolver_api.c +++ b/src/resolver/test_resolver_api.c @@ -126,7 +126,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct sockaddr_in sa; struct GNUNET_TIME_Relative timeout = diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 1c0981b805..e4c3fe040d 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -96,7 +96,7 @@ static uint32_t uidgen; */ static void load (struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *fn; struct GNUNET_DISK_FileHandle *fh; @@ -157,7 +157,8 @@ load (struct GNUNET_SERVER_Handle *server, * @param cfg configuration to use */ static void -save (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +save (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct StatsEntry *pos; char *fn; @@ -441,7 +442,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_SERVER_add_handlers (server, handlers); load (server, cfg); diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index bafb77c66b..fe75f93aa1 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -106,7 +106,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_STATISTICS_Handle *h; unsigned long long val; diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 5cbbfc9b61..26e2425e60 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -131,7 +131,7 @@ struct GNUNET_STATISTICS_Handle /** * Configuration to use. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Socket (if available). @@ -208,7 +208,7 @@ free_action_item (struct ActionItem *ai) struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, const char *subsystem, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_STATISTICS_Handle *ret; diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index b9f81d652f..97e2f59c74 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -91,7 +91,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); @@ -107,7 +108,8 @@ static void run_more (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); GNUNET_STATISTICS_get (h, NULL, "test-3", diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c index c43d681d79..3ab7d3dcc6 100644 --- a/src/template/gnunet-service-template.c +++ b/src/template/gnunet-service-template.c @@ -34,7 +34,8 @@ * @param cfg configuration to use */ static void -finish (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +finish (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* FIXME */ } @@ -61,7 +62,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* FIXME: do setup here */ GNUNET_SERVER_add_handlers (server, handlers); diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c index ea47c7f45b..ad0da8159b 100644 --- a/src/template/gnunet-template.c +++ b/src/template/gnunet-template.c @@ -46,7 +46,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* main code here */ } diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 04d9d88010..a67023542b 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -151,7 +151,7 @@ static struct GNUNET_SCHEDULER_Handle * sched; /** * Our configuration. */ -static struct GNUNET_CONFIGURATION_Handle * cfg; +static const struct GNUNET_CONFIGURATION_Handle * cfg; /** * Handle to the core API. @@ -725,7 +725,7 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { * Read the friends file. */ static void -read_friends_file (struct GNUNET_CONFIGURATION_Handle *cfg) +read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) { char *fn; char *data; @@ -998,7 +998,7 @@ run (void *cls, struct GNUNET_SCHEDULER_Handle * s, char *const *args, const char *cfgfile, - struct GNUNET_CONFIGURATION_Handle * c) + const struct GNUNET_CONFIGURATION_Handle * c) { struct GNUNET_CORE_MessageHandler handlers[] = { diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 96d2001aa1..d97cb15eb3 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -547,7 +547,7 @@ struct GNUNET_SCHEDULER_Handle *sched; /** * Our configuration. */ -struct GNUNET_CONFIGURATION_Handle *cfg; +const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Linked list of all clients to this service. @@ -2553,7 +2553,8 @@ client_disconnect_notification (void *cls, static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, - struct GNUNET_SERVER_Handle *serv, struct GNUNET_CONFIGURATION_Handle *c) + struct GNUNET_SERVER_Handle *serv, + const struct GNUNET_CONFIGURATION_Handle *c) { char *plugs; char *pos; @@ -2634,7 +2635,8 @@ run (void *cls, * @param cfg configuration to use */ static void -unload_plugins (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +unload_plugins (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct TransportPlugin *plug; struct AddressList *al; diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h index 2a2e90d2a7..1c545480d0 100644 --- a/src/transport/plugin_transport.h +++ b/src/transport/plugin_transport.h @@ -177,7 +177,7 @@ struct GNUNET_TRANSPORT_PluginEnvironment /** * Configuration to use. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Scheduler to use. diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index ef6c8a76a9..981ce142a5 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -67,7 +67,7 @@ struct GNUNET_SCHEDULER_Handle *sched; /** * Our configuration. */ -struct GNUNET_CONFIGURATION_Handle *cfg; +const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Number of neighbours we'd like to have. @@ -135,7 +135,8 @@ void lookup (void *cls, * @param cfg configuration to use */ static void -unload_plugins (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +unload_plugins (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_tcp",api)); if (my_private_key != NULL) @@ -256,7 +257,7 @@ run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, const char *cfgfile, - struct GNUNET_CONFIGURATION_Handle *c) + const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long tneigh; char *keyfile; diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index fb8cfe302d..f96710c38c 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -44,7 +44,7 @@ struct PeerContext { - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_PeerIdentity id; #if START_ARM @@ -232,7 +232,8 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index eef0ede5eb..3a5c8e0f5b 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -313,7 +313,7 @@ struct GNUNET_TRANSPORT_Handle /** * My configuration. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Linked list of the current neighbours of this peer. @@ -1430,7 +1430,7 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h, */ struct GNUNET_TRANSPORT_Handle * GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_TRANSPORT_ReceiveCallback rec, GNUNET_TRANSPORT_NotifyConnect nc, diff --git a/src/util/client.c b/src/util/client.c index 7d380fa5c2..ab50d9d4d9 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -124,7 +124,7 @@ struct GNUNET_CLIENT_Connection struct GNUNET_CLIENT_Connection * GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched, const char *service_name, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CLIENT_Connection *ret; struct GNUNET_NETWORK_SocketHandle *sock; @@ -455,7 +455,7 @@ write_test (void *cls, size_t size, void *buf) void GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, const char *service, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task task, void *task_cls) { diff --git a/src/util/configuration.c b/src/util/configuration.c index eacbdbf05e..769d2aadc3 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -235,7 +235,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, } int -GNUNET_CONFIGURATION_test_dirty (struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_CONFIGURATION_test_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg) { return cfg->dirty; } @@ -316,7 +316,7 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *data, static struct ConfigSection * -findSection (struct GNUNET_CONFIGURATION_Handle *data, const char *section) +findSection (const struct GNUNET_CONFIGURATION_Handle *data, const char *section) { struct ConfigSection *pos; @@ -328,7 +328,7 @@ findSection (struct GNUNET_CONFIGURATION_Handle *data, const char *section) static struct ConfigEntry * -findEntry (struct GNUNET_CONFIGURATION_Handle *data, +findEntry (const struct GNUNET_CONFIGURATION_Handle *data, const char *section, const char *key) { struct ConfigSection *sec; @@ -386,7 +386,7 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle } int -GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle +GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number) @@ -402,7 +402,7 @@ GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle } int -GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle +GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time) @@ -420,7 +420,7 @@ GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle } int -GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle +GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value) { @@ -437,7 +437,7 @@ GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle } int -GNUNET_CONFIGURATION_get_value_choice (struct GNUNET_CONFIGURATION_Handle +GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char **choices, @@ -473,7 +473,7 @@ GNUNET_CONFIGURATION_get_value_choice (struct GNUNET_CONFIGURATION_Handle * @return GNUNET_YES if so, GNUNET_NO if not. */ int -GNUNET_CONFIGURATION_have_value (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option) { struct ConfigEntry *e; @@ -491,7 +491,7 @@ GNUNET_CONFIGURATION_have_value (struct GNUNET_CONFIGURATION_Handle *cfg, * @return $-expanded string */ char * -GNUNET_CONFIGURATION_expand_dollar (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig) { int i; @@ -543,7 +543,7 @@ GNUNET_CONFIGURATION_expand_dollar (struct GNUNET_CONFIGURATION_Handle *cfg, * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_CONFIGURATION_get_value_filename (struct GNUNET_CONFIGURATION_Handle +GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *data, const char *section, const char *option, char **value) { @@ -574,7 +574,7 @@ GNUNET_CONFIGURATION_get_value_filename (struct GNUNET_CONFIGURATION_Handle * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR */ int -GNUNET_CONFIGURATION_get_value_yesno (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option) { static const char *yesno[] = { "YES", "NO", NULL }; @@ -597,7 +597,7 @@ GNUNET_CONFIGURATION_get_value_yesno (struct GNUNET_CONFIGURATION_Handle *cfg, * @return number of filenames iterated over, -1 on error */ int -GNUNET_CONFIGURATION_iterate_value_filenames (struct +GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, diff --git a/src/util/disk.c b/src/util/disk.c index b0f92c7f28..ff4aff1f70 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1132,6 +1132,7 @@ GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h) * a directory, end the last argument in '/' (or pass * DIR_SEPARATOR_STR as the last argument before NULL). * + * @param cfg configuration to use (determines HOME) * @param serviceName name of the service * @param varargs is NULL-terminated list of * path components to append to the @@ -1139,7 +1140,7 @@ GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h) * @return the constructed filename */ char * -GNUNET_DISK_get_home_filename (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *serviceName, ...) { const char *c; diff --git a/src/util/getopt.c b/src/util/getopt.c index e069e76f7f..799146e77d 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c @@ -997,7 +997,6 @@ GNgetopt_long (int argc, */ int GNUNET_GETOPT_run (const char *binaryOptions, - struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv) { @@ -1017,7 +1016,6 @@ GNUNET_GETOPT_run (const char *binaryOptions, clpc.allOptions = allOptions; clpc.argv = argv; clpc.argc = argc; - clpc.cfg = cfg; count = 0; while (allOptions[count].name != NULL) count++; diff --git a/src/util/os_load.c b/src/util/os_load.c index d1115e33f9..21e74eb49d 100644 --- a/src/util/os_load.c +++ b/src/util/os_load.c @@ -517,7 +517,7 @@ updateUsage () * that lock has already been obtained. */ static void -updateAgedLoad (struct GNUNET_CONFIGURATION_Handle *cfg) +updateAgedLoad (const struct GNUNET_CONFIGURATION_Handle *cfg) { static struct GNUNET_TIME_Absolute lastCall; @@ -573,7 +573,7 @@ updateAgedLoad (struct GNUNET_CONFIGURATION_Handle *cfg) * (100 is equivalent to full load) */ int -GNUNET_OS_load_cpu_get (struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_OS_load_cpu_get (const struct GNUNET_CONFIGURATION_Handle *cfg) { unsigned long long maxCPULoad; int ret; @@ -596,7 +596,7 @@ GNUNET_OS_load_cpu_get (struct GNUNET_CONFIGURATION_Handle *cfg) * (100 is equivalent to full load) */ int -GNUNET_OS_load_disk_get (struct GNUNET_CONFIGURATION_Handle *cfg) +GNUNET_OS_load_disk_get (const struct GNUNET_CONFIGURATION_Handle *cfg) { unsigned long long maxIOLoad; int ret; diff --git a/src/util/program.c b/src/util/program.c index c8ebfc4eb7..0cff324f80 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -63,7 +63,7 @@ struct CommandContext /** * Configuration to use. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; }; @@ -127,6 +127,7 @@ GNUNET_PROGRAM_run (int argc, char *loglev; int ret; unsigned int cnt; + struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_GETOPT_CommandLineOption defoptions[] = { GNUNET_GETOPT_OPTION_CFG_FILE (&cc.cfgfile), GNUNET_GETOPT_OPTION_HELP (binaryHelp), @@ -139,7 +140,7 @@ GNUNET_PROGRAM_run (int argc, loglev = NULL; cc.task = task; cc.task_cls = task_cls; - cc.cfg = GNUNET_CONFIGURATION_create (); + cc.cfg = cfg = GNUNET_CONFIGURATION_create (); /* prepare */ #if ENABLE_NLS @@ -169,15 +170,14 @@ GNUNET_PROGRAM_run (int argc, qsort (allopts, cnt, sizeof (struct GNUNET_GETOPT_CommandLineOption), &cmd_sorter); loglev = GNUNET_strdup ("WARNING"); - if ((-1 == (ret = GNUNET_GETOPT_run (binaryName, - cc.cfg, + if ((-1 == (ret = GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv))) || ((GNUNET_OK != GNUNET_log_setup (binaryName, loglev, NULL)) || - (GNUNET_OK != GNUNET_CONFIGURATION_load (cc.cfg, cc.cfgfile)))) + (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))) { GNUNET_free_non_null (cc.cfgfile); @@ -192,7 +192,7 @@ GNUNET_PROGRAM_run (int argc, GNUNET_SCHEDULER_run (&program_main, &cc); /* clean up */ - GNUNET_CONFIGURATION_destroy (cc.cfg); + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free_non_null (cc.cfgfile); GNUNET_free (loglev); return GNUNET_OK; diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index 52351c2c86..5bf336060f 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c @@ -64,7 +64,7 @@ internal_notify (const GNUNET_HashCode * id, * a new pseudonym. */ int -GNUNET_PSEUDONYM_discovery_callback_register (struct +GNUNET_PSEUDONYM_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PSEUDONYM_Iterator @@ -115,7 +115,7 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator * pseudonym identifier and directory prefix. */ static char * -get_data_filename (struct GNUNET_CONFIGURATION_Handle +get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *prefix, const GNUNET_HashCode * psid) { struct GNUNET_CRYPTO_HashAsciiEncoded enc; @@ -131,7 +131,7 @@ get_data_filename (struct GNUNET_CONFIGURATION_Handle } static void -write_pseudonym_info (struct GNUNET_CONFIGURATION_Handle *cfg, +write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * nsid, const struct GNUNET_CONTAINER_MetaData *meta, int32_t ranking, const char *ns_name) @@ -179,7 +179,7 @@ write_pseudonym_info (struct GNUNET_CONFIGURATION_Handle *cfg, } static int -read_info (struct GNUNET_CONFIGURATION_Handle *cfg, +read_info (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * nsid, struct GNUNET_CONTAINER_MetaData **meta, int32_t * ranking, char **ns_name) @@ -273,7 +273,7 @@ read_info (struct GNUNET_CONFIGURATION_Handle *cfg, * @return NULL on failure (should never happen) */ char * -GNUNET_PSEUDONYM_id_to_name (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * nsid) { struct GNUNET_CONTAINER_MetaData *meta; @@ -356,7 +356,7 @@ GNUNET_PSEUDONYM_id_to_name (struct GNUNET_CONFIGURATION_Handle *cfg, * @return GNUNET_OK on success */ int -GNUNET_PSEUDONYM_name_to_id (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *ns_uname, GNUNET_HashCode * nsid) { size_t slen; @@ -408,7 +408,7 @@ struct ListPseudonymClosure { GNUNET_PSEUDONYM_Iterator iterator; void *closure; - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; }; static int @@ -443,7 +443,7 @@ list_pseudonym_helper (void *cls, const char *fullname) * List all available pseudonyms. */ int -GNUNET_PSEUDONYM_list_all (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PSEUDONYM_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PSEUDONYM_Iterator iterator, void *closure) { struct ListPseudonymClosure cls; @@ -470,7 +470,7 @@ GNUNET_PSEUDONYM_list_all (struct GNUNET_CONFIGURATION_Handle *cfg, * @return new rating of the pseudonym */ int -GNUNET_PSEUDONYM_rank (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * nsid, int delta) { struct GNUNET_CONTAINER_MetaData *meta; @@ -513,7 +513,7 @@ merge_meta_helper (EXTRACTOR_KeywordType type, const char *data, void *cls) * @param id the pseudonym identifier */ void -GNUNET_PSEUDONYM_add (struct GNUNET_CONFIGURATION_Handle *cfg, +GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * id, const struct GNUNET_CONTAINER_MetaData *meta) { diff --git a/src/util/service.c b/src/util/service.c index 0569a0fde6..a976fab781 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -420,7 +420,7 @@ struct GNUNET_SERVICE_Context /** * Our configuration. */ - struct GNUNET_CONFIGURATION_Handle *cfg; + const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Handle for the server. @@ -1264,6 +1264,7 @@ GNUNET_SERVICE_run (int argc, char *logfile; int do_daemonize; struct GNUNET_SERVICE_Context sctx; + struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_GETOPT_CommandLineOption service_options[] = { GNUNET_GETOPT_OPTION_CFG_FILE (&cfg_fn), {'d', "daemonize", NULL, @@ -1286,18 +1287,17 @@ GNUNET_SERVICE_run (int argc, sctx.maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE; sctx.task = task; sctx.serviceName = serviceName; - sctx.cfg = GNUNET_CONFIGURATION_create (); + sctx.cfg = cfg = GNUNET_CONFIGURATION_create (); /* setup subsystems */ if ((GNUNET_SYSERR == - GNUNET_GETOPT_run (serviceName, - sctx.cfg, + GNUNET_GETOPT_run (serviceName, service_options, argc, argv)) || (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile)) || (GNUNET_OK != - GNUNET_CONFIGURATION_load (sctx.cfg, cfg_fn)) || + GNUNET_CONFIGURATION_load (cfg, cfg_fn)) || (GNUNET_OK != setup_service (&sctx)) || ((do_daemonize == 1) && @@ -1310,7 +1310,7 @@ GNUNET_SERVICE_run (int argc, GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "write"); GNUNET_break (0 == CLOSE (sctx.ready_confirm_fd)); } - GNUNET_CONFIGURATION_destroy (sctx.cfg); + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free_non_null (sctx.addr); GNUNET_free_non_null (logfile); GNUNET_free (loglev); @@ -1339,7 +1339,7 @@ GNUNET_SERVICE_run (int argc, if (sctx.server != NULL) GNUNET_SERVER_destroy (sctx.server); GNUNET_free_non_null (sctx.my_handlers); - GNUNET_CONFIGURATION_destroy (sctx.cfg); + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free_non_null (sctx.addr); GNUNET_free_non_null (logfile); GNUNET_free (loglev); @@ -1364,7 +1364,7 @@ GNUNET_SERVICE_run (int argc, struct GNUNET_SERVICE_Context * GNUNET_SERVICE_start (const char *serviceName, struct GNUNET_SCHEDULER_Handle *sched, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { int i; struct GNUNET_SERVICE_Context *sctx; diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c index 89e7be863f..7168dd8c13 100644 --- a/src/util/test_getopt.c +++ b/src/util/test_getopt.c @@ -31,7 +31,6 @@ static int testMinimal () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const emptyargv[] = { "test", NULL @@ -40,13 +39,8 @@ testMinimal () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); - if (1 != GNUNET_GETOPT_run ("test", cfg, emptyoptionlist, 1, emptyargv)) - { - GNUNET_CONFIGURATION_destroy (cfg); - return 1; - } - GNUNET_CONFIGURATION_destroy (cfg); + if (1 != GNUNET_GETOPT_run ("test", emptyoptionlist, 1, emptyargv)) + return 1; return 0; } @@ -54,7 +48,6 @@ testMinimal () static int testVerbose () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const myargv[] = { "test", "-V", @@ -68,14 +61,11 @@ testVerbose () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); - if (3 != GNUNET_GETOPT_run ("test", cfg, verboseoptionlist, 4, myargv)) + if (3 != GNUNET_GETOPT_run ("test", verboseoptionlist, 4, myargv)) { GNUNET_break (0); - GNUNET_CONFIGURATION_destroy (cfg); return 1; } - GNUNET_CONFIGURATION_destroy (cfg); if (vflags != 2) { GNUNET_break (0); @@ -87,7 +77,6 @@ testVerbose () static int testVersion () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const myargv[] = { "test_getopt", "-v", @@ -98,22 +87,18 @@ testVersion () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); if (-1 != GNUNET_GETOPT_run ("test_getopt", - cfg, versionoptionlist, 2, myargv)) + versionoptionlist, 2, myargv)) { GNUNET_break (0); - GNUNET_CONFIGURATION_destroy (cfg); return 1; } - GNUNET_CONFIGURATION_destroy (cfg); return 0; } static int testAbout () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const myargv[] = { "test_getopt", "-h", @@ -124,22 +109,18 @@ testAbout () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); if (-1 != GNUNET_GETOPT_run ("test_getopt", - cfg, aboutoptionlist, 2, myargv)) + aboutoptionlist, 2, myargv)) { GNUNET_break (0); - GNUNET_CONFIGURATION_destroy (cfg); return 1; } - GNUNET_CONFIGURATION_destroy (cfg); return 0; } static int testLogOpts () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const myargv[] = { "test_getopt", "-l", "filename", @@ -154,15 +135,12 @@ testLogOpts () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); - if (5 != GNUNET_GETOPT_run ("test_getopt", cfg, logoptionlist, 5, myargv)) + if (5 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 5, myargv)) { GNUNET_break (0); - GNUNET_CONFIGURATION_destroy (cfg); return 1; } GNUNET_assert (fn != NULL); - GNUNET_CONFIGURATION_destroy (cfg); if ((0 != strcmp (level, "WARNING")) || (0 != strcmp (fn, "filename"))) { GNUNET_break (0); @@ -178,7 +156,6 @@ testLogOpts () static int testFlagNum () { - struct GNUNET_CONFIGURATION_Handle *cfg; char *const myargv[] = { "test_getopt", "-f", @@ -199,14 +176,11 @@ testFlagNum () GNUNET_GETOPT_OPTION_END }; - cfg = GNUNET_CONFIGURATION_create (); - if (6 != GNUNET_GETOPT_run ("test_getopt", cfg, logoptionlist, 6, myargv)) + if (6 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 6, myargv)) { GNUNET_break (0); - GNUNET_CONFIGURATION_destroy (cfg); return 1; } - GNUNET_CONFIGURATION_destroy (cfg); if ((1 != flag) || (42 != num) || (42 != lnum)) { GNUNET_break (0); diff --git a/src/util/test_program.c b/src/util/test_program.c index dee602e2a5..5c58123b57 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c @@ -41,7 +41,8 @@ static void runner (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; GNUNET_assert (setme == 1); diff --git a/src/util/test_service.c b/src/util/test_service.c index 233c23ccf3..e8e3f8741d 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c @@ -74,7 +74,7 @@ build_msg (void *cls, size_t size, void *buf) static void ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - struct GNUNET_CONFIGURATION_Handle *cfg = cls; + const struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct GNUNET_CLIENT_Connection *client; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); @@ -108,17 +108,18 @@ static void runner (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); GNUNET_SERVER_add_handlers (server, myhandlers); GNUNET_CLIENT_service_test (sched, "test_service", - cfg, GNUNET_TIME_UNIT_SECONDS, &ready, cfg); + cfg, GNUNET_TIME_UNIT_SECONDS, &ready, (void*) cfg); } static void -term (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) +term (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; *ok = 0; @@ -157,7 +158,7 @@ check () static void ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - struct GNUNET_CONFIGURATION_Handle *cfg = cls; + const struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct GNUNET_CLIENT_Connection *client; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); @@ -176,13 +177,13 @@ static void runner6 (void *cls, struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); GNUNET_SERVER_add_handlers (server, myhandlers); GNUNET_CLIENT_service_test (sched, "test_service6", - cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, cfg); + cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, (void*) cfg); } /** @@ -252,7 +253,8 @@ static void start_stop_main (void *cls, struct GNUNET_SCHEDULER_Handle *sched, char *const *args, - const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ret = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |