first step to remove plibc
authorng0 <ng0@n0.is>
Fri, 6 Sep 2019 22:46:29 +0000 (22:46 +0000)
committerng0 <ng0@n0.is>
Fri, 6 Sep 2019 22:46:29 +0000 (22:46 +0000)
185 files changed:
ChangeLog
po/POTFILES.in
src/arm/Kyuafile [new file with mode: 0644]
src/arm/gnunet-arm.c
src/arm/gnunet-service-arm.c
src/arm/test_exponential_backoff.c
src/arm/test_gnunet_service_arm.c
src/ats-tool/gnunet-ats.c
src/cadet/gnunet-cadet-profiler.c
src/cadet/gnunet-cadet.c
src/cadet/test_cadet.c
src/cadet/test_cadet_flow.c
src/conversation/gnunet-conversation.c
src/core/gnunet-core.c
src/core/test_core_api_reliability.c
src/core/test_core_api_start_only.c
src/core/test_core_quota_compliance.c
src/datacache/datacache.c
src/datacache/perf_datacache.c
src/datacache/plugin_datacache_sqlite.c
src/datacache/test_datacache.c
src/datacache/test_datacache_quota.c
src/datastore/gnunet-datastore.c
src/datastore/gnunet-service-datastore.c
src/datastore/perf_datastore_api.c
src/datastore/perf_plugin_datastore.c
src/datastore/plugin_datastore_sqlite.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c
src/datastore/test_plugin_datastore.c
src/dht/gnunet-dht-get.c
src/dht/gnunet-dht-monitor.c
src/dht/gnunet-dht-put.c
src/dht/test_dht_api.c
src/dht/test_dht_topo.c
src/fragmentation/test_fragmentation.c
src/fragmentation/test_fragmentation_parallel.c
src/fs/fs_api.c
src/fs/fs_dirmetascan.c
src/fs/fs_download.c
src/fs/fs_file_information.c
src/fs/fs_namespace.c
src/fs/fs_uri.c
src/fs/gnunet-auto-share.c
src/fs/gnunet-directory.c
src/fs/gnunet-download.c
src/fs/gnunet-fs.c
src/fs/gnunet-helper-fs-publish.c
src/fs/gnunet-publish.c
src/fs/gnunet-search.c
src/fs/gnunet-service-fs_indexing.c
src/fs/gnunet-unindex.c
src/fs/perf_gnunet_service_fs_p2p.c
src/fs/perf_gnunet_service_fs_p2p_respect.c
src/fs/test_fs.c
src/fs/test_fs_directory.c
src/fs/test_fs_download.c
src/fs/test_fs_download_persistence.c
src/fs/test_fs_getopt.c
src/fs/test_fs_list_indexed.c
src/fs/test_fs_namespace.c
src/fs/test_fs_publish.c
src/fs/test_fs_publish_persistence.c
src/fs/test_fs_search.c
src/fs/test_fs_search_persistence.c
src/fs/test_fs_search_probes.c
src/fs/test_fs_search_with_and.c
src/fs/test_fs_unindex.c
src/fs/test_fs_unindex_persistence.c
src/fs/test_fs_uri.c
src/fs/test_gnunet_service_fs_migration.c
src/fs/test_gnunet_service_fs_p2p.c
src/fs/test_plugin_block_fs.c
src/gns/gnunet-bcd.c
src/gns/gnutls_ca.cfg [new file with mode: 0644]
src/gns/plugin_gnsrecord_gns.c
src/gnsrecord/plugin_gnsrecord_dns.c
src/hello/gnunet-hello.c
src/hostlist/hostlists_learn_peer2.file
src/hostlist/test_gnunet_daemon_hostlist_learning.c
src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
src/identity/gnunet-service-identity.c
src/include/Makefile.am
src/include/gnunet_common.h
src/include/platform.h
src/include/plibc.h [deleted file]
src/json/json.c
src/namecache/gnunet-namecache.c
src/namecache/test_plugin_namecache.c
src/namestore/gnunet-namestore.c
src/namestore/test_plugin_namestore.c
src/nat-auto/gnunet-nat-auto.c
src/nat-auto/nat_auto_api_test.c
src/nat/gnunet-nat.c
src/nat/gnunet-service-nat_helper.c
src/nat/gnunet-service-nat_mini.c
src/nse/gnunet-nse-profiler.c
src/nse/gnunet-nse.c
src/nse/test_nse_api.c
src/nse/test_nse_multipeer.c
src/peerinfo-tool/gnunet-peerinfo.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/perf_peerinfo_api.c
src/peerstore/test_plugin_peerstore.c
src/reclaim/oidc_helper.c
src/regex/gnunet-regex-simulation-profiler.c
src/regex/test_regex_api.c
src/regex/test_regex_integration.c
src/revocation/gnunet-revocation.c
src/rps/gnunet-rps.c
src/statistics/gnunet-service-statistics.c
src/statistics/gnunet-statistics.c
src/testbed/generate-underlay-topology.c
src/testbed/gnunet-helper-testbed.c
src/testbed/test_testbed_api_3peers_3controllers.c
src/testbed/test_testbed_api_controllerlink.c
src/testbed/testbed_api_hosts.c
src/testing/gnunet-testing.c
src/testing/list-keys.c
src/testing/testing.c
src/topology/test_gnunet_daemon_topology.c
src/transport/gnunet-communicator-tcp.c
src/transport/gnunet-communicator-udp.c
src/transport/gnunet-communicator-unix.c
src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-transport-profiler.c
src/transport/gnunet-transport.c
src/transport/plugin_transport_smtp.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_udp.c
src/transport/plugin_transport_unix.c
src/transport/tcp_connection_legacy.c
src/transport/tcp_service_legacy.c
src/transport/test_plugin_hostkey
src/transport/test_quota_compliance.c
src/transport/test_transport_address_switch.c
src/transport/test_transport_api_reliability.c
src/transport/test_transport_api_timeout.c
src/transport/test_transport_blacklisting.c
src/util/bio.c
src/util/common_allocation.c
src/util/common_logging.c
src/util/configuration.c
src/util/container_bloomfilter.c
src/util/crypto_ecc_setup.c
src/util/crypto_random.c
src/util/disk.c
src/util/dnsstub.c
src/util/getopt.c
src/util/getopt_helpers.c
src/util/gnunet-ecc.c
src/util/gnunet-resolver.c
src/util/gnunet-scrypt.c
src/util/helper.c
src/util/os_installation.c
src/util/os_priority.c
src/util/perf_crypto_asymmetric.c
src/util/perf_crypto_ecc_dlog.c
src/util/plugin.c
src/util/program.c
src/util/service.c
src/util/strings.c
src/util/test_common_allocation.c
src/util/test_common_logging.c
src/util/test_common_logging_dummy.c
src/util/test_common_logging_runtime_loglevels.c
src/util/test_configuration.c
src/util/test_container_bloomfilter.c
src/util/test_crypto_ecc_dlog.c
src/util/test_crypto_ecdh_eddsa.c
src/util/test_crypto_ecdhe.c
src/util/test_crypto_ecdsa.c
src/util/test_crypto_eddsa.c
src/util/test_crypto_hash.c
src/util/test_crypto_random.c
src/util/test_disk.c
src/util/test_getopt.c
src/util/test_peer.c
src/util/test_resolver_api.c
src/util/test_scheduler.c
src/util/test_scheduler_delay.c
src/util/test_service.c
src/util/test_strings.c
src/util/time.c
src/vpn/gnunet-vpn.c

index dff231b7d57ff16107b89d8029e1426c7e806252..d03d3a4fe29ae383813c8564e1d30abb077f4283 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Sep 6 00:00:00 UTC 2019
+  Remove plibc, closes #5877 as discussed in
+  https://lists.gnu.org/archive/html/gnunet-developers/2019-09/msg00002.html
+  -ng0
+
 Sun Sep 1 13:25:07 2019 +0200
   Improved support for external applications/services wrt
   localization/gettext.
index 2f09e8d8065fc60231927b3c41f0de9d9bd5d7d1..f363cc68a6f61a2b7f7993329eed99c67fe49d99 100644 (file)
@@ -4,6 +4,14 @@ src/arm/arm_monitor_api.c
 src/arm/gnunet-arm.c
 src/arm/gnunet-service-arm.c
 src/arm/mockup-service.c
+src/ats-tests/ats-testing-experiment.c
+src/ats-tests/ats-testing-log.c
+src/ats-tests/ats-testing-preferences.c
+src/ats-tests/ats-testing-traffic.c
+src/ats-tests/ats-testing.c
+src/ats-tests/gnunet-ats-sim.c
+src/ats-tests/gnunet-solver-eval.c
+src/ats-tool/gnunet-ats.c
 src/ats/ats_api2_application.c
 src/ats/ats_api2_transport.c
 src/ats/ats_api_connectivity.c
@@ -11,10 +19,10 @@ src/ats/ats_api_performance.c
 src/ats/ats_api_scanner.c
 src/ats/ats_api_scheduling.c
 src/ats/gnunet-ats-solver-eval.c
-src/ats/gnunet-service-ats_addresses.c
+src/ats/gnunet-service-ats-new.c
 src/ats/gnunet-service-ats.c
+src/ats/gnunet-service-ats_addresses.c
 src/ats/gnunet-service-ats_connectivity.c
-src/ats/gnunet-service-ats-new.c
 src/ats/gnunet-service-ats_normalization.c
 src/ats/gnunet-service-ats_performance.c
 src/ats/gnunet-service-ats_plugins.c
@@ -26,14 +34,6 @@ src/ats/plugin_ats2_simple.c
 src/ats/plugin_ats_mlp.c
 src/ats/plugin_ats_proportional.c
 src/ats/plugin_ats_ril.c
-src/ats-tests/ats-testing.c
-src/ats-tests/ats-testing-experiment.c
-src/ats-tests/ats-testing-log.c
-src/ats-tests/ats-testing-preferences.c
-src/ats-tests/ats-testing-traffic.c
-src/ats-tests/gnunet-ats-sim.c
-src/ats-tests/gnunet-solver-eval.c
-src/ats-tool/gnunet-ats.c
 src/auction/gnunet-auction-create.c
 src/auction/gnunet-auction-info.c
 src/auction/gnunet-auction-join.c
@@ -50,8 +50,8 @@ src/cadet/cadet_api_list_peers.c
 src/cadet/cadet_api_list_tunnels.c
 src/cadet/cadet_test_lib.c
 src/cadet/desirability_table.c
-src/cadet/gnunet-cadet.c
 src/cadet/gnunet-cadet-profiler.c
+src/cadet/gnunet-cadet.c
 src/cadet/gnunet-service-cadet.c
 src/cadet/gnunet-service-cadet_channel.c
 src/cadet/gnunet-service-cadet_connection.c
@@ -67,15 +67,15 @@ src/consensus/gnunet-service-consensus.c
 src/consensus/plugin_block_consensus.c
 src/conversation/conversation_api.c
 src/conversation/conversation_api_call.c
-src/conversation/gnunet-conversation.c
 src/conversation/gnunet-conversation-test.c
-src/conversation/gnunet_gst.c
-src/conversation/gnunet_gst_test.c
-src/conversation/gnunet-helper-audio-playback.c
+src/conversation/gnunet-conversation.c
 src/conversation/gnunet-helper-audio-playback-gst.c
-src/conversation/gnunet-helper-audio-record.c
+src/conversation/gnunet-helper-audio-playback.c
 src/conversation/gnunet-helper-audio-record-gst.c
+src/conversation/gnunet-helper-audio-record.c
 src/conversation/gnunet-service-conversation.c
+src/conversation/gnunet_gst.c
+src/conversation/gnunet_gst_test.c
 src/conversation/microphone.c
 src/conversation/plugin_gnsrecord_conversation.c
 src/conversation/speaker.c
@@ -112,7 +112,6 @@ src/dht/dht_api.c
 src/dht/dht_test_lib.c
 src/dht/gnunet-dht-get.c
 src/dht/gnunet-dht-monitor.c
-src/dht/gnunet_dht_profiler.c
 src/dht/gnunet-dht-put.c
 src/dht/gnunet-service-dht.c
 src/dht/gnunet-service-dht_clients.c
@@ -121,6 +120,7 @@ src/dht/gnunet-service-dht_hello.c
 src/dht/gnunet-service-dht_neighbours.c
 src/dht/gnunet-service-dht_nse.c
 src/dht/gnunet-service-dht_routing.c
+src/dht/gnunet_dht_profiler.c
 src/dht/plugin_block_dht.c
 src/dns/dns_api.c
 src/dns/gnunet-dns-monitor.c
@@ -130,8 +130,8 @@ src/dns/gnunet-service-dns.c
 src/dns/gnunet-zonewalk.c
 src/dns/plugin_block_dns.c
 src/exit/gnunet-daemon-exit.c
-src/exit/gnunet-helper-exit.c
 src/exit/gnunet-helper-exit-windows.c
+src/exit/gnunet-helper-exit.c
 src/fragmentation/defragmentation.c
 src/fragmentation/fragmentation.c
 src/fs/fs_api.c
@@ -156,8 +156,8 @@ src/fs/gnunet-auto-share.c
 src/fs/gnunet-daemon-fsprofiler.c
 src/fs/gnunet-directory.c
 src/fs/gnunet-download.c
-src/fs/gnunet-fs.c
 src/fs/gnunet-fs-profiler.c
+src/fs/gnunet-fs.c
 src/fs/gnunet-helper-fs-publish.c
 src/fs/gnunet-publish.c
 src/fs/gnunet-search.c
@@ -177,10 +177,10 @@ src/gns/gns_tld_api.c
 src/gns/gnunet-bcd.c
 src/gns/gnunet-dns2gns.c
 src/gns/gnunet-gns-benchmark.c
-src/gns/gnunet-gns.c
 src/gns/gnunet-gns-helper-service-w32.c
 src/gns/gnunet-gns-import.c
 src/gns/gnunet-gns-proxy.c
+src/gns/gnunet-gns.c
 src/gns/gnunet-service-gns.c
 src/gns/gnunet-service-gns_interceptor.c
 src/gns/gnunet-service-gns_resolver.c
@@ -189,19 +189,19 @@ src/gns/nss/nss_gns_query.c
 src/gns/plugin_block_gns.c
 src/gns/plugin_gnsrecord_gns.c
 src/gns/plugin_rest_gns.c
+src/gns/w32nsp-install.c
+src/gns/w32nsp-resolve.c
+src/gns/w32nsp-uninstall.c
+src/gns/w32nsp.c
 src/gnsrecord/gnsrecord.c
 src/gnsrecord/gnsrecord_crypto.c
 src/gnsrecord/gnsrecord_misc.c
 src/gnsrecord/gnsrecord_serialization.c
 src/gnsrecord/plugin_gnsrecord_dns.c
-src/gns/w32nsp.c
-src/gns/w32nsp-install.c
-src/gns/w32nsp-resolve.c
-src/gns/w32nsp-uninstall.c
 src/hello/address.c
 src/hello/gnunet-hello.c
-src/hello/hello.c
 src/hello/hello-ng.c
+src/hello/hello.c
 src/hostlist/gnunet-daemon-hostlist.c
 src/hostlist/gnunet-daemon-hostlist_client.c
 src/hostlist/gnunet-daemon-hostlist_server.c
@@ -226,8 +226,8 @@ src/namecache/namecache_api.c
 src/namecache/plugin_namecache_flat.c
 src/namecache/plugin_namecache_postgres.c
 src/namecache/plugin_namecache_sqlite.c
-src/namestore/gnunet-namestore.c
 src/namestore/gnunet-namestore-fcfsd.c
+src/namestore/gnunet-namestore.c
 src/namestore/gnunet-service-namestore.c
 src/namestore/gnunet-zoneimport.c
 src/namestore/namestore_api.c
@@ -243,10 +243,10 @@ src/nat-auto/gnunet-service-nat-auto.c
 src/nat-auto/gnunet-service-nat-auto_legacy.c
 src/nat-auto/nat_auto_api.c
 src/nat-auto/nat_auto_api_test.c
-src/nat/gnunet-helper-nat-client.c
 src/nat/gnunet-helper-nat-client-windows.c
-src/nat/gnunet-helper-nat-server.c
+src/nat/gnunet-helper-nat-client.c
 src/nat/gnunet-helper-nat-server-windows.c
+src/nat/gnunet-helper-nat-server.c
 src/nat/gnunet-nat.c
 src/nat/gnunet-service-nat.c
 src/nat/gnunet-service-nat_externalip.c
@@ -255,17 +255,17 @@ src/nat/gnunet-service-nat_mini.c
 src/nat/gnunet-service-nat_stun.c
 src/nat/nat_api.c
 src/nat/nat_api_stun.c
-src/nse/gnunet-nse.c
 src/nse/gnunet-nse-profiler.c
+src/nse/gnunet-nse.c
 src/nse/gnunet-service-nse.c
 src/nse/nse_api.c
 src/nt/nt.c
-src/peerinfo/gnunet-service-peerinfo.c
-src/peerinfo/peerinfo_api.c
-src/peerinfo/peerinfo_api_notify.c
 src/peerinfo-tool/gnunet-peerinfo.c
 src/peerinfo-tool/gnunet-peerinfo_plugins.c
 src/peerinfo-tool/plugin_rest_peerinfo.c
+src/peerinfo/gnunet-service-peerinfo.c
+src/peerinfo/peerinfo_api.c
+src/peerinfo/peerinfo_api_notify.c
 src/peerstore/gnunet-peerstore.c
 src/peerstore/gnunet-service-peerstore.c
 src/peerstore/peerstore_api.c
@@ -313,22 +313,22 @@ src/revocation/gnunet-revocation.c
 src/revocation/gnunet-service-revocation.c
 src/revocation/plugin_block_revocation.c
 src/revocation/revocation_api.c
-src/rps/gnunet-rps.c
 src/rps/gnunet-rps-profiler.c
+src/rps/gnunet-rps.c
 src/rps/gnunet-service-rps.c
 src/rps/gnunet-service-rps_custommap.c
 src/rps/gnunet-service-rps_sampler.c
 src/rps/gnunet-service-rps_sampler_elem.c
 src/rps/gnunet-service-rps_view.c
-src/rps/rps_api.c
 src/rps/rps-sampler_client.c
 src/rps/rps-sampler_common.c
 src/rps/rps-test_util.c
+src/rps/rps_api.c
 src/scalarproduct/gnunet-scalarproduct.c
-src/scalarproduct/gnunet-service-scalarproduct_alice.c
-src/scalarproduct/gnunet-service-scalarproduct_bob.c
 src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
 src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
+src/scalarproduct/gnunet-service-scalarproduct_alice.c
+src/scalarproduct/gnunet-service-scalarproduct_bob.c
 src/scalarproduct/scalarproduct_api.c
 src/secretsharing/gnunet-secretsharing-profiler.c
 src/secretsharing/gnunet-service-secretsharing.c
@@ -354,15 +354,16 @@ src/statistics/gnunet-statistics.c
 src/statistics/statistics_api.c
 src/template/gnunet-service-template.c
 src/template/gnunet-template.c
+src/testbed-logger/gnunet-service-testbed-logger.c
+src/testbed-logger/testbed_logger_api.c
 src/testbed/generate-underlay-topology.c
 src/testbed/gnunet-daemon-latency-logger.c
 src/testbed/gnunet-daemon-testbed-blacklist.c
 src/testbed/gnunet-daemon-testbed-underlay.c
 src/testbed/gnunet-helper-testbed.c
-src/testbed/gnunet_mpi_test.c
 src/testbed/gnunet-service-test-barriers.c
-src/testbed/gnunet-service-testbed_barriers.c
 src/testbed/gnunet-service-testbed.c
+src/testbed/gnunet-service-testbed_barriers.c
 src/testbed/gnunet-service-testbed_cache.c
 src/testbed/gnunet-service-testbed_connectionpool.c
 src/testbed/gnunet-service-testbed_cpustatus.c
@@ -370,20 +371,19 @@ src/testbed/gnunet-service-testbed_links.c
 src/testbed/gnunet-service-testbed_meminfo.c
 src/testbed/gnunet-service-testbed_oc.c
 src/testbed/gnunet-service-testbed_peers.c
-src/testbed/gnunet_testbed_mpi_spawn.c
 src/testbed/gnunet-testbed-profiler.c
-src/testbed-logger/gnunet-service-testbed-logger.c
-src/testbed-logger/testbed_logger_api.c
-src/testbed/testbed_api_barriers.c
+src/testbed/gnunet_mpi_test.c
+src/testbed/gnunet_testbed_mpi_spawn.c
 src/testbed/testbed_api.c
+src/testbed/testbed_api_barriers.c
 src/testbed/testbed_api_hosts.c
 src/testbed/testbed_api_operations.c
 src/testbed/testbed_api_peers.c
 src/testbed/testbed_api_sd.c
 src/testbed/testbed_api_services.c
 src/testbed/testbed_api_statistics.c
-src/testbed/testbed_api_testbed.c
 src/testbed/testbed_api_test.c
+src/testbed/testbed_api_testbed.c
 src/testbed/testbed_api_topology.c
 src/testbed/testbed_api_underlay.c
 src/testing/gnunet-testing.c
@@ -395,34 +395,40 @@ src/transport/gnunet-communicator-tcp.c
 src/transport/gnunet-communicator-udp.c
 src/transport/gnunet-communicator-unix.c
 src/transport/gnunet-helper-transport-bluetooth.c
-src/transport/gnunet-helper-transport-wlan.c
 src/transport/gnunet-helper-transport-wlan-dummy.c
+src/transport/gnunet-helper-transport-wlan.c
 src/transport/gnunet-service-tng.c
-src/transport/gnunet-service-transport_ats.c
 src/transport/gnunet-service-transport.c
+src/transport/gnunet-service-transport_ats.c
 src/transport/gnunet-service-transport_hello.c
 src/transport/gnunet-service-transport_manipulation.c
 src/transport/gnunet-service-transport_neighbours.c
 src/transport/gnunet-service-transport_plugins.c
 src/transport/gnunet-service-transport_validation.c
-src/transport/gnunet-transport.c
 src/transport/gnunet-transport-profiler.c
 src/transport/gnunet-transport-wlan-receiver.c
 src/transport/gnunet-transport-wlan-sender.c
+src/transport/gnunet-transport.c
 src/transport/plugin_transport_http_client.c
 src/transport/plugin_transport_http_common.c
 src/transport/plugin_transport_http_server.c
 src/transport/plugin_transport_smtp.c
 src/transport/plugin_transport_tcp.c
 src/transport/plugin_transport_template.c
-src/transport/plugin_transport_udp_broadcasting.c
 src/transport/plugin_transport_udp.c
+src/transport/plugin_transport_udp_broadcasting.c
 src/transport/plugin_transport_unix.c
 src/transport/plugin_transport_wlan.c
 src/transport/tcp_connection_legacy.c
 src/transport/tcp_server_legacy.c
 src/transport/tcp_server_mst_legacy.c
 src/transport/tcp_service_legacy.c
+src/transport/transport-testing-filenames.c
+src/transport/transport-testing-loggers.c
+src/transport/transport-testing-main.c
+src/transport/transport-testing-send.c
+src/transport/transport-testing.c
+src/transport/transport-testing2.c
 src/transport/transport_api2_application.c
 src/transport/transport_api2_communication.c
 src/transport/transport_api2_core.c
@@ -435,12 +441,6 @@ src/transport/transport_api_manipulation.c
 src/transport/transport_api_monitor_peers.c
 src/transport/transport_api_monitor_plugins.c
 src/transport/transport_api_offer_hello.c
-src/transport/transport-testing2.c
-src/transport/transport-testing.c
-src/transport/transport-testing-filenames.c
-src/transport/transport-testing-loggers.c
-src/transport/transport-testing-main.c
-src/transport/transport-testing-send.c
 src/util/bandwidth.c
 src/util/benchmark.c
 src/util/bio.c
@@ -453,8 +453,8 @@ src/util/configuration_loader.c
 src/util/container_bloomfilter.c
 src/util/container_heap.c
 src/util/container_meta_data.c
-src/util/container_multihashmap32.c
 src/util/container_multihashmap.c
+src/util/container_multihashmap32.c
 src/util/container_multipeermap.c
 src/util/container_multishortmap.c
 src/util/container_multiuuidmap.c
@@ -477,16 +477,16 @@ src/util/dnsparser.c
 src/util/dnsstub.c
 src/util/getopt.c
 src/util/getopt_helpers.c
-src/util/gnunet-config.c
 src/util/gnunet-config-diff.c
+src/util/gnunet-config.c
 src/util/gnunet-ecc.c
 src/util/gnunet-helper-w32-console.c
 src/util/gnunet-qr.c
 src/util/gnunet-resolver.c
 src/util/gnunet-scrypt.c
 src/util/gnunet-service-resolver.c
-src/util/gnunet-timeout.c
 src/util/gnunet-timeout-w32.c
+src/util/gnunet-timeout.c
 src/util/gnunet-uri.c
 src/util/helper.c
 src/util/load.c
@@ -515,13 +515,13 @@ src/util/tun.c
 src/util/w32cat.c
 src/util/win.c
 src/util/winproc.c
-src/vpn/gnunet-helper-vpn.c
 src/vpn/gnunet-helper-vpn-windows.c
+src/vpn/gnunet-helper-vpn.c
 src/vpn/gnunet-service-vpn.c
 src/vpn/gnunet-vpn.c
 src/vpn/vpn_api.c
-src/zonemaster/gnunet-service-zonemaster.c
 src/zonemaster/gnunet-service-zonemaster-monitor.c
+src/zonemaster/gnunet-service-zonemaster.c
 src/fs/fs_api.h
 src/include/compat.h
 src/include/gnunet_common.h
diff --git a/src/arm/Kyuafile b/src/arm/Kyuafile
new file mode 100644 (file)
index 0000000..f97f05e
--- /dev/null
@@ -0,0 +1,9 @@
+-- Tests for gnunet-arm
+
+syntax(2)
+
+-- name of the test suite
+test_suite('arm')
+
+-- test programs
+atf_test_program{name='atf_tests.sh'}
index 7d705733ad8e9a7eaf2746732a609ff9369fdb64..f96076231fa4095b908203bf98c89b1cf94734c6 100644 (file)
@@ -151,7 +151,7 @@ delete_files ()
     "Will attempt to remove configuration file %s and service directory %s\n",
     config_file,
     dir);
-  if (0 != UNLINK (config_file))
+  if (0 != unlink (config_file))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 _ ("Failed to remove configuration file %s\n"),
@@ -319,7 +319,7 @@ start_callback (void *cls,
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to start the ARM service: %s\n"),
              req_string (rs));
     GNUNET_SCHEDULER_shutdown ();
@@ -328,7 +328,7 @@ start_callback (void *cls,
   if ((GNUNET_ARM_RESULT_STARTING != result) &&
       (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to start the ARM service: %s\n"),
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
@@ -366,7 +366,7 @@ stop_callback (void *cls,
                      "%s",
                      _ (
                        "Failed to send a stop request to the ARM service: %s\n"));
-    FPRINTF (stdout, msg, req_string (rs));
+    fprintf (stdout, msg, req_string (rs));
     GNUNET_free (msg);
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -375,7 +375,7 @@ stop_callback (void *cls,
       (GNUNET_ARM_RESULT_STOPPED != result) &&
       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to stop the ARM service: %s\n"),
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
@@ -413,7 +413,7 @@ init_callback (void *cls,
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to send a request to start the `%s' service: %s\n"),
              init,
              req_string (rs));
@@ -423,7 +423,7 @@ init_callback (void *cls,
   if ((GNUNET_ARM_RESULT_STARTING != result) &&
       (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to start the `%s' service: %s\n"),
              init,
              ret_string (result));
@@ -465,7 +465,7 @@ term_callback (void *cls,
                      _ (
                        "Failed to send a request to kill the `%s' service: %%s\n"),
                      term);
-    FPRINTF (stdout, msg, req_string (rs));
+    fprintf (stdout, msg, req_string (rs));
     GNUNET_free (msg);
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -473,7 +473,7 @@ term_callback (void *cls,
   if ((GNUNET_ARM_RESULT_STOPPED != result) &&
       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Failed to kill the `%s' service: %s\n"),
              term,
              ret_string (result));
@@ -515,14 +515,14 @@ list_callback (void *cls,
     GNUNET_asprintf (&msg,
                      "%s",
                      _ ("Failed to request a list of services: %s\n"));
-    FPRINTF (stdout, msg, req_string (rs));
+    fprintf (stdout, msg, req_string (rs));
     GNUNET_free (msg);
     ret = 3;
     GNUNET_SCHEDULER_shutdown ();
   }
   if (NULL == list)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              _ ("Error communicating with ARM. ARM not running?\n"));
     GNUNET_SCHEDULER_shutdown ();
@@ -530,9 +530,9 @@ list_callback (void *cls,
     return;
   }
   if (! quiet)
-    FPRINTF (stdout, "%s", _ ("Running services:\n"));
+    fprintf (stdout, "%s", _ ("Running services:\n"));
   for (unsigned int i = 0; i < count; i++)
-    FPRINTF (stdout, "%s\n", list[i]);
+    fprintf (stdout, "%s\n", list[i]);
   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
 }
 
@@ -661,9 +661,9 @@ srv_status (void *cls,
   if (! quiet)
   {
     if (NULL != msg)
-      FPRINTF (stderr, msg, service);
+      fprintf (stderr, msg, service);
     else
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ ("Unknown status %u for service %s.\n"),
                status,
                service);
index 4b7cbec20dafbf548e5eaecb37ea1a08c483a2c7..a052575634961626f9a72ccb4d27b2e791ed691b 100644 (file)
 #include "gnunet_protocols.h"
 #include "arm.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
+#define LOG_strerror(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util", syscall)
 
 
 #if HAVE_WAIT4
@@ -100,7 +101,6 @@ struct ServiceListeningInfo
    * Task doing the accepting.
    */
   struct GNUNET_SCHEDULER_Task *accept_task;
-
 };
 
 
@@ -330,9 +330,9 @@ add_unixpath (struct sockaddr **saddrs,
  */
 static int
 get_server_addresses (const char *service_name,
-                     const struct GNUNET_CONFIGURATION_Handle *cfg,
-                     struct sockaddr ***addrs,
-                     socklen_t ** addr_lens)
+                      const struct GNUNET_CONFIGURATION_Handle *cfg,
+                      struct sockaddr ***addrs,
+                      socklen_t **addr_lens)
 {
   int disablev6;
   struct GNUNET_NETWORK_Handle *desc;
@@ -353,15 +353,12 @@ get_server_addresses (const char *service_name,
   *addrs = NULL;
   *addr_lens = NULL;
   desc = NULL;
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                      service_name,
-                                      "DISABLEV6"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
   {
     if (GNUNET_SYSERR ==
-        (disablev6 =
-         GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                              service_name,
-                                              "DISABLEV6")))
+        (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                           service_name,
+                                                           "DISABLEV6")))
       return GNUNET_SYSERR;
   }
   else
@@ -370,24 +367,20 @@ get_server_addresses (const char *service_name,
   if (! disablev6)
   {
     /* probe IPv6 support */
-    desc = GNUNET_NETWORK_socket_create (PF_INET6,
-                                        SOCK_STREAM,
-                                        0);
+    desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
     if (NULL == desc)
     {
-      if ( (ENOBUFS == errno) ||
-          (ENOMEM == errno) ||
-          (ENFILE == errno) ||
-          (EACCES == errno) )
+      if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
+          (EACCES == errno))
       {
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                     "socket");
+        LOG_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+           _ (
+             "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
            service_name,
-          STRERROR (errno));
+           strerror (errno));
       disablev6 = GNUNET_YES;
     }
     else
@@ -398,38 +391,33 @@ get_server_addresses (const char *service_name,
   }
 
   port = 0;
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                      service_name,
-                                      "PORT"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
   {
-    if (GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_number (cfg,
-                                              service_name,
-                                              "PORT",
-                                              &port))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                            service_name,
+                                                            "PORT",
+                                                            &port))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
     }
     if (port > 65535)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
       return GNUNET_SYSERR;
     }
   }
 
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                      service_name,
-                                      "BINDTO"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
                   GNUNET_CONFIGURATION_get_value_string (cfg,
-                                                        service_name,
+                                                         service_name,
                                                          "BINDTO",
-                                                        &hostname));
+                                                         &hostname));
   }
   else
     hostname = NULL;
@@ -438,14 +426,11 @@ get_server_addresses (const char *service_name,
   abstract = GNUNET_NO;
 #ifdef AF_UNIX
   if ((GNUNET_YES ==
-       GNUNET_CONFIGURATION_have_value (cfg,
-                                       service_name,
-                                       "UNIXPATH")) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               service_name,
-                                               "UNIXPATH",
-                                               &unixpath)) &&
+       GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                             service_name,
+                                                             "UNIXPATH",
+                                                             &unixpath)) &&
       (0 < strlen (unixpath)))
   {
     /* probe UNIX support */
@@ -454,13 +439,11 @@ get_server_addresses (const char *service_name,
     if (strlen (unixpath) >= sizeof (s_un.sun_path))
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("UNIXPATH `%s' too long, maximum length is %llu\n"),
-          unixpath,
+           _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
+           unixpath,
            (unsigned long long) sizeof (s_un.sun_path));
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
-      LOG (GNUNET_ERROR_TYPE_INFO,
-          _("Using `%s' instead\n"),
-           unixpath);
+      LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
     }
 #ifdef LINUX
     abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -469,32 +452,28 @@ get_server_addresses (const char *service_name,
     if (GNUNET_SYSERR == abstract)
       abstract = GNUNET_NO;
 #endif
-    if ( (GNUNET_YES != abstract) &&
-        (GNUNET_OK !=
-         GNUNET_DISK_directory_create_for_file (unixpath)) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                               "mkdir",
-                               unixpath);
+    if ((GNUNET_YES != abstract) &&
+        (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
   }
   if (NULL != unixpath)
   {
     desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
     if (NULL == desc)
     {
-      if ( (ENOBUFS == errno) ||
-          (ENOMEM == errno) ||
-          (ENFILE == errno) ||
-          (EACCES == errno) )
+      if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
+          (EACCES == errno))
       {
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
+        LOG_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
         GNUNET_free_non_null (hostname);
         GNUNET_free (unixpath);
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+           _ (
+             "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
            service_name,
-           STRERROR (errno));
+           strerror (errno));
       GNUNET_free (unixpath);
       unixpath = NULL;
     }
@@ -506,29 +485,23 @@ get_server_addresses (const char *service_name,
   }
 #endif
 
-  if ( (0 == port) &&
-       (NULL == unixpath) )
+  if ((0 == port) && (NULL == unixpath))
   {
-    if (GNUNET_YES ==
-       GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                             service_name,
-                                             "START_ON_DEMAND"))
+    if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                            service_name,
+                                                            "START_ON_DEMAND"))
       LOG (GNUNET_ERROR_TYPE_ERROR,
-          _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
-          service_name);
+           _ (
+             "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+           service_name);
     GNUNET_free_non_null (hostname);
     return GNUNET_SYSERR;
   }
   if (0 == port)
   {
-    saddrs = GNUNET_new_array (2,
-                              struct sockaddr *);
-    saddrlens = GNUNET_new_array (2,
-                                 socklen_t);
-    add_unixpath (saddrs,
-                 saddrlens,
-                 unixpath,
-                 abstract);
+    saddrs = GNUNET_new_array (2, struct sockaddr *);
+    saddrlens = GNUNET_new_array (2, socklen_t);
+    add_unixpath (saddrs, saddrlens, unixpath, abstract);
     GNUNET_free_non_null (unixpath);
     GNUNET_free_non_null (hostname);
     *addrs = saddrs;
@@ -546,14 +519,11 @@ get_server_addresses (const char *service_name,
     if (disablev6)
       hints.ai_family = AF_INET;
     hints.ai_protocol = IPPROTO_TCP;
-    if ((0 != (ret = getaddrinfo (hostname,
-                                 NULL,
-                                 &hints,
-                                 &res))) ||
+    if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
         (NULL == res))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to resolve `%s': %s\n"),
+           _ ("Failed to resolve `%s': %s\n"),
            hostname,
            gai_strerror (ret));
       GNUNET_free (hostname);
@@ -572,7 +542,7 @@ get_server_addresses (const char *service_name,
     if (0 == i)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to find %saddress for `%s'.\n"),
+           _ ("Failed to find %saddress for `%s'.\n"),
            disablev6 ? "IPv4 " : "",
            hostname);
       freeaddrinfo (res);
@@ -583,10 +553,8 @@ get_server_addresses (const char *service_name,
     resi = i;
     if (NULL != unixpath)
       resi++;
-    saddrs = GNUNET_new_array (resi + 1,
-                              struct sockaddr *);
-    saddrlens = GNUNET_new_array (resi + 1,
-                                 socklen_t);
+    saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+    saddrlens = GNUNET_new_array (resi + 1, socklen_t);
     i = 0;
     if (NULL != unixpath)
     {
@@ -600,11 +568,13 @@ get_server_addresses (const char *service_name,
       if ((disablev6) && (AF_INET6 == pos->ai_family))
         continue;
       if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
-        continue;               /* not TCP */
+        continue; /* not TCP */
       if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
-        continue;               /* huh? */
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
-           service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+        continue; /* huh? */
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Service `%s' will bind to `%s'\n",
+           service_name,
+           GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
       if (AF_INET == pos->ai_family)
       {
         GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
@@ -638,10 +608,8 @@ get_server_addresses (const char *service_name,
       if (NULL != unixpath)
         resi++;
       i = 0;
-      saddrs = GNUNET_new_array (resi + 1,
-                                struct sockaddr *);
-      saddrlens = GNUNET_new_array (resi + 1,
-                                   socklen_t);
+      saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1, socklen_t);
       if (NULL != unixpath)
       {
         add_unixpath (saddrs, saddrlens, unixpath, abstract);
@@ -661,17 +629,12 @@ get_server_addresses (const char *service_name,
       resi = 2;
       if (NULL != unixpath)
         resi++;
-      saddrs = GNUNET_new_array (resi + 1,
-                                struct sockaddr *);
-      saddrlens = GNUNET_new_array (resi + 1,
-                                   socklen_t);
+      saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1, socklen_t);
       i = 0;
       if (NULL != unixpath)
       {
-        add_unixpath (saddrs,
-                     saddrlens,
-                     unixpath,
-                     abstract);
+        add_unixpath (saddrs, saddrlens, unixpath, abstract);
         i++;
       }
       saddrlens[i] = sizeof (struct sockaddr_in6);
@@ -710,20 +673,18 @@ get_server_addresses (const char *service_name,
  */
 static void
 signal_result (struct GNUNET_SERVICE_Client *client,
-              const char *name,
-              uint64_t request_id,
-              enum GNUNET_ARM_Result result)
+               const char *name,
+               uint64_t request_id,
+               enum GNUNET_ARM_Result result)
 {
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_ARM_ResultMessage *msg;
 
   (void) name;
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_ARM_RESULT);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_RESULT);
   msg->result = htonl (result);
   msg->arm_msg.request_id = GNUNET_htonll (request_id);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
 }
 
 
@@ -737,8 +698,8 @@ signal_result (struct GNUNET_SERVICE_Client *client,
  */
 static void
 broadcast_status (const char *name,
-                 enum GNUNET_ARM_ServiceStatus status,
-                 struct GNUNET_SERVICE_Client *unicast)
+                  enum GNUNET_ARM_ServiceStatus status,
+                  struct GNUNET_SERVICE_Client *unicast)
 {
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_ARM_StatusMessage *msg;
@@ -749,13 +710,9 @@ broadcast_status (const char *name,
               (unsigned int) status,
               name);
   namelen = strlen (name) + 1;
-  env = GNUNET_MQ_msg_extra (msg,
-                             namelen,
-                             GNUNET_MESSAGE_TYPE_ARM_STATUS);
+  env = GNUNET_MQ_msg_extra (msg, namelen, GNUNET_MESSAGE_TYPE_ARM_STATUS);
   msg->status = htonl ((uint32_t) (status));
-  GNUNET_memcpy ((char *) &msg[1],
-                 name,
-                 namelen);
+  GNUNET_memcpy ((char *) &msg[1], name, namelen);
   if (NULL == unicast)
   {
     if (NULL != notifier)
@@ -766,8 +723,7 @@ broadcast_status (const char *name,
   }
   else
   {
-    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (unicast),
-                    env);
+    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (unicast), env);
   }
 }
 
@@ -799,44 +755,37 @@ start_process (struct ServiceList *sl,
   lsocks = NULL;
   ls = 0;
   for (sli = sl->listen_head; NULL != sli; sli = sli->next)
+  {
+    GNUNET_array_append (lsocks,
+                         ls,
+                         GNUNET_NETWORK_get_fd (sli->listen_socket));
+    if (NULL != sli->accept_task)
     {
-      GNUNET_array_append (lsocks, ls,
-                          GNUNET_NETWORK_get_fd (sli->listen_socket));
-      if (NULL != sli->accept_task)
-       {
-         GNUNET_SCHEDULER_cancel (sli->accept_task);
-         sli->accept_task = NULL;
-       }
+      GNUNET_SCHEDULER_cancel (sli->accept_task);
+      sli->accept_task = NULL;
     }
+  }
 #if WINDOWS
-  GNUNET_array_append (lsocks,
-                       ls,
-                       INVALID_SOCKET);
+  GNUNET_array_append (lsocks, ls, INVALID_SOCKET);
 #else
-  GNUNET_array_append (lsocks,
-                       ls,
-                       -1);
+  GNUNET_array_append (lsocks, ls, -1);
 #endif
 
   /* obtain configuration */
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             sl->name,
-                                             "PREFIX",
-                                             &loprefix))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          sl->name,
+                                                          "PREFIX",
+                                                          &loprefix))
     loprefix = GNUNET_strdup (prefix_command);
   else
-    loprefix = GNUNET_CONFIGURATION_expand_dollar (cfg,
-                                                   loprefix);
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             sl->name,
-                                             "OPTIONS",
-                                             &options))
+    loprefix = GNUNET_CONFIGURATION_expand_dollar (cfg, loprefix);
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          sl->name,
+                                                          "OPTIONS",
+                                                          &options))
     options = NULL;
   else
-    options = GNUNET_CONFIGURATION_expand_dollar (cfg,
-                                                  options);
+    options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
   {
     char *new_options;
     char *optpos;
@@ -844,8 +793,7 @@ start_process (struct ServiceList *sl,
 
     fin_options = GNUNET_strdup (final_option);
     /* replace '{}' with service name */
-    while (NULL != (optpos = strstr (fin_options,
-                                     "{}")))
+    while (NULL != (optpos = strstr (fin_options, "{}")))
     {
       /* terminate string at opening parenthesis */
       *optpos = 0;
@@ -861,10 +809,7 @@ start_process (struct ServiceList *sl,
     {
       /* combine "fin_options" with "options" */
       optpos = options;
-      GNUNET_asprintf (&options,
-                       "%s %s",
-                       fin_options,
-                       optpos);
+      GNUNET_asprintf (&options, "%s %s", fin_options, optpos);
       GNUNET_free (fin_options);
       GNUNET_free (optpos);
     }
@@ -874,23 +819,19 @@ start_process (struct ServiceList *sl,
       options = fin_options;
     }
   }
-  options = GNUNET_CONFIGURATION_expand_dollar (cfg,
-                                                options);
-  use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                                    sl->name,
-                                                    "DEBUG");
+  options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
+  use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");
   {
     const char *service_type = NULL;
-    const char *choices[] = { "GNUNET", "SIMPLE", NULL };
+    const char *choices[] = {"GNUNET", "SIMPLE", NULL};
 
     is_simple_service = GNUNET_NO;
-    if ( (GNUNET_OK ==
-          GNUNET_CONFIGURATION_get_value_choice (cfg,
-                                                 sl->name,
-                                                 "TYPE",
-                                                 choices,
-                                                 &service_type)) &&
-         (0 == strcasecmp (service_type, "SIMPLE")) )
+    if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_choice (cfg,
+                                                             sl->name,
+                                                             "TYPE",
+                                                             choices,
+                                                             &service_type)) &&
+        (0 == strcasecmp (service_type, "SIMPLE")))
       is_simple_service = GNUNET_YES;
   }
 
@@ -901,81 +842,79 @@ start_process (struct ServiceList *sl,
        command line options. */
     binary = GNUNET_strdup (sl->binary);
     binary = GNUNET_CONFIGURATION_expand_dollar (cfg, binary);
-    GNUNET_asprintf (&quotedbinary,
-                     "\"%s\"",
-                     sl->binary);
+    GNUNET_asprintf (&quotedbinary, "\"%s\"", sl->binary);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting simple service `%s' using binary `%s'\n",
-                sl->name, sl->binary);
+                sl->name,
+                sl->binary);
     /* FIXME: dollar expansion should only be done outside
      * of ''-quoted strings, escaping should be considered. */
     if (NULL != options)
       options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
-    sl->proc =
-      GNUNET_OS_start_process_s (sl->pipe_control,
-                                 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                 lsocks,
-                                 loprefix,
-                                 quotedbinary,
-                                 options,
-                                 NULL);
+    sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
+                                          GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                                          lsocks,
+                                          loprefix,
+                                          quotedbinary,
+                                          options,
+                                          NULL);
   }
   else
   {
     /* actually start process */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting service `%s' using binary `%s' and configuration `%s'\n",
-                sl->name, sl->binary, sl->config);
+                sl->name,
+                sl->binary,
+                sl->config);
     binary = GNUNET_OS_get_libexec_binary_path (sl->binary);
-    GNUNET_asprintf (&quotedbinary,
-                     "\"%s\"",
-                     binary);
+    GNUNET_asprintf (&quotedbinary, "\"%s\"", binary);
 
     if (GNUNET_YES == use_debug)
     {
       if (NULL == sl->config)
-        sl->proc =
-          GNUNET_OS_start_process_s (sl->pipe_control,
-                                     GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                     lsocks,
-                                     loprefix,
-                                     quotedbinary,
-                                     "-L", "DEBUG",
-                                     options,
-                                     NULL);
+        sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
+                                              GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                                              lsocks,
+                                              loprefix,
+                                              quotedbinary,
+                                              "-L",
+                                              "DEBUG",
+                                              options,
+                                              NULL);
       else
-        sl->proc =
-            GNUNET_OS_start_process_s (sl->pipe_control,
-                                       GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks,
-                                       loprefix,
-                                       quotedbinary,
-                                       "-c", sl->config,
-                                       "-L", "DEBUG",
-                                       options,
-                                       NULL);
+        sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
+                                              GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                                              lsocks,
+                                              loprefix,
+                                              quotedbinary,
+                                              "-c",
+                                              sl->config,
+                                              "-L",
+                                              "DEBUG",
+                                              options,
+                                              NULL);
     }
     else
     {
       if (NULL == sl->config)
-        sl->proc =
-            GNUNET_OS_start_process_s (sl->pipe_control,
-                                       GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks,
-                                       loprefix,
-                                       quotedbinary,
-                                       options,
-                                       NULL);
+        sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
+                                              GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                                              lsocks,
+                                              loprefix,
+                                              quotedbinary,
+                                              options,
+                                              NULL);
       else
-        sl->proc =
-            GNUNET_OS_start_process_s (sl->pipe_control,
-                                       GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks,
-                                       loprefix,
-                                       quotedbinary,
-                                       "-c", sl->config,
-                                       options,
-                                       NULL);
+        sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
+                                              GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                                              lsocks,
+                                              loprefix,
+                                              quotedbinary,
+                                              "-c",
+                                              sl->config,
+                                              options,
+                                              NULL);
     }
   }
   GNUNET_free (binary);
@@ -983,8 +922,8 @@ start_process (struct ServiceList *sl,
   if (NULL == sl->proc)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to start service `%s'\n"),
-               sl->name);
+                _ ("Failed to start service `%s'\n"),
+                sl->name);
     if (client)
       signal_result (client,
                      sl->name,
@@ -994,23 +933,16 @@ start_process (struct ServiceList *sl,
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Starting service `%s'\n"),
-               sl->name);
-    broadcast_status (sl->name,
-                      GNUNET_ARM_SERVICE_STARTING,
-                      NULL);
+                _ ("Starting service `%s'\n"),
+                sl->name);
+    broadcast_status (sl->name, GNUNET_ARM_SERVICE_STARTING, NULL);
     if (client)
-      signal_result (client,
-                     sl->name,
-                     request_id,
-                     GNUNET_ARM_RESULT_STARTING);
+      signal_result (client, sl->name, request_id, GNUNET_ARM_RESULT_STARTING);
   }
   /* clean up */
   GNUNET_free (loprefix);
   GNUNET_free (options);
-  GNUNET_array_grow (lsocks,
-                     ls,
-                     0);
+  GNUNET_array_grow (lsocks, ls, 0);
 }
 
 
@@ -1028,11 +960,11 @@ find_service (const char *name)
 
   sl = running_head;
   while (sl != NULL)
-    {
-      if (0 == strcasecmp (sl->name, name))
-       return sl;
-      sl = sl->next;
-    }
+  {
+    if (0 == strcasecmp (sl->name, name))
+      return sl;
+    sl = sl->next;
+  }
   return NULL;
 }
 
@@ -1066,7 +998,7 @@ accept_connection (void *cls)
 static void
 create_listen_socket (struct sockaddr *sa,
                       socklen_t addr_len,
-                     struct ServiceList *sl)
+                      struct ServiceList *sl)
 {
   static int on = 1;
   struct GNUNET_NETWORK_Handle *sock;
@@ -1079,23 +1011,16 @@ create_listen_socket (struct sockaddr *sa,
   switch (sa->sa_family)
   {
   case AF_INET:
-    sock = GNUNET_NETWORK_socket_create (PF_INET,
-                                         SOCK_STREAM,
-                                         0);
+    sock = GNUNET_NETWORK_socket_create (PF_INET, SOCK_STREAM, 0);
     break;
   case AF_INET6:
-    sock = GNUNET_NETWORK_socket_create (PF_INET6,
-                                         SOCK_STREAM,
-                                         0);
+    sock = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
     break;
   case AF_UNIX:
-    if (0 == strcmp (GNUNET_a2s (sa,
-                                 addr_len),
-                     "@"))     /* Do not bind to blank UNIX path! */
+    if (0 == strcmp (GNUNET_a2s (sa, addr_len),
+                     "@")) /* Do not bind to blank UNIX path! */
       return;
-    sock = GNUNET_NETWORK_socket_create (PF_UNIX,
-                                         SOCK_STREAM,
-                                         0);
+    sock = GNUNET_NETWORK_socket_create (PF_UNIX, SOCK_STREAM, 0);
     break;
   default:
     GNUNET_break (0);
@@ -1106,48 +1031,44 @@ create_listen_socket (struct sockaddr *sa,
   if (NULL == sock)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Unable to create socket for service `%s': %s\n"),
+                _ ("Unable to create socket for service `%s': %s\n"),
                 sl->name,
-                STRERROR (errno));
+                strerror (errno));
     GNUNET_free (sa);
     return;
   }
-  if (GNUNET_OK !=
-      GNUNET_NETWORK_socket_setsockopt (sock,
-                                        SOL_SOCKET,
-                                        SO_REUSEADDR,
-                                        &on,
-                                        sizeof (on)))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (sock,
+                                                     SOL_SOCKET,
+                                                     SO_REUSEADDR,
+                                                     &on,
+                                                     sizeof (on)))
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                        "setsockopt");
+                         "setsockopt");
 #ifdef IPV6_V6ONLY
-  if ( (sa->sa_family == AF_INET6) &&
-       (GNUNET_OK !=
-        GNUNET_NETWORK_socket_setsockopt (sock,
-                                          IPPROTO_IPV6,
-                                          IPV6_V6ONLY,
-                                          &on,
-                                          sizeof (on))) )
+  if ((sa->sa_family == AF_INET6) &&
+      (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (sock,
+                                                      IPPROTO_IPV6,
+                                                      IPV6_V6ONLY,
+                                                      &on,
+                                                      sizeof (on))))
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                        "setsockopt");
+                         "setsockopt");
 #endif
 #ifndef WINDOWS
   if (AF_UNIX == sa->sa_family)
     GNUNET_NETWORK_unix_precheck ((struct sockaddr_un *) sa);
 #endif
   if (GNUNET_OK !=
-      GNUNET_NETWORK_socket_bind (sock,
-                                  (const struct sockaddr *) sa,
-                                  addr_len))
+      GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) sa, addr_len))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Unable to bind listening socket for service `%s' to address `%s': %s\n"),
-                sl->name,
-                GNUNET_a2s (sa,
-                            addr_len),
-                STRERROR (errno));
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (sock));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ (
+        "Unable to bind listening socket for service `%s' to address `%s': %s\n"),
+      sl->name,
+      GNUNET_a2s (sa, addr_len),
+      strerror (errno));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
     GNUNET_free (sa);
     return;
   }
@@ -1155,51 +1076,41 @@ create_listen_socket (struct sockaddr *sa,
   if ((AF_UNIX == sa->sa_family)
 #ifdef LINUX
       /* Permission settings are not required when abstract sockets are used */
-      && ('\0' != ((const struct sockaddr_un *)sa)->sun_path[0])
+      && ('\0' != ((const struct sockaddr_un *) sa)->sun_path[0])
 #endif
-      )
+  )
   {
     match_uid =
-      GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            sl->name,
-                                            "UNIX_MATCH_UID");
+      GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "UNIX_MATCH_UID");
     match_gid =
-      GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            sl->name,
-                                            "UNIX_MATCH_GID");
-    GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sa)->sun_path,
+      GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "UNIX_MATCH_GID");
+    GNUNET_DISK_fix_permissions (((const struct sockaddr_un *) sa)->sun_path,
                                  match_uid,
                                  match_gid);
-
   }
 #endif
-  if (GNUNET_OK !=
-      GNUNET_NETWORK_socket_listen (sock, 5))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock, 5))
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                         "listen");
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (sock));
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "listen");
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
     GNUNET_free (sa);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("ARM now monitors connections to service `%s' at `%s'\n"),
-             sl->name,
-              GNUNET_a2s (sa,
-                          addr_len));
+              _ ("ARM now monitors connections to service `%s' at `%s'\n"),
+              sl->name,
+              GNUNET_a2s (sa, addr_len));
   sli = GNUNET_new (struct ServiceListeningInfo);
   sli->service_addr = sa;
   sli->service_addr_len = addr_len;
   sli->listen_socket = sock;
   sli->sl = sl;
-  sli->accept_task
-    = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     sock,
-                                     &accept_connection, sli);
-  GNUNET_CONTAINER_DLL_insert (sl->listen_head,
-                              sl->listen_tail,
-                              sli);
+  sli->accept_task =
+    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                   sock,
+                                   &accept_connection,
+                                   sli);
+  GNUNET_CONTAINER_DLL_insert (sl->listen_head, sl->listen_tail, sli);
 }
 
 
@@ -1213,9 +1124,7 @@ static void
 free_service (struct ServiceList *sl)
 {
   GNUNET_assert (GNUNET_YES == in_shutdown);
-  GNUNET_CONTAINER_DLL_remove (running_head,
-                               running_tail,
-                               sl);
+  GNUNET_CONTAINER_DLL_remove (running_head, running_tail, sl);
   GNUNET_assert (NULL == sl->listen_head);
   GNUNET_free_non_null (sl->config);
   GNUNET_free_non_null (sl->binary);
@@ -1233,8 +1142,7 @@ free_service (struct ServiceList *sl)
  *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-check_start (void *cls,
-             const struct GNUNET_ARM_Message *amsg)
+check_start (void *cls, const struct GNUNET_ARM_Message *amsg)
 {
   (void) cls;
   GNUNET_MQ_check_zero_termination (amsg);
@@ -1249,8 +1157,7 @@ check_start (void *cls,
  * @param amsg the actual message
  */
 static void
-handle_start (void *cls,
-             const struct GNUNET_ARM_Message *amsg)
+handle_start (void *cls, const struct GNUNET_ARM_Message *amsg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   const char *servicename;
@@ -1265,7 +1172,7 @@ handle_start (void *cls,
     signal_result (client,
                    servicename,
                    request_id,
-                  GNUNET_ARM_RESULT_IN_SHUTDOWN);
+                   GNUNET_ARM_RESULT_IN_SHUTDOWN);
     return;
   }
   sl = find_service (servicename);
@@ -1274,7 +1181,7 @@ handle_start (void *cls,
     signal_result (client,
                    servicename,
                    request_id,
-                  GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+                   GNUNET_ARM_RESULT_IS_NOT_KNOWN);
     return;
   }
   sl->force_start = GNUNET_YES;
@@ -1283,12 +1190,10 @@ handle_start (void *cls,
     signal_result (client,
                    servicename,
                    request_id,
-                  GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
+                   GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
     return;
   }
-  start_process (sl,
-                 client,
-                 request_id);
+  start_process (sl, client, request_id);
 }
 
 
@@ -1301,8 +1206,7 @@ static void
 trigger_shutdown (void *cls)
 {
   (void) cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Triggering shutdown\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering shutdown\n");
   GNUNET_SCHEDULER_shutdown ();
 }
 
@@ -1316,8 +1220,7 @@ trigger_shutdown (void *cls)
  *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-check_stop (void *cls,
-            const struct GNUNET_ARM_Message *amsg)
+check_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
 {
   (void) cls;
   GNUNET_MQ_check_zero_termination (amsg);
@@ -1332,8 +1235,7 @@ check_stop (void *cls,
  * @param amsg the actual message
  */
 static void
-handle_stop (void *cls,
-            const struct GNUNET_ARM_Message *amsg)
+handle_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct ServiceList *sl;
@@ -1343,22 +1245,15 @@ handle_stop (void *cls,
   request_id = GNUNET_ntohll (amsg->request_id);
   servicename = (const char *) &amsg[1];
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("Preparing to stop `%s'\n"),
-             servicename);
+              _ ("Preparing to stop `%s'\n"),
+              servicename);
   GNUNET_SERVICE_client_continue (client);
-  if (0 == strcasecmp (servicename,
-                       "arm"))
+  if (0 == strcasecmp (servicename, "arm"))
   {
-    broadcast_status (servicename,
-                     GNUNET_ARM_SERVICE_STOPPING,
-                      NULL);
-    signal_result (client,
-                  servicename,
-                  request_id,
-                  GNUNET_ARM_RESULT_STOPPING);
+    broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
+    signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_STOPPING);
     GNUNET_SERVICE_client_persist (client);
-    GNUNET_SCHEDULER_add_now (&trigger_shutdown,
-                              NULL);
+    GNUNET_SCHEDULER_add_now (&trigger_shutdown, NULL);
     return;
   }
   sl = find_service (servicename);
@@ -1384,32 +1279,28 @@ handle_stop (void *cls,
   {
     /* killing already in progress */
     signal_result (client,
-                  servicename,
-                  request_id,
-                  GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
+                   servicename,
+                   request_id,
+                   GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
     return;
   }
   if (NULL == sl->proc)
   {
     /* process is down */
     signal_result (client,
-                  servicename,
-                  request_id,
-                  GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
+                   servicename,
+                   request_id,
+                   GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Sending kill signal to service `%s', waiting for process to die.\n",
-             servicename);
-  broadcast_status (servicename,
-                   GNUNET_ARM_SERVICE_STOPPING,
-                   NULL);
+              "Sending kill signal to service `%s', waiting for process to die.\n",
+              servicename);
+  broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
   /* no signal_start - only when it's STOPPED */
   sl->killed_at = GNUNET_TIME_absolute_get ();
-  if (0 != GNUNET_OS_process_kill (sl->proc,
-                                   GNUNET_TERM_SIG))
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                         "kill");
+  if (0 != GNUNET_OS_process_kill (sl->proc, GNUNET_TERM_SIG))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
   sl->killing_client = client;
   sl->killing_client_request_id = request_id;
 }
@@ -1422,8 +1313,7 @@ handle_stop (void *cls,
  * @param message the actual message
  */
 static void
-handle_list (void *cls,
-             const struct GNUNET_ARM_Message *request)
+handle_list (void *cls, const struct GNUNET_ARM_Message *request)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_MQ_Envelope *env;
@@ -1461,16 +1351,11 @@ handle_list (void *cls,
     if (NULL != sl->proc)
     {
       size_t s = strlen (sl->name) + strlen (sl->binary) + 4;
-      GNUNET_snprintf (pos,
-                       s,
-                       "%s (%s)",
-                       sl->name,
-                       sl->binary);
+      GNUNET_snprintf (pos, s, "%s (%s)", sl->name, sl->binary);
       pos += s;
     }
   }
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1482,18 +1367,15 @@ handle_list (void *cls,
  * @param message the actual message
  */
 static void
-handle_test (void *cls,
-             const struct GNUNET_MessageHeader *message)
+handle_test (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_MessageHeader *msg;
 
   (void) message;
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_ARM_TEST);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_TEST);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1505,8 +1387,7 @@ handle_test (void *cls,
 static void
 do_shutdown ()
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Last shutdown phase\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Last shutdown phase\n");
   if (NULL != notifier)
   {
     GNUNET_notification_context_destroy (notifier);
@@ -1538,9 +1419,7 @@ list_count (struct ServiceList *running_head)
   unsigned int res;
 
   for (res = 0, i = running_head; NULL != i; i = i->next, res++)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "%s\n",
-               i->name);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", i->name);
   return res;
 }
 
@@ -1558,8 +1437,7 @@ shutdown_task (void *cls)
   struct ServiceListeningInfo *sli;
 
   (void) cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "First shutdown phase\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First shutdown phase\n");
   if (NULL != child_restart_task)
   {
     GNUNET_SCHEDULER_cancel (child_restart_task);
@@ -1571,9 +1449,7 @@ shutdown_task (void *cls)
   {
     while (NULL != (sli = pos->listen_head))
     {
-      GNUNET_CONTAINER_DLL_remove (pos->listen_head,
-                                   pos->listen_tail,
-                                   sli);
+      GNUNET_CONTAINER_DLL_remove (pos->listen_head, pos->listen_tail, sli);
       if (NULL != sli->accept_task)
       {
         GNUNET_SCHEDULER_cancel (sli->accept_task);
@@ -1592,14 +1468,10 @@ shutdown_task (void *cls)
     nxt = pos->next;
     if (NULL != pos->proc)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                 "Stopping service `%s'\n",
-                 pos->name);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", pos->name);
       pos->killed_at = GNUNET_TIME_absolute_get ();
-      if (0 != GNUNET_OS_process_kill (pos->proc,
-                                       GNUNET_TERM_SIG))
-       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                             "kill");
+      if (0 != GNUNET_OS_process_kill (pos->proc, GNUNET_TERM_SIG))
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
     }
     else
     {
@@ -1611,8 +1483,8 @@ shutdown_task (void *cls)
     do_shutdown ();
   else
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Delaying shutdown, have %u childs still running\n",
-               list_count (running_head));
+                "Delaying shutdown, have %u childs still running\n",
+                list_count (running_head));
 }
 
 
@@ -1646,48 +1518,47 @@ delayed_restart_task (void *cls)
       /* restart is now allowed */
       if (sl->force_start)
       {
-       /* process should run by default, start immediately */
-       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                   _("Restarting service `%s'.\n"),
+        /* process should run by default, start immediately */
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    _ ("Restarting service `%s'.\n"),
                     sl->name);
-       start_process (sl,
-                       NULL,
-                       0);
+        start_process (sl, NULL, 0);
       }
       else
       {
-       /* process is run on-demand, ensure it is re-started if there is demand */
-       for (sli = sl->listen_head; NULL != sli; sli = sli->next)
-         if (NULL == sli->accept_task)
-         {
-           /* accept was actually paused, so start it again */
-           sli->accept_task
-             = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                               sli->listen_socket,
-                                               &accept_connection,
-                                               sli);
-         }
+        /* process is run on-demand, ensure it is re-started if there is demand */
+        for (sli = sl->listen_head; NULL != sli; sli = sli->next)
+          if (NULL == sli->accept_task)
+          {
+            /* accept was actually paused, so start it again */
+            sli->accept_task =
+              GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                             sli->listen_socket,
+                                             &accept_connection,
+                                             sli);
+          }
       }
     }
     else
     {
       /* update calculation for earliest time to reactivate a service */
       lowestRestartDelay =
-       GNUNET_TIME_relative_min (lowestRestartDelay,
-                                 GNUNET_TIME_absolute_get_remaining
-                                 (sl->restart_at));
+        GNUNET_TIME_relative_min (lowestRestartDelay,
+                                  GNUNET_TIME_absolute_get_remaining (
+                                    sl->restart_at));
     }
   }
-  if (lowestRestartDelay.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
+  if (lowestRestartDelay.rel_value_us !=
+      GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Will restart process in %s\n",
-               GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay,
+                "Will restart process in %s\n",
+                GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay,
                                                         GNUNET_YES));
     child_restart_task =
       GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay,
-                                                 GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                 &delayed_restart_task,
+                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                  &delayed_restart_task,
                                                   NULL);
   }
 }
@@ -1714,13 +1585,10 @@ maint_child_death (void *cls)
   const struct GNUNET_DISK_FileHandle *pr;
 
   (void) cls;
-  pr = GNUNET_DISK_pipe_handle (sigpipe,
-                               GNUNET_DISK_PIPE_END_READ);
+  pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
   child_death_task = NULL;
   /* consume the signal */
-  GNUNET_break (0 < GNUNET_DISK_file_read (pr,
-                                           &c,
-                                           sizeof (c)));
+  GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c)));
 
   /* check for services that died (WAITPID) */
   next = running_head;
@@ -1743,10 +1611,7 @@ maint_child_death (void *cls)
       pid_t pid;
 
       pid = GNUNET_OS_process_get_pid (pos->proc);
-      ret = wait4 (pid,
-                   &status,
-                   WNOHANG,
-                   &ru);
+      ret = wait4 (pid, &status, WNOHANG, &ru);
       if (ret <= 0)
         continue; /* no process done */
       if (WIFEXITED (status))
@@ -1776,8 +1641,8 @@ maint_child_death (void *cls)
         statusType = GNUNET_OS_PROCESS_UNKNOWN;
         statusCode = 0;
       }
-      if ( (GNUNET_OS_PROCESS_EXITED == statusType) ||
-           (GNUNET_OS_PROCESS_SIGNALED == statusType) )
+      if ((GNUNET_OS_PROCESS_EXITED == statusType) ||
+          (GNUNET_OS_PROCESS_SIGNALED == statusType))
       {
         double utime = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 10e6);
         double stime = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 10e6);
@@ -1796,48 +1661,45 @@ maint_child_death (void *cls)
     }
     else /* continue with JUST this "if" as "else" (intentionally no brackets!) */
 #endif
-    if ( (GNUNET_SYSERR ==
-          (ret =
-           GNUNET_OS_process_status (pos->proc,
-                                     &statusType,
-                                     &statusCode))) ||
-         (ret == GNUNET_NO) ||
-         (statusType == GNUNET_OS_PROCESS_STOPPED) ||
-         (statusType == GNUNET_OS_PROCESS_UNKNOWN) ||
-         (statusType == GNUNET_OS_PROCESS_RUNNING) )
+      if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc,
+                                                             &statusType,
+                                                             &statusCode))) ||
+          (ret == GNUNET_NO) || (statusType == GNUNET_OS_PROCESS_STOPPED) ||
+          (statusType == GNUNET_OS_PROCESS_UNKNOWN) ||
+          (statusType == GNUNET_OS_PROCESS_RUNNING))
       continue;
 
     if (statusType == GNUNET_OS_PROCESS_EXITED)
     {
-      statstr = _/* process termination method */ "exit");
+      statstr = _ (/* process termination method */ "exit");
       statcode = statusCode;
     }
     else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
     {
-      statstr = _/* process termination method */ "signal");
+      statstr = _ (/* process termination method */ "signal");
       statcode = statusCode;
     }
     else
     {
-      statstr = _/* process termination method */ "unknown");
+      statstr = _ (/* process termination method */ "unknown");
       statcode = 0;
     }
     if (0 != pos->killed_at.abs_value_us)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Service `%s' took %s to terminate\n"),
+                  _ ("Service `%s' took %s to terminate\n"),
                   pos->name,
-                  GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (pos->killed_at),
-                                                          GNUNET_YES));
+                  GNUNET_STRINGS_relative_time_to_string (
+                    GNUNET_TIME_absolute_get_duration (pos->killed_at),
+                    GNUNET_YES));
     }
     GNUNET_OS_process_destroy (pos->proc);
     pos->proc = NULL;
-    broadcast_status (pos->name,
-                      GNUNET_ARM_SERVICE_STOPPED,
-                      NULL);
+    broadcast_status (pos->name, GNUNET_ARM_SERVICE_STOPPED, NULL);
     if (NULL != pos->killing_client)
     {
-      signal_result (pos->killing_client, pos->name,
+      signal_result (pos->killing_client,
+                     pos->name,
                      pos->killing_client_request_id,
                      GNUNET_ARM_RESULT_STOPPED);
       pos->killing_client = NULL;
@@ -1845,14 +1707,14 @@ maint_child_death (void *cls)
     }
     if (GNUNET_YES != in_shutdown)
     {
-      if ( (statusType == GNUNET_OS_PROCESS_EXITED) &&
-           (statcode == 0) )
+      if ((statusType == GNUNET_OS_PROCESS_EXITED) && (statcode == 0))
       {
         /* process terminated normally, allow restart at any time */
         pos->restart_at.abs_value_us = 0;
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    _("Service `%s' terminated normally, will restart at any time\n"),
-                    pos->name);
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_INFO,
+          _ ("Service `%s' terminated normally, will restart at any time\n"),
+          pos->name);
         /* process can still be re-started on-demand, ensure it is re-started if there is demand */
         for (sli = pos->listen_head; NULL != sli; sli = sli->next)
         {
@@ -1866,36 +1728,37 @@ maint_child_death (void *cls)
       }
       else
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                   _("Service `%s' terminated with status %s/%d, will restart in %s\n"),
-                   pos->name,
-                   statstr,
-                   statcode,
-                   GNUNET_STRINGS_relative_time_to_string (pos->backoff,
-                                                           GNUNET_YES));
-       {
-         /* Reduce backoff based on runtime of the process,
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_INFO,
+          _ ("Service `%s' terminated with status %s/%d, will restart in %s\n"),
+          pos->name,
+          statstr,
+          statcode,
+          GNUNET_STRINGS_relative_time_to_string (pos->backoff, GNUNET_YES));
+        {
+          /* Reduce backoff based on runtime of the process,
             so that there is a cool-down if a process actually
             runs for a while. */
-         struct GNUNET_TIME_Relative runtime;
-         unsigned int minutes;
-
-         runtime = GNUNET_TIME_absolute_get_duration (pos->restart_at);
-         minutes = runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
-         if (minutes > 31)
-           pos->backoff = GNUNET_TIME_UNIT_ZERO;
-         else
-           pos->backoff.rel_value_us <<= minutes;
-       }
-       /* schedule restart */
+          struct GNUNET_TIME_Relative runtime;
+          unsigned int minutes;
+
+          runtime = GNUNET_TIME_absolute_get_duration (pos->restart_at);
+          minutes =
+            runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
+          if (minutes > 31)
+            pos->backoff = GNUNET_TIME_UNIT_ZERO;
+          else
+            pos->backoff.rel_value_us <<= minutes;
+        }
+        /* schedule restart */
         pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff);
         pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff);
         if (NULL != child_restart_task)
           GNUNET_SCHEDULER_cancel (child_restart_task);
-        child_restart_task
-          GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                &delayed_restart_task,
-                                                NULL);
+        child_restart_task =
+          GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                              &delayed_restart_task,
+                                              NULL);
       }
     }
     else
@@ -1903,17 +1766,17 @@ maint_child_death (void *cls)
       free_service (pos);
     }
   }
-  child_death_task = GNUNET_SCHEDULER_add_read_file (
-      GNUNET_TIME_UNIT_FOREVER_REL,
-      pr,
-      &maint_child_death, NULL);
+  child_death_task =
+    GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                    pr,
+                                    &maint_child_death,
+                                    NULL);
   if ((NULL == running_head) && (GNUNET_YES == in_shutdown))
     do_shutdown ();
   else if (GNUNET_YES == in_shutdown)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Delaying shutdown after child's death, still have %u children\n",
-        list_count (running_head));
-
+                "Delaying shutdown after child's death, still have %u children\n",
+                list_count (running_head));
 }
 
 
@@ -1925,14 +1788,15 @@ static void
 sighandler_child_death ()
 {
   static char c;
-  int old_errno = errno;       /* back-up errno */
-
-  GNUNET_break (1 ==
-               GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
-                                                                 GNUNET_DISK_PIPE_END_WRITE),
-                                       &c,
-                                        sizeof (c)));
-  errno = old_errno;           /* restore errno */
+  int old_errno = errno; /* back-up errno */
+
+  GNUNET_break (
+    1 ==
+    GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
+                                                     GNUNET_DISK_PIPE_END_WRITE),
+                            &c,
+                            sizeof (c)));
+  errno = old_errno; /* restore errno */
 }
 
 
@@ -1945,8 +1809,7 @@ sighandler_child_death ()
  * @return #GNUNET_OK (continue)
  */
 static void
-setup_service (void *cls,
-               const char *section)
+setup_service (void *cls, const char *section)
 {
   struct ServiceList *sl;
   char *binary;
@@ -1957,26 +1820,18 @@ setup_service (void *cls,
   int ret;
 
   (void) cls;
-  if (0 == strcasecmp (section,
-                       "arm"))
+  if (0 == strcasecmp (section, "arm"))
     return;
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             section,
-                                             "BINARY",
-                                             &binary))
+      GNUNET_CONFIGURATION_get_value_string (cfg, section, "BINARY", &binary))
   {
     /* not a service section */
     return;
   }
   if ((GNUNET_YES ==
-       GNUNET_CONFIGURATION_have_value (cfg,
-                                        section,
-                                        "RUN_PER_USER")) &&
+       GNUNET_CONFIGURATION_have_value (cfg, section, "RUN_PER_USER")) &&
       (GNUNET_YES ==
-       GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                             section,
-                                             "RUN_PER_USER")))
+       GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "RUN_PER_USER")))
   {
     if (GNUNET_NO == start_user)
     {
@@ -2001,23 +1856,22 @@ setup_service (void *cls,
     return;
   }
   config = NULL;
-  if (( (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                  section,
-                                                  "CONFIG",
-                                                  &config)) &&
-       (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                  "PATHS",
-                                                  "DEFAULTCONFIG",
-                                                 &config)) ) ||
-      (0 != STAT (config, &sbuf)))
+  if (((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                              section,
+                                                              "CONFIG",
+                                                              &config)) &&
+       (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                              "PATHS",
+                                                              "DEFAULTCONFIG",
+                                                              &config))) ||
+      (0 != stat (config, &sbuf)))
   {
     if (NULL != config)
     {
       GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
-                                section, "CONFIG",
-                                STRERROR (errno));
+                                 section,
+                                 "CONFIG",
+                                 strerror (errno));
       GNUNET_free (config);
       config = NULL;
     }
@@ -2031,46 +1885,30 @@ setup_service (void *cls,
 #if WINDOWS
   sl->pipe_control = GNUNET_YES;
 #else
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                       section,
-                                       "PIPECONTROL"))
-    sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                                             section,
-                                                             "PIPECONTROL");
+  if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
+    sl->pipe_control =
+      GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL");
 #endif
-  GNUNET_CONTAINER_DLL_insert (running_head,
-                               running_tail,
-                               sl);
+  GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
   if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            section,
-                                            "IMMEDIATE_START"))
+      GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "IMMEDIATE_START"))
   {
     sl->force_start = GNUNET_YES;
     if (GNUNET_YES ==
-        GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                              section,
-                                              "NOARMBIND"))
+        GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "NOARMBIND"))
       return;
   }
   else
   {
     if (GNUNET_YES !=
-        GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                              section,
-                                              "START_ON_DEMAND"))
+        GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "START_ON_DEMAND"))
       return;
   }
-  if (0 >= (ret = get_server_addresses (section,
-                                       cfg,
-                                       &addrs,
-                                       &addr_lens)))
+  if (0 >= (ret = get_server_addresses (section, cfg, &addrs, &addr_lens)))
     return;
   /* this will free (or capture) addrs[i] */
   for (unsigned int i = 0; i < (unsigned int) ret; i++)
-    create_listen_socket (addrs[i],
-                          addr_lens[i],
-                          sl);
+    create_listen_socket (addrs[i], addr_lens[i], sl);
   GNUNET_free (addrs);
   GNUNET_free (addr_lens);
 }
@@ -2128,8 +1966,7 @@ client_disconnect_cb (void *cls,
  *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static void
-handle_monitor (void *cls,
-                const struct GNUNET_MessageHeader *message)
+handle_monitor (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
@@ -2139,9 +1976,7 @@ handle_monitor (void *cls,
   /* Removal is handled by the server implementation, internally. */
   GNUNET_notification_context_add (notifier,
                                    GNUNET_SERVICE_client_get_mq (client));
-  broadcast_status ("arm",
-                    GNUNET_ARM_SERVICE_MONITORING_STARTED,
-                    client);
+  broadcast_status ("arm", GNUNET_ARM_SERVICE_MONITORING_STARTED, client);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -2163,14 +1998,12 @@ run (void *cls,
   (void) cls;
   cfg = c;
   service = serv;
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
-  child_death_task =
-    GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                   GNUNET_DISK_pipe_handle (sigpipe,
-                                                            GNUNET_DISK_PIPE_END_READ),
-                                   &maint_child_death,
-                                    NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+  child_death_task = GNUNET_SCHEDULER_add_read_file (
+    GNUNET_TIME_UNIT_FOREVER_REL,
+    GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ),
+    &maint_child_death,
+    NULL);
 #if HAVE_WAIT4
   if (GNUNET_OK ==
       GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -2178,8 +2011,7 @@ run (void *cls,
                                                "RESOURCE_DIAGNOSTICS",
                                                &wait_filename))
   {
-    wait_file = fopen (wait_filename,
-                       "w");
+    wait_file = fopen (wait_filename, "w");
     if (NULL == wait_file)
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
@@ -2188,49 +2020,39 @@ run (void *cls,
     }
   }
 #endif
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             "ARM",
-                                             "GLOBAL_PREFIX",
-                                             &prefix_command))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          "ARM",
+                                                          "GLOBAL_PREFIX",
+                                                          &prefix_command))
     prefix_command = GNUNET_strdup ("");
   else
-    prefix_command = GNUNET_CONFIGURATION_expand_dollar (cfg,
-                                                         prefix_command);
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             "ARM",
-                                             "GLOBAL_POSTFIX",
-                                             &final_option))
+    prefix_command = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix_command);
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          "ARM",
+                                                          "GLOBAL_POSTFIX",
+                                                          &final_option))
     final_option = GNUNET_strdup ("");
   else
-    final_option = GNUNET_CONFIGURATION_expand_dollar (cfg,
-                                                       final_option);
-  start_user = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            "ARM",
-                                            "START_USER_SERVICES");
-  start_system = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            "ARM",
-                                            "START_SYSTEM_SERVICES");
-  if ( (GNUNET_NO == start_user) &&
-       (GNUNET_NO == start_system) )
+    final_option = GNUNET_CONFIGURATION_expand_dollar (cfg, final_option);
+  start_user =
+    GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "START_USER_SERVICES");
+  start_system =
+    GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "START_SYSTEM_SERVICES");
+  if ((GNUNET_NO == start_user) && (GNUNET_NO == start_system))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-       "Please configure either START_USER_SERVICES or START_SYSTEM_SERVICES or both.\n");
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_ERROR,
+      "Please configure either START_USER_SERVICES or START_SYSTEM_SERVICES or both.\n");
     GNUNET_SCHEDULER_shutdown ();
     global_ret = 1;
     return;
   }
-  GNUNET_CONFIGURATION_iterate_sections (cfg,
-                                         &setup_service,
-                                         NULL);
+  GNUNET_CONFIGURATION_iterate_sections (cfg, &setup_service, NULL);
 
   /* start default services... */
   for (sl = running_head; NULL != sl; sl = sl->next)
     if (GNUNET_YES == sl->force_start)
-      start_process (sl,
-                     NULL,
-                     0);
+      start_process (sl, NULL, 0);
   notifier = GNUNET_notification_context_create (MAX_NOTIFY_QUEUE);
 }
 
@@ -2243,52 +2065,45 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
   struct GNUNET_SIGNAL_Context *shc_chld;
-  struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_var_size (start,
-                           GNUNET_MESSAGE_TYPE_ARM_START,
-                           struct GNUNET_ARM_Message,
-                           NULL),
-    GNUNET_MQ_hd_var_size (stop,
-                           GNUNET_MESSAGE_TYPE_ARM_STOP,
-                           struct GNUNET_ARM_Message,
-                           NULL),
-    GNUNET_MQ_hd_fixed_size (monitor,
-                             GNUNET_MESSAGE_TYPE_ARM_MONITOR,
-                             struct GNUNET_MessageHeader,
-                             NULL),
-    GNUNET_MQ_hd_fixed_size (list,
-                             GNUNET_MESSAGE_TYPE_ARM_LIST,
-                             struct GNUNET_ARM_Message,
-                             NULL),
-    GNUNET_MQ_hd_fixed_size (test,
-                             GNUNET_MESSAGE_TYPE_ARM_TEST,
-                             struct GNUNET_MessageHeader,
-                             NULL),
-    GNUNET_MQ_handler_end ()
-  };
-
-  sigpipe = GNUNET_DISK_pipe (GNUNET_NO,
-                              GNUNET_NO,
-                              GNUNET_NO,
-                              GNUNET_NO);
+  struct GNUNET_MQ_MessageHandler handlers[] =
+    {GNUNET_MQ_hd_var_size (start,
+                            GNUNET_MESSAGE_TYPE_ARM_START,
+                            struct GNUNET_ARM_Message,
+                            NULL),
+     GNUNET_MQ_hd_var_size (stop,
+                            GNUNET_MESSAGE_TYPE_ARM_STOP,
+                            struct GNUNET_ARM_Message,
+                            NULL),
+     GNUNET_MQ_hd_fixed_size (monitor,
+                              GNUNET_MESSAGE_TYPE_ARM_MONITOR,
+                              struct GNUNET_MessageHeader,
+                              NULL),
+     GNUNET_MQ_hd_fixed_size (list,
+                              GNUNET_MESSAGE_TYPE_ARM_LIST,
+                              struct GNUNET_ARM_Message,
+                              NULL),
+     GNUNET_MQ_hd_fixed_size (test,
+                              GNUNET_MESSAGE_TYPE_ARM_TEST,
+                              struct GNUNET_MessageHeader,
+                              NULL),
+     GNUNET_MQ_handler_end ()};
+
+  sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
   GNUNET_assert (NULL != sigpipe);
   shc_chld =
-    GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
-                                   &sighandler_child_death);
-  if (0 !=
-      GNUNET_SERVICE_run_ (argc,
-                          argv,
-                          "arm",
-                          GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
-                          &run,
-                          &client_connect_cb,
-                          &client_disconnect_cb,
-                          NULL,
-                          handlers))
+    GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
+  if (0 != GNUNET_SERVICE_run_ (argc,
+                                argv,
+                                "arm",
+                                GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
+                                &run,
+                                &client_connect_cb,
+                                &client_disconnect_cb,
+                                NULL,
+                                handlers))
     global_ret = 2;
 #if HAVE_WAIT4
   if (NULL != wait_file)
index e3c2a399ae9469ca1574451e4825d41b2a380124..43984f9bf4346214f6cfb23500c8c114973e102d 100644 (file)
@@ -370,7 +370,7 @@ init ()
 
 #if LOG_BACKOFF
   killLogFileName = GNUNET_DISK_mktemp ("exponential-backoff-waiting.log");
-  if (NULL == (killLogFilePtr = FOPEN (killLogFileName,
+  if (NULL == (killLogFilePtr = fopen (killLogFileName,
                                        "w")))
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
index 55903c4990661d8797e942cf798076e59b190bda..9508581defbfada4bc729c4c18e787e68da012b5 100644 (file)
@@ -205,7 +205,7 @@ main (int argc, char *av[])
 
     if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai)))
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "Failed to resolve `%s', testcase not run.\n",
                hostname);
       return 77;
@@ -221,7 +221,7 @@ main (int argc, char *av[])
       host = gethostbyname2 (hostname, AF_INET6);
     if (NULL == host)
       {
-        FPRINTF (stderr,
+        fprintf (stderr,
                  "Failed to resolve `%s', testcase not run.\n",
                  hostname);
         return 77;
@@ -234,14 +234,14 @@ main (int argc, char *av[])
     host = gethostbyname (hostname);
     if (NULL == host)
       {
-        FPRINTF (stderr,
+        fprintf (stderr,
                  "Failed to resolve `%s', testcase not run.\n",
                  hostname);
         return 77;
       }
   }
 #else
-  FPRINTF (stderr,
+  fprintf (stderr,
            "libc fails to have resolver function, testcase not run.\n");
   return 77;
 #endif
index 88c3c41e98f315740d633959e745f7508149e903..519f77af8cf2f8dce498b4df607cc1bda77ebc74 100644 (file)
@@ -221,7 +221,6 @@ struct ATSAddress
    * Is this an active address?
    */
   int active;
-
 };
 
 
@@ -245,16 +244,12 @@ static struct PendingResolutions *tail;
  * @return #GNUNET_YES (always)
  */
 static int
-free_addr_it (void *cls,
-              const struct GNUNET_PeerIdentity *key,
-              void *value)
+free_addr_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 {
   struct ATSAddress *a = value;
 
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONTAINER_multipeermap_remove (addresses,
-                                                       key,
-                                                       value));
+                 GNUNET_CONTAINER_multipeermap_remove (addresses, key, value));
   GNUNET_HELLO_address_free (a->address);
   GNUNET_free (a);
   return GNUNET_OK;
@@ -269,8 +264,8 @@ free_addr_it (void *cls,
 static void
 end (void *cls)
 {
-  struct PendingResolutions * pr;
-  struct PendingResolutions * next;
+  struct PendingResolutions *pr;
+  struct PendingResolutions *next;
   unsigned int pending;
 
   if (NULL != alh)
@@ -290,25 +285,21 @@ end (void *cls)
   while (NULL != (pr = next))
   {
     next = pr->next;
-    GNUNET_CONTAINER_DLL_remove(head, tail, pr);
+    GNUNET_CONTAINER_DLL_remove (head, tail, pr);
     GNUNET_TRANSPORT_address_to_string_cancel (pr->tats_ctx);
-    GNUNET_free(pr->address);
-    GNUNET_free(pr);
+    GNUNET_free (pr->address);
+    GNUNET_free (pr);
     pending++;
   }
-  GNUNET_CONTAINER_multipeermap_iterate (addresses,
-                                         &free_addr_it,
-                                         NULL);
+  GNUNET_CONTAINER_multipeermap_iterate (addresses, &free_addr_it, NULL);
   GNUNET_CONTAINER_multipeermap_destroy (addresses);
   addresses = NULL;
 
   if (0 < pending)
-    FPRINTF (stdout,
-             _("%u address resolutions had a timeout\n"),
-             pending);
+    fprintf (stdout, _ ("%u address resolutions had a timeout\n"), pending);
   if (opt_list_used || opt_list_all)
-    FPRINTF (stdout,
-             _("ATS returned stat_results for %u addresses\n"),
+    fprintf (stdout,
+             _ ("ATS returned stat_results for %u addresses\n"),
              stat_results);
 
   if (NULL != ats_sh)
@@ -342,18 +333,14 @@ end (void *cls)
  *        if #GNUNET_SYSERR: communication error (IPC error)
  */
 static void
-transport_addr_to_str_cb (void *cls,
-                          const char *address,
-                          int res)
+transport_addr_to_str_cb (void *cls, const char *address, int res)
 {
   struct PendingResolutions *pr = cls;
 
   if (NULL == address)
   {
     /* We're done */
-    GNUNET_CONTAINER_DLL_remove (head,
-                                 tail,
-                                 pr);
+    GNUNET_CONTAINER_DLL_remove (head, tail, pr);
     GNUNET_free (pr->address);
     GNUNET_free (pr);
     stat_pending--;
@@ -370,18 +357,20 @@ transport_addr_to_str_cb (void *cls,
   switch (res)
   {
   case GNUNET_SYSERR:
-    FPRINTF (stderr,
-             "Failed to convert address for peer `%s' plugin `%s' length %u to string (communication error)\n",
-             GNUNET_i2s (&pr->address->peer),
-             pr->address->transport_name,
-             (unsigned int) pr->address->address_length);
+    fprintf (
+      stderr,
+      "Failed to convert address for peer `%s' plugin `%s' length %u to string (communication error)\n",
+      GNUNET_i2s (&pr->address->peer),
+      pr->address->transport_name,
+      (unsigned int) pr->address->address_length);
     return;
   case GNUNET_NO:
-    FPRINTF (stderr,
-             "Failed to convert address for peer `%s' plugin `%s' length %u to string (address invalid or not supported)\n",
-             GNUNET_i2s (&pr->address->peer),
-             pr->address->transport_name,
-             (unsigned int) pr->address->address_length);
+    fprintf (
+      stderr,
+      "Failed to convert address for peer `%s' plugin `%s' length %u to string (address invalid or not supported)\n",
+      GNUNET_i2s (&pr->address->peer),
+      pr->address->transport_name,
+      (unsigned int) pr->address->address_length);
     return;
   case GNUNET_OK:
     /* continues below */
@@ -391,15 +380,17 @@ transport_addr_to_str_cb (void *cls,
     return;
   }
 
-  FPRINTF (stdout,
-           _("Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
-           GNUNET_i2s (&pr->address->peer),
-           pr->address->transport_name,
-           address,
-           GNUNET_NT_to_string (pr->properties.scope),
-           ntohl (pr->bandwidth_out.value__),
-           ntohl (pr->bandwidth_in.value__),
-           pr->active ? _("active ") : _("inactive "));
+  fprintf (
+    stdout,
+    _ (
+      "Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
+    GNUNET_i2s (&pr->address->peer),
+    pr->address->transport_name,
+    address,
+    GNUNET_NT_to_string (pr->properties.scope),
+    ntohl (pr->bandwidth_out.value__),
+    ntohl (pr->bandwidth_in.value__),
+    pr->active ? _ ("active ") : _ ("inactive "));
 }
 
 
@@ -429,9 +420,7 @@ struct AddressFindCtx
  * @return #GNUNET_NO if we found a match, #GNUNET_YES if not
  */
 static int
-find_address_it (void *cls,
-                 const struct GNUNET_PeerIdentity *key,
-                 void *value)
+find_address_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 {
   struct AddressFindCtx *actx = cls;
   struct ATSAddress *exist = value;
@@ -445,7 +434,6 @@ find_address_it (void *cls,
 }
 
 
-
 /**
  * Signature of a function that is called with QoS information about an address.
  *
@@ -483,9 +471,7 @@ ats_perf_mon_cb (void *cls,
       GNUNET_HELLO_address_free (cur->address);
       GNUNET_free (cur);
     }
-    GNUNET_CONTAINER_multipeermap_iterate (addresses,
-                                           &free_addr_it,
-                                           NULL);
+    GNUNET_CONTAINER_multipeermap_iterate (addresses, &free_addr_it, NULL);
     return;
   }
   if (GNUNET_SYSERR == active)
@@ -504,12 +490,12 @@ ats_perf_mon_cb (void *cls,
       GNUNET_break (0);
       return;
     }
-    GNUNET_break(GNUNET_OK ==
-                 GNUNET_CONTAINER_multipeermap_remove (addresses,
-                                                       &address->peer,
-                                                       actx.res));
-    FPRINTF (stdout,
-             _("Removed address of peer `%s' with plugin `%s'\n"),
+    GNUNET_break (GNUNET_OK ==
+                  GNUNET_CONTAINER_multipeermap_remove (addresses,
+                                                        &address->peer,
+                                                        actx.res));
+    fprintf (stdout,
+             _ ("Removed address of peer `%s' with plugin `%s'\n"),
              GNUNET_i2s (&address->peer),
              actx.res->address->transport_name);
     GNUNET_HELLO_address_free (actx.res);
@@ -545,14 +531,15 @@ ats_perf_mon_cb (void *cls,
     {
       a = GNUNET_new (struct ATSAddress);
 
-      a->address = GNUNET_HELLO_address_copy(address);
+      a->address = GNUNET_HELLO_address_copy (address);
       a->bandwidth_in = bandwidth_in;
       a->bandwidth_out = bandwidth_out;
       a->active = active;
-      GNUNET_CONTAINER_multipeermap_put (addresses,
-                                         &address->peer,
-                                         a,
-                                         GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+      GNUNET_CONTAINER_multipeermap_put (
+        addresses,
+        &address->peer,
+        a,
+        GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
     }
   }
 
@@ -562,11 +549,13 @@ ats_perf_mon_cb (void *cls,
   pr->bandwidth_in = bandwidth_in;
   pr->bandwidth_out = bandwidth_out;
   pr->active = active;
-  pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address,
-                                                     opt_resolve_addresses_numeric,
-                                                     GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
-                                                     &transport_addr_to_str_cb,
-                                                     pr);
+  pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (
+    cfg,
+    address,
+    opt_resolve_addresses_numeric,
+    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
+    &transport_addr_to_str_cb,
+    pr);
   GNUNET_CONTAINER_DLL_insert (head, tail, pr);
   stat_results++;
   stat_pending++;
@@ -615,10 +604,13 @@ ats_perf_cb (void *cls,
   pr->bandwidth_in = bandwidth_in;
   pr->bandwidth_out = bandwidth_out;
   pr->active = active;
-  pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (cfg, address,
-                                                     opt_resolve_addresses_numeric,
-                                                     GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
-                                                     &transport_addr_to_str_cb, pr);
+  pr->tats_ctx = GNUNET_TRANSPORT_address_to_string (
+    cfg,
+    address,
+    opt_resolve_addresses_numeric,
+    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
+    &transport_addr_to_str_cb,
+    pr);
   GNUNET_CONTAINER_DLL_insert (head, tail, pr);
   stat_results++;
   stat_pending++;
@@ -635,10 +627,10 @@ ats_perf_cb (void *cls,
 static unsigned int
 print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  char * entry_in = NULL;
-  char * entry_out = NULL;
-  char * quota_out_str;
-  char * quota_in_str;
+  char *entry_in = NULL;
+  char *entry_out = NULL;
+  char *quota_out_str;
+  char *quota_in_str;
   unsigned long long int quota_out;
   unsigned long long int quota_in;
   int c;
@@ -646,32 +638,26 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
   for (c = 0; (c < GNUNET_NT_COUNT); c++)
   {
 
-    GNUNET_asprintf (&entry_out,
-                     "%s_QUOTA_OUT",
-                     GNUNET_NT_to_string (c));
-    GNUNET_asprintf (&entry_in,
-                     "%s_QUOTA_IN",
-                     GNUNET_NT_to_string (c));
+    GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", GNUNET_NT_to_string (c));
+    GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", GNUNET_NT_to_string (c));
 
     /* quota out */
-    if (GNUNET_OK ==
-        GNUNET_CONFIGURATION_get_value_string (cfg,
-                                               "ats",
-                                               entry_out,
-                                               &quota_out_str))
+    if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                            "ats",
+                                                            entry_out,
+                                                            &quota_out_str))
     {
-      if (0 == strcmp (quota_out_str, UNLIMITED_STRING)
-          || (GNUNET_SYSERR ==
-              GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str,
-                                                  &quota_out)))
+      if (0 == strcmp (quota_out_str, UNLIMITED_STRING) ||
+          (GNUNET_SYSERR ==
+           GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &quota_out)))
         quota_out = UINT32_MAX;
 
-      GNUNET_free(quota_out_str);
+      GNUNET_free (quota_out_str);
       GNUNET_asprintf (&quota_out_str, "%llu", quota_out);
     }
     else
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "Outbound quota for network `%11s' not configured!\n",
                GNUNET_NT_to_string (c));
       GNUNET_asprintf (&quota_out_str, "-");
@@ -679,35 +665,34 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
     GNUNET_free (entry_out);
 
     /* quota in */
-    if (GNUNET_OK ==
-        GNUNET_CONFIGURATION_get_value_string (cfg,
-                                               "ats",
-                                               entry_in,
-                                               &quota_in_str))
+    if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                            "ats",
+                                                            entry_in,
+                                                            &quota_in_str))
     {
-      if (0 == strcmp (quota_in_str, UNLIMITED_STRING)
-          || (GNUNET_SYSERR ==
-              GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &quota_in)))
+      if (0 == strcmp (quota_in_str, UNLIMITED_STRING) ||
+          (GNUNET_SYSERR ==
+           GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &quota_in)))
         quota_in = UINT32_MAX;
       GNUNET_free (quota_in_str);
       GNUNET_asprintf (&quota_in_str, "%llu", quota_in);
     }
     else
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "Inbound quota for network `%11s' not configured!\n",
                GNUNET_NT_to_string (c));
       GNUNET_asprintf (&quota_in_str, "-");
     }
-    GNUNET_free(entry_in);
+    GNUNET_free (entry_in);
 
-    FPRINTF (stdout,
-             _("Quota for network `%11s' (in/out): %10s / %10s\n"),
+    fprintf (stdout,
+             _ ("Quota for network `%11s' (in/out): %10s / %10s\n"),
              GNUNET_NT_to_string (c),
              quota_in_str,
              quota_out_str);
-    GNUNET_free(quota_out_str);
-    GNUNET_free(quota_in_str);
+    GNUNET_free (quota_out_str);
+    GNUNET_free (quota_in_str);
   }
   return GNUNET_NT_COUNT;
 }
@@ -723,7 +708,7 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
  */
 static void
 run (void *cls,
-     char * const *args,
+     char *const *args,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *my_cfg)
 {
@@ -744,9 +729,7 @@ run (void *cls,
                                                     strlen (opt_pid_str),
                                                     &pid.public_key))
     {
-      FPRINTF (stderr,
-               _("Failed to parse peer identity `%s'\n"),
-               opt_pid_str);
+      fprintf (stderr, _ ("Failed to parse peer identity `%s'\n"), opt_pid_str);
       return;
     }
   }
@@ -757,9 +740,7 @@ run (void *cls,
                                                     strlen (cpid_str),
                                                     &cpid.public_key))
     {
-      FPRINTF (stderr,
-               _("Failed to parse peer identity `%s'\n"),
-               cpid_str);
+      fprintf (stderr, _ ("Failed to parse peer identity `%s'\n"), cpid_str);
       return;
     }
     c++;
@@ -769,8 +750,8 @@ run (void *cls,
 
   if (1 < c)
   {
-    FPRINTF (stderr,
-             _("Please select one operation: %s or %s or %s or %s or %s\n"),
+    fprintf (stderr,
+             _ ("Please select one operation: %s or %s or %s or %s or %s\n"),
              "--used",
              "--all",
              "--monitor",
@@ -790,65 +771,56 @@ run (void *cls,
     ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
     if (NULL == ph)
     {
-      FPRINTF (stderr,
-               "%s",
-               _("Cannot connect to ATS service, exiting...\n"));
+      fprintf (stderr, "%s", _ ("Cannot connect to ATS service, exiting...\n"));
       return;
     }
     alh = GNUNET_ATS_performance_list_addresses (ph,
-                                                 (NULL == opt_pid_str) ? NULL : &pid,
+                                                 (NULL == opt_pid_str) ? NULL
+                                                                       : &pid,
                                                  GNUNET_YES,
-                                                 &ats_perf_cb, NULL);
+                                                 &ats_perf_cb,
+                                                 NULL);
     if (NULL == alh)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
-               _("Cannot issue request to ATS service, exiting...\n"));
+               _ ("Cannot issue request to ATS service, exiting...\n"));
       shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL);
       return;
     }
-    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end,
-                                                  NULL);
+    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, NULL);
     return;
   }
   if (opt_list_used)
   {
     ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
     if (NULL == ph)
-      FPRINTF (stderr,
-               "%s",
-               _("Cannot connect to ATS service, exiting...\n"));
+      fprintf (stderr, "%s", _ ("Cannot connect to ATS service, exiting...\n"));
 
     alh = GNUNET_ATS_performance_list_addresses (ph,
-                                                 (NULL == opt_pid_str)
-                                                 ? NULL
-                                                 : &pid,
+                                                 (NULL == opt_pid_str) ? NULL
+                                                                       : &pid,
                                                  GNUNET_NO,
-                                                 &ats_perf_cb, NULL);
+                                                 &ats_perf_cb,
+                                                 NULL);
     if (NULL == alh)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
-               _("Cannot issue request to ATS service, exiting...\n"));
+               _ ("Cannot issue request to ATS service, exiting...\n"));
       shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL);
       return;
     }
-    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end,
-                                                  NULL);
+    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, NULL);
     return;
   }
   if (opt_monitor)
   {
-    ph = GNUNET_ATS_performance_init (cfg,
-                                      &ats_perf_mon_cb,
-                                      NULL);
-    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end,
-                                                  NULL);
+    ph = GNUNET_ATS_performance_init (cfg, &ats_perf_mon_cb, NULL);
+    shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, NULL);
     if (NULL == ph)
     {
-      FPRINTF (stderr,
-               "%s",
-               _("Cannot connect to ATS service, exiting...\n"));
+      fprintf (stderr, "%s", _ ("Cannot connect to ATS service, exiting...\n"));
       GNUNET_SCHEDULER_shutdown ();
     }
     return;
@@ -857,16 +829,12 @@ run (void *cls,
   {
     if (NULL == opt_type_str)
     {
-      FPRINTF (stderr,
-               "%s",
-               _("No preference type given!\n"));
+      fprintf (stderr, "%s", _ ("No preference type given!\n"));
       return;
     }
     if (NULL == opt_pid_str)
     {
-      FPRINTF (stderr,
-               "%s",
-               _("No peer given!\n"));
+      fprintf (stderr, "%s", _ ("No peer given!\n"));
       return;
     }
 
@@ -882,18 +850,14 @@ run (void *cls,
       type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
     else
     {
-      FPRINTF (stderr,
-               "%s",
-               _("Valid type required\n"));
+      fprintf (stderr, "%s", _ ("Valid type required\n"));
       return;
     }
 
     /* set */
     ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
     if (NULL == ph)
-      FPRINTF (stderr,
-               "%s",
-               _("Cannot connect to ATS service, exiting...\n"));
+      fprintf (stderr, "%s", _ ("Cannot connect to ATS service, exiting...\n"));
 
     GNUNET_ATS_performance_change_preference (ph,
                                               &pid,
@@ -901,21 +865,16 @@ run (void *cls,
                                               (double) opt_pref_value,
                                               GNUNET_ATS_PREFERENCE_END);
 
-    shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                                  &end,
-                                                  NULL);
+    shutdown_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &end, NULL);
     return;
   }
   if (NULL != cpid_str)
   {
     ats_ch = GNUNET_ATS_connectivity_init (cfg);
-    ats_sh = GNUNET_ATS_connectivity_suggest (ats_ch,
-                                              &cpid,
-                                              1000);
-    shutdown_task
-      = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                      &end,
-                                      NULL);
+    ats_sh = GNUNET_ATS_connectivity_suggest (ats_ch, &cpid, 1000);
+    shutdown_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &end, NULL);
     return;
   }
   ret = 1;
@@ -930,8 +889,7 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char * const *argv)
+main (int argc, char *const *argv)
 {
   int res;
 
@@ -944,76 +902,83 @@ main (int argc,
   stat_receive_done = GNUNET_NO;
   opt_type_str = NULL;
 
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('u',
-                                  "used",
-                                  gettext_noop ("get list of active addresses currently used"),
-                                  &opt_list_used),
-    GNUNET_GETOPT_option_flag ('a',
-                                  "all",
-                                  gettext_noop ("get list of all active addresses"),
-                                  &opt_list_all),
-
-    GNUNET_GETOPT_option_string ('C',
-                                 "connect",
-                                 NULL,
-                                 gettext_noop ("connect to PEER"),
-                                 &cpid_str),
-    GNUNET_GETOPT_option_flag ('n',
-                                  "numeric",
-                                  gettext_noop ("do not resolve IP addresses to hostnames"),
-                                  &opt_resolve_addresses_numeric),
-
-    GNUNET_GETOPT_option_flag ('m',
-                                  "monitor",
-                                  gettext_noop ("monitor mode"),
-                                  &opt_monitor),
-
-    GNUNET_GETOPT_option_flag ('p',
-                                  "preference",
-                                  gettext_noop ("set preference for the given peer"),
-                                  &opt_set_pref),
-
-    GNUNET_GETOPT_option_flag ('q',
-                                  "quotas",
-                                  gettext_noop ("print all configured quotas"),
-                                  &opt_print_quotas),
-    GNUNET_GETOPT_option_string ('i',
-                                 "id",
-                                 "TYPE",
-                                 gettext_noop ("peer id"),
-                                 &opt_pid_str),
-
-    GNUNET_GETOPT_option_string ('t',
-                                 "type",
-                                 "TYPE",
-                                 gettext_noop ("preference type to set: latency | bandwidth"),
-                                 &opt_type_str),
-
-    GNUNET_GETOPT_option_uint ('k',
-                                   "value",
-                                   "VALUE",
-                                   gettext_noop ("preference value"),
-                                   &opt_pref_value),
-
-    GNUNET_GETOPT_option_flag ('V',
-                                  "verbose",
-                                  gettext_noop ("verbose output (include ATS address properties)"),
-                                  &opt_verbose),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('u',
+                                "used",
+                                gettext_noop (
+                                  "get list of active addresses currently used"),
+                                &opt_list_used),
+     GNUNET_GETOPT_option_flag ('a',
+                                "all",
+                                gettext_noop (
+                                  "get list of all active addresses"),
+                                &opt_list_all),
+
+     GNUNET_GETOPT_option_string ('C',
+                                  "connect",
+                                  NULL,
+                                  gettext_noop ("connect to PEER"),
+                                  &cpid_str),
+     GNUNET_GETOPT_option_flag ('n',
+                                "numeric",
+                                gettext_noop (
+                                  "do not resolve IP addresses to hostnames"),
+                                &opt_resolve_addresses_numeric),
+
+     GNUNET_GETOPT_option_flag ('m',
+                                "monitor",
+                                gettext_noop ("monitor mode"),
+                                &opt_monitor),
+
+     GNUNET_GETOPT_option_flag ('p',
+                                "preference",
+                                gettext_noop (
+                                  "set preference for the given peer"),
+                                &opt_set_pref),
+
+     GNUNET_GETOPT_option_flag ('q',
+                                "quotas",
+                                gettext_noop ("print all configured quotas"),
+                                &opt_print_quotas),
+     GNUNET_GETOPT_option_string ('i',
+                                  "id",
+                                  "TYPE",
+                                  gettext_noop ("peer id"),
+                                  &opt_pid_str),
+
+     GNUNET_GETOPT_option_string ('t',
+                                  "type",
+                                  "TYPE",
+                                  gettext_noop (
+                                    "preference type to set: latency | bandwidth"),
+                                  &opt_type_str),
+
+     GNUNET_GETOPT_option_uint ('k',
+                                "value",
+                                "VALUE",
+                                gettext_noop ("preference value"),
+                                &opt_pref_value),
+
+     GNUNET_GETOPT_option_flag (
+       'V',
+       "verbose",
+       gettext_noop ("verbose output (include ATS address properties)"),
+       &opt_verbose),
+     GNUNET_GETOPT_OPTION_END};
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  res = GNUNET_PROGRAM_run (argc, argv,
+  res = GNUNET_PROGRAM_run (argc,
+                            argv,
                             "gnunet-ats",
                             gettext_noop ("Print information about ATS state"),
                             options,
-                            &run, NULL);
-  GNUNET_free_non_null(opt_pid_str);
-  GNUNET_free_non_null(opt_type_str);
-  GNUNET_free((void *) argv);
+                            &run,
+                            NULL);
+  GNUNET_free_non_null (opt_pid_str);
+  GNUNET_free_non_null (opt_type_str);
+  GNUNET_free ((void *) argv);
 
   if (GNUNET_OK == res)
     return ret;
index 2de17dc9e61c7e57940827f597c4f91aa7bd3d31..34ea53a57bedd11ef7521f1cb7c8cd461df2656a 100644 (file)
@@ -305,7 +305,7 @@ show_end_data (void)
     for (j = 0; j < peers_pinging; j++)
     {
       peer = &peers[j];
-      FPRINTF (stdout,
+      fprintf (stdout,
                "ROUND %3u PEER %3u: %10.2f / %10.2f, PINGS: %3u, PONGS: %3u\n",
                i, j, peer->mean[i], sqrt (peer->var[i] / (peer->pongs[i] - 1)),
                peer->pings[i], peer->pongs[i]);
index 262cdf64ddff23eece9e45754ddd20f784339c78..4e81d52f2c3436af7cd6cf7d581bc3b6f1aa6ddf 100644 (file)
@@ -29,7 +29,7 @@
 #include "gnunet_cadet_service.h"
 #include "cadet.h"
 
-#define STREAM_BUFFER_SIZE 1024  // Pakets
+#define STREAM_BUFFER_SIZE 1024 // Pakets
 
 /**
  * Option -P.
@@ -158,16 +158,16 @@ enc_2s (uint16_t status)
 {
   switch (status)
   {
-    case 0:
-      return "NULL ";
-    case 1:
-      return "KSENT";
-    case 2:
-      return "KRECV";
-    case 3:
-      return "READY";
-    default:
-      return "";
+  case 0:
+    return "NULL ";
+  case 1:
+    return "KSENT";
+  case 2:
+    return "KRECV";
+  case 3:
+    return "READY";
+  default:
+    return "";
   }
 }
 
@@ -184,23 +184,22 @@ conn_2s (uint16_t status)
 {
   switch (status)
   {
-    case 0:
-      return "NEW  ";
-    case 1:
-      return "SRCH ";
-    case 2:
-      return "WAIT ";
-    case 3:
-      return "READY";
-    case 4:
-      return "SHUTD";
-    default:
-      return "";
+  case 0:
+    return "NEW  ";
+  case 1:
+    return "SRCH ";
+  case 2:
+    return "WAIT ";
+  case 3:
+    return "READY";
+  case 4:
+    return "SHUTD";
+  default:
+    return "";
   }
 }
 
 
-
 /**
  * Task to shut down this application.
  *
@@ -209,8 +208,7 @@ conn_2s (uint16_t status)
 static void
 shutdown_task (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Shutdown\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
   if (NULL != lp)
   {
     GNUNET_CADET_close_port (lp);
@@ -259,7 +257,7 @@ shutdown_task (void *cls)
 }
 
 void
-mq_cb(void *cls)
+mq_cb (void *cls)
 {
   listen_stdio ();
 }
@@ -279,27 +277,21 @@ read_stdio (void *cls)
   ssize_t data_size;
 
   rd_task = NULL;
-  data_size = read (0,
-                    buf,
-                    60000);
+  data_size = read (0, buf, 60000);
   if (data_size < 1)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "read() returned  %s\n", strerror(errno));
-    GNUNET_SCHEDULER_shutdown();
+                "read() returned  %s\n",
+                strerror (errno));
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Read %u bytes from stdio\n",
               (unsigned int) data_size);
-  env = GNUNET_MQ_msg_extra (msg,
-                             data_size,
-                             GNUNET_MESSAGE_TYPE_CADET_CLI);
-  GNUNET_memcpy (&msg[1],
-                 buf,
-                 data_size);
-  GNUNET_MQ_send (GNUNET_CADET_get_mq (ch),
-                  env);
+  env = GNUNET_MQ_msg_extra (msg, data_size, GNUNET_MESSAGE_TYPE_CADET_CLI);
+  GNUNET_memcpy (&msg[1], buf, data_size);
+  GNUNET_MQ_send (GNUNET_CADET_get_mq (ch), env);
 
   sent_pkt++;
 
@@ -333,8 +325,7 @@ listen_stdio ()
 
   /* FIXME: why use 'rs' here, seems overly complicated... */
   rs = GNUNET_NETWORK_fdset_create ();
-  GNUNET_NETWORK_fdset_set_native (rs,
-                                   0); /* STDIN */
+  GNUNET_NETWORK_fdset_set_native (rs, 0); /* STDIN */
   rd_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          rs,
@@ -355,11 +346,9 @@ listen_stdio ()
  * @param channel connection to the other end (henceforth invalid)
  */
 static void
-channel_ended (void *cls,
-               const struct GNUNET_CADET_Channel *channel)
+channel_ended (void *cls, const struct GNUNET_CADET_Channel *channel)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Channel ended!\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel ended!\n");
   GNUNET_assert (channel == ch);
   ch = NULL;
   GNUNET_SCHEDULER_shutdown ();
@@ -413,10 +402,8 @@ send_echo (void *cls)
   echo_task = NULL;
   if (NULL == ch)
     return;
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_CADET_CLI);
-  GNUNET_MQ_send (GNUNET_CADET_get_mq (ch),
-                  env);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_CLI);
+  GNUNET_MQ_send (GNUNET_CADET_get_mq (ch), env);
 }
 
 
@@ -429,8 +416,7 @@ send_echo (void *cls)
  *         #GNUNET_SYSERR to close it (signal serious error).
  */
 static int
-check_data (void *cls,
-            const struct GNUNET_MessageHeader *message)
+check_data (void *cls, const struct GNUNET_MessageHeader *message)
 {
   return GNUNET_OK; /* all is well-formed */
 }
@@ -447,8 +433,7 @@ check_data (void *cls,
  * @param message The actual message.
  */
 static void
-handle_data (void *cls,
-             const struct GNUNET_MessageHeader *message)
+handle_data (void *cls, const struct GNUNET_MessageHeader *message)
 {
   size_t payload_size = ntohs (message->size) - sizeof (*message);
   uint16_t len;
@@ -464,14 +449,10 @@ handle_data (void *cls,
       struct GNUNET_MQ_Envelope *env;
       struct GNUNET_MessageHeader *msg;
 
-      env = GNUNET_MQ_msg_extra (msg,
-                                 payload_size,
-                                 GNUNET_MESSAGE_TYPE_CADET_CLI);
-      GNUNET_memcpy (&msg[1],
-                     &message[1],
-                     payload_size);
-      GNUNET_MQ_send (GNUNET_CADET_get_mq (ch),
-                      env);
+      env =
+        GNUNET_MQ_msg_extra (msg, payload_size, GNUNET_MESSAGE_TYPE_CADET_CLI);
+      GNUNET_memcpy (&msg[1], &message[1], payload_size);
+      GNUNET_MQ_send (GNUNET_CADET_get_mq (ch), env);
       return;
     }
     else
@@ -482,8 +463,7 @@ handle_data (void *cls,
       echo_time = GNUNET_TIME_UNIT_FOREVER_ABS;
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
                   "time: %s\n",
-                  GNUNET_STRINGS_relative_time_to_string (latency,
-                                                          GNUNET_NO));
+                  GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
       echo_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                                 &send_echo,
                                                 NULL);
@@ -491,21 +471,16 @@ handle_data (void *cls,
   }
 
   len = ntohs (message->size) - sizeof (*message);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Got %u bytes\n",
-              len);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got %u bytes\n", len);
   buf = (const char *) &message[1];
   off = 0;
   while (off < len)
   {
-    done = write (1,
-                  &buf[off],
-                  len - off);
+    done = write (1, &buf[off], len - off);
     if (done <= 0)
     {
       if (-1 == done)
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                             "write");
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "write");
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
@@ -524,16 +499,15 @@ handle_data (void *cls,
  * @param ple information about peer, or NULL on "EOF".
  */
 static void
-peers_callback (void *cls,
-               const struct GNUNET_CADET_PeerListEntry *ple)
+peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
 {
   if (NULL == ple)
   {
     plo = NULL;
-    GNUNET_SCHEDULER_shutdown();
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  FPRINTF (stdout,
+  fprintf (stdout,
            "%s tunnel: %c, paths: %u\n",
            GNUNET_i2s_full (&ple->peer),
            ple->have_tunnel ? 'Y' : 'N',
@@ -549,24 +523,20 @@ peers_callback (void *cls,
  * @param ppd path detail
  */
 static void
-path_callback (void *cls,
-               const struct GNUNET_CADET_PeerPathDetail *ppd)
+path_callback (void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)
 {
   if (NULL == ppd)
   {
     gpo = NULL;
-    GNUNET_SCHEDULER_shutdown();
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  FPRINTF (stdout,
-          "Path of length %u: ",
-          ppd->path_length);
+  fprintf (stdout, "Path of length %u: ", ppd->path_length);
   for (unsigned int i = 0; i < ppd->path_length; i++)
-    FPRINTF (stdout,
-            (i == ppd->target_offset) ? "*%s* " : "%s ",
-            GNUNET_i2s (&ppd->path[i]));
-  FPRINTF (stdout,
-          "\n");
+    fprintf (stdout,
+             (i == ppd->target_offset) ? "*%s* " : "%s ",
+             GNUNET_i2s (&ppd->path[i]));
+  fprintf (stdout, "\n");
 }
 
 
@@ -577,16 +547,15 @@ path_callback (void *cls,
  * @param td tunnel details
  */
 static void
-tunnels_callback (void *cls,
-                 const struct GNUNET_CADET_TunnelDetails *td)
+tunnels_callback (void *cls, const struct GNUNET_CADET_TunnelDetails *td)
 {
   if (NULL == td)
   {
     tio = NULL;
-    GNUNET_SCHEDULER_shutdown();
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  FPRINTF (stdout,
+  fprintf (stdout,
            "%s [ENC: %s, CON: %s] CHs: %u, CONNs: %u\n",
            GNUNET_i2s_full (&td->peer),
            enc_2s (td->estate),
@@ -605,9 +574,7 @@ static void
 get_peers (void *cls)
 {
   job = NULL;
-  plo = GNUNET_CADET_list_peers (my_cfg,
-                                &peers_callback,
-                                NULL);
+  plo = GNUNET_CADET_list_peers (my_cfg, &peers_callback, NULL);
 }
 
 
@@ -622,21 +589,15 @@ show_peer (void *cls)
   struct GNUNET_PeerIdentity pid;
 
   job = NULL;
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
-                                                  strlen (peer_id),
-                                                  &pid.public_key))
+  if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
+                                                               strlen (peer_id),
+                                                               &pid.public_key))
   {
-    fprintf (stderr,
-             _("Invalid peer ID `%s'\n"),
-             peer_id);
-    GNUNET_SCHEDULER_shutdown();
+    fprintf (stderr, _ ("Invalid peer ID `%s'\n"), peer_id);
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  gpo = GNUNET_CADET_get_path (my_cfg,
-                              &pid,
-                              &path_callback,
-                              NULL);
+  gpo = GNUNET_CADET_get_path (my_cfg, &pid, &path_callback, NULL);
 }
 
 
@@ -649,9 +610,7 @@ static void
 get_tunnels (void *cls)
 {
   job = NULL;
-  tio = GNUNET_CADET_list_tunnels (my_cfg,
-                                  &tunnels_callback,
-                                  NULL);
+  tio = GNUNET_CADET_list_tunnels (my_cfg, &tunnels_callback, NULL);
 }
 
 
@@ -695,13 +654,12 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_var_size (data,
-                           GNUNET_MESSAGE_TYPE_CADET_CLI,
-                           struct GNUNET_MessageHeader,
-                           NULL),
-    GNUNET_MQ_handler_end ()
-  };
+  struct GNUNET_MQ_MessageHandler handlers[] =
+    {GNUNET_MQ_hd_var_size (data,
+                            GNUNET_MESSAGE_TYPE_CADET_CLI,
+                            struct GNUNET_MessageHeader,
+                            NULL),
+     GNUNET_MQ_handler_end ()};
 
   /* FIXME add option to monitor apps */
   my_cfg = cfg;
@@ -709,58 +667,45 @@ run (void *cls,
   if (target_id && args[1])
     target_port = args[1];
 
-  if ( (0 != (request_peers | request_tunnels)
-        || NULL != conn_id
-        || NULL != channel_id)
-       && target_id != NULL)
+  if ((0 != (request_peers | request_tunnels) || NULL != conn_id ||
+       NULL != channel_id) &&
+      target_id != NULL)
   {
-    FPRINTF (stderr,
-             _("Extra arguments are not applicable "
-               "in combination with this option.\n"));
+    fprintf (stderr,
+             _ ("Extra arguments are not applicable "
+                "in combination with this option.\n"));
     return;
   }
 
   if (NULL != peer_id)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Show peer\n");
-    job = GNUNET_SCHEDULER_add_now (&show_peer,
-                                    NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show peer\n");
+    job = GNUNET_SCHEDULER_add_now (&show_peer, NULL);
   }
   else if (NULL != channel_id)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Show channel\n");
-    job = GNUNET_SCHEDULER_add_now (&show_channel,
-                                    NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n");
+    job = GNUNET_SCHEDULER_add_now (&show_channel, NULL);
   }
   else if (NULL != conn_id)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Show connection\n");
-    job = GNUNET_SCHEDULER_add_now (&show_connection,
-                                    NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n");
+    job = GNUNET_SCHEDULER_add_now (&show_connection, NULL);
   }
   else if (GNUNET_YES == request_peers)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Show all peers\n");
-    job = GNUNET_SCHEDULER_add_now (&get_peers,
-                                    NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all peers\n");
+    job = GNUNET_SCHEDULER_add_now (&get_peers, NULL);
   }
   else if (GNUNET_YES == request_tunnels)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Show all tunnels\n");
-    job = GNUNET_SCHEDULER_add_now (&get_tunnels,
-                                    NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n");
+    job = GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Connecting to CADET service\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CADET service\n");
   mh = GNUNET_CADET_connect (cfg);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
   if (NULL == mh)
   {
     GNUNET_SCHEDULER_shutdown ();
@@ -768,11 +713,8 @@ run (void *cls,
   }
   if (NULL != listen_port)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Opening CADET listen port\n");
-    GNUNET_CRYPTO_hash (listen_port,
-                        strlen (listen_port),
-                        &porthash);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening CADET listen port\n");
+    GNUNET_CRYPTO_hash (listen_port, strlen (listen_port), &porthash);
     lp = GNUNET_CADET_open_port (mh,
                                  &porthash,
                                  &channel_incoming,
@@ -791,7 +733,7 @@ run (void *cls,
                                                     &pid.public_key))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                  _("Invalid target `%s'\n"),
+                  _ ("Invalid target `%s'\n"),
                   target_id);
       GNUNET_SCHEDULER_shutdown ();
       return;
@@ -800,9 +742,7 @@ run (void *cls,
                 "Connecting to `%s:%s'\n",
                 target_id,
                 target_port);
-    GNUNET_CRYPTO_hash (target_port,
-                        strlen(target_port),
-                        &porthash);
+    GNUNET_CRYPTO_hash (target_port, strlen (target_port), &porthash);
     ch = GNUNET_CADET_channel_create (mh,
                                       NULL,
                                       &pid,
@@ -812,8 +752,7 @@ run (void *cls,
                                       handlers);
     if (GNUNET_YES == echo)
     {
-      echo_task = GNUNET_SCHEDULER_add_now (&send_echo,
-                                            NULL);
+      echo_task = GNUNET_SCHEDULER_add_now (&send_echo, NULL);
     }
     else
     {
@@ -821,12 +760,9 @@ run (void *cls,
     }
   }
 
-  if ( (NULL == lp) &&
-       (NULL == job) &&
-       (NULL == ch) )
+  if ((NULL == lp) && (NULL == job) && (NULL == ch))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                _("No action requested\n"));
+    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, _ ("No action requested\n"));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
@@ -841,52 +777,58 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
   int res;
-  const char helpstr[] = "Create tunnels and retrieve info about CADET's status.";
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    /* I would use the terminology 'circuit' here...  --lynX */
-    GNUNET_GETOPT_option_string ('C',
-                                 "connection",
-                                 "CONNECTION_ID",
-                                 gettext_noop ("Provide information about a particular connection"),
-                                 &conn_id),
-    GNUNET_GETOPT_option_flag ('e',
-                              "echo",
-                              gettext_noop ("Activate echo mode"),
-                              &echo),
-    GNUNET_GETOPT_option_string ('o',
-                                 "open-port",
-                                 "SHARED_SECRET",
-                                 gettext_noop ("Listen for connections using a shared secret among sender and recipient"),
-                                 &listen_port),
-    GNUNET_GETOPT_option_string ('p',
-                                 "peer",
-                                 "PEER_ID",
-                                 gettext_noop ("Provide information about a patricular peer"),
-                                 &peer_id),
-    GNUNET_GETOPT_option_flag ('P',
-                              "peers",
-                              gettext_noop ("Provide information about all peers"),
-                              &request_peers),
-    GNUNET_GETOPT_option_flag ('T',
-                              "tunnels",
-                              gettext_noop ("Provide information about all tunnels"),
-                              &request_tunnels),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                    &argc, &argv))
+  const char helpstr[] =
+    "Create tunnels and retrieve info about CADET's status.";
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {/* I would use the terminology 'circuit' here...  --lynX */
+     GNUNET_GETOPT_option_string (
+       'C',
+       "connection",
+       "CONNECTION_ID",
+       gettext_noop ("Provide information about a particular connection"),
+       &conn_id),
+     GNUNET_GETOPT_option_flag ('e',
+                                "echo",
+                                gettext_noop ("Activate echo mode"),
+                                &echo),
+     GNUNET_GETOPT_option_string (
+       'o',
+       "open-port",
+       "SHARED_SECRET",
+       gettext_noop (
+         "Listen for connections using a shared secret among sender and recipient"),
+       &listen_port),
+     GNUNET_GETOPT_option_string ('p',
+                                  "peer",
+                                  "PEER_ID",
+                                  gettext_noop (
+                                    "Provide information about a patricular peer"),
+                                  &peer_id),
+     GNUNET_GETOPT_option_flag ('P',
+                                "peers",
+                                gettext_noop (
+                                  "Provide information about all peers"),
+                                &request_peers),
+     GNUNET_GETOPT_option_flag ('T',
+                                "tunnels",
+                                gettext_noop (
+                                  "Provide information about all tunnels"),
+                                &request_tunnels),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  res = GNUNET_PROGRAM_run (argc, argv,
+  res = GNUNET_PROGRAM_run (argc,
+                            argv,
                             "gnunet-cadet (OPTIONS | PEER_ID SHARED_SECRET)",
                             gettext_noop (helpstr),
-                            options, &run, NULL);
+                            options,
+                            &run,
+                            NULL);
 
   GNUNET_free ((void *) argv);
 
index 80a6e8227c5d8d10025b0396c5341af7f1418829..5a28b439e7358f183ed158620bda2e38ed215399 100644 (file)
@@ -280,16 +280,16 @@ show_end_data (void)
 
   end_time = GNUNET_TIME_absolute_get ();
   total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
-  FPRINTF (stderr,
+  fprintf (stderr,
           "\nResults of test \"%s\"\n",
           test_name);
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test time %s\n",
            GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test bandwidth: %f kb/s\n",
           4 * total_packets * 1.0 / (total_time.rel_value_us / 1000));    // 4bytes * ms
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test throughput: %f packets/s\n\n",
           total_packets * 1000.0 / (total_time.rel_value_us / 1000));     // packets * ms
   GAUGER ("CADET",
@@ -1171,7 +1171,7 @@ main (int argc, char *argv[])
   short_time = SHORT_TIME;
   if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
   {
-    FPRINTF (stderr, "test failed: problem with CLI parameters\n");
+    fprintf (stderr, "test failed: problem with CLI parameters\n");
     exit (1);
   }
 
index 552d0fdb329bea50e9f5d02bc9dc0627e76a05e6..87e7b9a030046283a0e8caafa7aa64e4fd1f8e25 100644 (file)
@@ -216,16 +216,16 @@ show_end_data (void)
 
   end_time = GNUNET_TIME_absolute_get ();
   total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
-  FPRINTF (stderr,
+  fprintf (stderr,
           "\nResults of test \"%s\"\n",
           test_name);
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test time %s\n",
            GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test bandwidth: %f kb/s\n",
           4 * total_packets * 1.0 / (total_time.rel_value_us / 1000));    // 4bytes * ms
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Test throughput: %f packets/s\n\n",
           total_packets * 1000.0 / (total_time.rel_value_us / 1000));     // packets * ms
   GAUGER ("CADET",
@@ -863,7 +863,7 @@ main (int argc,
                                argc,
                                argv))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "test failed: problem with CLI parameters\n");
     return 1;
   }
index 6c3db21849655ceef259706b7e1242840247eff2..4c5407cd714de6c99ac9c653df98b3c9d951cdb0 100644 (file)
@@ -38,7 +38,7 @@
  */
 #define MAX_MESSAGE_LENGTH 1024
 
-#define XSTRINGIFY(x) STRINGIFY(x)
+#define XSTRINGIFY(x) STRINGIFY (x)
 
 #define STRINGIFY(x) (#x)
 
@@ -134,11 +134,9 @@ struct CallList
    * Unique number of the call.
    */
   unsigned int caller_num;
-
 };
 
 
-
 /**
  * Phone handle
  */
@@ -173,7 +171,7 @@ static char *line;
 /**
  * Task which handles the commands
  */
-static struct GNUNET_SCHEDULER_Task * handle_cmd_task;
+static struct GNUNET_SCHEDULER_Task *handle_cmd_task;
 
 /**
  * Our speaker.
@@ -273,33 +271,32 @@ phone_event_handler (void *cls,
      *
      * see https://gstreamer.freedesktop.org/documentation/application-development/highlevel/playback-components.html on how to play a wav using the gst framework being used here
      */
-    FPRINTF (stdout,
-             _("Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
-             GNUNET_GNSRECORD_pkey_to_zkey (caller_id),
-             caller_num_gen,
-             caller_num_gen);
+    fprintf (
+      stdout,
+      _ (
+        "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
+      GNUNET_GNSRECORD_pkey_to_zkey (caller_id),
+      caller_num_gen,
+      caller_num_gen);
     cl = GNUNET_new (struct CallList);
     cl->caller = caller;
     cl->caller_id = *caller_id;
     cl->caller_num = caller_num_gen++;
-    GNUNET_CONTAINER_DLL_insert (cl_head,
-                                 cl_tail,
-                                 cl);
+    GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
     break;
   case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
     for (cl = cl_head; NULL != cl; cl = cl->next)
       if (caller == cl->caller)
         break;
-    if ( (NULL == cl) &&
-         (caller == cl_active->caller) )
+    if ((NULL == cl) && (caller == cl_active->caller))
       cl = cl_active;
     if (NULL == cl)
     {
       GNUNET_break (0);
       return;
     }
-    FPRINTF (stdout,
-             _("Call from `%s' terminated\n"),
+    fprintf (stdout,
+             _ ("Call from `%s' terminated\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     if (cl == cl_active)
     {
@@ -308,9 +305,7 @@ phone_event_handler (void *cls,
     }
     else
     {
-      GNUNET_CONTAINER_DLL_remove (cl_head,
-                                   cl_tail,
-                                   cl);
+      GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
     }
     GNUNET_free (cl);
     break;
@@ -325,21 +320,20 @@ phone_event_handler (void *cls,
  * @param code type of the event issued by the caller
  */
 static void
-caller_event_handler (void *cls,
-                      enum GNUNET_CONVERSATION_CallerEventCode code)
+caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
 {
   struct CallList *cl = cls;
 
   switch (code)
   {
   case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
-    FPRINTF (stdout,
-             _("Call from `%s' suspended by other user\n"),
+    fprintf (stdout,
+             _ ("Call from `%s' suspended by other user\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     break;
   case GNUNET_CONVERSATION_EC_CALLER_RESUME:
-    FPRINTF (stdout,
-             _("Call from `%s' resumed by other user\n"),
+    fprintf (stdout,
+             _ ("Call from `%s' resumed by other user\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     break;
   }
@@ -356,8 +350,8 @@ start_phone ()
 
   if (NULL == my_caller_id)
   {
-    FPRINTF (stderr,
-             _("Ego `%s' no longer available, phone is now down.\n"),
+    fprintf (stderr,
+             _ ("Ego `%s' no longer available, phone is now down.\n"),
              ego_name);
     phone_state = PS_LOOKUP_EGO;
     return;
@@ -370,22 +364,20 @@ start_phone ()
   /* FIXME: get record and print full GNS record info later here... */
   if (NULL == phone)
   {
-    FPRINTF (stderr,
-             "%s",
-             _("Failed to setup phone (internal error)\n"));
+    fprintf (stderr, "%s", _ ("Failed to setup phone (internal error)\n"));
     phone_state = PS_ERROR;
   }
   else
   {
-    GNUNET_CONVERSATION_phone_get_record (phone,
-                                          &rd);
+    GNUNET_CONVERSATION_phone_get_record (phone, &rd);
     GNUNET_free_non_null (address);
-    address = GNUNET_GNSRECORD_value_to_string (rd.record_type,
-                                                rd.data,
-                                                rd.data_size);
-    FPRINTF (stdout,
-             _("Phone active at `%s'.  Type `/help' for a list of available commands\n"),
-             address);
+    address =
+      GNUNET_GNSRECORD_value_to_string (rd.record_type, rd.data, rd.data_size);
+    fprintf (
+      stdout,
+      _ (
+        "Phone active at `%s'.  Type `/help' for a list of available commands\n"),
+      address);
     phone_state = PS_LISTEN;
   }
 }
@@ -398,59 +390,51 @@ start_phone ()
  * @param code type of the event on the call
  */
 static void
-call_event_handler (void *cls,
-                    enum GNUNET_CONVERSATION_CallEventCode code)
+call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
 {
   (void) cls;
-  
+
   switch (code)
   {
   case GNUNET_CONVERSATION_EC_CALL_RINGING:
     GNUNET_break (CS_RESOLVING == call_state);
-    FPRINTF (stdout,
-             _("Resolved address of `%s'. Now ringing other party.\n"),
+    fprintf (stdout,
+             _ ("Resolved address of `%s'. Now ringing other party.\n"),
              peer_name);
     call_state = CS_RINGING;
     break;
   case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
     GNUNET_break (CS_RINGING == call_state);
-    FPRINTF (stdout,
-             _("Connection established to `%s'\n"),
-             peer_name);
+    fprintf (stdout, _ ("Connection established to `%s'\n"), peer_name);
     call_state = CS_CONNECTED;
     break;
   case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
     GNUNET_break (CS_RESOLVING == call_state);
-    FPRINTF (stdout,
-             _("Failed to resolve `%s'\n"),
-             peer_name);
+    fprintf (stdout, _ ("Failed to resolve `%s'\n"), peer_name);
     GNUNET_free (peer_name);
     peer_name = NULL;
     call = NULL;
     break;
   case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
-    FPRINTF (stdout,
-             _("Call to `%s' terminated\n"),
-             peer_name);
+    fprintf (stdout, _ ("Call to `%s' terminated\n"), peer_name);
     GNUNET_free (peer_name);
     peer_name = NULL;
     call = NULL;
     break;
   case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
     GNUNET_break (CS_CONNECTED == call_state);
-    FPRINTF (stdout,
-             _("Connection to `%s' suspended (by other user)\n"),
+    fprintf (stdout,
+             _ ("Connection to `%s' suspended (by other user)\n"),
              peer_name);
     break;
   case GNUNET_CONVERSATION_EC_CALL_RESUMED:
     GNUNET_break (CS_CONNECTED == call_state);
-    FPRINTF (stdout,
-             _("Connection to `%s' resumed (by other user)\n"),
+    fprintf (stdout,
+             _ ("Connection to `%s' resumed (by other user)\n"),
              peer_name);
     break;
   case GNUNET_CONVERSATION_EC_CALL_ERROR:
-    FPRINTF (stdout,
-             _("Error with the call, restarting it\n"));
+    fprintf (stdout, _ ("Error with the call, restarting it\n"));
     GNUNET_free (peer_name);
     peer_name = NULL;
     call = NULL;
@@ -464,8 +448,7 @@ call_event_handler (void *cls,
  *
  * @param arguments arguments given to the function
  */
-typedef void
-(*ActionFunction) (const char *arguments);
+typedef void (*ActionFunction) (const char *arguments);
 
 
 /**
@@ -520,9 +503,7 @@ do_quit (const char *args)
 static void
 do_unknown (const char *msg)
 {
-  FPRINTF (stderr,
-          _("Unknown command `%s'\n"),
-          msg);
+  fprintf (stderr, _ ("Unknown command `%s'\n"), msg);
 }
 
 
@@ -536,31 +517,29 @@ do_call (const char *arg)
 {
   if (NULL == my_caller_id)
   {
-    FPRINTF (stderr,
-             _("Ego `%s' not available\n"),
-             ego_name);
+    fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name);
     return;
   }
   if (NULL != call)
   {
-    FPRINTF (stderr,
-             _("You are calling someone else already, hang up first!\n"));
+    fprintf (stderr,
+             _ ("You are calling someone else already, hang up first!\n"));
     return;
   }
   switch (phone_state)
   {
   case PS_LOOKUP_EGO:
-    FPRINTF (stderr,
-             _("Ego `%s' not available\n"),
-             ego_name);
+    fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name);
     return;
   case PS_LISTEN:
     /* ok to call! */
     break;
   case PS_ACCEPTED:
-    FPRINTF (stderr,
-             _("You are answering call from `%s', hang up or suspend that call first!\n"),
-             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
+    fprintf (
+      stderr,
+      _ (
+        "You are answering call from `%s', hang up or suspend that call first!\n"),
+      GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   case PS_ERROR:
     /* ok to call */
@@ -568,8 +547,7 @@ do_call (const char *arg)
   }
   if (NULL == arg)
   {
-    FPRINTF (stderr,
-             _("Call recipient missing.\n"));
+    fprintf (stderr, _ ("Call recipient missing.\n"));
     do_help ("/call");
     return;
   }
@@ -581,7 +559,8 @@ do_call (const char *arg)
                                          arg,
                                          speaker,
                                          mic,
-                                         &call_event_handler, NULL);
+                                         &call_event_handler,
+                                         NULL);
 }
 
 
@@ -596,11 +575,10 @@ do_accept (const char *args)
   struct CallList *cl;
   char buf[32];
 
-  if ( (NULL != call) &&
-       (CS_SUSPENDED != call_state) )
+  if ((NULL != call) && (CS_SUSPENDED != call_state))
   {
-    FPRINTF (stderr,
-             _("You are calling someone else already, hang up first!\n"));
+    fprintf (stderr,
+             _ ("You are calling someone else already, hang up first!\n"));
     return;
   }
   switch (phone_state)
@@ -612,9 +590,11 @@ do_accept (const char *args)
     /* this is the expected state */
     break;
   case PS_ACCEPTED:
-    FPRINTF (stderr,
-             _("You are answering call from `%s', hang up or suspend that call first!\n"),
-             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
+    fprintf (
+      stderr,
+      _ (
+        "You are answering call from `%s', hang up or suspend that call first!\n"),
+      GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   case PS_ERROR:
     GNUNET_break (0);
@@ -623,31 +603,26 @@ do_accept (const char *args)
   cl = cl_head;
   if (NULL == cl)
   {
-    FPRINTF (stderr,
-             _("There is no incoming call to accept here!\n"));
+    fprintf (stderr, _ ("There is no incoming call to accept here!\n"));
     return;
   }
-  if ( (NULL != cl->next) || (NULL != args) )
+  if ((NULL != cl->next) || (NULL != args))
   {
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
-      GNUNET_snprintf (buf, sizeof (buf),
-                       "%u",
-                       cl->caller_num);
+      GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
       if (0 == strcmp (buf, args))
         break;
     }
   }
   if (NULL == cl)
   {
-    FPRINTF (stderr,
-             _("There is no incoming call `%s' to accept right now!\n"),
+    fprintf (stderr,
+             _ ("There is no incoming call `%s' to accept right now!\n"),
              args);
     return;
   }
-  GNUNET_CONTAINER_DLL_remove (cl_head,
-                               cl_tail,
-                               cl);
+  GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
   cl_active = cl;
   peer_key = cl->caller_id;
   phone_state = PS_ACCEPTED;
@@ -670,14 +645,10 @@ do_address (const char *args)
   (void) args;
   if (NULL == address)
   {
-    FPRINTF (stdout,
-             "%s",
-             _("We currently do not have an address.\n"));
+    fprintf (stdout, "%s", _ ("We currently do not have an address.\n"));
     return;
   }
-  FPRINTF (stdout,
-           "%s\n",
-           address);
+  fprintf (stdout, "%s\n", address);
 }
 
 
@@ -695,24 +666,30 @@ do_status (const char *args)
   switch (phone_state)
   {
   case PS_LOOKUP_EGO:
-    FPRINTF (stdout,
-             _("We are currently trying to locate the private key for the ego `%s'.\n"),
-             ego_name);
+    fprintf (
+      stdout,
+      _ (
+        "We are currently trying to locate the private key for the ego `%s'.\n"),
+      ego_name);
     break;
   case PS_LISTEN:
-    FPRINTF (stdout,
-             _("We are listening for incoming calls for ego `%s' on line `%s'.\n"),
+    fprintf (stdout,
+             _ (
+               "We are listening for incoming calls for ego `%s' on line `%s'.\n"),
              ego_name,
              line);
     break;
   case PS_ACCEPTED:
-    FPRINTF (stdout,
-             _("You are having a conversation with `%s'.\n"),
-             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));;
+    fprintf (stdout,
+             _ ("You are having a conversation with `%s'.\n"),
+             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
+    ;
     break;
   case PS_ERROR:
-    FPRINTF (stdout,
-             _("We had an internal error setting up our phone line. You can still make calls.\n"));
+    fprintf (
+      stdout,
+      _ (
+        "We had an internal error setting up our phone line. You can still make calls.\n"));
     break;
   }
   if (NULL != call)
@@ -720,18 +697,18 @@ do_status (const char *args)
     switch (call_state)
     {
     case CS_RESOLVING:
-      FPRINTF (stdout,
-               _("We are trying to find the network address to call `%s'.\n"),
+      fprintf (stdout,
+               _ ("We are trying to find the network address to call `%s'.\n"),
                peer_name);
       break;
     case CS_RINGING:
-      FPRINTF (stdout,
-               _("We are calling `%s', their phone should be ringing.\n"),
+      fprintf (stdout,
+               _ ("We are calling `%s', their phone should be ringing.\n"),
                peer_name);
       break;
     case CS_CONNECTED:
-      FPRINTF (stdout,
-               _("You are having a conversation with `%s'.\n"),
+      fprintf (stdout,
+               _ ("You are having a conversation with `%s'.\n"),
                peer_name);
       break;
     case CS_SUSPENDED:
@@ -739,25 +716,19 @@ do_status (const char *args)
       break;
     }
   }
-  if ( (NULL != cl_head) &&
-       ( (cl_head != cl_active) ||
-         (cl_head != cl_tail) ) )
+  if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
   {
-    FPRINTF (stdout,
-             "%s",
-             _("Calls waiting:\n"));
+    fprintf (stdout, "%s", _ ("Calls waiting:\n"));
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
       if (cl == cl_active)
         continue;
-      FPRINTF (stdout,
-               _("#%u: `%s'\n"),
+      fprintf (stdout,
+               _ ("#%u: `%s'\n"),
                cl->caller_num,
                GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     }
-    FPRINTF (stdout,
-             "%s",
-             "\n");
+    fprintf (stdout, "%s", "\n");
   }
 }
 
@@ -778,9 +749,9 @@ do_suspend (const char *args)
     case CS_RESOLVING:
     case CS_RINGING:
     case CS_SUSPENDED:
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
-               _("There is no call that could be suspended right now.\n"));
+               _ ("There is no call that could be suspended right now.\n"));
       return;
     case CS_CONNECTED:
       call_state = CS_SUSPENDED;
@@ -793,9 +764,9 @@ do_suspend (const char *args)
   case PS_LOOKUP_EGO:
   case PS_LISTEN:
   case PS_ERROR:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
-             _("There is no call that could be suspended right now.\n"));
+             _ ("There is no call that could be suspended right now.\n"));
     return;
   case PS_ACCEPTED:
     /* expected state, do rejection logic */
@@ -826,15 +797,13 @@ do_resume (const char *args)
     case CS_RESOLVING:
     case CS_RINGING:
     case CS_CONNECTED:
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
-               _("There is no call that could be resumed right now.\n"));
+               _ ("There is no call that could be resumed right now.\n"));
       return;
     case CS_SUSPENDED:
       call_state = CS_CONNECTED;
-      GNUNET_CONVERSATION_call_resume (call,
-                                       speaker,
-                                       mic);
+      GNUNET_CONVERSATION_call_resume (call, speaker, mic);
       return;
     }
   }
@@ -842,16 +811,16 @@ do_resume (const char *args)
   {
   case PS_LOOKUP_EGO:
   case PS_ERROR:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
-             _("There is no call that could be resumed right now.\n"));
+             _ ("There is no call that could be resumed right now.\n"));
     return;
   case PS_LISTEN:
     /* expected state, do resume logic */
     break;
   case PS_ACCEPTED:
-    FPRINTF (stderr,
-             _("Already talking with `%s', cannot resume a call right now.\n"),
+    fprintf (stderr,
+             _ ("Already talking with `%s', cannot resume a call right now.\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   }
@@ -859,32 +828,27 @@ do_resume (const char *args)
   cl = cl_head;
   if (NULL == cl)
   {
-    FPRINTF (stderr,
-             _("There is no incoming call to resume here!\n"));
+    fprintf (stderr, _ ("There is no incoming call to resume here!\n"));
     return;
   }
-  if ( (NULL != cl->next) || (NULL != args) )
+  if ((NULL != cl->next) || (NULL != args))
   {
     for (cl = cl_head; NULL != cl; cl = cl->next)
     {
-      GNUNET_snprintf (buf, sizeof (buf),
-                       "%u",
-                       cl->caller_num);
+      GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
       if (0 == strcmp (buf, args))
         break;
     }
   }
   if (NULL == cl)
   {
-    FPRINTF (stderr,
-             _("There is no incoming call `%s' to resume right now!\n"),
+    fprintf (stderr,
+             _ ("There is no incoming call `%s' to resume right now!\n"),
              args);
     return;
   }
   cl_active = cl;
-  GNUNET_CONVERSATION_caller_resume (cl_active->caller,
-                                     speaker,
-                                     mic);
+  GNUNET_CONVERSATION_caller_resume (cl_active->caller, speaker, mic);
   phone_state = PS_ACCEPTED;
 }
 
@@ -910,41 +874,36 @@ do_reject (const char *args)
   {
   case PS_LOOKUP_EGO:
   case PS_ERROR:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
-             _("There is no call that could be cancelled right now.\n"));
+             _ ("There is no call that could be cancelled right now.\n"));
     return;
   case PS_LISTEN:
     /* look for active incoming calls to refuse */
     cl = cl_head;
     if (NULL == cl)
     {
-      FPRINTF (stderr,
-               _("There is no incoming call to refuse here!\n"));
+      fprintf (stderr, _ ("There is no incoming call to refuse here!\n"));
       return;
     }
-    if ( (NULL != cl->next) || (NULL != args) )
+    if ((NULL != cl->next) || (NULL != args))
     {
       for (cl = cl_head; NULL != cl; cl = cl->next)
       {
-        GNUNET_snprintf (buf, sizeof (buf),
-                         "%u",
-                         cl->caller_num);
+        GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
         if (0 == strcmp (buf, args))
           break;
       }
     }
     if (NULL == cl)
     {
-      FPRINTF (stderr,
-               _("There is no incoming call `%s' to refuse right now!\n"),
+      fprintf (stderr,
+               _ ("There is no incoming call `%s' to refuse right now!\n"),
                args);
       return;
     }
     GNUNET_CONVERSATION_caller_hang_up (cl->caller);
-    GNUNET_CONTAINER_DLL_remove (cl_head,
-                                 cl_tail,
-                                 cl);
+    GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
     GNUNET_free (cl);
     break;
   case PS_ACCEPTED:
@@ -962,26 +921,34 @@ do_reject (const char *args)
  * List of supported commands.
  */
 static struct VoipCommand commands[] = {
-  {"/address", &do_address,
-   gettext_noop ("Use `/address' to find out which address this phone should have in GNS")},
-  {"/call", &do_call,
-   gettext_noop ("Use `/call USER.gnu' to call USER")},
-  {"/accept", &do_accept,
+  {"/address",
+   &do_address,
+   gettext_noop (
+     "Use `/address' to find out which address this phone should have in GNS")},
+  {"/call", &do_call, gettext_noop ("Use `/call USER.gnu' to call USER")},
+  {"/accept",
+   &do_accept,
    gettext_noop ("Use `/accept #NUM' to accept incoming call #NUM")},
-  {"/suspend", &do_suspend,
+  {"/suspend",
+   &do_suspend,
    gettext_noop ("Use `/suspend' to suspend the active call")},
-  {"/resume", &do_resume,
-   gettext_noop ("Use `/resume [#NUM]' to resume a call, #NUM is needed to resume incoming calls, no argument is needed to resume the current outgoing call.")},
-  {"/cancel", &do_reject,
+  {"/resume",
+   &do_resume,
+   gettext_noop (
+     "Use `/resume [#NUM]' to resume a call, #NUM is needed to resume incoming calls, no argument is needed to resume the current outgoing call.")},
+  {"/cancel",
+   &do_reject,
    gettext_noop ("Use `/cancel' to reject or terminate a call")},
-  {"/status", &do_status,
+  {"/status",
+   &do_status,
    gettext_noop ("Use `/status' to print status information")},
-  {"/quit", &do_quit,
+  {"/quit",
+   &do_quit,
    gettext_noop ("Use `/quit' to terminate gnunet-conversation")},
-  {"/help", &do_help,
+  {"/help",
+   &do_help,
    gettext_noop ("Use `/help command' to get help for a specific command")},
-  {"", &do_unknown,
-   NULL},
+  {"", &do_unknown, NULL},
   {NULL, NULL, NULL},
 };
 
@@ -997,37 +964,25 @@ do_help (const char *args)
   unsigned int i;
 
   i = 0;
-  while ( (NULL != args) &&
-          (0 != strlen (args)) &&
-          (commands[i].Action != &do_help))
+  while ((NULL != args) && (0 != strlen (args)) &&
+         (commands[i].Action != &do_help))
   {
-    if (0 ==
-       strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1))
+    if (0 == strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1))
     {
-      FPRINTF (stdout,
-              "%s\n",
-              gettext (commands[i].helptext));
+      fprintf (stdout, "%s\n", gettext (commands[i].helptext));
       return;
     }
     i++;
   }
   i = 0;
-  FPRINTF (stdout,
-          "%s",
-          "Available commands:\n");
+  fprintf (stdout, "%s", "Available commands:\n");
   while (commands[i].Action != &do_help)
   {
-    FPRINTF (stdout,
-            "%s\n",
-            gettext (commands[i].command));
+    fprintf (stdout, "%s\n", gettext (commands[i].command));
     i++;
   }
-  FPRINTF (stdout,
-          "%s",
-          "\n");
-  FPRINTF (stdout,
-          "%s\n",
-          gettext (commands[i].helptext));
+  fprintf (stdout, "%s", "\n");
+  fprintf (stdout, "%s\n", gettext (commands[i].helptext));
 }
 
 
@@ -1086,8 +1041,7 @@ do_stop_task (void *cls)
  * @param str_len number of bytes to process in @a message
  */
 static void
-handle_command_string (char *message,
-                       size_t str_len)
+handle_command_string (char *message, size_t str_len)
 {
   size_t i;
   const char *ptr;
@@ -1101,9 +1055,10 @@ handle_command_string (char *message,
   if (0 == strlen (message))
     return;
   i = 0;
-  while ((NULL != commands[i].command) &&
-        (0 != strncasecmp (commands[i].command, message,
-                            strlen (commands[i].command))))
+  while (
+    (NULL != commands[i].command) &&
+    (0 !=
+     strncasecmp (commands[i].command, message, strlen (commands[i].command))))
     i++;
   ptr = &message[strlen (commands[i].command)];
   while (isspace ((unsigned char) *ptr))
@@ -1159,17 +1114,13 @@ handle_command (void *cls)
   handle_cmd_task =
     GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                     stdin_fh,
-                                    &handle_command, NULL);
+                                    &handle_command,
+                                    NULL);
   /* read message from command line and handle it */
-  memset (message,
-         0,
-         MAX_MESSAGE_LENGTH + 1);
-  if (NULL == fgets (message,
-                    MAX_MESSAGE_LENGTH,
-                    stdin))
+  memset (message, 0, MAX_MESSAGE_LENGTH + 1);
+  if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin))
     return;
-  handle_command_string (message,
-                        strlen (message));
+  handle_command_string (message, strlen (message));
 }
 
 
@@ -1194,30 +1145,22 @@ identity_cb (void *cls,
   if (ego == my_caller_id)
   {
     if (verbose)
-      FPRINTF (stdout,
-               _("Name of our ego changed to `%s'\n"),
-               name);
+      fprintf (stdout, _ ("Name of our ego changed to `%s'\n"), name);
     GNUNET_free (ego_name);
     ego_name = GNUNET_strdup (name);
     return;
   }
-  if (0 != strcmp (name,
-                   ego_name))
+  if (0 != strcmp (name, ego_name))
     return;
   if (NULL == ego)
   {
     if (verbose)
-      FPRINTF (stdout,
-               _("Our ego `%s' was deleted!\n"),
-               ego_name);
+      fprintf (stdout, _ ("Our ego `%s' was deleted!\n"), ego_name);
     my_caller_id = NULL;
     return;
   }
   my_caller_id = ego;
-  GNUNET_CONFIGURATION_set_value_string (cfg,
-                                         "CONVERSATION",
-                                         "LINE",
-                                         line);
+  GNUNET_CONFIGURATION_set_value_string (cfg, "CONVERSATION", "LINE", line);
   start_phone ();
 }
 
@@ -1244,43 +1187,39 @@ run (void *cls,
   mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
   if (NULL == ego_name)
   {
-    FPRINTF (stderr,
-             "%s",
-             _("You must specify the NAME of an ego to use\n"));
+    fprintf (stderr, "%s", _ ("You must specify the NAME of an ego to use\n"));
     return;
   }
-  id = GNUNET_IDENTITY_connect (cfg,
-                                &identity_cb,
-                                NULL);
+  id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
 #ifdef WINDOWS
   if (stdin_fh == NULL)
   {
     static char cpid[64];
-    static char *args[] = {"gnunet-helper-w32-console.exe", "chars",
-        XSTRINGIFY (MAX_MESSAGE_LENGTH), cpid, NULL};
+    static char *args[] = {"gnunet-helper-w32-console.exe",
+                           "chars",
+                           XSTRINGIFY (MAX_MESSAGE_LENGTH),
+                           cpid,
+                           NULL};
     snprintf (cpid, 64, "%d", GetCurrentProcessId ());
-    stdin_hlp = GNUNET_HELPER_start (
-        GNUNET_NO,
-       "gnunet-helper-w32-console",
-       args,
-       console_reader_chars,
-       NULL,
-       NULL);
+    stdin_hlp = GNUNET_HELPER_start (GNUNET_NO,
+                                     "gnunet-helper-w32-console",
+                                     args,
+                                     console_reader_chars,
+                                     NULL,
+                                     NULL);
     if (NULL == stdin_hlp)
     {
-      FPRINTF (stderr,
-               "%s",
-               _("Failed to start gnunet-helper-w32-console\n"));
+      fprintf (stderr, "%s", _ ("Failed to start gnunet-helper-w32-console\n"));
       return;
     }
   }
   else
 #endif
-  handle_cmd_task =
-    GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI,
-                                       &handle_command, NULL);
-  GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
-                                NULL);
+    handle_cmd_task =
+      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI,
+                                          &handle_command,
+                                          NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_stop_task, NULL);
 }
 
 
@@ -1292,30 +1231,29 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_string ('e',
-                                 "ego",
-                                 "NAME",
-                                 gettext_noop ("sets the NAME of the ego to use for the caller ID"),
-                                 &ego_name),
-    GNUNET_GETOPT_option_string ('p',
-                                 "phone",
-                                 "LINE",
-                                 gettext_noop ("sets the LINE to use for the phone"),
-                                 &line),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_string (
+       'e',
+       "ego",
+       "NAME",
+       gettext_noop ("sets the NAME of the ego to use for the caller ID"),
+       &ego_name),
+     GNUNET_GETOPT_option_string ('p',
+                                  "phone",
+                                  "LINE",
+                                  gettext_noop (
+                                    "sets the LINE to use for the phone"),
+                                  &line),
+     GNUNET_GETOPT_OPTION_END};
   int ret;
 #ifndef WINDOWS
   int flags;
   flags = fcntl (0, F_GETFL, 0);
   flags |= O_NONBLOCK;
   if (0 != fcntl (0, F_SETFL, flags))
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                         "fcntl");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl");
   stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0);
 #else
   if (FILE_TYPE_CHAR == GetFileType ((HANDLE) _get_osfhandle (0)))
@@ -1326,16 +1264,17 @@ main (int argc,
     stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0);
 #endif
 
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-  ret = GNUNET_PROGRAM_run (argc,
-                           argv,
-                            "gnunet-conversation",
-                           gettext_noop ("Enables having a conversation with other GNUnet users."),
-                           options,
-                           &run, NULL);
+  ret =
+    GNUNET_PROGRAM_run (argc,
+                        argv,
+                        "gnunet-conversation",
+                        gettext_noop (
+                          "Enables having a conversation with other GNUnet users."),
+                        options,
+                        &run,
+                        NULL);
   GNUNET_free ((void *) argv);
   if (NULL != cfg)
   {
index 674da705a47c1dc4a8ecfdf9682eed582a2a3088..aeb3ba61f34bbace668b92ff3b0cbcd8c2ddeb36 100644 (file)
@@ -108,7 +108,7 @@ monitor_cb (void *cls,
   case GNUNET_CORE_KX_ITERATION_FINISHED:
     return;
   case GNUNET_CORE_KX_CORE_DISCONNECT:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s\n",
              _ ("Connection to CORE service lost (reconnecting)"));
     return;
@@ -117,7 +117,7 @@ monitor_cb (void *cls,
     break;
   }
   now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-  FPRINTF (stdout,
+  fprintf (stdout,
            _ ("%24s: %-30s %4s (timeout in %6s)\n"),
            now_str,
            state_str,
@@ -146,13 +146,13 @@ run (void *cls,
   (void) cfgfile;
   if (NULL != args[0])
   {
-    FPRINTF (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
+    fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
     return;
   }
   mh = GNUNET_CORE_monitor_start (cfg, &monitor_cb, NULL);
   if (NULL == mh)
   {
-    FPRINTF (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
+    fprintf (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
     return;
   }
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
index a2f7c0cf002528aa09102c093caeb0e4e13d54d5..7bd4bfea015d1af026bdea18a1f8c5b31a74476e 100644 (file)
@@ -147,7 +147,7 @@ do_shutdown (void *cls)
   delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
   if (0 == delta)
     delta = 1;
-  FPRINTF (stderr,
+  fprintf (stderr,
            "\nThroughput was %llu kb/s\n",
            total_bytes * 1000000LL / 1024 / delta);
   GAUGER ("CORE",
@@ -301,7 +301,7 @@ handle_test (void *cls,
               (unsigned int) ntohs (hdr->header.size));
   n++;
   if (0 == (n % (TOTAL_MSGS / 100)))
-    FPRINTF (stderr,
+    fprintf (stderr,
             "%s",
             ".");
   if (n == TOTAL_MSGS)
index 03edffe8ee194f7f06edf0e8bd32688d68bab803..92574e3d480fb34969a320bd4f18bfe4ff1a1d66 100644 (file)
@@ -135,7 +135,7 @@ setup_peer (struct PeerContext *p,
 static void
 timeout_task (void *cls)
 {
-  FPRINTF (stderr,
+  fprintf (stderr,
           "%s",
           "Timeout.\n");
   if (NULL != p1.ch)
index c661ff3e5852b431d87f67207cdc367b9e752462..908d90ac32014b05dacf93714186da4e2a03ae08 100644 (file)
@@ -225,7 +225,7 @@ measurement_stop (void *cls)
   enum GNUNET_ErrorType kind = GNUNET_ERROR_TYPE_DEBUG;
 
   measure_task = NULL;
-  FPRINTF (stdout, "%s",  "\n");
+  fprintf (stdout, "%s",  "\n");
   running = GNUNET_NO;
 
   delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
@@ -451,7 +451,7 @@ handle_test (void *cls,
               ntohl (hdr->num));
   n++;
   if (0 == (n % 10))
-    FPRINTF (stderr, "%s",  ".");
+    fprintf (stderr, "%s",  ".");
 
   if (GNUNET_YES == running)
     do_transmit (NULL);
index 7dcd54fcfecf87f5ba0c8303e8df3cf1347fe8be..57e0b0bb7af6711b4fba76e3aa41fd171a0d0fa8 100644 (file)
 #include "gnunet_datacache_plugin.h"
 
 
-#define LOG(kind,...) GNUNET_log_from (kind, "datacache", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "datacache", __VA_ARGS__)
 
-#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache", op, fn)
+#define LOG_STRERROR_FILE(kind, op, fn) \
+  GNUNET_log_from_strerror_file (kind, "datacache", op, fn)
 
 /**
  * Internal state of the datacache library.
@@ -89,7 +90,6 @@ struct GNUNET_DATACACHE_Handle
    * How much space is in use right now?
    */
   unsigned long long utilization;
-
 };
 
 
@@ -102,9 +102,7 @@ struct GNUNET_DATACACHE_Handle
  * @param size number of bytes that were made available
  */
 static void
-env_delete_notify (void *cls,
-                   const struct GNUNET_HashCode *key,
-                   size_t size)
+env_delete_notify (void *cls, const struct GNUNET_HashCode *key, size_t size)
 {
   struct GNUNET_DATACACHE_Handle *h = cls;
 
@@ -113,11 +111,10 @@ env_delete_notify (void *cls,
        GNUNET_h2s (key));
   GNUNET_assert (h->utilization >= size);
   h->utilization -= size;
-  GNUNET_CONTAINER_bloomfilter_remove (h->filter,
-                                       key);
+  GNUNET_CONTAINER_bloomfilter_remove (h->filter, key);
   GNUNET_STATISTICS_update (h->stats,
                             gettext_noop ("# bytes stored"),
-                            - (long long) size,
+                            -(long long) size,
                             GNUNET_NO);
   GNUNET_STATISTICS_update (h->stats,
                             gettext_noop ("# items stored"),
@@ -144,54 +141,42 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
   char *name;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_size (cfg,
-                                           section,
-                                           "QUOTA",
-                                           &quota))
+      GNUNET_CONFIGURATION_get_value_size (cfg, section, "QUOTA", &quota))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                               section,
-                               "QUOTA");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, "QUOTA");
     return NULL;
   }
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             section,
-                                             "DATABASE",
-                                             &name))
+      GNUNET_CONFIGURATION_get_value_string (cfg, section, "DATABASE", &name))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                               section,
-                               "DATABASE");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, section, "DATABASE");
     return NULL;
   }
-  bf_size = quota / 32;         /* 8 bit per entry, 1 bit per 32 kb in DB */
+  bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */
 
   ret = GNUNET_new (struct GNUNET_DATACACHE_Handle);
 
   if (GNUNET_YES !=
-      GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            section,
-                                            "DISABLE_BF"))
+      GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF"))
   {
     if (GNUNET_YES !=
-       GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                              section,
-                                              "DISABLE_BF_RC"))
+        GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF_RC"))
     {
       ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom");
     }
     if (NULL != ret->bloom_name)
     {
-      ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name,
-                                                       quota / 1024,     /* 8 bit per entry in DB, expect 1k entries */
-                                                      5);
+      ret->filter = GNUNET_CONTAINER_bloomfilter_load (
+        ret->bloom_name,
+        quota / 1024, /* 8 bit per entry in DB, expect 1k entries */
+        5);
     }
     if (NULL == ret->filter)
     {
-      ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL,
-                                                      bf_size,
-                                                      5); /* approx. 3% false positives at max use */
+      ret->filter =
+        GNUNET_CONTAINER_bloomfilter_init (NULL,
+                                           bf_size,
+                                           5); /* approx. 3% false positives at max use */
     }
   }
   ret->stats = GNUNET_STATISTICS_create ("datacache", cfg);
@@ -202,19 +187,15 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
   ret->env.cls = ret;
   ret->env.delete_notify = &env_delete_notify;
   ret->env.quota = quota;
-  LOG (GNUNET_ERROR_TYPE_INFO,
-       _("Loading `%s' datacache plugin\n"),
-       name);
-  GNUNET_asprintf (&libname,
-                   "libgnunet_plugin_datacache_%s",
-                   name);
+  LOG (GNUNET_ERROR_TYPE_INFO, _ ("Loading `%s' datacache plugin\n"), name);
+  GNUNET_asprintf (&libname, "libgnunet_plugin_datacache_%s", name);
   ret->short_name = name;
   ret->lib_name = libname;
   ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
   if (ret->api == NULL)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Failed to load datacache plugin for `%s'\n"),
+         _ ("Failed to load datacache plugin for `%s'\n"),
          name);
     GNUNET_DATACACHE_destroy (ret);
     return NULL;
@@ -234,23 +215,20 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
   if (NULL != h->filter)
     GNUNET_CONTAINER_bloomfilter_free (h->filter);
   if (NULL != h->api)
-    GNUNET_break (NULL ==
-                  GNUNET_PLUGIN_unload (h->lib_name,
-                                        h->api));
+    GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api));
   GNUNET_free (h->lib_name);
   GNUNET_free (h->short_name);
   GNUNET_free (h->section);
   if (NULL != h->bloom_name)
   {
-    if (0 != UNLINK (h->bloom_name))
+    if (0 != unlink (h->bloom_name))
       GNUNET_log_from_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                                      "datacache",
                                      "unlink",
                                      h->bloom_name);
     GNUNET_free (h->bloom_name);
   }
-  GNUNET_STATISTICS_destroy (h->stats,
-                             GNUNET_NO);
+  GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO);
   GNUNET_free (h);
 }
 
@@ -277,19 +255,19 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
                       const char *data,
                       enum GNUNET_BLOCK_Type type,
                       struct GNUNET_TIME_Absolute discard_time,
-                     unsigned int path_info_len,
-                     const struct GNUNET_PeerIdentity *path_info)
+                      unsigned int path_info_len,
+                      const struct GNUNET_PeerIdentity *path_info)
 {
   ssize_t used;
 
   used = h->api->put (h->api->cls,
                       key,
                       xor_distance,
-                     data_size,
+                      data_size,
                       data,
-                     type,
+                      type,
                       discard_time,
-                     path_info_len,
+                      path_info_len,
                       path_info);
   if (-1 == used)
   {
@@ -305,8 +283,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
        "Stored data under key `%s' in cache\n",
        GNUNET_h2s (key));
   if (NULL != h->filter)
-    GNUNET_CONTAINER_bloomfilter_add (h->filter,
-                                      key);
+    GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
   GNUNET_STATISTICS_update (h->stats,
                             gettext_noop ("# bytes stored"),
                             used,
@@ -316,8 +293,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
                             1,
                             GNUNET_NO);
   while (h->utilization + used > h->env.quota)
-    GNUNET_assert (GNUNET_OK ==
-                  h->api->del (h->api->cls));
+    GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls));
   h->utilization += used;
   return GNUNET_OK;
 }
@@ -348,23 +324,20 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing request for key `%s'\n",
        GNUNET_h2s (key));
-  if ( (NULL != h->filter) &&
-       (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) )
+  if ((NULL != h->filter) &&
+      (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)))
   {
     GNUNET_STATISTICS_update (h->stats,
-                              gettext_noop ("# requests filtered by bloom filter"),
+                              gettext_noop (
+                                "# requests filtered by bloom filter"),
                               1,
                               GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Bloomfilter filters request for key `%s'\n",
          GNUNET_h2s (key));
-    return 0;                   /* can not be present */
+    return 0; /* can not be present */
   }
-  return h->api->get (h->api->cls,
-                      key,
-                      type,
-                      iter,
-                      iter_cls);
+  return h->api->get (h->api->cls, key, type, iter, iter_cls);
 }
 
 
@@ -382,14 +355,12 @@ GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h,
                              void *iter_cls)
 {
   GNUNET_STATISTICS_update (h->stats,
-                            gettext_noop ("# requests for random value received"),
+                            gettext_noop (
+                              "# requests for random value received"),
                             1,
                             GNUNET_NO);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Processing request for random value\n");
-  return h->api->get_random (h->api->cls,
-                             iter,
-                             iter_cls);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for random value\n");
+  return h->api->get_random (h->api->cls, iter, iter_cls);
 }
 
 
@@ -414,17 +385,14 @@ GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h,
                               void *iter_cls)
 {
   GNUNET_STATISTICS_update (h->stats,
-                            gettext_noop ("# proximity search requests received"),
+                            gettext_noop (
+                              "# proximity search requests received"),
                             1,
                             GNUNET_NO);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing proximity search at `%s'\n",
        GNUNET_h2s (key));
-  return h->api->get_closest (h->api->cls,
-                              key,
-                              num_results,
-                              iter,
-                              iter_cls);
+  return h->api->get_closest (h->api->cls, key, num_results, iter, iter_cls);
 }
 
 
index 4381171c5ee41b26f26a7852c0da9f9a35f5d693..1dfb46cf184f6be1de34079b61f85eb2f3705b56 100644 (file)
@@ -74,7 +74,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   if (h == NULL)
   {
-    FPRINTF (stderr, "%s", "Failed to initialize datacache.  Database likely not setup, skipping test.\n");
+    fprintf (stderr, "%s", "Failed to initialize datacache.  Database likely not setup, skipping test.\n");
     ok = 77; /* mark test as skipped */
     return;
   }
@@ -84,7 +84,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   for (i = 0; i < ITERATIONS; i++)
   {
     if (0 == i % (ITERATIONS / 80))
-      FPRINTF (stderr, "%s",  ".");
+      fprintf (stderr, "%s",  ".");
     GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
     ASSERT (GNUNET_OK ==
             GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode),
@@ -92,8 +92,8 @@ run (void *cls, char *const *args, const char *cfgfile,
                                  0, NULL));
     k = n;
   }
-  FPRINTF (stderr, "%s",  "\n");
-  FPRINTF (stdout, "Stored %u items in %s\n", ITERATIONS,
+  fprintf (stderr, "%s",  "\n");
+  fprintf (stdout, "Stored %u items in %s\n", ITERATIONS,
           GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
   GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
   GAUGER (gstr, "Time to PUT item in datacache",
@@ -104,13 +104,13 @@ run (void *cls, char *const *args, const char *cfgfile,
   for (i = 0; i < ITERATIONS; i++)
   {
     if (0 == i % (ITERATIONS / 80))
-      FPRINTF (stderr, "%s",  ".");
+      fprintf (stderr, "%s",  ".");
     GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
     GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n);
     k = n;
   }
-  FPRINTF (stderr, "%s",  "\n");
-  FPRINTF (stdout,
+  fprintf (stderr, "%s",  "\n");
+  fprintf (stdout,
            "Found %u/%u items in %s (%u were deleted during storage processing)\n",
            found, ITERATIONS,
            GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES),
@@ -152,7 +152,7 @@ main (int argc, char *argv[])
   GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
                       "perf-datacache", "nohelp", options, &run, NULL);
   if ( (0 != ok) && (77 != ok) )
-    FPRINTF (stderr, "Missed some perfcases: %d\n", ok);
+    fprintf (stderr, "Missed some perfcases: %d\n", ok);
   return ok;
 }
 
index 07a72957abecd2832a5148c4e45bde5905115fd1..0cf77d6e683f60705dc29ac552f2150c9f4cf1b7 100644 (file)
 #include "gnunet_sq_lib.h"
 #include <sqlite3.h>
 
-#define LOG(kind,...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__)
 
-#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn)
+#define LOG_STRERROR_FILE(kind, op, fn) \
+  GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn)
 
 
 /**
  * How much overhead do we assume per entry in the
  * datacache?
  */
-#define OVERHEAD (sizeof(struct GNUNET_HashCode) + 36)
+#define OVERHEAD (sizeof (struct GNUNET_HashCode) + 36)
 
 /**
  * Context for all functions in this plugin.
@@ -115,7 +116,16 @@ struct Plugin
  * @param level log level
  * @param cmd failed command
  */
-#define LOG_SQLITE(db, level, cmd) do { LOG (level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db)); } while(0)
+#define LOG_SQLITE(db, level, cmd)                    \
+  do                                                  \
+  {                                                   \
+    LOG (level,                                       \
+         _ ("`%s' failed at %s:%d with error: %s\n"), \
+         cmd,                                         \
+         __FILE__,                                    \
+         __LINE__,                                    \
+         sqlite3_errmsg (db));                        \
+  } while (0)
 
 
 /**
@@ -124,7 +134,21 @@ struct Plugin
  * @param db database handle
  * @param cmd SQL command to execute
  */
-#define SQLITE3_EXEC(db, cmd) do { emsg = NULL; if (SQLITE_OK != sqlite3_exec(db, cmd, NULL, NULL, &emsg)) { LOG (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_exec", __FILE__, __LINE__, emsg); sqlite3_free(emsg); } } while(0)
+#define SQLITE3_EXEC(db, cmd)                                   \
+  do                                                            \
+  {                                                             \
+    emsg = NULL;                                                \
+    if (SQLITE_OK != sqlite3_exec (db, cmd, NULL, NULL, &emsg)) \
+    {                                                           \
+      LOG (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,    \
+           _ ("`%s' failed at %s:%d with error: %s\n"),         \
+           "sqlite3_exec",                                      \
+           __FILE__,                                            \
+           __LINE__,                                            \
+           emsg);                                               \
+      sqlite3_free (emsg);                                      \
+    }                                                           \
+  } while (0)
 
 
 /**
@@ -137,9 +161,9 @@ struct Plugin
  */
 static int
 sq_prepare (sqlite3 *dbh,
-            const char *zSql,    /* SQL statement, UTF-8 encoded */
+            const char *zSql, /* SQL statement, UTF-8 encoded */
             sqlite3_stmt **ppStmt)
-{                               /* OUT: Statement handle */
+{ /* OUT: Statement handle */
   char *dummy;
 
   return sqlite3_prepare (dbh,
@@ -166,58 +190,53 @@ sq_prepare (sqlite3 *dbh,
  */
 static ssize_t
 sqlite_plugin_put (void *cls,
-                  const struct GNUNET_HashCode *key,
+                   const struct GNUNET_HashCode *key,
                    uint32_t xor_distance,
-                  size_t size,
+                   size_t size,
                    const char *data,
-                  enum GNUNET_BLOCK_Type type,
+                   enum GNUNET_BLOCK_Type type,
                    struct GNUNET_TIME_Absolute discard_time,
-                  unsigned int path_info_len,
-                  const struct GNUNET_PeerIdentity *path_info)
+                   unsigned int path_info_len,
+                   const struct GNUNET_PeerIdentity *path_info)
 {
   struct Plugin *plugin = cls;
   uint32_t type32 = type;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_absolute_time (&discard_time),
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_uint32 (&xor_distance),
-    GNUNET_SQ_query_param_fixed_size (data, size),
-    GNUNET_SQ_query_param_fixed_size (path_info,
-                                      path_info_len * sizeof (struct GNUNET_PeerIdentity)),
-    GNUNET_SQ_query_param_end
-  };
+  struct GNUNET_SQ_QueryParam params[] =
+    {GNUNET_SQ_query_param_uint32 (&type32),
+     GNUNET_SQ_query_param_absolute_time (&discard_time),
+     GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_uint32 (&xor_distance),
+     GNUNET_SQ_query_param_fixed_size (data, size),
+     GNUNET_SQ_query_param_fixed_size (path_info,
+                                       path_info_len *
+                                         sizeof (struct GNUNET_PeerIdentity)),
+     GNUNET_SQ_query_param_end};
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing PUT of %u bytes with key `%s' and expiration %s\n",
        (unsigned int) size,
        GNUNET_h2s (key),
-       GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time),
+       GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (
+                                                 discard_time),
                                                GNUNET_YES));
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->insert_stmt,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->insert_stmt, params))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_xxx");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->insert_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->insert_stmt);
     return -1;
   }
-  if (SQLITE_DONE !=
-      sqlite3_step (plugin->insert_stmt))
+  if (SQLITE_DONE != sqlite3_step (plugin->insert_stmt))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->insert_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->insert_stmt);
     return -1;
   }
   plugin->num_items++;
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->insert_stmt);
+  GNUNET_SQ_reset (plugin->dbh, plugin->insert_stmt);
   return size + OVERHEAD;
 }
 
@@ -251,62 +270,50 @@ sqlite_plugin_get (void *cls,
   unsigned int total;
   size_t psize;
   struct GNUNET_PeerIdentity *path;
-  struct GNUNET_SQ_QueryParam params_count[] = {
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_absolute_time (&now),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_QueryParam params_select[] = {
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_absolute_time (&now),
-    GNUNET_SQ_query_param_uint32 (&off),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_ResultSpec rs[] = {
-    GNUNET_SQ_result_spec_variable_size (&dat,
-                                         &size),
-    GNUNET_SQ_result_spec_absolute_time (&exp),
-    GNUNET_SQ_result_spec_variable_size ((void **) &path,
-                                         &psize),
-    GNUNET_SQ_result_spec_end
-  };
+  struct GNUNET_SQ_QueryParam params_count[] =
+    {GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_uint32 (&type32),
+     GNUNET_SQ_query_param_absolute_time (&now),
+     GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_QueryParam params_select[] =
+    {GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_uint32 (&type32),
+     GNUNET_SQ_query_param_absolute_time (&now),
+     GNUNET_SQ_query_param_uint32 (&off),
+     GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_ResultSpec rs[] =
+    {GNUNET_SQ_result_spec_variable_size (&dat, &size),
+     GNUNET_SQ_result_spec_absolute_time (&exp),
+     GNUNET_SQ_result_spec_variable_size ((void **) &path, &psize),
+     GNUNET_SQ_result_spec_end};
 
   now = GNUNET_TIME_absolute_get ();
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing GET for key `%s'\n",
        GNUNET_h2s (key));
 
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->get_count_stmt,
-                      params_count))
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_count_stmt, params_count))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_xxx");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_count_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_count_stmt);
     return 0;
   }
-  if (SQLITE_ROW !=
-      sqlite3_step (plugin->get_count_stmt))
+  if (SQLITE_ROW != sqlite3_step (plugin->get_count_stmt))
   {
-    LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+    LOG_SQLITE (plugin->dbh,
+                GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_count_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_count_stmt);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "No content found when processing GET for key `%s'\n",
          GNUNET_h2s (key));
     return 0;
   }
-  total = sqlite3_column_int (plugin->get_count_stmt,
-                              0);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->get_count_stmt);
-  if ( (0 == total) ||
-       (NULL == iter) )
+  total = sqlite3_column_int (plugin->get_count_stmt, 0);
+  GNUNET_SQ_reset (plugin->dbh, plugin->get_count_stmt);
+  if ((0 == total) || (NULL == iter))
   {
     if (0 == total)
       LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -316,32 +323,24 @@ sqlite_plugin_get (void *cls,
   }
 
   cnt = 0;
-  off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                  total);
+  off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, total);
   while (cnt < total)
   {
     off = (off + 1) % total;
-    if (GNUNET_OK !=
-        GNUNET_SQ_bind (plugin->get_stmt,
-                        params_select))
+    if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_stmt, params_select))
     {
       LOG_SQLITE (plugin->dbh,
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_bind_xxx");
-      GNUNET_SQ_reset (plugin->dbh,
-                       plugin->get_stmt);
+      GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
       return cnt;
     }
-    if (SQLITE_ROW !=
-        sqlite3_step (plugin->get_stmt))
+    if (SQLITE_ROW != sqlite3_step (plugin->get_stmt))
       break;
-    if (GNUNET_OK !=
-        GNUNET_SQ_extract_result (plugin->get_stmt,
-                                  rs))
+    if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->get_stmt, rs))
     {
       GNUNET_break (0);
-      GNUNET_SQ_reset (plugin->dbh,
-                       plugin->get_stmt);
+      GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
       break;
     }
     if (0 != psize % sizeof (struct GNUNET_PeerIdentity))
@@ -356,26 +355,16 @@ sqlite_plugin_get (void *cls,
          "Found %u-byte result when processing GET for key `%s'\n",
          (unsigned int) size,
          GNUNET_h2s (key));
-    if (GNUNET_OK != iter (iter_cls,
-                           key,
-                           size,
-                           dat,
-                           type,
-                           exp,
-                           psize,
-                           path))
+    if (GNUNET_OK != iter (iter_cls, key, size, dat, type, exp, psize, path))
     {
       GNUNET_SQ_cleanup_result (rs);
-      GNUNET_SQ_reset (plugin->dbh,
-                       plugin->get_stmt);
+      GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
       break;
     }
     GNUNET_SQ_cleanup_result (rs);
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
   }
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->get_stmt);
+  GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
   return cnt;
 }
 
@@ -396,94 +385,66 @@ sqlite_plugin_del (void *cls)
   size_t dsize;
   struct GNUNET_HashCode hc;
   struct GNUNET_TIME_Absolute now;
-  struct GNUNET_SQ_ResultSpec rs[] = {
-    GNUNET_SQ_result_spec_uint64 (&rowid),
-    GNUNET_SQ_result_spec_auto_from_type (&hc),
-    GNUNET_SQ_result_spec_variable_size ((void **) &data,
-                                         &dsize),
-    GNUNET_SQ_result_spec_end
-  };
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint64 (&rowid),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_QueryParam time_params[] = {
-    GNUNET_SQ_query_param_absolute_time (&now),
-    GNUNET_SQ_query_param_end
-  };
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Processing DEL\n");
+  struct GNUNET_SQ_ResultSpec rs[] =
+    {GNUNET_SQ_result_spec_uint64 (&rowid),
+     GNUNET_SQ_result_spec_auto_from_type (&hc),
+     GNUNET_SQ_result_spec_variable_size ((void **) &data, &dsize),
+     GNUNET_SQ_result_spec_end};
+  struct GNUNET_SQ_QueryParam params[] = {GNUNET_SQ_query_param_uint64 (&rowid),
+                                          GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_QueryParam time_params[] =
+    {GNUNET_SQ_query_param_absolute_time (&now), GNUNET_SQ_query_param_end};
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing DEL\n");
   now = GNUNET_TIME_absolute_get ();
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->del_expired_stmt,
-                      time_params))
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->del_expired_stmt, time_params))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->del_expired_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->del_expired_stmt);
     return GNUNET_SYSERR;
   }
-  if ( (SQLITE_ROW !=
-        sqlite3_step (plugin->del_expired_stmt)) ||
-       (GNUNET_OK !=
-        GNUNET_SQ_extract_result (plugin->del_expired_stmt,
-                                  rs)) )
+  if ((SQLITE_ROW != sqlite3_step (plugin->del_expired_stmt)) ||
+      (GNUNET_OK != GNUNET_SQ_extract_result (plugin->del_expired_stmt, rs)))
   {
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->del_expired_stmt);
-    if (SQLITE_ROW !=
-        sqlite3_step (plugin->del_select_stmt))
+    GNUNET_SQ_reset (plugin->dbh, plugin->del_expired_stmt);
+    if (SQLITE_ROW != sqlite3_step (plugin->del_select_stmt))
     {
       LOG_SQLITE (plugin->dbh,
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_step");
-      GNUNET_SQ_reset (plugin->dbh,
-                       plugin->del_select_stmt);
+      GNUNET_SQ_reset (plugin->dbh, plugin->del_select_stmt);
       return GNUNET_SYSERR;
     }
-    if (GNUNET_OK !=
-        GNUNET_SQ_extract_result (plugin->del_select_stmt,
-                                  rs))
+    if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->del_select_stmt, rs))
     {
-      GNUNET_SQ_reset (plugin->dbh,
-                       plugin->del_select_stmt);
+      GNUNET_SQ_reset (plugin->dbh, plugin->del_select_stmt);
       GNUNET_break (0);
       return GNUNET_SYSERR;
     }
   }
   GNUNET_SQ_cleanup_result (rs);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->del_select_stmt);
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->del_stmt,
-                      params))
+  GNUNET_SQ_reset (plugin->dbh, plugin->del_select_stmt);
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->del_stmt, params))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->del_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->del_stmt);
     return GNUNET_SYSERR;
   }
-  if (SQLITE_DONE !=
-      sqlite3_step (plugin->del_stmt))
+  if (SQLITE_DONE != sqlite3_step (plugin->del_stmt))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->del_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->del_stmt);
     return GNUNET_SYSERR;
   }
   plugin->num_items--;
-  plugin->env->delete_notify (plugin->env->cls,
-                              &hc,
-                              dsize + OVERHEAD);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->del_stmt);
+  plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD);
+  GNUNET_SQ_reset (plugin->dbh, plugin->del_stmt);
   return GNUNET_OK;
 }
 
@@ -510,48 +471,36 @@ sqlite_plugin_get_random (void *cls,
   uint32_t type;
   struct GNUNET_PeerIdentity *path;
   struct GNUNET_HashCode key;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint32 (&off),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_ResultSpec rs[] = {
-    GNUNET_SQ_result_spec_variable_size (&dat,
-                                         &size),
-    GNUNET_SQ_result_spec_absolute_time (&exp),
-    GNUNET_SQ_result_spec_variable_size ((void **) &path,
-                                         &psize),
-    GNUNET_SQ_result_spec_auto_from_type (&key),
-    GNUNET_SQ_result_spec_uint32 (&type),
-    GNUNET_SQ_result_spec_end
-  };
+  struct GNUNET_SQ_QueryParam params[] = {GNUNET_SQ_query_param_uint32 (&off),
+                                          GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_ResultSpec rs[] =
+    {GNUNET_SQ_result_spec_variable_size (&dat, &size),
+     GNUNET_SQ_result_spec_absolute_time (&exp),
+     GNUNET_SQ_result_spec_variable_size ((void **) &path, &psize),
+     GNUNET_SQ_result_spec_auto_from_type (&key),
+     GNUNET_SQ_result_spec_uint32 (&type),
+     GNUNET_SQ_result_spec_end};
 
   if (0 == plugin->num_items)
     return 0;
   if (NULL == iter)
     return 1;
-  off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
-                                  plugin->num_items);
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->get_random_stmt,
-                      params))
+  off =
+    GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, plugin->num_items);
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_random_stmt, params))
   {
     return 0;
   }
-  if (SQLITE_ROW !=
-      sqlite3_step (plugin->get_random_stmt))
+  if (SQLITE_ROW != sqlite3_step (plugin->get_random_stmt))
   {
     GNUNET_break (0);
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_random_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
     return 0;
   }
-  if (GNUNET_OK !=
-      GNUNET_SQ_extract_result (plugin->get_random_stmt,
-                                rs))
+  if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->get_random_stmt, rs))
   {
     GNUNET_break (0);
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_random_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
     return 0;
   }
   if (0 != psize % sizeof (struct GNUNET_PeerIdentity))
@@ -574,8 +523,7 @@ sqlite_plugin_get_random (void *cls,
                psize,
                path);
   GNUNET_SQ_cleanup_result (rs);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->get_random_stmt);
+  GNUNET_SQ_reset (plugin->dbh, plugin->get_random_stmt);
   return 1;
 }
 
@@ -611,45 +559,35 @@ sqlite_plugin_get_closest (void *cls,
   uint32_t type;
   struct GNUNET_HashCode hc;
   struct GNUNET_PeerIdentity *path;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_absolute_time (&now),
-    GNUNET_SQ_query_param_uint32 (&num_results32),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_ResultSpec rs[] = {
-    GNUNET_SQ_result_spec_variable_size (&dat,
-                                         &size),
-    GNUNET_SQ_result_spec_absolute_time (&exp),
-    GNUNET_SQ_result_spec_variable_size ((void **) &path,
-                                         &psize),
-    GNUNET_SQ_result_spec_uint32 (&type),
-    GNUNET_SQ_result_spec_auto_from_type (&hc),
-    GNUNET_SQ_result_spec_end
-  };
+  struct GNUNET_SQ_QueryParam params[] =
+    {GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_absolute_time (&now),
+     GNUNET_SQ_query_param_uint32 (&num_results32),
+     GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_ResultSpec rs[] =
+    {GNUNET_SQ_result_spec_variable_size (&dat, &size),
+     GNUNET_SQ_result_spec_absolute_time (&exp),
+     GNUNET_SQ_result_spec_variable_size ((void **) &path, &psize),
+     GNUNET_SQ_result_spec_uint32 (&type),
+     GNUNET_SQ_result_spec_auto_from_type (&hc),
+     GNUNET_SQ_result_spec_end};
 
   now = GNUNET_TIME_absolute_get ();
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing GET_CLOSEST for key `%s'\n",
        GNUNET_h2s (key));
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->get_closest_stmt,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->get_closest_stmt, params))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_xxx");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->get_closest_stmt);
+    GNUNET_SQ_reset (plugin->dbh, plugin->get_closest_stmt);
     return 0;
   }
   cnt = 0;
-  while (SQLITE_ROW ==
-         sqlite3_step (plugin->get_closest_stmt))
+  while (SQLITE_ROW == sqlite3_step (plugin->get_closest_stmt))
   {
-    if (GNUNET_OK !=
-        GNUNET_SQ_extract_result (plugin->get_closest_stmt,
-                                  rs))
+    if (GNUNET_OK != GNUNET_SQ_extract_result (plugin->get_closest_stmt, rs))
     {
       GNUNET_break (0);
       break;
@@ -666,22 +604,14 @@ sqlite_plugin_get_closest (void *cls,
          "Found %u-byte result at %s when processing GET_CLOSE\n",
          (unsigned int) size,
          GNUNET_h2s (&hc));
-    if (GNUNET_OK != iter (iter_cls,
-                           &hc,
-                           size,
-                           dat,
-                           type,
-                           exp,
-                           psize,
-                           path))
+    if (GNUNET_OK != iter (iter_cls, &hc, size, dat, type, exp, psize, path))
     {
       GNUNET_SQ_cleanup_result (rs);
       break;
     }
     GNUNET_SQ_cleanup_result (rs);
   }
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->get_closest_stmt);
+  GNUNET_SQ_reset (plugin->dbh, plugin->get_closest_stmt);
   return cnt;
 }
 
@@ -703,10 +633,9 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
   sqlite3 *dbh;
   char *emsg;
 
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
-                                           "datacache-sqlite",
-                                           "IN_MEMORY"))
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+                                                          "datacache-sqlite",
+                                                          "IN_MEMORY"))
   {
     if (SQLITE_OK != sqlite3_open (":memory:", &dbh))
       return NULL;
@@ -716,10 +645,10 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
   {
     fn = GNUNET_DISK_mktemp ("gnunet-datacache");
     if (fn == NULL)
-      {
-       GNUNET_break (0);
-       return NULL;
-      }
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
     /* fn should be UTF-8-encoded. If it isn't, it's a bug. */
     fn_utf8 = GNUNET_strdup (fn);
     if (SQLITE_OK != sqlite3_open (fn_utf8, &dbh))
@@ -736,10 +665,9 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
   SQLITE3_EXEC (dbh, "PRAGMA journal_mode=OFF");
   SQLITE3_EXEC (dbh, "PRAGMA synchronous=OFF");
   SQLITE3_EXEC (dbh, "PRAGMA page_size=4092");
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
-                                           "datacache-sqlite",
-                                           "IN_MEMORY"))
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+                                                          "datacache-sqlite",
+                                                          "IN_MEMORY"))
     SQLITE3_EXEC (dbh, "PRAGMA sqlite_temp_store=3");
 
   SQLITE3_EXEC (dbh,
@@ -749,7 +677,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
                 "  key BLOB NOT NULL DEFAULT '',"
                 "  prox INTEGER NOT NULL,"
                 "  value BLOB NOT NULL,"
-               "  path BLOB DEFAULT '')");
+                "  path BLOB DEFAULT '')");
   SQLITE3_EXEC (dbh, "CREATE INDEX idx_hashidx ON ds091 (key,type,expire)");
   SQLITE3_EXEC (dbh, "CREATE INDEX idx_prox_expire ON ds091 (prox,expire)");
   SQLITE3_EXEC (dbh, "CREATE INDEX idx_expire_only ON ds091 (expire)");
@@ -758,53 +686,46 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
   plugin->dbh = dbh;
   plugin->fn = fn_utf8;
 
-  if ( (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "INSERT INTO ds091 (type, expire, key, prox, value, path) "
-                    "VALUES (?, ?, ?, ?, ?, ?)",
-                    &plugin->insert_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT count(*) FROM ds091 "
-                    "WHERE key=? AND type=? AND expire >= ?",
-                    &plugin->get_count_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT value,expire,path FROM ds091"
-                    " WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET ?",
-                    &plugin->get_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT _ROWID_,key,value FROM ds091"
-                    " WHERE expire < ?"
-                    " ORDER BY expire ASC LIMIT 1",
-                    &plugin->del_expired_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT _ROWID_,key,value FROM ds091"
-                    " ORDER BY prox ASC, expire ASC LIMIT 1",
-                    &plugin->del_select_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "DELETE FROM ds091 WHERE _ROWID_=?",
-                    &plugin->del_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT value,expire,path,key,type FROM ds091 "
-                    "ORDER BY key LIMIT 1 OFFSET ?",
-                    &plugin->get_random_stmt)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT value,expire,path,type,key FROM ds091 "
-                    "WHERE key>=? AND expire >= ? ORDER BY KEY ASC LIMIT ?",
-                    &plugin->get_closest_stmt))
-       )
+  if ((SQLITE_OK !=
+       sq_prepare (plugin->dbh,
+                   "INSERT INTO ds091 (type, expire, key, prox, value, path) "
+                   "VALUES (?, ?, ?, ?, ?, ?)",
+                   &plugin->insert_stmt)) ||
+      (SQLITE_OK != sq_prepare (plugin->dbh,
+                                "SELECT count(*) FROM ds091 "
+                                "WHERE key=? AND type=? AND expire >= ?",
+                                &plugin->get_count_stmt)) ||
+      (SQLITE_OK !=
+       sq_prepare (plugin->dbh,
+                   "SELECT value,expire,path FROM ds091"
+                   " WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET ?",
+                   &plugin->get_stmt)) ||
+      (SQLITE_OK != sq_prepare (plugin->dbh,
+                                "SELECT _ROWID_,key,value FROM ds091"
+                                " WHERE expire < ?"
+                                " ORDER BY expire ASC LIMIT 1",
+                                &plugin->del_expired_stmt)) ||
+      (SQLITE_OK != sq_prepare (plugin->dbh,
+                                "SELECT _ROWID_,key,value FROM ds091"
+                                " ORDER BY prox ASC, expire ASC LIMIT 1",
+                                &plugin->del_select_stmt)) ||
+      (SQLITE_OK != sq_prepare (plugin->dbh,
+                                "DELETE FROM ds091 WHERE _ROWID_=?",
+                                &plugin->del_stmt)) ||
+      (SQLITE_OK != sq_prepare (plugin->dbh,
+                                "SELECT value,expire,path,key,type FROM ds091 "
+                                "ORDER BY key LIMIT 1 OFFSET ?",
+                                &plugin->get_random_stmt)) ||
+      (SQLITE_OK !=
+       sq_prepare (plugin->dbh,
+                   "SELECT value,expire,path,type,key FROM ds091 "
+                   "WHERE key>=? AND expire >= ? ORDER BY KEY ASC LIMIT ?",
+                   &plugin->get_closest_stmt)))
   {
     LOG_SQLITE (plugin->dbh,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sq_prepare");
-    GNUNET_break (SQLITE_OK ==
-                  sqlite3_close (plugin->dbh));
+    GNUNET_break (SQLITE_OK == sqlite3_close (plugin->dbh));
     GNUNET_free (plugin);
     return NULL;
   }
@@ -816,8 +737,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
   api->del = &sqlite_plugin_del;
   api->get_random = &sqlite_plugin_get_random;
   api->get_closest = &sqlite_plugin_get_closest;
-  LOG (GNUNET_ERROR_TYPE_INFO,
-       "Sqlite datacache running\n");
+  LOG (GNUNET_ERROR_TYPE_INFO, "Sqlite datacache running\n");
   return api;
 }
 
@@ -839,12 +759,9 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
   sqlite3_stmt *stmt;
 #endif
 
-#if !WINDOWS || defined(__CYGWIN__)
-  if ( (NULL != plugin->fn) &&
-       (0 != UNLINK (plugin->fn)) )
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "unlink",
-                       plugin->fn);
+#if ! WINDOWS || defined(__CYGWIN__)
+  if ((NULL != plugin->fn) && (0 != unlink (plugin->fn)))
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn);
   GNUNET_free_non_null (plugin->fn);
 #endif
   sqlite3_finalize (plugin->insert_stmt);
@@ -860,7 +777,8 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
   if (SQLITE_BUSY == result)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Tried to close sqlite without finalizing all prepared statements.\n"));
+         _ (
+           "Tried to close sqlite without finalizing all prepared statements.\n"));
     stmt = sqlite3_next_stmt (plugin->dbh, NULL);
     while (NULL != stmt)
     {
@@ -876,16 +794,11 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
   }
 #endif
   if (SQLITE_OK != result)
-    LOG_SQLITE (plugin->dbh,
-                GNUNET_ERROR_TYPE_ERROR,
-                "sqlite3_close");
-
-#if WINDOWS && !defined(__CYGWIN__)
-  if ( (NULL != plugin->fn) &&
-       (0 != UNLINK (plugin->fn)) )
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "unlink",
-                       plugin->fn);
+    LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR, "sqlite3_close");
+
+#if WINDOWS && ! defined(__CYGWIN__)
+  if ((NULL != plugin->fn) && (0 != unlink (plugin->fn)))
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn);
   GNUNET_free_non_null (plugin->fn);
 #endif
   GNUNET_free (plugin);
@@ -894,5 +807,4 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
 }
 
 
-
 /* end of plugin_datacache_sqlite.c */
index d62a31c27be37f56b5f4408c1ce0eb0127aa99f4..572a775df0768ae81b0f7ca68e482ec4b52edb1e 100644 (file)
@@ -84,7 +84,7 @@ run (void *cls,
                               "testcache");
   if (h == NULL)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
             "Failed to initialize datacache.  Database likely not setup, skipping test.\n");
     ok = 77; /* mark test as skipped */
@@ -183,7 +183,7 @@ main (int argc, char *argv[])
                      &run,
                      NULL);
   if ( (0 != ok) && (77 != ok) )
-    FPRINTF (stderr,
+    fprintf (stderr,
             "Missed some testcases: %d\n",
             ok);
   return ok;
index 7c4e56ea58077e231af242aae7e8c9e1dd004a9f..0201df3b3610b29ec138d2063eb8de68b14d5904 100644 (file)
@@ -63,7 +63,7 @@ run (void *cls,
 
   if (h == NULL)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              "Failed to initialize datacache.  Database likely not setup, skipping test.\n");
     return;
@@ -73,7 +73,7 @@ run (void *cls,
   memset (&k, 0, sizeof (struct GNUNET_HashCode));
   for (unsigned int i = 0; i < 10; i++)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              ".");
     GNUNET_CRYPTO_hash (&k,
@@ -97,11 +97,11 @@ run (void *cls,
     }
     k = n;
   }
-  FPRINTF (stderr, "%s",  "\n");
+  fprintf (stderr, "%s",  "\n");
   memset (&k, 0, sizeof (struct GNUNET_HashCode));
   for (unsigned int i = 0; i < 10; i++)
   {
-    FPRINTF (stderr, "%s",  ".");
+    fprintf (stderr, "%s",  ".");
     GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
     if (i < 2)
       ASSERT (0 == GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL));
@@ -109,7 +109,7 @@ run (void *cls,
       ASSERT (0 < GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL));
     k = n;
   }
-  FPRINTF (stderr, "%s",  "\n");
+  fprintf (stderr, "%s",  "\n");
   GNUNET_DATACACHE_destroy (h);
   return;
 FAILURE:
@@ -152,7 +152,7 @@ main (int argc,
                      &run,
                      NULL);
   if (0 != ok)
-    FPRINTF (stderr,
+    fprintf (stderr,
             "Missed some testcases: %d\n",
             ok);
   return ok;
index cd089071c946065f27197c87242109e3b34773a8..4cf318777bc7a8ceeb0efd7304c134582013b75a 100644 (file)
@@ -66,7 +66,6 @@ struct DataRecord
    * Key under which the item can be found.
    */
   struct GNUNET_HashCode key;
-
 };
 GNUNET_NETWORK_STRUCT_END
 
@@ -185,13 +184,11 @@ get_cb (void *cls,
   qe = NULL;
   if (NULL == key)
   {
-    FPRINTF (stderr,
-             _("Dumped %" PRIu64 " records\n"),
-             record_count);
+    fprintf (stderr, _ ("Dumped %" PRIu64 " records\n"), record_count);
     GNUNET_DISK_file_close (file_handle);
     file_handle = NULL;
     if (insert)
-      start_insert();
+      start_insert ();
     else
     {
       ret = 0;
@@ -213,8 +210,8 @@ get_cb (void *cls,
   len = GNUNET_DISK_file_write (file_handle, &dr, sizeof (dr));
   if (sizeof (dr) != len)
   {
-    FPRINTF (stderr,
-             _("Short write to file: %zd bytes expecting %zd\n"),
+    fprintf (stderr,
+             _ ("Short write to file: %zd bytes expecting %zd\n"),
              len,
              sizeof (dr));
     ret = 1;
@@ -225,8 +222,8 @@ get_cb (void *cls,
   len = GNUNET_DISK_file_write (file_handle, data, size);
   if (size != len)
   {
-    FPRINTF (stderr,
-             _("Short write to file: %zd bytes expecting %zd\n"),
+    fprintf (stderr,
+             _ ("Short write to file: %zd bytes expecting %zd\n"),
              len,
              size);
     ret = 1;
@@ -235,7 +232,7 @@ get_cb (void *cls,
   }
 
   record_count++;
-  do_get(uid + 1);
+  do_get (uid + 1);
 }
 
 
@@ -257,8 +254,7 @@ do_get (const uint64_t next_uid)
                                  NULL /* proc_cls */);
   if (NULL == qe)
   {
-    FPRINTF (stderr,
-             _("Error queueing datastore GET operation\n"));
+    fprintf (stderr, _ ("Error queueing datastore GET operation\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
   }
@@ -277,15 +273,13 @@ start_dump ()
   {
     file_handle = GNUNET_DISK_file_open (file_name,
                                          GNUNET_DISK_OPEN_WRITE |
-                                         GNUNET_DISK_OPEN_TRUNCATE |
-                                         GNUNET_DISK_OPEN_CREATE,
+                                           GNUNET_DISK_OPEN_TRUNCATE |
+                                           GNUNET_DISK_OPEN_CREATE,
                                          GNUNET_DISK_PERM_USER_READ |
-                                         GNUNET_DISK_PERM_USER_WRITE);
+                                           GNUNET_DISK_PERM_USER_WRITE);
     if (NULL == file_handle)
     {
-      FPRINTF (stderr,
-               _("Unable to open dump file: %s\n"),
-               file_name);
+      fprintf (stderr, _ ("Unable to open dump file: %s\n"), file_name);
       ret = 1;
       GNUNET_SCHEDULER_shutdown ();
       return;
@@ -296,7 +290,7 @@ start_dump ()
     file_handle = GNUNET_DISK_get_handle_from_int_fd (STDOUT_FILENO);
   }
   GNUNET_DISK_file_write (file_handle, MAGIC_BYTES, MAGIC_LEN);
-  do_get(0);
+  do_get (0);
 }
 
 
@@ -322,9 +316,7 @@ put_cb (void *cls,
   qe = NULL;
   if (GNUNET_SYSERR == success)
   {
-    FPRINTF (stderr,
-             _("Failed to store item: %s, aborting\n"),
-             msg);
+    fprintf (stderr, _ ("Failed to store item: %s, aborting\n"), msg);
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -336,17 +328,15 @@ put_cb (void *cls,
   len = GNUNET_DISK_file_read (file_handle, &dr, sizeof (dr));
   if (0 == len)
   {
-    FPRINTF (stderr,
-             _("Inserted %" PRIu64 " records\n"),
-             record_count);
+    fprintf (stderr, _ ("Inserted %" PRIu64 " records\n"), record_count);
     ret = 0;
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   else if (sizeof (dr) != len)
   {
-    FPRINTF (stderr,
-             _("Short read from file: %zd bytes expecting %zd\n"),
+    fprintf (stderr,
+             _ ("Short read from file: %zd bytes expecting %zd\n"),
              len,
              sizeof (dr));
     ret = 1;
@@ -359,8 +349,8 @@ put_cb (void *cls,
   len = GNUNET_DISK_file_read (file_handle, data, size);
   if (size != len)
   {
-    FPRINTF (stderr,
-             _("Short read from file: %zd bytes expecting %zd\n"),
+    fprintf (stderr,
+             _ ("Short read from file: %zd bytes expecting %zd\n"),
              len,
              size);
     ret = 1;
@@ -385,8 +375,7 @@ put_cb (void *cls,
                              NULL);
   if (NULL == qe)
   {
-    FPRINTF (stderr,
-             _("Error queueing datastore PUT operation\n"));
+    fprintf (stderr, _ ("Error queueing datastore PUT operation\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
   }
@@ -408,9 +397,7 @@ start_insert ()
                                          GNUNET_DISK_PERM_NONE);
     if (NULL == file_handle)
     {
-      FPRINTF (stderr,
-               _("Unable to open dump file: %s\n"),
-               file_name);
+      fprintf (stderr, _ ("Unable to open dump file: %s\n"), file_name);
       ret = 1;
       GNUNET_SCHEDULER_shutdown ();
       return;
@@ -425,11 +412,9 @@ start_insert ()
   ssize_t len;
 
   len = GNUNET_DISK_file_read (file_handle, buf, MAGIC_LEN);
-  if (len != MAGIC_LEN ||
-      0 != memcmp (buf, MAGIC_BYTES, MAGIC_LEN))
+  if (len != MAGIC_LEN || 0 != memcmp (buf, MAGIC_BYTES, MAGIC_LEN))
   {
-    FPRINTF (stderr,
-             _("Input file is not of a supported format\n"));
+    fprintf (stderr, _ ("Input file is not of a supported format\n"));
     return;
   }
   put_cb (NULL, GNUNET_YES, GNUNET_TIME_UNIT_ZERO_ABS, NULL);
@@ -454,20 +439,19 @@ run (void *cls,
   datastore = GNUNET_DATASTORE_connect (cfg);
   if (NULL == datastore)
   {
-    FPRINTF (stderr,
-             _("Failed connecting to the datastore.\n"));
+    fprintf (stderr, _ ("Failed connecting to the datastore.\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   if (dump)
-    start_dump();
+    start_dump ();
   else if (insert)
-    start_insert();
+    start_insert ();
   else
   {
-    FPRINTF (stderr,
-             _("Please choose at least one operation: %s, %s\n"),
+    fprintf (stderr,
+             _ ("Please choose at least one operation: %s, %s\n"),
              "dump",
              "insert");
     ret = 1;
@@ -484,34 +468,38 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('d',
-                               "dump",
-                               gettext_noop ("Dump all records from the datastore"),
-                               &dump),
-    GNUNET_GETOPT_option_flag ('i',
-                               "insert",
-                               gettext_noop ("Insert records into the datastore"),
-                               &insert),
-    GNUNET_GETOPT_option_filename ('f',
-                                   "file",
-                                   "FILENAME",
-                                   gettext_noop ("File to dump or insert"),
-                                   &file_name),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('d',
+                                "dump",
+                                gettext_noop (
+                                  "Dump all records from the datastore"),
+                                &dump),
+     GNUNET_GETOPT_option_flag ('i',
+                                "insert",
+                                gettext_noop (
+                                  "Insert records into the datastore"),
+                                &insert),
+     GNUNET_GETOPT_option_filename ('f',
+                                    "file",
+                                    "FILENAME",
+                                    gettext_noop ("File to dump or insert"),
+                                    &file_name),
+     GNUNET_GETOPT_OPTION_END};
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv, "gnunet-datastore",
-                         gettext_noop ("Manipulate GNUnet datastore"),
-                         options, &run, NULL))
+      GNUNET_PROGRAM_run (argc,
+                          argv,
+                          "gnunet-datastore",
+                          gettext_noop ("Manipulate GNUnet datastore"),
+                          options,
+                          &run,
+                          NULL))
     ret = 1;
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 70a946ca5644379d2bb302f2581504fd7b9deb91..4596f61313124546748ea5aee3c332e4616dacfd 100644 (file)
  * How long are we at most keeping "expired" content
  * past the expiration date in the database?
  */
-#define MAX_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
+#define MAX_EXPIRE_DELAY \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
 /**
  * How fast are we allowed to query the database for deleting
  * expired content? (1 item per second).
  */
-#define MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+#define MIN_EXPIRE_DELAY \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 
 /**
  * Name under which we store current space consumption.
@@ -97,7 +99,6 @@ struct DatastorePlugin
    * for this plugin.
    */
   struct GNUNET_DATASTORE_PluginEnvironment env;
-
 };
 
 
@@ -131,11 +132,9 @@ struct ReservationList
    * Reservation identifier.
    */
   int32_t rid;
-
 };
 
 
-
 /**
  * Our datastore plugin (NULL if not available).
  */
@@ -234,10 +233,7 @@ static int stats_worked;
 static void
 sync_stats ()
 {
-  GNUNET_STATISTICS_set (stats,
-                         quota_stat_name,
-                         payload,
-                         GNUNET_YES);
+  GNUNET_STATISTICS_set (stats, quota_stat_name, payload, GNUNET_YES);
   GNUNET_STATISTICS_set (stats,
                          "# utilization by current datastore",
                          payload,
@@ -312,9 +308,10 @@ expired_processor (void *cls,
   if (NULL == key)
   {
     expired_kill_task =
-        GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
-                                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                   &delete_expired, NULL);
+      GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
+                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                  &delete_expired,
+                                                  NULL);
     return GNUNET_SYSERR;
   }
   now = GNUNET_TIME_absolute_get ();
@@ -322,17 +319,19 @@ expired_processor (void *cls,
   {
     /* finished processing */
     expired_kill_task =
-        GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
-                                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                   &delete_expired, NULL);
+      GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
+                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                  &delete_expired,
+                                                  NULL);
     return GNUNET_SYSERR;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Deleting content `%s' of type %u that expired %s ago\n",
-              GNUNET_h2s (key), type,
-             GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (expiration,
-                                                                                          now),
-                                                     GNUNET_YES));
+              GNUNET_h2s (key),
+              type,
+              GNUNET_STRINGS_relative_time_to_string (
+                GNUNET_TIME_absolute_get_difference (expiration, now),
+                GNUNET_YES));
   min_expiration = now;
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# bytes expired"),
@@ -340,9 +339,10 @@ expired_processor (void *cls,
                             GNUNET_YES);
   GNUNET_CONTAINER_bloomfilter_remove (filter, key);
   expired_kill_task =
-      GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY,
-                                                 GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                 &delete_expired, NULL);
+    GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY,
+                                                GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                &delete_expired,
+                                                NULL);
   return GNUNET_NO;
 }
 
@@ -359,9 +359,7 @@ static void
 delete_expired (void *cls)
 {
   expired_kill_task = NULL;
-  plugin->api->get_expiration (plugin->api->cls,
-                              &expired_processor,
-                              NULL);
+  plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL);
 }
 
 
@@ -400,14 +398,17 @@ quota_processor (void *cls,
 
   if (NULL == key)
     return GNUNET_SYSERR;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n",
-              (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
-             (unsigned int) priority,
-              GNUNET_h2s (key), type,
-             GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
-                                                     GNUNET_YES),
-             *need);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n",
+    (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
+    (unsigned int) priority,
+    GNUNET_h2s (key),
+    type,
+    GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (
+                                              expiration),
+                                            GNUNET_YES),
+    *need);
   if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
     *need = 0;
   else
@@ -418,7 +419,8 @@ quota_processor (void *cls,
     min_expiration = expiration;
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# bytes purged (low-priority)"),
-                            size, GNUNET_YES);
+                            size,
+                            GNUNET_YES);
   GNUNET_CONTAINER_bloomfilter_remove (filter, key);
   return GNUNET_NO;
 }
@@ -448,9 +450,7 @@ manage_space (unsigned long long need)
   while ((need > 0) && (last != need))
   {
     last = need;
-    plugin->api->get_expiration (plugin->api->cls,
-                                 &quota_processor,
-                                 &need);
+    plugin->api->get_expiration (plugin->api->cls, &quota_processor, &need);
   }
 }
 
@@ -473,18 +473,15 @@ transmit_status (struct GNUNET_SERVICE_Client *client,
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Transmitting `%s' message with value %d and message `%s'\n",
-              "STATUS", code, msg != NULL ? msg : "(none)");
+              "STATUS",
+              code,
+              msg != NULL ? msg : "(none)");
   slen = (msg == NULL) ? 0 : strlen (msg) + 1;
-  env = GNUNET_MQ_msg_extra (sm,
-                             slen,
-                             GNUNET_MESSAGE_TYPE_DATASTORE_STATUS);
+  env = GNUNET_MQ_msg_extra (sm, slen, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS);
   sm->status = htonl (code);
   sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration);
-  GNUNET_memcpy (&sm[1],
-                 msg,
-                 slen);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_memcpy (&sm[1], msg, slen);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
 }
 
 
@@ -526,19 +523,13 @@ transmit_item (void *cls,
   if (NULL == key)
   {
     /* transmit 'DATA_END' */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Transmitting DATA_END message\n");
-    env = GNUNET_MQ_msg (end,
-                         GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
-    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                    env);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting DATA_END message\n");
+    env = GNUNET_MQ_msg (end, GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
+    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
     return GNUNET_OK;
   }
-  GNUNET_assert (sizeof (struct DataMessage) + size <
-                 GNUNET_MAX_MESSAGE_SIZE);
-  env = GNUNET_MQ_msg_extra (dm,
-                             size,
-                             GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
+  GNUNET_assert (sizeof (struct DataMessage) + size < GNUNET_MAX_MESSAGE_SIZE);
+  env = GNUNET_MQ_msg_extra (dm, size, GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
   dm->rid = htonl (0);
   dm->size = htonl (size);
   dm->type = htonl (type);
@@ -548,22 +539,21 @@ transmit_item (void *cls,
   dm->expiration = GNUNET_TIME_absolute_hton (expiration);
   dm->uid = GNUNET_htonll (uid);
   dm->key = *key;
-  GNUNET_memcpy (&dm[1],
-                 data,
-                 size);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Transmitting DATA message for `%s' of type %u with expiration %s (in: %s)\n",
-              GNUNET_h2s (key),
-              type,
-              GNUNET_STRINGS_absolute_time_to_string (expiration),
-              GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
-                                                     GNUNET_YES));
+  GNUNET_memcpy (&dm[1], data, size);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Transmitting DATA message for `%s' of type %u with expiration %s (in: %s)\n",
+    GNUNET_h2s (key),
+    type,
+    GNUNET_STRINGS_absolute_time_to_string (expiration),
+    GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (
+                                              expiration),
+                                            GNUNET_YES));
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# results found"),
                             1,
                             GNUNET_NO);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   return GNUNET_OK;
 }
 
@@ -575,8 +565,7 @@ transmit_item (void *cls,
  * @param message the actual message
  */
 static void
-handle_reserve (void *cls,
-                const struct ReserveMessage *msg)
+handle_reserve (void *cls, const struct ReserveMessage *msg)
 {
   /**
    * Static counter to produce reservation identifiers.
@@ -589,20 +578,23 @@ handle_reserve (void *cls,
   uint64_t amount;
   uint32_t entries;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing RESERVE request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing RESERVE request\n");
   amount = GNUNET_ntohll (msg->amount);
   entries = ntohl (msg->entries);
   used = payload + reserved;
-  req = amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries;
+  req =
+    amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries;
   if (used + req > quota)
   {
     if (quota < used)
-      used = quota;             /* cheat a bit for error message (to avoid negative numbers) */
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Insufficient space (%llu bytes are available) to satisfy RESERVE request for %llu bytes\n"),
-                quota - used,
-                req);
+      used =
+        quota; /* cheat a bit for error message (to avoid negative numbers) */
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ (
+        "Insufficient space (%llu bytes are available) to satisfy RESERVE request for %llu bytes\n"),
+      quota - used,
+      req);
     if (cache_size < req)
     {
       /* TODO: document this in the FAQ; essentially, if this
@@ -610,15 +602,17 @@ handle_reserve (void *cls,
        * by less-important content from migration because it is
        * larger than 1/8th of the overall available space, and
        * we only reserve 1/8th for "fresh" insertions */
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _("The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"),
-                  req,
-                  cache_size);
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_WARNING,
+        _ (
+          "The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"),
+        req,
+        cache_size);
       transmit_status (client,
                        0,
-                       gettext_noop
-                       ("Insufficient space to satisfy request and "
-                        "requested amount is larger than cache size"));
+                       gettext_noop (
+                         "Insufficient space to satisfy request and "
+                         "requested amount is larger than cache size"));
     }
     else
     {
@@ -642,10 +636,8 @@ handle_reserve (void *cls,
   e->entries = entries;
   e->rid = ++reservation_gen;
   if (reservation_gen < 0)
-    reservation_gen = 0;        /* wrap around */
-  transmit_status (client,
-                   e->rid,
-                   NULL);
+    reservation_gen = 0; /* wrap around */
+  transmit_status (client, e->rid, NULL);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -657,8 +649,7 @@ handle_reserve (void *cls,
  * @param message the actual message
  */
 static void
-handle_release_reserve (void *cls,
-                        const struct ReleaseReserveMessage *msg)
+handle_release_reserve (void *cls, const struct ReleaseReserveMessage *msg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct ReservationList *pos;
@@ -667,8 +658,7 @@ handle_release_reserve (void *cls,
   int rid = ntohl (msg->rid);
   unsigned long long rem;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing RELEASE_RESERVE request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing RELEASE_RESERVE request\n");
   next = reservations;
   prev = NULL;
   while (NULL != (pos = next))
@@ -681,8 +671,8 @@ handle_release_reserve (void *cls,
       else
         prev->next = next;
       rem =
-          pos->amount +
-          ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries;
+        pos->amount +
+        ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries;
       GNUNET_assert (reserved >= rem);
       reserved -= rem;
       GNUNET_STATISTICS_set (stats,
@@ -693,9 +683,7 @@ handle_release_reserve (void *cls,
                   "Returning %llu remaining reserved bytes to storage pool\n",
                   rem);
       GNUNET_free (pos);
-      transmit_status (client,
-                       GNUNET_OK,
-                       NULL);
+      transmit_status (client, GNUNET_OK, NULL);
       GNUNET_SERVICE_client_continue (client);
       return;
     }
@@ -757,8 +745,7 @@ put_continuation (void *cls,
                               gettext_noop ("# bytes stored"),
                               size,
                               GNUNET_YES);
-    GNUNET_CONTAINER_bloomfilter_add (filter,
-                                      key);
+    GNUNET_CONTAINER_bloomfilter_add (filter, key);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Successfully stored %u bytes under key `%s'\n",
                 size,
@@ -770,7 +757,7 @@ put_continuation (void *cls,
   if (quota - reserved - cache_size < payload)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Need %llu bytes more space (%llu allowed, using %llu)\n"),
+                _ ("Need %llu bytes more space (%llu allowed, using %llu)\n"),
                 (unsigned long long) size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
                 (unsigned long long) (quota - reserved - cache_size),
                 (unsigned long long) payload);
@@ -787,8 +774,7 @@ put_continuation (void *cls,
  * @return #GNUNET_OK if @a dm is well-formed
  */
 static int
-check_put (void *cls,
-           const struct DataMessage *dm)
+check_put (void *cls, const struct DataMessage *dm)
 {
   if (GNUNET_OK != check_data (dm))
   {
@@ -806,8 +792,7 @@ check_put (void *cls,
  * @param message the actual message
  */
 static void
-handle_put (void *cls,
-            const struct DataMessage *dm)
+handle_put (void *cls, const struct DataMessage *dm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   int rid;
@@ -839,8 +824,8 @@ handle_put (void *cls,
                              GNUNET_NO);
     }
   }
-  bool absent = GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (filter,
-                                                                &dm->key);
+  bool absent =
+    GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key);
   plugin->api->put (plugin->api->cls,
                     &dm->key,
                     absent,
@@ -864,8 +849,7 @@ handle_put (void *cls,
  * @param msg the actual message
  */
 static void
-handle_get (void *cls,
-            const struct GetMessage *msg)
+handle_get (void *cls, const struct GetMessage *msg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
@@ -894,8 +878,7 @@ handle_get (void *cls,
  * @param msg the actual message
  */
 static void
-handle_get_key (void *cls,
-                const struct GetKeyMessage *msg)
+handle_get_key (void *cls, const struct GetKeyMessage *msg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
@@ -907,21 +890,25 @@ handle_get_key (void *cls,
                             gettext_noop ("# GET KEY requests received"),
                             1,
                             GNUNET_NO);
-  if (GNUNET_YES !=
-      GNUNET_CONTAINER_bloomfilter_test (filter,
-                                         &msg->key))
+  if (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key))
   {
     /* don't bother database... */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Empty result set for GET request for `%s' (bloomfilter).\n",
                 GNUNET_h2s (&msg->key));
     GNUNET_STATISTICS_update (stats,
-                              gettext_noop
-                              ("# requests filtered by bloomfilter"),
+                              gettext_noop (
+                                "# requests filtered by bloomfilter"),
                               1,
                               GNUNET_NO);
     transmit_item (client,
-                   NULL, 0, NULL, 0, 0, 0, 0,
+                   NULL,
+                   0,
+                   NULL,
+                   0,
+                   0,
+                   0,
+                   0,
                    GNUNET_TIME_UNIT_ZERO_ABS,
                    0);
     GNUNET_SERVICE_client_continue (client);
@@ -945,20 +932,17 @@ handle_get_key (void *cls,
  * @param message the actual message
  */
 static void
-handle_get_replication (void *cls,
-                        const struct GNUNET_MessageHeader *message)
+handle_get_replication (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing GET_REPLICATION request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing GET_REPLICATION request\n");
   GNUNET_STATISTICS_update (stats,
-                            gettext_noop ("# GET REPLICATION requests received"),
+                            gettext_noop (
+                              "# GET REPLICATION requests received"),
                             1,
                             GNUNET_NO);
-  plugin->api->get_replication (plugin->api->cls,
-                                &transmit_item,
-                                client);
+  plugin->api->get_replication (plugin->api->cls, &transmit_item, client);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -970,8 +954,7 @@ handle_get_replication (void *cls,
  * @param message the actual message
  */
 static void
-handle_get_zero_anonymity (void *cls,
-                           const struct GetZeroAnonymityMessage *msg)
+handle_get_zero_anonymity (void *cls, const struct GetZeroAnonymityMessage *msg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   enum GNUNET_BLOCK_Type type;
@@ -986,7 +969,8 @@ handle_get_zero_anonymity (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Processing GET_ZERO_ANONYMITY request\n");
   GNUNET_STATISTICS_update (stats,
-                            gettext_noop ("# GET ZERO ANONYMITY requests received"),
+                            gettext_noop (
+                              "# GET ZERO ANONYMITY requests received"),
                             1,
                             GNUNET_NO);
   plugin->api->get_zero_anonymity (plugin->api->cls,
@@ -1019,21 +1003,15 @@ remove_continuation (void *cls,
 
   if (GNUNET_SYSERR == status)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "REMOVE request failed: %s.\n",
-                msg);
-    transmit_status (client,
-                     GNUNET_NO,
-                     msg);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "REMOVE request failed: %s.\n", msg);
+    transmit_status (client, GNUNET_NO, msg);
     return;
   }
   if (GNUNET_NO == status)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Content not found for REMOVE request.\n");
-    transmit_status (client,
-                     GNUNET_NO,
-                     _("Content not found"));
+    transmit_status (client, GNUNET_NO, _ ("Content not found"));
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1043,11 +1021,8 @@ remove_continuation (void *cls,
                             gettext_noop ("# bytes removed (explicit request)"),
                             size,
                             GNUNET_YES);
-  GNUNET_CONTAINER_bloomfilter_remove (filter,
-                                       key);
-  transmit_status (client,
-                   GNUNET_OK,
-                   NULL);
+  GNUNET_CONTAINER_bloomfilter_remove (filter, key);
+  transmit_status (client, GNUNET_OK, NULL);
 }
 
 
@@ -1059,8 +1034,7 @@ remove_continuation (void *cls,
  * @return #GNUNET_OK if @a dm is well-formed
  */
 static int
-check_remove (void *cls,
-              const struct DataMessage *dm)
+check_remove (void *cls, const struct DataMessage *dm)
 {
   if (GNUNET_OK != check_data (dm))
   {
@@ -1079,14 +1053,14 @@ check_remove (void *cls,
  * @param message the actual message
  */
 static void
-handle_remove (void *cls,
-               const struct DataMessage *dm)
+handle_remove (void *cls, const struct DataMessage *dm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# REMOVE requests received"),
-                            1, GNUNET_NO);
+                            1,
+                            GNUNET_NO);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Processing REMOVE request for `%s'\n",
               GNUNET_h2s (&dm->key));
@@ -1107,13 +1081,11 @@ handle_remove (void *cls,
  * @param message the actual message
  */
 static void
-handle_drop (void *cls,
-             const struct GNUNET_MessageHeader *message)
+handle_drop (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing DROP request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing DROP request\n");
   do_drop = GNUNET_YES;
   GNUNET_SERVICE_client_continue (client);
 }
@@ -1128,21 +1100,21 @@ handle_drop (void *cls,
  *        0 for "reset to empty"
  */
 static void
-disk_utilization_change_cb (void *cls,
-                            int delta)
+disk_utilization_change_cb (void *cls, int delta)
 {
   if ((delta < 0) && (payload < -delta))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Datastore payload must have been inaccurate (%lld < %lld). Recomputing it.\n"),
-                (long long) payload,
-                (long long) -delta);
-    plugin->api->estimate_size (plugin->api->cls,
-                                &payload);
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ (
+        "Datastore payload must have been inaccurate (%lld < %lld). Recomputing it.\n"),
+      (long long) payload,
+      (long long) -delta);
+    plugin->api->estimate_size (plugin->api->cls, &payload);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("New payload: %lld\n"),
+                _ ("New payload: %lld\n"),
                 (long long) payload);
-     sync_stats ();
+    sync_stats ();
     return;
   }
   payload += delta;
@@ -1172,10 +1144,11 @@ process_stat_in (void *cls,
   GNUNET_assert (GNUNET_NO == stats_worked);
   stats_worked = GNUNET_YES;
   payload += value;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Notification from statistics about existing payload (%llu), new payload is %llu\n",
-              (unsigned long long) value,
-              (unsigned long long) payload);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Notification from statistics about existing payload (%llu), new payload is %llu\n",
+    (unsigned long long) value,
+    (unsigned long long) payload);
   return GNUNET_OK;
 }
 
@@ -1194,19 +1167,16 @@ load_plugin ()
   ret->env.duc = &disk_utilization_change_cb;
   ret->env.cls = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Loading `%s' datastore plugin\n"),
+              _ ("Loading `%s' datastore plugin\n"),
               plugin_name);
-  GNUNET_asprintf (&libname,
-                   "libgnunet_plugin_datastore_%s",
-                   plugin_name);
+  GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", plugin_name);
   ret->short_name = GNUNET_strdup (plugin_name);
   ret->lib_name = libname;
-  ret->api = GNUNET_PLUGIN_load (libname,
-                                 &ret->env);
+  ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
   if (NULL == ret->api)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to load datastore plugin for `%s'\n"),
+                _ ("Failed to load datastore plugin for `%s'\n"),
                 plugin_name);
     GNUNET_free (ret->short_name);
     GNUNET_free (libname);
@@ -1242,10 +1212,10 @@ static void
 begin_service ()
 {
   GNUNET_SERVICE_resume (service);
-  expired_kill_task
-    GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                          &delete_expired,
-                                          NULL);
+  expired_kill_task =
+    GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                        &delete_expired,
+                                        NULL);
 }
 
 
@@ -1258,22 +1228,21 @@ begin_service ()
  */
 static void
 add_key_to_bloomfilter (void *cls,
-                       const struct GNUNET_HashCode *key,
-                       unsigned int count)
+                        const struct GNUNET_HashCode *key,
+                        unsigned int count)
 {
   struct GNUNET_CONTAINER_BloomFilter *bf = cls;
 
   if (NULL == key)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-               _("Bloomfilter construction complete.\n"));
+                _ ("Bloomfilter construction complete.\n"));
     begin_service ();
     return;
   }
 
   while (0 < count--)
-    GNUNET_CONTAINER_bloomfilter_add (bf,
-                                      key);
+    GNUNET_CONTAINER_bloomfilter_add (bf, key);
 }
 
 
@@ -1285,8 +1254,7 @@ add_key_to_bloomfilter (void *cls,
  * @param success #GNUNET_NO if we failed to read the stat
  */
 static void
-process_stat_done (void *cls,
-                   int success)
+process_stat_done (void *cls, int success)
 {
   stat_get = NULL;
   if (NULL != stat_timeout_task)
@@ -1301,8 +1269,7 @@ process_stat_done (void *cls,
     filter = NULL;
     if (NULL != stats)
     {
-      GNUNET_STATISTICS_destroy (stats,
-                                 GNUNET_YES);
+      GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
       stats = NULL;
     }
     return;
@@ -1312,28 +1279,26 @@ process_stat_done (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Failed to obtain value from statistics service, recomputing it\n");
-    plugin->api->estimate_size (plugin->api->cls,
-                                &payload);
+    plugin->api->estimate_size (plugin->api->cls, &payload);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("New payload: %lld\n"),
+                _ ("New payload: %lld\n"),
                 (long long) payload);
   }
 
   if (GNUNET_YES == refresh_bf)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-               _("Rebuilding bloomfilter.  Please be patient.\n"));
+                _ ("Rebuilding bloomfilter.  Please be patient.\n"));
     if (NULL != plugin->api->get_keys)
     {
-      plugin->api->get_keys (plugin->api->cls,
-                             &add_key_to_bloomfilter,
-                             filter);
+      plugin->api->get_keys (plugin->api->cls, &add_key_to_bloomfilter, filter);
       return;
     }
     else
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Plugin does not support get_keys function. Please fix!\n"));
+                  _ (
+                    "Plugin does not support get_keys function. Please fix!\n"));
     }
   }
   begin_service ();
@@ -1350,8 +1315,7 @@ stat_timeout (void *cls)
 {
   stat_timeout_task = NULL;
   GNUNET_STATISTICS_get_cancel (stat_get);
-  process_stat_done (NULL,
-                     GNUNET_NO);
+  process_stat_done (NULL, GNUNET_NO);
 }
 
 
@@ -1369,8 +1333,7 @@ cleaning_task (void *cls)
   }
   if (GNUNET_YES == do_drop)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Dropping database!\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dropping database!\n");
     plugin->api->drop (plugin->api->cls);
     payload = 0;
     last_sync++;
@@ -1401,8 +1364,7 @@ cleaning_task (void *cls)
     sync_stats ();
   if (NULL != stats)
   {
-    GNUNET_STATISTICS_destroy (stats,
-                               GNUNET_YES);
+    GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
     stats = NULL;
   }
   GNUNET_free (quota_stat_name);
@@ -1420,8 +1382,8 @@ cleaning_task (void *cls)
  */
 static void *
 client_connect_cb (void *cls,
-                  struct GNUNET_SERVICE_Client *client,
-                  struct GNUNET_MQ_Handle *mq)
+                   struct GNUNET_SERVICE_Client *client,
+                   struct GNUNET_MQ_Handle *mq)
 {
   return client;
 }
@@ -1437,8 +1399,8 @@ client_connect_cb (void *cls,
  */
 static void
 client_disconnect_cb (void *cls,
-                     struct GNUNET_SERVICE_Client *client,
-                     void *app_ctx)
+                      struct GNUNET_SERVICE_Client *client,
+                      void *app_ctx)
 {
   struct ReservationList *pos;
   struct ReservationList *prev;
@@ -1469,7 +1431,6 @@ client_disconnect_cb (void *cls,
                          gettext_noop ("# reserved"),
                          reserved,
                          GNUNET_NO);
-
 }
 
 
@@ -1491,11 +1452,10 @@ run (void *cls,
 
   service = serv;
   cfg = c;
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             "DATASTORE",
-                                             "DATABASE",
-                                             &plugin_name))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          "DATASTORE",
+                                                          "DATABASE",
+                                                          &plugin_name))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "DATABASE",
@@ -1503,26 +1463,17 @@ run (void *cls,
     return;
   }
   GNUNET_asprintf (&quota_stat_name,
-                  _("# bytes used in file-sharing datastore `%s'"),
-                  plugin_name);
+                   _ ("# bytes used in file-sharing datastore `%s'"),
+                   plugin_name);
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_size (cfg,
-                                           "DATASTORE",
-                                           "QUOTA",
-                                           &quota))
+      GNUNET_CONFIGURATION_get_value_size (cfg, "DATASTORE", "QUOTA", &quota))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                               "QUOTA",
-                               "DATASTORE");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "QUOTA", "DATASTORE");
     return;
   }
-  stats = GNUNET_STATISTICS_create ("datastore",
-                                    cfg);
-  GNUNET_STATISTICS_set (stats,
-                         gettext_noop ("# quota"),
-                         quota,
-                         GNUNET_NO);
-  cache_size = quota / 8;       /* Or should we make this an option? */
+  stats = GNUNET_STATISTICS_create ("datastore", cfg);
+  GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, GNUNET_NO);
+  cache_size = quota / 8; /* Or should we make this an option? */
   GNUNET_STATISTICS_set (stats,
                          gettext_noop ("# cache size"),
                          cache_size,
@@ -1530,17 +1481,17 @@ run (void *cls,
   if (quota / (32 * 1024LL) > MAX_BF_SIZE)
     bf_size = MAX_BF_SIZE;
   else
-    bf_size = quota / (32 * 1024LL);         /* 8 bit per entry, 1 bit per 32 kb in DB */
+    bf_size =
+      quota / (32 * 1024LL); /* 8 bit per entry, 1 bit per 32 kb in DB */
   fn = NULL;
-  if ((GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                "DATASTORE",
-                                                "BLOOMFILTER",
-                                                &fn)) ||
+  if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                             "DATASTORE",
+                                                             "BLOOMFILTER",
+                                                             &fn)) ||
       (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Could not use specified filename `%s' for bloomfilter.\n"),
+                _ ("Could not use specified filename `%s' for bloomfilter.\n"),
                 NULL != fn ? fn : "");
     GNUNET_free_non_null (fn);
     fn = NULL;
@@ -1550,139 +1501,150 @@ run (void *cls,
     GNUNET_asprintf (&pfn, "%s.%s", fn, plugin_name);
     if (GNUNET_YES == GNUNET_DISK_file_test (pfn))
     {
-      filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5);        /* approx. 3% false positives at max use */
+      filter =
+        GNUNET_CONTAINER_bloomfilter_load (pfn,
+                                           bf_size,
+                                           5); /* approx. 3% false positives at max use */
       if (NULL == filter)
       {
-       /* file exists but not valid, remove and try again, but refresh */
-       if (0 != UNLINK (pfn))
-       {
-         /* failed to remove, run without file */
-         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                     _("Failed to remove bogus bloomfilter file `%s'\n"),
-                     pfn);
-         GNUNET_free (pfn);
-         pfn = NULL;
-         filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5);        /* approx. 3% false positives at max use */
-         refresh_bf = GNUNET_YES;
-       }
-       else
-       {
-         /* try again after remove */
-         filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5);        /* approx. 3% false positives at max use */
-         refresh_bf = GNUNET_YES;
-         if (NULL == filter)
-         {
-           /* failed yet again, give up on using file */
-           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                       _("Failed to remove bogus bloomfilter file `%s'\n"),
-                       pfn);
-           GNUNET_free (pfn);
-           pfn = NULL;
-           filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5);        /* approx. 3% false positives at max use */
-         }
-       }
+        /* file exists but not valid, remove and try again, but refresh */
+        if (0 != unlink (pfn))
+        {
+          /* failed to remove, run without file */
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _ ("Failed to remove bogus bloomfilter file `%s'\n"),
+                      pfn);
+          GNUNET_free (pfn);
+          pfn = NULL;
+          filter = GNUNET_CONTAINER_bloomfilter_load (
+            NULL,
+            bf_size,
+            5); /* approx. 3% false positives at max use */
+          refresh_bf = GNUNET_YES;
+        }
+        else
+        {
+          /* try again after remove */
+          filter = GNUNET_CONTAINER_bloomfilter_load (
+            pfn,
+            bf_size,
+            5); /* approx. 3% false positives at max use */
+          refresh_bf = GNUNET_YES;
+          if (NULL == filter)
+          {
+            /* failed yet again, give up on using file */
+            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                        _ ("Failed to remove bogus bloomfilter file `%s'\n"),
+                        pfn);
+            GNUNET_free (pfn);
+            pfn = NULL;
+            filter = GNUNET_CONTAINER_bloomfilter_init (
+              NULL,
+              bf_size,
+              5); /* approx. 3% false positives at max use */
+          }
+        }
       }
       else
       {
-       /* normal case: have an existing valid bf file, no need to refresh */
-       refresh_bf = GNUNET_NO;
+        /* normal case: have an existing valid bf file, no need to refresh */
+        refresh_bf = GNUNET_NO;
       }
     }
     else
     {
-      filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5);        /* approx. 3% false positives at max use */
+      filter =
+        GNUNET_CONTAINER_bloomfilter_load (pfn,
+                                           bf_size,
+                                           5); /* approx. 3% false positives at max use */
       refresh_bf = GNUNET_YES;
     }
     GNUNET_free (pfn);
   }
   else
   {
-    filter = GNUNET_CONTAINER_bloomfilter_init (NULL,
-                                                bf_size,
-                                                5);      /* approx. 3% false positives at max use */
+    filter =
+      GNUNET_CONTAINER_bloomfilter_init (NULL,
+                                         bf_size,
+                                         5); /* approx. 3% false positives at max use */
     refresh_bf = GNUNET_YES;
   }
   GNUNET_free_non_null (fn);
   if (NULL == filter)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to initialize bloomfilter.\n"));
+                _ ("Failed to initialize bloomfilter.\n"));
     if (NULL != stats)
     {
-      GNUNET_STATISTICS_destroy (stats,
-                                 GNUNET_YES);
+      GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
       stats = NULL;
     }
     return;
   }
   GNUNET_SERVICE_suspend (service);
-  stat_get =
-      GNUNET_STATISTICS_get (stats,
-                             "datastore",
-                             quota_stat_name,
-                             &process_stat_done,
-                             &process_stat_in,
-                             NULL);
+  stat_get = GNUNET_STATISTICS_get (stats,
+                                    "datastore",
+                                    quota_stat_name,
+                                    &process_stat_done,
+                                    &process_stat_in,
+                                    NULL);
   if (NULL == stat_get)
-    process_stat_done (NULL,
-                       GNUNET_SYSERR);
+    process_stat_done (NULL, GNUNET_SYSERR);
   else
-    stat_timeout_task
-      = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                      &stat_timeout,
-                                      NULL);
-  GNUNET_SCHEDULER_add_shutdown (&cleaning_task,
-                                NULL);
+    stat_timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                                      &stat_timeout,
+                                                      NULL);
+  GNUNET_SCHEDULER_add_shutdown (&cleaning_task, NULL);
 }
 
 
 /**
  * Define "main" method using service macro.
  */
-GNUNET_SERVICE_MAIN
-("datastore",
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_fixed_size (reserve,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE,
-                          struct ReserveMessage,
-                          NULL),
- GNUNET_MQ_hd_fixed_size (release_reserve,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE,
-                          struct ReleaseReserveMessage,
-                          NULL),
- GNUNET_MQ_hd_var_size (put,
-                        GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
-                        struct DataMessage,
-                        NULL),
- GNUNET_MQ_hd_fixed_size (get,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_GET,
-                          struct GetMessage,
-                          NULL),
- GNUNET_MQ_hd_fixed_size (get_key,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY,
-                          struct GetKeyMessage,
-                          NULL),
- GNUNET_MQ_hd_fixed_size (get_replication,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
-                          struct GNUNET_MessageHeader,
-                          NULL),
- GNUNET_MQ_hd_fixed_size (get_zero_anonymity,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
-                          struct GetZeroAnonymityMessage,
-                          NULL),
- GNUNET_MQ_hd_var_size (remove,
-                        GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE,
-                        struct DataMessage,
-                        NULL),
- GNUNET_MQ_hd_fixed_size (drop,
-                          GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
-                          struct GNUNET_MessageHeader,
-                          NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN (
+  "datastore",
 GNUNET_SERVICE_OPTION_NONE,
 &run,
 &client_connect_cb,
 &client_disconnect_cb,
 NULL,
 GNUNET_MQ_hd_fixed_size (reserve,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE,
+                           struct ReserveMessage,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (release_reserve,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE,
+                           struct ReleaseReserveMessage,
+                           NULL),
 GNUNET_MQ_hd_var_size (put,
+                         GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
+                         struct DataMessage,
+                         NULL),
 GNUNET_MQ_hd_fixed_size (get,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_GET,
+                           struct GetMessage,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (get_key,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY,
+                           struct GetKeyMessage,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (get_replication,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
+                           struct GNUNET_MessageHeader,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (get_zero_anonymity,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
+                           struct GetZeroAnonymityMessage,
+                           NULL),
 GNUNET_MQ_hd_var_size (remove,
+                         GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE,
+                         struct DataMessage,
+                         NULL),
 GNUNET_MQ_hd_fixed_size (drop,
+                           GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
+                           struct GNUNET_MessageHeader,
+                           NULL),
 GNUNET_MQ_handler_end ());
 
 
 /* end of gnunet-service-datastore.c */
index 2c261b155ad8038181ee59300d9cc3f498500c12..96ec9e924e30403831ccc07329bf0d712c40176d 100644 (file)
@@ -211,7 +211,7 @@ check_success (void *cls,
   struct CpsRunContext *crc = cls;
 
 #if REPORT_ID
-  FPRINTF (stderr, "%s",  (GNUNET_OK == success) ? "I" : "i");
+  fprintf (stderr, "%s",  (GNUNET_OK == success) ? "I" : "i");
 #endif
   if (GNUNET_OK != success)
   {
@@ -285,7 +285,7 @@ remove_next (void *cls,
     return;
   }
 #if REPORT_ID
-  FPRINTF (stderr, "%s",  "D");
+  fprintf (stderr, "%s",  "D");
 #endif
   GNUNET_assert (GNUNET_OK == success);
   GNUNET_SCHEDULER_add_now (&run_continuation,
@@ -528,7 +528,7 @@ run_tests (void *cls,
 
   if (success != GNUNET_YES)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Test 'put' operation failed with error `%s' database likely not setup, skipping test.\n",
              msg);
     GNUNET_DATASTORE_disconnect (datastore,
@@ -573,7 +573,7 @@ run (void *cls,
                             0, 1,
                             &run_tests, crc))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              "Test 'put' operation failed.\n");
     ok = 1;
@@ -608,7 +608,7 @@ main (int argc,
                               &run,
                               NULL))
     return 1;
-  FPRINTF (stderr, "%s", "\n");
+  fprintf (stderr, "%s", "\n");
   return ok;
 }
 
index f68d1f38992df100fcfd228562ac0d903116eb73..564f8f37b25cfac69fc5e3124d018c6bc13a7b52 100644 (file)
@@ -122,7 +122,7 @@ put_continuation (void *cls,
 
   if (GNUNET_OK != status)
   {
-    FPRINTF (stderr, "ERROR: `%s'\n", msg);
+    fprintf (stderr, "ERROR: `%s'\n", msg);
   }
   else
   {
@@ -477,7 +477,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
   GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
   if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
   {
-    FPRINTF (stderr, "Failed to load plugin `%s'!\n", name);
+    fprintf (stderr, "Failed to load plugin `%s'!\n", name);
     GNUNET_free (name);
     GNUNET_free (libname);
     return NULL;
@@ -503,7 +503,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   api = load_plugin (c);
   if (api == NULL)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n");
     return;
   }
@@ -544,7 +544,7 @@ main (int argc, char *argv[])
   GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
                       "perf-plugin-datastore", "nohelp", options, &run, NULL);
   if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
+    fprintf (stderr, "Missed some testcases: %u\n", ok);
   GNUNET_DISK_directory_remove (dir_name);
 
   return ok;
index d548935eaffca9919bfb0883034f20ec0c8576b9..4bd2b39cbcb2fa9e45787bcda6fe86e3f75df8f1 100644 (file)
@@ -1,4 +1,4 @@
- /*
+/*
   * This file is part of GNUnet
   * Copyright (C) 2009, 2011, 2017 GNUnet e.V.
   *
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).
  */
-#define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
+#define LOG_SQLITE(db, level, cmd)                                \
+  do                                                              \
+  {                                                               \
+    GNUNET_log_from (level,                                       \
+                     "sqlite",                                    \
+                     _ ("`%s' failed at %s:%d with error: %s\n"), \
+                     cmd,                                         \
+                     __FILE__,                                    \
+                     __LINE__,                                    \
+                     sqlite3_errmsg (db->dbh));                   \
+  } while (0)
 
 
 /**
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).
  */
-#define LOG_SQLITE_MSG(db, msg, level, cmd) do { GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); GNUNET_asprintf(msg, _("`%s' failed at %s:%u with error: %s"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
-
+#define LOG_SQLITE_MSG(db, msg, level, cmd)                       \
+  do                                                              \
+  {                                                               \
+    GNUNET_log_from (level,                                       \
+                     "sqlite",                                    \
+                     _ ("`%s' failed at %s:%d with error: %s\n"), \
+                     cmd,                                         \
+                     __FILE__,                                    \
+                     __LINE__,                                    \
+                     sqlite3_errmsg (db->dbh));                   \
+    GNUNET_asprintf (msg,                                         \
+                     _ ("`%s' failed at %s:%u with error: %s"),   \
+                     cmd,                                         \
+                     __FILE__,                                    \
+                     __LINE__,                                    \
+                     sqlite3_errmsg (db->dbh));                   \
+  } while (0)
 
 
 /**
@@ -141,7 +166,6 @@ struct Plugin
    * Should the database be dropped on shutdown?
    */
   int drop_on_shutdown;
-
 };
 
 
@@ -154,9 +178,7 @@ struct Plugin
  * @return 0 on success
  */
 static int
-sq_prepare (sqlite3 *dbh,
-            const char *zSql,
-            sqlite3_stmt **ppStmt)
+sq_prepare (sqlite3 *dbh, const char *zSql, sqlite3_stmt **ppStmt)
 {
   char *dummy;
   int result;
@@ -182,37 +204,56 @@ sq_prepare (sqlite3 *dbh,
  * @param dbh handle to the database
  */
 static void
-create_indices (sqlite3 * dbh)
+create_indices (sqlite3 *dbh)
 {
   /* create indices */
-  if (0 !=
-      (SQLITE_OK !=
-       sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS idx_hash ON gn091 (hash)",
-                     NULL, NULL, NULL)) +
+  if (
+    0 !=
+    (SQLITE_OK !=
+     sqlite3_exec (dbh,
+                   "CREATE INDEX IF NOT EXISTS idx_hash ON gn091 (hash)",
+                   NULL,
+                   NULL,
+                   NULL)) +
       (SQLITE_OK !=
-       sqlite3_exec (dbh,
-                     "CREATE INDEX IF NOT EXISTS idx_anon_type ON gn091 (anonLevel ASC,type)",
-                     NULL, NULL, NULL)) +
+       sqlite3_exec (
+         dbh,
+         "CREATE INDEX IF NOT EXISTS idx_anon_type ON gn091 (anonLevel ASC,type)",
+         NULL,
+         NULL,
+         NULL)) +
       (SQLITE_OK !=
        sqlite3_exec (dbh,
                      "CREATE INDEX IF NOT EXISTS idx_expire ON gn091 (expire ASC)",
-                     NULL, NULL, NULL)) +
+                     NULL,
+                     NULL,
+                     NULL)) +
       (SQLITE_OK !=
-       sqlite3_exec (dbh,
-                     "CREATE INDEX IF NOT EXISTS idx_repl_rvalue ON gn091 (repl,rvalue)",
-                     NULL, NULL, NULL)) )
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "sqlite",
-                     "Failed to create indices: %s\n", sqlite3_errmsg (dbh));
+       sqlite3_exec (
+         dbh,
+         "CREATE INDEX IF NOT EXISTS idx_repl_rvalue ON gn091 (repl,rvalue)",
+         NULL,
+         NULL,
+         NULL)))
+    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                     "sqlite",
+                     "Failed to create indices: %s\n",
+                     sqlite3_errmsg (dbh));
 }
 
 
 #if 0
-#define CHECK(a) GNUNET_break(a)
+#define CHECK(a) GNUNET_break (a)
 #define ENULL NULL
 #else
 #define ENULL &e
 #define ENULL_DEFINED 1
-#define CHECK(a) if (! (a)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", e); sqlite3_free(e); }
+#define CHECK(a)                                     \
+  if (! (a))                                         \
+  {                                                  \
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", e); \
+    sqlite3_free (e);                                \
+  }
 #endif
 
 
@@ -235,21 +276,19 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
   char *e;
 #endif
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               "datastore-sqlite",
-                                               "FILENAME",
-                                               &afsdir))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                            "datastore-sqlite",
+                                                            "FILENAME",
+                                                            &afsdir))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "datastore-sqlite",
+                               "datastore-sqlite",
                                "FILENAME");
     return GNUNET_SYSERR;
   }
   if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
   {
-    if (GNUNET_OK !=
-        GNUNET_DISK_directory_create_for_file (afsdir))
+    if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (afsdir))
     {
       GNUNET_break (0);
       GNUNET_free (afsdir);
@@ -257,48 +296,46 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     /* database is new or got deleted, reset payload to zero! */
     if (NULL != plugin->env->duc)
-      plugin->env->duc (plugin->env->cls,
-                        0);
+      plugin->env->duc (plugin->env->cls, 0);
   }
   /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */
   plugin->fn = afsdir;
 
   /* Open database and precompile statements */
-  if (SQLITE_OK !=
-      sqlite3_open (plugin->fn, &plugin->dbh))
+  if (SQLITE_OK != sqlite3_open (plugin->fn, &plugin->dbh))
   {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "sqlite",
-                     _("Unable to initialize SQLite: %s.\n"),
+    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                     "sqlite",
+                     _ ("Unable to initialize SQLite: %s.\n"),
                      sqlite3_errmsg (plugin->dbh));
     return GNUNET_SYSERR;
   }
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA temp_store=MEMORY", NULL, NULL,
-                       ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA synchronous=OFF", NULL, NULL,
-                       ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA legacy_file_format=OFF", NULL, NULL,
-                       ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA auto_vacuum=INCREMENTAL", NULL,
-                       NULL, ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
-                       ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA page_size=4096", NULL, NULL,
-                       ENULL));
-
-  CHECK (SQLITE_OK ==
-         sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
+  CHECK (
+    SQLITE_OK ==
+    sqlite3_exec (plugin->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL, ENULL));
+  CHECK (
+    SQLITE_OK ==
+    sqlite3_exec (plugin->dbh, "PRAGMA synchronous=OFF", NULL, NULL, ENULL));
+  CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh,
+                                    "PRAGMA legacy_file_format=OFF",
+                                    NULL,
+                                    NULL,
+                                    ENULL));
+  CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh,
+                                    "PRAGMA auto_vacuum=INCREMENTAL",
+                                    NULL,
+                                    NULL,
+                                    ENULL));
+  CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh,
+                                    "PRAGMA locking_mode=EXCLUSIVE",
+                                    NULL,
+                                    NULL,
+                                    ENULL));
+  CHECK (
+    SQLITE_OK ==
+    sqlite3_exec (plugin->dbh, "PRAGMA page_size=4096", NULL, NULL, ENULL));
+
+  CHECK (SQLITE_OK == sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
 
 
   /* We have to do it here, because otherwise precompiling SQL might fail */
@@ -312,152 +349,135 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
    * we do math or inequality tests, so we can't handle the entire range of uint32_t.
    * This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
    */
-  if ( (SQLITE_DONE ==
-        sqlite3_step (stmt)) &&
-       (SQLITE_OK !=
-        sqlite3_exec (plugin->dbh,
-                      "CREATE TABLE gn091 ("
-                      "  repl INT4 NOT NULL DEFAULT 0,"
-                      "  type INT4 NOT NULL DEFAULT 0,"
-                      "  prio INT4 NOT NULL DEFAULT 0,"
-                      "  anonLevel INT4 NOT NULL DEFAULT 0,"
-                      "  expire INT8 NOT NULL DEFAULT 0,"
-                      "  rvalue INT8 NOT NULL,"
-                      "  hash TEXT NOT NULL DEFAULT '',"
-                      "  vhash TEXT NOT NULL DEFAULT '',"
-                      "  value BLOB NOT NULL DEFAULT '')",
-                      NULL,
-                      NULL,
-                      NULL)) )
+  if ((SQLITE_DONE == sqlite3_step (stmt)) &&
+      (SQLITE_OK != sqlite3_exec (plugin->dbh,
+                                  "CREATE TABLE gn091 ("
+                                  "  repl INT4 NOT NULL DEFAULT 0,"
+                                  "  type INT4 NOT NULL DEFAULT 0,"
+                                  "  prio INT4 NOT NULL DEFAULT 0,"
+                                  "  anonLevel INT4 NOT NULL DEFAULT 0,"
+                                  "  expire INT8 NOT NULL DEFAULT 0,"
+                                  "  rvalue INT8 NOT NULL,"
+                                  "  hash TEXT NOT NULL DEFAULT '',"
+                                  "  vhash TEXT NOT NULL DEFAULT '',"
+                                  "  value BLOB NOT NULL DEFAULT '')",
+                                  NULL,
+                                  NULL,
+                                  NULL)))
   {
-    LOG_SQLITE (plugin,
-                GNUNET_ERROR_TYPE_ERROR,
-                "sqlite3_exec");
+    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
     sqlite3_finalize (stmt);
     return GNUNET_SYSERR;
   }
   sqlite3_finalize (stmt);
   create_indices (plugin->dbh);
 
-#define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, _ROWID_"
-  if ( (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "UPDATE gn091 "
-                    "SET prio = prio + ?, "
-                    "repl = repl + ?, "
-                    "expire = MAX(expire, ?) "
-                    "WHERE hash = ? AND vhash = ?",
-                    &plugin->update)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "UPDATE gn091 " "SET repl = MAX (0, repl - 1) WHERE _ROWID_ = ?",
-                    &plugin->updRepl)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE repl=?2 AND " " (rvalue>=?1 OR "
-                    "  NOT EXISTS (SELECT 1 FROM gn091 "
-                    "WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) "
-                    "ORDER BY rvalue ASC LIMIT 1",
-                    &plugin->selRepl)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT MAX(repl) FROM gn091",
-                    &plugin->maxRepl)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE NOT EXISTS (SELECT 1 FROM gn091 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) "
-                    "ORDER BY expire ASC LIMIT 1",
-                    &plugin->selExpi)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ? AND "
-                    "anonLevel = 0 AND "
-                    "type = ? "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->selZeroAnon)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "INSERT INTO gn091 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) "
-                    "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
-                    &plugin->insertContent)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[0])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "type = ?4 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[1])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "hash = ?3 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[2])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "hash = ?3 AND "
-                    "type = ?4 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[3])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "rvalue >= ?2 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[4])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "rvalue >= ?2 AND "
-                    "type = ?4 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[5])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "rvalue >= ?2 AND "
-                    "hash = ?3 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[6])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "SELECT " RESULT_COLUMNS " FROM gn091 "
-                    "WHERE _ROWID_ >= ?1 AND "
-                    "rvalue >= ?2 AND "
-                    "hash = ?3 AND "
-                    "type = ?4 "
-                    "ORDER BY _ROWID_ ASC LIMIT 1",
-                    &plugin->get[7])) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "DELETE FROM gn091 WHERE _ROWID_ = ?",
-                    &plugin->delRow)) ||
-       (SQLITE_OK !=
-        sq_prepare (plugin->dbh,
-                    "DELETE FROM gn091 "
-                    "WHERE hash = ? AND "
-                    "value = ? ",
-                    &plugin->remove)) ||
-       false)
+#define RESULT_COLUMNS \
+  "repl, type, prio, anonLevel, expire, hash, value, _ROWID_"
+  if (
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "UPDATE gn091 "
+                              "SET prio = prio + ?, "
+                              "repl = repl + ?, "
+                              "expire = MAX(expire, ?) "
+                              "WHERE hash = ? AND vhash = ?",
+                              &plugin->update)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "UPDATE gn091 "
+                              "SET repl = MAX (0, repl - 1) WHERE _ROWID_ = ?",
+                              &plugin->updRepl)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE repl=?2 AND "
+                              " (rvalue>=?1 OR "
+                              "  NOT EXISTS (SELECT 1 FROM gn091 "
+                              "WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) "
+                              "ORDER BY rvalue ASC LIMIT 1",
+                              &plugin->selRepl)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT MAX(repl) FROM gn091",
+                              &plugin->maxRepl)) ||
+    (SQLITE_OK !=
+     sq_prepare (plugin->dbh,
+                 "SELECT " RESULT_COLUMNS " FROM gn091 "
+                 "WHERE NOT EXISTS (SELECT 1 FROM gn091 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) "
+                 "ORDER BY expire ASC LIMIT 1",
+                 &plugin->selExpi)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ? AND "
+                              "anonLevel = 0 AND "
+                              "type = ? "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->selZeroAnon)) ||
+    (SQLITE_OK !=
+     sq_prepare (plugin->dbh,
+                 "INSERT INTO gn091 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) "
+                 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+                 &plugin->insertContent)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[0])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "type = ?4 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[1])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "hash = ?3 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[2])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "hash = ?3 AND "
+                              "type = ?4 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[3])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "rvalue >= ?2 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[4])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "rvalue >= ?2 AND "
+                              "type = ?4 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[5])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "rvalue >= ?2 AND "
+                              "hash = ?3 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[6])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "SELECT " RESULT_COLUMNS " FROM gn091 "
+                              "WHERE _ROWID_ >= ?1 AND "
+                              "rvalue >= ?2 AND "
+                              "hash = ?3 AND "
+                              "type = ?4 "
+                              "ORDER BY _ROWID_ ASC LIMIT 1",
+                              &plugin->get[7])) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "DELETE FROM gn091 WHERE _ROWID_ = ?",
+                              &plugin->delRow)) ||
+    (SQLITE_OK != sq_prepare (plugin->dbh,
+                              "DELETE FROM gn091 "
+                              "WHERE hash = ? AND "
+                              "value = ? ",
+                              &plugin->remove)) ||
+    false)
   {
-    LOG_SQLITE (plugin,
-                GNUNET_ERROR_TYPE_ERROR,
-                "precompiling");
+    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "precompiling");
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -503,11 +523,12 @@ database_shutdown (struct Plugin *plugin)
 #if SQLITE_VERSION_NUMBER >= 3007000
   if (result == SQLITE_BUSY)
   {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
-                     "sqlite",
-                     _("Tried to close sqlite without finalizing all prepared statements.\n"));
-    stmt = sqlite3_next_stmt (plugin->dbh,
-                              NULL);
+    GNUNET_log_from (
+      GNUNET_ERROR_TYPE_WARNING,
+      "sqlite",
+      _ (
+        "Tried to close sqlite without finalizing all prepared statements.\n"));
+    stmt = sqlite3_next_stmt (plugin->dbh, NULL);
     while (NULL != stmt)
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
@@ -521,16 +542,13 @@ database_shutdown (struct Plugin *plugin)
                          "Failed to close statement %p: %d\n",
                          stmt,
                          result);
-      stmt = sqlite3_next_stmt (plugin->dbh,
-                                NULL);
+      stmt = sqlite3_next_stmt (plugin->dbh, NULL);
     }
     result = sqlite3_close (plugin->dbh);
   }
 #endif
   if (SQLITE_OK != result)
-    LOG_SQLITE (plugin,
-                GNUNET_ERROR_TYPE_ERROR,
-                "sqlite3_close");
+    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_close");
   GNUNET_free_non_null (plugin->fn);
 }
 
@@ -543,28 +561,22 @@ database_shutdown (struct Plugin *plugin)
  * @param rid the ID of the row to delete
  */
 static int
-delete_by_rowid (struct Plugin *plugin,
-                 uint64_t rid)
+delete_by_rowid (struct Plugin *plugin, uint64_t rid)
 {
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint64 (&rid),
-    GNUNET_SQ_query_param_end
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->delRow,
-                      params))
+  struct GNUNET_SQ_QueryParam params[] = {GNUNET_SQ_query_param_uint64 (&rid),
+                                          GNUNET_SQ_query_param_end};
+
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->delRow, params))
     return GNUNET_SYSERR;
   if (SQLITE_DONE != sqlite3_step (plugin->delRow))
   {
-    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+    LOG_SQLITE (plugin,
+                GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->delRow);
+    GNUNET_SQ_reset (plugin->dbh, plugin->delRow);
     return GNUNET_SYSERR;
   }
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->delRow);
+  GNUNET_SQ_reset (plugin->dbh, plugin->delRow);
   return GNUNET_OK;
 }
 
@@ -603,94 +615,78 @@ sqlite_plugin_put (void *cls,
   struct GNUNET_HashCode vhash;
   char *msg = NULL;
 
-  GNUNET_CRYPTO_hash (data,
-                      size,
-                      &vhash);
+  GNUNET_CRYPTO_hash (data, size, &vhash);
 
-  if (!absent)
+  if (! absent)
   {
-    struct GNUNET_SQ_QueryParam params[] = {
-      GNUNET_SQ_query_param_uint32 (&priority),
-      GNUNET_SQ_query_param_uint32 (&replication),
-      GNUNET_SQ_query_param_absolute_time (&expiration),
-      GNUNET_SQ_query_param_auto_from_type (key),
-      GNUNET_SQ_query_param_auto_from_type (&vhash),
-      GNUNET_SQ_query_param_end
-    };
-
-    if (GNUNET_OK !=
-        GNUNET_SQ_bind (plugin->update,
-                        params))
+    struct GNUNET_SQ_QueryParam params[] =
+      {GNUNET_SQ_query_param_uint32 (&priority),
+       GNUNET_SQ_query_param_uint32 (&replication),
+       GNUNET_SQ_query_param_absolute_time (&expiration),
+       GNUNET_SQ_query_param_auto_from_type (key),
+       GNUNET_SQ_query_param_auto_from_type (&vhash),
+       GNUNET_SQ_query_param_end};
+
+    if (GNUNET_OK != GNUNET_SQ_bind (plugin->update, params))
     {
-      cont (cont_cls,
-            key,
-            size,
-            GNUNET_SYSERR,
-            _("sqlite bind failure"));
+      cont (cont_cls, key, size, GNUNET_SYSERR, _ ("sqlite bind failure"));
       return;
     }
     if (SQLITE_DONE != sqlite3_step (plugin->update))
     {
-      LOG_SQLITE_MSG (plugin, &msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+      LOG_SQLITE_MSG (plugin,
+                      &msg,
+                      GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                       "sqlite3_step");
-      cont (cont_cls,
-            key,
-            size,
-            GNUNET_SYSERR,
-            msg);
+      cont (cont_cls, key, size, GNUNET_SYSERR, msg);
       GNUNET_free_non_null (msg);
       return;
     }
     int changes = sqlite3_changes (plugin->dbh);
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->update);
+    GNUNET_SQ_reset (plugin->dbh, plugin->update);
     if (0 != changes)
     {
-      cont (cont_cls,
-            key,
-            size,
-            GNUNET_NO,
-            NULL);
+      cont (cont_cls, key, size, GNUNET_NO, NULL);
       return;
     }
   }
 
   uint64_t rvalue;
   uint32_t type32 = (uint32_t) type;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint32 (&replication),
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_uint32 (&priority),
-    GNUNET_SQ_query_param_uint32 (&anonymity),
-    GNUNET_SQ_query_param_absolute_time (&expiration),
-    GNUNET_SQ_query_param_uint64 (&rvalue),
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_auto_from_type (&vhash),
-    GNUNET_SQ_query_param_fixed_size (data, size),
-    GNUNET_SQ_query_param_end
-  };
+  struct GNUNET_SQ_QueryParam params[] =
+    {GNUNET_SQ_query_param_uint32 (&replication),
+     GNUNET_SQ_query_param_uint32 (&type32),
+     GNUNET_SQ_query_param_uint32 (&priority),
+     GNUNET_SQ_query_param_uint32 (&anonymity),
+     GNUNET_SQ_query_param_absolute_time (&expiration),
+     GNUNET_SQ_query_param_uint64 (&rvalue),
+     GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_auto_from_type (&vhash),
+     GNUNET_SQ_query_param_fixed_size (data, size),
+     GNUNET_SQ_query_param_end};
   int n;
   int ret;
   sqlite3_stmt *stmt;
 
   if (size > MAX_ITEM_SIZE)
   {
-    cont (cont_cls, key, size, GNUNET_SYSERR, _("Data too large"));
+    cont (cont_cls, key, size, GNUNET_SYSERR, _ ("Data too large"));
     return;
   }
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
-                   "Storing in database block with type %u/key `%s'/priority %u/expiration in %s (%s).\n",
-                   type,
-                   GNUNET_h2s (key),
-                   priority,
-                   GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
-                                                          GNUNET_YES),
-                   GNUNET_STRINGS_absolute_time_to_string (expiration));
+  GNUNET_log_from (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "sqlite",
+    "Storing in database block with type %u/key `%s'/priority %u/expiration in %s (%s).\n",
+    type,
+    GNUNET_h2s (key),
+    priority,
+    GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (
+                                              expiration),
+                                            GNUNET_YES),
+    GNUNET_STRINGS_absolute_time_to_string (expiration));
   stmt = plugin->insertContent;
   rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (stmt,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (stmt, params))
   {
     cont (cont_cls, key, size, GNUNET_SYSERR, NULL);
     return;
@@ -702,7 +698,8 @@ sqlite_plugin_put (void *cls,
     if (NULL != plugin->env->duc)
       plugin->env->duc (plugin->env->cls,
                         size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                     "sqlite",
                      "Stored new entry (%u bytes)\n",
                      size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
     ret = GNUNET_OK;
@@ -710,28 +707,26 @@ sqlite_plugin_put (void *cls,
   case SQLITE_BUSY:
     GNUNET_break (0);
     LOG_SQLITE_MSG (plugin,
-                   &msg,
-                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+                    &msg,
+                    GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                     "sqlite3_step");
     ret = GNUNET_SYSERR;
     break;
   default:
     LOG_SQLITE_MSG (plugin,
-                   &msg,
-                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+                    &msg,
+                    GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                     "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     stmt);
+    GNUNET_SQ_reset (plugin->dbh, stmt);
     database_shutdown (plugin);
     database_setup (plugin->env->cfg, plugin);
     cont (cont_cls, key, size, GNUNET_SYSERR, msg);
-    GNUNET_free_non_null(msg);
+    GNUNET_free_non_null (msg);
     return;
   }
-  GNUNET_SQ_reset (plugin->dbh,
-                   stmt);
+  GNUNET_SQ_reset (plugin->dbh, stmt);
   cont (cont_cls, key, size, ret, msg);
-  GNUNET_free_non_null(msg);
+  GNUNET_free_non_null (msg);
 }
 
 
@@ -761,26 +756,22 @@ execute_get (struct Plugin *plugin,
   size_t value_size;
   struct GNUNET_HashCode key;
   int ret;
-  struct GNUNET_SQ_ResultSpec rs[] = {
-    GNUNET_SQ_result_spec_uint32 (&replication),
-    GNUNET_SQ_result_spec_uint32 (&type),
-    GNUNET_SQ_result_spec_uint32 (&priority),
-    GNUNET_SQ_result_spec_uint32 (&anonymity),
-    GNUNET_SQ_result_spec_absolute_time (&expiration),
-    GNUNET_SQ_result_spec_auto_from_type (&key),
-    GNUNET_SQ_result_spec_variable_size (&value,
-                                         &value_size),
-    GNUNET_SQ_result_spec_uint64 (&rowid),
-    GNUNET_SQ_result_spec_end
-  };
+  struct GNUNET_SQ_ResultSpec rs[] =
+    {GNUNET_SQ_result_spec_uint32 (&replication),
+     GNUNET_SQ_result_spec_uint32 (&type),
+     GNUNET_SQ_result_spec_uint32 (&priority),
+     GNUNET_SQ_result_spec_uint32 (&anonymity),
+     GNUNET_SQ_result_spec_absolute_time (&expiration),
+     GNUNET_SQ_result_spec_auto_from_type (&key),
+     GNUNET_SQ_result_spec_variable_size (&value, &value_size),
+     GNUNET_SQ_result_spec_uint64 (&rowid),
+     GNUNET_SQ_result_spec_end};
 
   n = sqlite3_step (stmt);
   switch (n)
   {
   case SQLITE_ROW:
-    if (GNUNET_OK !=
-        GNUNET_SQ_extract_result (stmt,
-                                  rs))
+    if (GNUNET_OK != GNUNET_SQ_extract_result (stmt, rs))
     {
       GNUNET_break (0);
       break;
@@ -800,12 +791,9 @@ execute_get (struct Plugin *plugin,
                 expiration,
                 rowid);
     GNUNET_SQ_cleanup_result (rs);
-    GNUNET_SQ_reset (plugin->dbh,
-                     stmt);
-    if ( (GNUNET_NO == ret) &&
-         (GNUNET_OK == delete_by_rowid (plugin,
-                                        rowid)) &&
-         (NULL != plugin->env->duc) )
+    GNUNET_SQ_reset (plugin->dbh, stmt);
+    if ((GNUNET_NO == ret) && (GNUNET_OK == delete_by_rowid (plugin, rowid)) &&
+        (NULL != plugin->env->duc))
       plugin->env->duc (plugin->env->cls,
                         -(value_size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
     return;
@@ -819,20 +807,17 @@ execute_get (struct Plugin *plugin,
     LOG_SQLITE (plugin,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_step");
-    if (SQLITE_OK !=
-        sqlite3_reset (stmt))
+    if (SQLITE_OK != sqlite3_reset (stmt))
       LOG_SQLITE (plugin,
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_reset");
     GNUNET_break (0);
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     database_shutdown (plugin);
-    database_setup (plugin->env->cfg,
-                    plugin);
+    database_setup (plugin->env->cfg, plugin);
     return;
   }
-  GNUNET_SQ_reset (plugin->dbh,
-                   stmt);
+  GNUNET_SQ_reset (plugin->dbh, stmt);
   proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
 }
 
@@ -858,16 +843,14 @@ sqlite_plugin_get_zero_anonymity (void *cls,
 {
   struct Plugin *plugin = cls;
   uint32_t type32 = type;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint64 (&next_uid),
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_end
-  };
+  struct GNUNET_SQ_QueryParam params[] = {GNUNET_SQ_query_param_uint64 (
+                                            &next_uid),
+                                          GNUNET_SQ_query_param_uint32 (
+                                            &type32),
+                                          GNUNET_SQ_query_param_end};
 
   GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->selZeroAnon,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->selZeroAnon, params))
   {
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
@@ -905,13 +888,12 @@ sqlite_plugin_get_key (void *cls,
   int use_type = GNUNET_BLOCK_TYPE_ANY != type;
   int use_key = NULL != key;
   sqlite3_stmt *stmt = plugin->get[use_rvalue * 4 + use_key * 2 + use_type];
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_uint64 (&next_uid),
-    GNUNET_SQ_query_param_uint64 (&rvalue),
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_uint32 (&type32),
-    GNUNET_SQ_query_param_end
-  };
+  struct GNUNET_SQ_QueryParam params[] =
+    {GNUNET_SQ_query_param_uint64 (&next_uid),
+     GNUNET_SQ_query_param_uint64 (&rvalue),
+     GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_uint32 (&type32),
+     GNUNET_SQ_query_param_end};
 
   /* SQLite doesn't like it when you try to bind a parameter greater than the
    * last numbered parameter, but unused parameters in the middle are OK.
@@ -928,24 +910,18 @@ sqlite_plugin_get_key (void *cls,
   }
   if (random)
   {
-    rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                       UINT64_MAX);
+    rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
     next_uid = 0;
   }
   else
     rvalue = 0;
 
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (stmt,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (stmt, params))
   {
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
-  execute_get (plugin,
-               stmt,
-               proc,
-               proc_cls);
+  execute_get (plugin, stmt, proc, proc_cls);
 }
 
 
@@ -1051,37 +1027,27 @@ sqlite_plugin_get_replication (void *cls,
   struct ReplCtx rc;
   uint64_t rvalue;
   uint32_t repl;
-  struct GNUNET_SQ_QueryParam params_sel_repl[] = {
-    GNUNET_SQ_query_param_uint64 (&rvalue),
-    GNUNET_SQ_query_param_uint32 (&repl),
-    GNUNET_SQ_query_param_end
-  };
-  struct GNUNET_SQ_QueryParam params_upd_repl[] = {
-    GNUNET_SQ_query_param_uint64 (&rc.uid),
-    GNUNET_SQ_query_param_end
-  };
+  struct GNUNET_SQ_QueryParam params_sel_repl[] =
+    {GNUNET_SQ_query_param_uint64 (&rvalue),
+     GNUNET_SQ_query_param_uint32 (&repl),
+     GNUNET_SQ_query_param_end};
+  struct GNUNET_SQ_QueryParam params_upd_repl[] =
+    {GNUNET_SQ_query_param_uint64 (&rc.uid), GNUNET_SQ_query_param_end};
 
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                    "datastore-sqlite",
                    "Getting random block based on replication order.\n");
-  if (SQLITE_ROW !=
-      sqlite3_step (plugin->maxRepl))
+  if (SQLITE_ROW != sqlite3_step (plugin->maxRepl))
   {
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->maxRepl);
+    GNUNET_SQ_reset (plugin->dbh, plugin->maxRepl);
     /* DB empty */
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
   }
-  repl = sqlite3_column_int (plugin->maxRepl,
-                             0);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->maxRepl);
-  rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                     UINT64_MAX);
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->selRepl,
-                      params_sel_repl))
+  repl = sqlite3_column_int (plugin->maxRepl, 0);
+  GNUNET_SQ_reset (plugin->dbh, plugin->maxRepl);
+  rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->selRepl, params_sel_repl))
   {
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
@@ -1089,26 +1055,19 @@ sqlite_plugin_get_replication (void *cls,
   rc.have_uid = GNUNET_SYSERR;
   rc.proc = proc;
   rc.proc_cls = proc_cls;
-  execute_get (plugin,
-               plugin->selRepl,
-               &repl_proc,
-               &rc);
+  execute_get (plugin, plugin->selRepl, &repl_proc, &rc);
   if (GNUNET_YES == rc.have_uid)
   {
-    if (GNUNET_OK !=
-        GNUNET_SQ_bind (plugin->updRepl,
-                        params_upd_repl))
+    if (GNUNET_OK != GNUNET_SQ_bind (plugin->updRepl, params_upd_repl))
     {
       proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
       return;
     }
-    if (SQLITE_DONE !=
-        sqlite3_step (plugin->updRepl))
+    if (SQLITE_DONE != sqlite3_step (plugin->updRepl))
       LOG_SQLITE (plugin,
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->updRepl);
+    GNUNET_SQ_reset (plugin->dbh, plugin->updRepl);
   }
   if (GNUNET_SYSERR == rc.have_uid)
   {
@@ -1127,25 +1086,24 @@ sqlite_plugin_get_replication (void *cls,
  * @param proc_cls closure for @a proc
  */
 static void
-sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
+sqlite_plugin_get_expiration (void *cls,
+                              PluginDatumProcessor proc,
                               void *proc_cls)
 {
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
   struct GNUNET_TIME_Absolute now;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_absolute_time (&now),
-    GNUNET_SQ_query_param_end
-  };
-
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
-                   "sqlite",
-                   "Getting random block based on expiration and priority order.\n");
+  struct GNUNET_SQ_QueryParam params[] = {GNUNET_SQ_query_param_absolute_time (
+                                            &now),
+                                          GNUNET_SQ_query_param_end};
+
+  GNUNET_log_from (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "sqlite",
+    "Getting random block based on expiration and priority order.\n");
   now = GNUNET_TIME_absolute_get ();
   stmt = plugin->selExpi;
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (stmt,
-                      params))
+  if (GNUNET_OK != GNUNET_SQ_bind (stmt, params))
   {
     proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
     return;
@@ -1162,52 +1120,35 @@ sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
  * @param proc_cls closure for @a proc
  */
 static void
-sqlite_plugin_get_keys (void *cls,
-                       PluginKeyProcessor proc,
-                       void *proc_cls)
+sqlite_plugin_get_keys (void *cls, PluginKeyProcessor proc, void *proc_cls)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_HashCode key;
-  struct GNUNET_SQ_ResultSpec results[] = {
-    GNUNET_SQ_result_spec_auto_from_type (&key),
-    GNUNET_SQ_result_spec_end
-  };
+  struct GNUNET_SQ_ResultSpec results[] =
+    {GNUNET_SQ_result_spec_auto_from_type (&key), GNUNET_SQ_result_spec_end};
   sqlite3_stmt *stmt;
   int ret;
 
   GNUNET_assert (NULL != proc);
-  if (SQLITE_OK !=
-      sq_prepare (plugin->dbh,
-                  "SELECT hash FROM gn091",
-                  &stmt))
+  if (SQLITE_OK != sq_prepare (plugin->dbh, "SELECT hash FROM gn091", &stmt))
   {
     LOG_SQLITE (plugin,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-               "sqlite_prepare");
-    proc (proc_cls,
-          NULL,
-          0);
+                "sqlite_prepare");
+    proc (proc_cls, NULL, 0);
     return;
   }
   while (SQLITE_ROW == (ret = sqlite3_step (stmt)))
   {
-    if (GNUNET_OK ==
-        GNUNET_SQ_extract_result (stmt,
-                                  results))
-      proc (proc_cls,
-            &key,
-            1);
+    if (GNUNET_OK == GNUNET_SQ_extract_result (stmt, results))
+      proc (proc_cls, &key, 1);
     else
       GNUNET_break (0);
   }
   if (SQLITE_DONE != ret)
-    LOG_SQLITE (plugin,
-                GNUNET_ERROR_TYPE_ERROR,
-                "sqlite_step");
+    LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
   sqlite3_finalize (stmt);
-  proc (proc_cls,
-        NULL,
-        0);
+  proc (proc_cls, NULL, 0);
 }
 
 
@@ -1244,21 +1185,14 @@ sqlite_plugin_remove_key (void *cls,
                           void *cont_cls)
 {
   struct Plugin *plugin = cls;
-  struct GNUNET_SQ_QueryParam params[] = {
-    GNUNET_SQ_query_param_auto_from_type (key),
-    GNUNET_SQ_query_param_fixed_size (data, size),
-    GNUNET_SQ_query_param_end
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_SQ_bind (plugin->remove,
-                      params))
+  struct GNUNET_SQ_QueryParam params[] =
+    {GNUNET_SQ_query_param_auto_from_type (key),
+     GNUNET_SQ_query_param_fixed_size (data, size),
+     GNUNET_SQ_query_param_end};
+
+  if (GNUNET_OK != GNUNET_SQ_bind (plugin->remove, params))
   {
-    cont (cont_cls,
-          key,
-          size,
-          GNUNET_SYSERR,
-          "bind failed");
+    cont (cont_cls, key, size, GNUNET_SYSERR, "bind failed");
     return;
   }
   if (SQLITE_DONE != sqlite3_step (plugin->remove))
@@ -1266,35 +1200,21 @@ sqlite_plugin_remove_key (void *cls,
     LOG_SQLITE (plugin,
                 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_step");
-    GNUNET_SQ_reset (plugin->dbh,
-                     plugin->remove);
-    cont (cont_cls,
-          key,
-          size,
-          GNUNET_SYSERR,
-          "sqlite3_step failed");
+    GNUNET_SQ_reset (plugin->dbh, plugin->remove);
+    cont (cont_cls, key, size, GNUNET_SYSERR, "sqlite3_step failed");
     return;
   }
   int changes = sqlite3_changes (plugin->dbh);
-  GNUNET_SQ_reset (plugin->dbh,
-                   plugin->remove);
+  GNUNET_SQ_reset (plugin->dbh, plugin->remove);
   if (0 == changes)
   {
-    cont (cont_cls,
-          key,
-          size,
-          GNUNET_NO,
-          NULL);
+    cont (cont_cls, key, size, GNUNET_NO, NULL);
     return;
   }
   if (NULL != plugin->env->duc)
     plugin->env->duc (plugin->env->cls,
                       -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
-  cont (cont_cls,
-        key,
-        size,
-        GNUNET_OK,
-        NULL);
+  cont (cont_cls, key, size, GNUNET_OK, NULL);
 }
 
 
@@ -1306,8 +1226,7 @@ sqlite_plugin_remove_key (void *cls,
  * @return the size of the database on disk (estimate)
  */
 static void
-sqlite_plugin_estimate_size (void *cls,
-                             unsigned long long *estimate)
+sqlite_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
@@ -1322,45 +1241,35 @@ sqlite_plugin_estimate_size (void *cls,
     return;
   if (SQLITE_VERSION_NUMBER < 3006000)
   {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
-                     "datastore-sqlite",
-                     _("sqlite version to old to determine size, assuming zero\n"));
+    GNUNET_log_from (
+      GNUNET_ERROR_TYPE_WARNING,
+      "datastore-sqlite",
+      _ ("sqlite version to old to determine size, assuming zero\n"));
     *estimate = 0;
     return;
   }
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "VACUUM",
-                       NULL,
-                       NULL,
-                       ENULL));
-  CHECK (SQLITE_OK ==
-         sqlite3_exec (plugin->dbh,
-                       "PRAGMA auto_vacuum=INCREMENTAL",
-                       NULL,
-                       NULL, ENULL));
-  CHECK (SQLITE_OK ==
-         sq_prepare (plugin->dbh,
-                     "PRAGMA page_count",
-                     &stmt));
+  CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh, "VACUUM", NULL, NULL, ENULL));
+  CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh,
+                                    "PRAGMA auto_vacuum=INCREMENTAL",
+                                    NULL,
+                                    NULL,
+                                    ENULL));
+  CHECK (SQLITE_OK == sq_prepare (plugin->dbh, "PRAGMA page_count", &stmt));
   if (SQLITE_ROW == sqlite3_step (stmt))
-    pages = sqlite3_column_int64 (stmt,
-                                  0);
+    pages = sqlite3_column_int64 (stmt, 0);
   else
     pages = 0;
   sqlite3_finalize (stmt);
-  CHECK (SQLITE_OK ==
-         sq_prepare (plugin->dbh,
-                     "PRAGMA page_size",
-                     &stmt));
-  CHECK (SQLITE_ROW ==
-         sqlite3_step (stmt));
+  CHECK (SQLITE_OK == sq_prepare (plugin->dbh, "PRAGMA page_size", &stmt));
+  CHECK (SQLITE_ROW == sqlite3_step (stmt));
   page_size = sqlite3_column_int64 (stmt, 0);
   sqlite3_finalize (stmt);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Using sqlite page utilization to estimate payload (%llu pages of size %llu bytes)\n"),
-              (unsigned long long) pages,
-              (unsigned long long) page_size);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_INFO,
+    _ (
+      "Using sqlite page utilization to estimate payload (%llu pages of size %llu bytes)\n"),
+    (unsigned long long) pages,
+    (unsigned long long) page_size);
   *estimate = pages * page_size;
 }
 
@@ -1379,10 +1288,8 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
   struct GNUNET_DATASTORE_PluginFunctions *api;
 
   if (NULL != plugin.env)
-    return NULL;                /* can only initialize once! */
-  memset (&plugin,
-          0,
-          sizeof (struct Plugin));
+    return NULL; /* can only initialize once! */
+  memset (&plugin, 0, sizeof (struct Plugin));
   plugin.env = env;
   if (GNUNET_OK != database_setup (env->cfg, &plugin))
   {
@@ -1402,7 +1309,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
   api->remove_key = &sqlite_plugin_remove_key;
   GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
                    "sqlite",
-                   _("Sqlite database running\n"));
+                   _ ("Sqlite database running\n"));
   return api;
 }
 
@@ -1431,10 +1338,8 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
   GNUNET_free (api);
   if (NULL != fn)
   {
-    if (0 != UNLINK (fn))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                "unlink",
-                                fn);
+    if (0 != unlink (fn))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
     GNUNET_free (fn);
   }
   return NULL;
index daf6cccb35afda9ab0b2bf512692d0b0a40c0f2b..ee78a8cfce75e4b9f10c9ec66fe42069779a64a5 100644 (file)
@@ -251,11 +251,11 @@ check_value (void *cls,
     return;
   }
 #if 0
-  FPRINTF (stderr,
+  fprintf (stderr,
           "Check value got `%s' of size %u, type %d, expire %s\n",
            GNUNET_h2s (key), (unsigned int) size, type,
            GNUNET_STRINGS_absolute_time_to_string (expiration));
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Check value iteration %d wants size %u, type %d, expire %s\n", i,
            (unsigned int) get_size (i), get_type (i),
            GNUNET_STRINGS_absolute_time_to_string (get_expiration(i)));
@@ -555,14 +555,14 @@ run_tests (void *cls,
                               crc);
     return;
   case GNUNET_NO:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s", "Test 'put' operation failed, key already exists (!?)\n");
     GNUNET_DATASTORE_disconnect (datastore,
                                  GNUNET_YES);
     GNUNET_free (crc);
     return;
   case GNUNET_SYSERR:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Test 'put' operation failed with error `%s' database likely not setup, skipping test.\n",
              msg);
     GNUNET_DATASTORE_disconnect (datastore,
@@ -609,7 +609,7 @@ run (void *cls,
                             0, 1,
                             &run_tests, crc))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              "Test 'put' operation failed.\n");
     ok = 1;
index d91fe748baeb5f81c810675ba069ac12248308cc..fc4c03885e2c7e38a4339e4cdc58d9f97478ad0a 100644 (file)
@@ -272,7 +272,7 @@ run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, c
 
   if (success != GNUNET_YES)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Test 'put' operation failed with error `%s' database likely not setup, skipping test.\n",
              msg);
     GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
@@ -310,7 +310,7 @@ run (void *cls,
                             &run_tests,
                             crc))
   {
-    FPRINTF (stderr, "%s",  "Test 'put' operation failed.\n");
+    fprintf (stderr, "%s",  "Test 'put' operation failed.\n");
     GNUNET_free (crc);
     ok = 1;
   }
index c37b8ddb9f1959a5bc21876e27974ca0a37c8392..2b7bf9ae401fb455e550d7da9e5cb0c177a869e0 100644 (file)
@@ -108,7 +108,7 @@ put_continuation (void *cls,
 
   if (GNUNET_OK != status)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "ERROR: `%s'\n",
              msg);
   }
@@ -399,7 +399,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
   GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
   if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
   {
-    FPRINTF (stderr, "Failed to load plugin `%s'!\n", name);
+    fprintf (stderr, "Failed to load plugin `%s'!\n", name);
     GNUNET_free (libname);
     GNUNET_free (name);
     ok = 77; /* mark test as skipped */
@@ -421,7 +421,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   api = load_plugin (c);
   if (api == NULL)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n");
     return;
   }
@@ -461,7 +461,7 @@ main (int argc, char *argv[])
   GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
                       "test-plugin-datastore", "nohelp", options, &run, NULL);
   if ( (0 != ok) && (77 != ok) )
-    FPRINTF (stderr, "Missed some testcases: %u\n", ok);
+    fprintf (stderr, "Missed some testcases: %u\n", ok);
   GNUNET_DISK_directory_remove (dir_name);
   return ok;
 }
index b42326fc5b9aaf119758716c8cb17be40425cd92..af667584b24ab6ffe200cf224ae3b957e50a98ac 100644 (file)
@@ -26,7 +26,7 @@
 #include "platform.h"
 #include "gnunet_dht_service.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "dht-clients", __VA_ARGS__)
 /**
  * The type of the query
  */
@@ -45,7 +45,7 @@ static char *query_key;
 /**
  * User supplied timeout value
  */
-static struct GNUNET_TIME_Relative timeout_request = { 60000 };
+static struct GNUNET_TIME_Relative timeout_request = {60000};
 
 /**
  * Be verbose
@@ -143,8 +143,9 @@ timeout_task (void *cls)
  * @param data pointer to the result data
  */
 static void
-get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
-                     const struct GNUNET_HashCode * key,
+get_result_iterator (void *cls,
+                     struct GNUNET_TIME_Absolute exp,
+                     const struct GNUNET_HashCode *key,
                      const struct GNUNET_PeerIdentity *get_path,
                      unsigned int get_path_length,
                      const struct GNUNET_PeerIdentity *put_path,
@@ -153,32 +154,22 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
                      size_t size,
                      const void *data)
 {
-  FPRINTF (stdout,
-          (GNUNET_BLOCK_TYPE_TEST == type)
-           ? _("Result %d, type %d:\n%.*s\n")
-           : _("Result %d, type %d:\n"),
-          result_count,
+  fprintf (stdout,
+           (GNUNET_BLOCK_TYPE_TEST == type) ? _ ("Result %d, type %d:\n%.*s\n")
+                                            : _ ("Result %d, type %d:\n"),
+           result_count,
            type,
            (unsigned int) size,
            (char *) data);
   if (verbose)
   {
-    FPRINTF (stdout,
-             "  GET path: ");
-    for (unsigned int i=0;i<get_path_length;i++)
-      FPRINTF (stdout,
-               "%s%s",
-               (0 == i) ? "" : "-",
-               GNUNET_i2s (&get_path[i]));
-    FPRINTF (stdout,
-             "\n  PUT path: ");
-    for (unsigned int i=0;i<put_path_length;i++)
-      FPRINTF (stdout,
-               "%s%s",
-               (0 == i) ? "" : "-",
-               GNUNET_i2s (&put_path[i]));
-    FPRINTF (stdout,
-             "\n");
+    fprintf (stdout, "  GET path: ");
+    for (unsigned int i = 0; i < get_path_length; i++)
+      fprintf (stdout, "%s%s", (0 == i) ? "" : "-", GNUNET_i2s (&get_path[i]));
+    fprintf (stdout, "\n  PUT path: ");
+    for (unsigned int i = 0; i < put_path_length; i++)
+      fprintf (stdout, "%s%s", (0 == i) ? "" : "-", GNUNET_i2s (&put_path[i]));
+    fprintf (stdout, "\n");
   }
   result_count++;
 }
@@ -193,7 +184,9 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
  * @param c configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   struct GNUNET_HashCode key;
@@ -201,33 +194,37 @@ run (void *cls, char *const *args, const char *cfgfile,
   cfg = c;
   if (NULL == query_key)
   {
-    FPRINTF (stderr, "%s",  _("Must provide key for DHT GET!\n"));
+    fprintf (stderr, "%s", _ ("Must provide key for DHT GET!\n"));
     ret = 1;
     return;
   }
   if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1)))
   {
-    FPRINTF (stderr, "%s",  _("Failed to connect to DHT service!\n"));
+    fprintf (stderr, "%s", _ ("Failed to connect to DHT service!\n"));
     ret = 1;
     return;
   }
-  if (query_type == GNUNET_BLOCK_TYPE_ANY)      /* Type of data not set */
+  if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */
     query_type = GNUNET_BLOCK_TYPE_TEST;
   GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
   if (verbose)
-    FPRINTF (stderr, "%s `%s' \n",
-             _("Issuing DHT GET with key"),
+    fprintf (stderr,
+             "%s `%s' \n",
+             _ ("Issuing DHT GET with key"),
              GNUNET_h2s_full (&key));
   GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
-  tt = GNUNET_SCHEDULER_add_delayed (timeout_request,
-                                    &timeout_task,
+  tt = GNUNET_SCHEDULER_add_delayed (timeout_request, &timeout_task, NULL);
+  get_handle = GNUNET_DHT_get_start (dht_handle,
+                                     query_type,
+                                     &key,
+                                     replication,
+                                     (demultixplex_everywhere)
+                                       ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
+                                       : GNUNET_DHT_RO_NONE,
+                                     NULL,
+                                     0,
+                                     &get_result_iterator,
                                      NULL);
-  get_handle =
-      GNUNET_DHT_get_start (dht_handle, query_type, &key, replication,
-                            (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE,
-                            NULL, 0,
-                            &get_result_iterator,
-                            NULL);
 }
 
 
@@ -241,44 +238,52 @@ run (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_string ('k',
-                                 "key",
-                                 "KEY",
-                                 gettext_noop ("the query key"),
-                                 &query_key),
-    GNUNET_GETOPT_option_uint ('r',
-                               "replication",
-                               "LEVEL",
-                               gettext_noop ("how many parallel requests (replicas) to create"),
-                               &replication),
-    GNUNET_GETOPT_option_uint ('t',
-                               "type",
-                               "TYPE",
-                               gettext_noop ("the type of data to look for"),
-                               &query_type),
-    GNUNET_GETOPT_option_relative_time ('T',
-                                        "timeout",
-                                        "TIMEOUT",
-                                        gettext_noop ("how long to execute this query before giving up?"),
-                                        &timeout_request),
-    GNUNET_GETOPT_option_flag ('x',
-                               "demultiplex",
-                               gettext_noop ("use DHT's demultiplex everywhere option"),
-                               &demultixplex_everywhere),
-    GNUNET_GETOPT_option_verbose (&verbose),
-    GNUNET_GETOPT_OPTION_END
-  };
-
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_string ('k',
+                                  "key",
+                                  "KEY",
+                                  gettext_noop ("the query key"),
+                                  &query_key),
+     GNUNET_GETOPT_option_uint (
+       'r',
+       "replication",
+       "LEVEL",
+       gettext_noop ("how many parallel requests (replicas) to create"),
+       &replication),
+     GNUNET_GETOPT_option_uint ('t',
+                                "type",
+                                "TYPE",
+                                gettext_noop ("the type of data to look for"),
+                                &query_type),
+     GNUNET_GETOPT_option_relative_time (
+       'T',
+       "timeout",
+       "TIMEOUT",
+       gettext_noop ("how long to execute this query before giving up?"),
+       &timeout_request),
+     GNUNET_GETOPT_option_flag ('x',
+                                "demultiplex",
+                                gettext_noop (
+                                  "use DHT's demultiplex everywhere option"),
+                                &demultixplex_everywhere),
+     GNUNET_GETOPT_option_verbose (&verbose),
+     GNUNET_GETOPT_OPTION_END};
 
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   return (GNUNET_OK ==
-          GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get",
-                              gettext_noop
-                              ("Issue a GET request to the GNUnet DHT, prints results."),
-                              options, &run, NULL)) ? ret : 1;
+          GNUNET_PROGRAM_run (
+            argc,
+            argv,
+            "gnunet-dht-get",
+            gettext_noop (
+              "Issue a GET request to the GNUnet DHT, prints results."),
+            options,
+            &run,
+            NULL))
+           ? ret
+           : 1;
 }
 
 /* end of gnunet-dht-get.c */
index 52a57473b1f61ebc0029d6ce8bb537c161d71be1..3787b7cfab7ab0db217e08f40bc2b345f4a6bd38 100644 (file)
@@ -39,7 +39,7 @@ static char *query_key;
 /**
  * User supplied timeout value (in seconds)
  */
-static struct GNUNET_TIME_Relative timeout_request = { 60000 };
+static struct GNUNET_TIME_Relative timeout_request = {60000};
 
 /**
  * Be verbose
@@ -86,7 +86,7 @@ static void
 cleanup_task (void *cls)
 {
   if (verbose)
-    FPRINTF (stderr, "%s",  "Cleaning up!\n");
+    fprintf (stderr, "%s", "Cleaning up!\n");
   if (NULL != monitor_handle)
   {
     GNUNET_DHT_monitor_stop (monitor_handle);
@@ -118,7 +118,6 @@ timeout_task (void *cls)
 }
 
 
-
 /**
  * Callback called on each GET request going through the DHT.
  *
@@ -139,13 +138,13 @@ get_callback (void *cls,
               uint32_t desired_replication_level,
               unsigned int path_length,
               const struct GNUNET_PeerIdentity *path,
-              const struct GNUNET_HashCode * key)
+              const struct GNUNET_HashCode *key)
 {
-  FPRINTF (stdout,
+  fprintf (stdout,
            "GET #%u: type %d, key `%s'\n",
            result_count,
            (int) type,
-           GNUNET_h2s_full(key));
+           GNUNET_h2s_full (key));
   result_count++;
 }
 
@@ -172,14 +171,14 @@ get_resp_callback (void *cls,
                    const struct GNUNET_PeerIdentity *put_path,
                    unsigned int put_path_length,
                    struct GNUNET_TIME_Absolute exp,
-                   const struct GNUNET_HashCode * key,
+                   const struct GNUNET_HashCode *key,
                    const void *data,
                    size_t size)
 {
-  FPRINTF (stdout,
+  fprintf (stdout,
            (GNUNET_BLOCK_TYPE_TEST == type)
-          ? "RESPONSE #%u (%s): type %d, key `%s', data `%.*s'\n"
-           : "RESPONSE #%u (%s): type %d, key `%s'\n",
+             ? "RESPONSE #%u (%s): type %d, key `%s', data `%.*s'\n"
+             : "RESPONSE #%u (%s): type %d, key `%s'\n",
            result_count,
            GNUNET_STRINGS_absolute_time_to_string (exp),
            (int) type,
@@ -214,18 +213,18 @@ put_callback (void *cls,
               unsigned int path_length,
               const struct GNUNET_PeerIdentity *path,
               struct GNUNET_TIME_Absolute exp,
-              const struct GNUNET_HashCode * key,
+              const struct GNUNET_HashCode *key,
               const void *data,
               size_t size)
 {
-  FPRINTF (stdout,
+  fprintf (stdout,
            (GNUNET_BLOCK_TYPE_TEST == type)
-          ? "PUT %u (%s): type %d, key `%s', data `%.*s'\n"
-           : "PUT %u (%s): type %d, key `%s'\n",
+             ? "PUT %u (%s): type %d, key `%s', data `%.*s'\n"
+             : "PUT %u (%s): type %d, key `%s'\n",
            result_count,
            GNUNET_STRINGS_absolute_time_to_string (exp),
            (int) type,
-           GNUNET_h2s_full(key),
+           GNUNET_h2s_full (key),
            (unsigned int) size,
            (char *) data);
   result_count++;
@@ -253,33 +252,29 @@ run (void *cls,
 
   if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1)))
   {
-    FPRINTF (stderr, "%s",
-            _("Failed to connect to DHT service!\n"));
+    fprintf (stderr, "%s", _ ("Failed to connect to DHT service!\n"));
     ret = 1;
     return;
   }
-  if (GNUNET_BLOCK_TYPE_ANY == block_type)      /* Type of data not set */
+  if (GNUNET_BLOCK_TYPE_ANY == block_type) /* Type of data not set */
     block_type = GNUNET_BLOCK_TYPE_TEST;
   if (NULL != query_key)
-    {
-      key = &hc;
-      if (GNUNET_OK !=
-         GNUNET_CRYPTO_hash_from_string (query_key, key))
-       GNUNET_CRYPTO_hash (query_key, strlen (query_key), key);
-    }
+  {
+    key = &hc;
+    if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (query_key, key))
+      GNUNET_CRYPTO_hash (query_key, strlen (query_key), key);
+  }
   else
-    {
-      key = NULL;
-    }
+  {
+    key = NULL;
+  }
   if (verbose)
-    FPRINTF (stderr,
-            "Monitoring for %s\n",
-            GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO));
-  tt = GNUNET_SCHEDULER_add_delayed (timeout_request,
-                                    &timeout_task,
-                                    NULL);
-  GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
-                               NULL);
+    fprintf (stderr,
+             "Monitoring for %s\n",
+             GNUNET_STRINGS_relative_time_to_string (timeout_request,
+                                                     GNUNET_NO));
+  tt = GNUNET_SCHEDULER_add_delayed (timeout_request, &timeout_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
   monitor_handle = GNUNET_DHT_monitor_start (dht_handle,
                                              block_type,
                                              key,
@@ -308,34 +303,41 @@ main (int argc, char *const *argv)
                                  &query_key),
 
     GNUNET_GETOPT_option_uint ('t',
-                                   "type",
-                                   "TYPE",
-                                   gettext_noop ("the type of data to look for"),
-                                   &block_type),
-
-    GNUNET_GETOPT_option_relative_time ('T',
-                                            "timeout",
-                                            "TIMEOUT",
-                                            gettext_noop ("how long should the monitor command run"),
-                                            &timeout_request),
+                               "type",
+                               "TYPE",
+                               gettext_noop ("the type of data to look for"),
+                               &block_type),
+
+    GNUNET_GETOPT_option_relative_time (
+      'T',
+      "timeout",
+      "TIMEOUT",
+      gettext_noop ("how long should the monitor command run"),
+      &timeout_request),
 
     GNUNET_GETOPT_option_flag ('V',
-                                  "verbose",
-                                  gettext_noop ("be verbose (print progress information)"),
-                                  &verbose),
+                               "verbose",
+                               gettext_noop (
+                                 "be verbose (print progress information)"),
+                               &verbose),
 
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
 
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   return (GNUNET_OK ==
-          GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-monitor",
-                              gettext_noop
-                              ("Prints all packets that go through the DHT."),
-                              options, &run, NULL)) ? ret : 1;
+          GNUNET_PROGRAM_run (argc,
+                              argv,
+                              "gnunet-dht-monitor",
+                              gettext_noop (
+                                "Prints all packets that go through the DHT."),
+                              options,
+                              &run,
+                              NULL))
+           ? ret
+           : 1;
 }
 
 /* end of gnunet-dht-monitor.c */
index 4c26f98a5e3fd4a30b11a25fe88d8d3ca69405bd..0432dc4a01dc6b9db400458d33c1fb87240237f6 100644 (file)
@@ -107,8 +107,7 @@ shutdown_task (void *cls)
 static void
 message_sent_cont (void *cls)
 {
-  GNUNET_SCHEDULER_add_now (&shutdown_task,
-                            NULL);
+  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
 }
 
 
@@ -131,26 +130,25 @@ run (void *cls,
   cfg = c;
   if ((NULL == query_key) || (NULL == data))
   {
-    FPRINTF (stderr, "%s",  _("Must provide KEY and DATA for DHT put!\n"));
+    fprintf (stderr, "%s", _ ("Must provide KEY and DATA for DHT put!\n"));
     ret = 1;
     return;
   }
 
   if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1)))
   {
-    FPRINTF (stderr,
-             _("Could not connect to DHT service!\n"));
+    fprintf (stderr, _ ("Could not connect to DHT service!\n"));
     ret = 1;
     return;
   }
-  if (GNUNET_BLOCK_TYPE_ANY == query_type)      /* Type of data not set */
+  if (GNUNET_BLOCK_TYPE_ANY == query_type) /* Type of data not set */
     query_type = GNUNET_BLOCK_TYPE_TEST;
 
   GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
 
   if (verbose)
-    FPRINTF (stderr,
-             _("Issuing put request for `%s' with data `%s'!\n"),
+    fprintf (stderr,
+             _ ("Issuing put request for `%s' with data `%s'!\n"),
              query_key,
              data);
   ro = GNUNET_DHT_RO_NONE;
@@ -181,60 +179,62 @@ int
 main (int argc, char *const *argv)
 {
 
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_string ('d',
-                                 "data",
-                                 "DATA",
-                                 gettext_noop ("the data to insert under the key"),
-                                 &data),
-    GNUNET_GETOPT_option_relative_time ('e',
-                                        "expiration",
-                                        "EXPIRATION",
-                                        gettext_noop ("how long to store this entry in the dht (in seconds)"),
-                                        &expiration),
-    GNUNET_GETOPT_option_string ('k',
-                                 "key",
-                                 "KEY",
-                                 gettext_noop ("the query key"),
-                                 &query_key),
-    GNUNET_GETOPT_option_flag ('x',
-                               "demultiplex",
-                               gettext_noop ("use DHT's demultiplex everywhere option"),
-                               &demultixplex_everywhere),
-    GNUNET_GETOPT_option_uint ('r',
-                               "replication",
-                               "LEVEL",
-                               gettext_noop ("how many replicas to create"),
-                               &replication),
-    GNUNET_GETOPT_option_flag ('R',
-                               "record",
-                               gettext_noop ("use DHT's record route option"),
-                               &record_route),
-    GNUNET_GETOPT_option_uint ('t',
-                               "type",
-                               "TYPE",
-                               gettext_noop ("the type to insert data as"),
-                               &query_type),
-    GNUNET_GETOPT_option_verbose (&verbose),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                    &argc, &argv))
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_string ('d',
+                                  "data",
+                                  "DATA",
+                                  gettext_noop (
+                                    "the data to insert under the key"),
+                                  &data),
+     GNUNET_GETOPT_option_relative_time (
+       'e',
+       "expiration",
+       "EXPIRATION",
+       gettext_noop ("how long to store this entry in the dht (in seconds)"),
+       &expiration),
+     GNUNET_GETOPT_option_string ('k',
+                                  "key",
+                                  "KEY",
+                                  gettext_noop ("the query key"),
+                                  &query_key),
+     GNUNET_GETOPT_option_flag ('x',
+                                "demultiplex",
+                                gettext_noop (
+                                  "use DHT's demultiplex everywhere option"),
+                                &demultixplex_everywhere),
+     GNUNET_GETOPT_option_uint ('r',
+                                "replication",
+                                "LEVEL",
+                                gettext_noop ("how many replicas to create"),
+                                &replication),
+     GNUNET_GETOPT_option_flag ('R',
+                                "record",
+                                gettext_noop ("use DHT's record route option"),
+                                &record_route),
+     GNUNET_GETOPT_option_uint ('t',
+                                "type",
+                                "TYPE",
+                                gettext_noop ("the type to insert data as"),
+                                &query_type),
+     GNUNET_GETOPT_option_verbose (&verbose),
+     GNUNET_GETOPT_OPTION_END};
+
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   expiration = GNUNET_TIME_UNIT_HOURS;
   return (GNUNET_OK ==
-          GNUNET_PROGRAM_run (argc,
-                              argv,
-                              "gnunet-dht-put",
-                              gettext_noop
-                              ("Issue a PUT request to the GNUnet DHT insert DATA under KEY."),
-                              options,
-                              &run,
-                              NULL))
-    ? ret : 1;
+          GNUNET_PROGRAM_run (
+            argc,
+            argv,
+            "gnunet-dht-put",
+            gettext_noop (
+              "Issue a PUT request to the GNUnet DHT insert DATA under KEY."),
+            options,
+            &run,
+            NULL))
+           ? ret
+           : 1;
 }
 
 /* end of gnunet-dht-put.c */
index 38adbc2190a0ff5623316075cb208d00b4ab0dd1..7ec6758b7a03b85babd639ba79410b310cbd5cc9 100644 (file)
@@ -74,7 +74,7 @@ static void
 end_badly (void *cls)
 {
   die_task = NULL;
-  FPRINTF (stderr,
+  fprintf (stderr,
            "%s",
            "Ending on an unhappy note.\n");
   GNUNET_SCHEDULER_shutdown ();
index 2ff0e7a59b80367e7b367a26b9603199dbb225dc..a0d80e52cea13b666b2e461d69b9d4a1ebe940e6 100644 (file)
@@ -212,7 +212,7 @@ stats_finished (void *cls,
     return;
   }
   for (i = 0; NULL != stats[i].name; i++)
-    FPRINTF (stderr,
+    fprintf (stderr,
             "%6s/%60s = %12llu\n",
             stats[i].subsystem,
             stats[i].name,
index 0bf3b2ab16792975e0391a83bfd3ab33eee3ad01..a49f6d71af1c62e42a7fc7064ebc9bf4d5896000 100644 (file)
@@ -98,7 +98,7 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
   const char *buf;
 
 #if DETAILS
-  FPRINTF (stderr, "%s",  "M! ");        /* message complete, good! */
+  fprintf (stderr, "%s",  "M! ");        /* message complete, good! */
 #endif
   buf = (const char *) hdr;
   for (i = sizeof (struct GNUNET_MessageHeader); i < ntohs (hdr->size); i++)
@@ -106,7 +106,7 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
   total++;
 #if ! DETAILS
   if (0 == (total % (NUM_MSGS / 100)))
-    FPRINTF (stderr, "%s",  ".");
+    fprintf (stderr, "%s",  ".");
 #endif
   /* tolerate 10% loss, i.e. due to duplicate fragment IDs */
   if ((total >= NUM_MSGS - (NUM_MSGS / 10)) && (ret != 0))
@@ -131,27 +131,27 @@ proc_frac (void *cls, const struct GNUNET_MessageHeader *hdr)
   {
     frag_drops++;
 #if DETAILS
-    FPRINTF (stderr, "%s",  "DF ");    /* dropped Frag */
+    fprintf (stderr, "%s",  "DF ");    /* dropped Frag */
 #endif
     return;                     /* random drop */
   }
   if (NULL == defrag)
   {
-    FPRINTF (stderr, "%s",  "?E ");      /* Error: frag after shutdown!? */
+    fprintf (stderr, "%s",  "?E ");      /* Error: frag after shutdown!? */
     return;
   }
   ret = GNUNET_DEFRAGMENT_process_fragment (defrag, hdr);
   if (ret == GNUNET_NO)
   {
 #if DETAILS
-    FPRINTF (stderr, "%s",  "FF ");      /* duplicate fragment */
+    fprintf (stderr, "%s",  "FF ");      /* duplicate fragment */
 #endif
     dups++;
   }
   else if (ret == GNUNET_OK)
   {
 #if DETAILS
-    FPRINTF (stderr, "%s",  "F! ");      /* good fragment */
+    fprintf (stderr, "%s",  "F! ");      /* good fragment */
 #endif
     fragc++;
   }
@@ -181,7 +181,7 @@ next_transmission ()
   if (i == NUM_MSGS)
     return;
 #if DETAILS
-  FPRINTF (stderr, "%s",  "T! ");        /* sending message */
+  fprintf (stderr, "%s",  "T! ");        /* sending message */
 #endif
   msg = (struct GNUNET_MessageHeader *) buf;
   msg->type = htons ((uint16_t) i);
@@ -212,7 +212,7 @@ proc_acks (void *cls,
   {
     ack_drops++;
 #if DETAILS
-    FPRINTF (stderr, "%s",  "DA ");    /* dropped ACK */
+    fprintf (stderr, "%s",  "DA ");    /* dropped ACK */
 #endif
     return;                     /* random drop */
   }
@@ -224,7 +224,7 @@ proc_acks (void *cls,
     if (ret == GNUNET_OK)
     {
 #if DETAILS
-      FPRINTF (stderr, "%s",  "GA ");    /* good ACK */
+      fprintf (stderr, "%s",  "GA ");    /* good ACK */
 #endif
       next_transmission ();
       acks++;
@@ -233,14 +233,14 @@ proc_acks (void *cls,
     if (ret == GNUNET_NO)
     {
 #if DETAILS
-      FPRINTF (stderr, "%s",  "AA ");    /* duplciate ACK */
+      fprintf (stderr, "%s",  "AA ");    /* duplciate ACK */
 #endif
       acks++;
       return;
     }
   }
 #if DETAILS
-  FPRINTF (stderr, "%s",  "?A ");        /* BAD: ack that nobody feels responsible for... */
+  fprintf (stderr, "%s",  "?A ");        /* BAD: ack that nobody feels responsible for... */
 #endif
 }
 
@@ -293,7 +293,7 @@ main (int argc, char *argv[])
                       "test-fragmentation", "nohelp",
                       options,
                       &run, NULL);
-  FPRINTF (stderr,
+  fprintf (stderr,
            "\nHad %u good fragments, %u duplicate fragments, %u acks and %u simulated drops of acks\n",
            fragc,
            dups,
index 5cde75c0b2fb89285eac2e916e7376f509735aec..d8e598484faef65256310cb91943081b51977366 100644 (file)
@@ -90,7 +90,7 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
   const char *buf;
 
 #if DETAILS
-  FPRINTF (stderr, "%s",  "!");        /* message complete, good! */
+  fprintf (stderr, "%s",  "!");        /* message complete, good! */
 #endif
   buf = (const char *) hdr;
   for (i = sizeof (struct GNUNET_MessageHeader); i < ntohs (hdr->size); i++)
@@ -98,7 +98,7 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
   total++;
 #if ! DETAILS
   if (0 == (total % (NUM_MSGS / 100)))
-    FPRINTF (stderr, "%s",  ".");
+    fprintf (stderr, "%s",  ".");
 #endif
   /* tolerate 10% loss, i.e. due to duplicate fragment IDs */
   if ((total >= NUM_MSGS - (NUM_MSGS / 10)) && (ret != 0))
@@ -131,7 +131,7 @@ proc_acks (void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
     if (ret == GNUNET_OK)
     {
 #if DETAILS
-      FPRINTF (stderr, "%s",  "@");    /* good ACK */
+      fprintf (stderr, "%s",  "@");    /* good ACK */
 #endif
       GNUNET_FRAGMENT_context_destroy (frags[i], NULL, NULL);
       frags[i] = NULL;
@@ -141,14 +141,14 @@ proc_acks (void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
     if (ret == GNUNET_NO)
     {
 #if DETAILS
-      FPRINTF (stderr, "%s",  "@");    /* good ACK */
+      fprintf (stderr, "%s",  "@");    /* good ACK */
 #endif
       acks++;
       return;
     }
   }
 #if DETAILS
-  FPRINTF (stderr, "%s",  "_");        /* BAD: ack that nobody feels responsible for... */
+  fprintf (stderr, "%s",  "_");        /* BAD: ack that nobody feels responsible for... */
 #endif
 }
 
@@ -170,21 +170,21 @@ proc_frac (void *cls, const struct GNUNET_MessageHeader *hdr)
   }
   if (NULL == defrag)
   {
-    FPRINTF (stderr, "%s",  "E");      /* Error: frag after shutdown!? */
+    fprintf (stderr, "%s",  "E");      /* Error: frag after shutdown!? */
     return;
   }
   ret = GNUNET_DEFRAGMENT_process_fragment (defrag, hdr);
   if (ret == GNUNET_NO)
   {
 #if DETAILS
-    FPRINTF (stderr, "%s",  "?");      /* duplicate fragment */
+    fprintf (stderr, "%s",  "?");      /* duplicate fragment */
 #endif
     dups++;
   }
   else if (ret == GNUNET_OK)
   {
 #if DETAILS
-    FPRINTF (stderr, "%s",  ".");      /* good fragment */
+    fprintf (stderr, "%s",  ".");      /* good fragment */
 #endif
     fragc++;
   }
@@ -247,7 +247,7 @@ main (int argc, char *argv[])
                                    100);
   GNUNET_PROGRAM_run (5, argv_prog, "test-fragmentation", "nohelp", options,
                       &run, NULL);
-  FPRINTF (stderr,
+  fprintf (stderr,
            "\nHad %u good fragments, %u duplicate fragments, %u acks and %u simulated drops of acks\n",
            fragc, dups, acks, ack_drops);
   return ret;
index aec5ff3405b997eb02c11430ad5f341025c2aa40..f7b64a5c9d10ca11f3c37ef3e2f80a691d64a5e5 100644 (file)
@@ -56,12 +56,10 @@ start_job (struct GNUNET_FS_QueueEntry *qe)
   qe->h->active_downloads++;
   qe->start_time = GNUNET_TIME_absolute_get ();
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting job %p (%u active)\n",
-             qe,
-             qe->h->active_downloads);
-  GNUNET_CONTAINER_DLL_remove (qe->h->pending_head,
-                               qe->h->pending_tail,
-                               qe);
+              "Starting job %p (%u active)\n",
+              qe,
+              qe->h->active_downloads);
+  GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe);
   GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head,
                                      qe->h->running_tail,
                                      qe->h->running_tail,
@@ -83,17 +81,14 @@ stop_job (struct GNUNET_FS_QueueEntry *qe)
   GNUNET_assert (0 < qe->h->active_downloads);
   qe->h->active_downloads--;
   qe->h->active_blocks -= qe->blocks;
-  qe->run_time =
-      GNUNET_TIME_relative_add (qe->run_time,
-                                GNUNET_TIME_absolute_get_duration
-                                (qe->start_time));
+  qe->run_time = GNUNET_TIME_relative_add (qe->run_time,
+                                           GNUNET_TIME_absolute_get_duration (
+                                             qe->start_time));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Stopping job %p (%u active)\n",
-             qe,
-             qe->h->active_downloads);
-  GNUNET_CONTAINER_DLL_remove (qe->h->running_head,
-                               qe->h->running_tail,
-                               qe);
+              "Stopping job %p (%u active)\n",
+              qe,
+              qe->h->active_downloads);
+  GNUNET_CONTAINER_DLL_remove (qe->h->running_head, qe->h->running_tail, qe);
   GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head,
                                      qe->h->pending_tail,
                                      qe->h->pending_tail,
@@ -167,13 +162,13 @@ process_job_queue (void *cls)
       rst = GNUNET_TIME_absolute_get_remaining (end_time);
       if (0 == rst.rel_value_us)
       {
-       num_probes_expired++;
-       stop_job (qe);
+        num_probes_expired++;
+        stop_job (qe);
       }
       else
       {
-       num_probes_active++;
-       restart_at = GNUNET_TIME_relative_min (rst, restart_at);
+        num_probes_active++;
+        restart_at = GNUNET_TIME_relative_min (rst, restart_at);
       }
       break;
     case GNUNET_FS_QUEUE_PRIORITY_NORMAL:
@@ -184,13 +179,13 @@ process_job_queue (void *cls)
       rst = GNUNET_TIME_absolute_get_remaining (end_time);
       if (0 == rst.rel_value_us)
       {
-       num_downloads_expired++;
-       stop_job (qe);
+        num_downloads_expired++;
+        stop_job (qe);
       }
       else
       {
-       num_downloads_active++;
-       restart_at = GNUNET_TIME_relative_min (rst, restart_at);
+        num_downloads_active++;
+        restart_at = GNUNET_TIME_relative_min (rst, restart_at);
       }
       break;
     default:
@@ -201,41 +196,44 @@ process_job_queue (void *cls)
   GNUNET_break (h->active_downloads ==
                 num_downloads_active + num_probes_active);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "PA: %u, PE: %u, PW: %u; DA: %u, DE: %u, DW: %u\n",
-             num_probes_active,
-             num_probes_expired,
-             num_probes_waiting,
-             num_downloads_active,
-             num_downloads_expired,
-             num_downloads_waiting);
+              "PA: %u, PE: %u, PW: %u; DA: %u, DE: %u, DW: %u\n",
+              num_probes_active,
+              num_probes_expired,
+              num_probes_waiting,
+              num_downloads_active,
+              num_downloads_expired,
+              num_downloads_waiting);
   GNUNET_break (h->active_downloads + num_probes_active <=
                 h->max_parallel_downloads);
   /* calculate start/stop decisions */
   if (h->active_downloads + num_downloads_waiting > h->max_parallel_downloads)
   {
     /* stop as many probes as there are downloads and probes */
-    num_probes_change = - GNUNET_MIN (num_probes_active,
-                                      num_downloads_waiting);
+    num_probes_change = -GNUNET_MIN (num_probes_active, num_downloads_waiting);
     /* start as many downloads as there are free slots, including those
        we just opened up */
-    num_downloads_change = h->max_parallel_downloads - h->active_downloads - num_probes_change;
+    num_downloads_change =
+      h->max_parallel_downloads - h->active_downloads - num_probes_change;
   }
   else
   {
     /* start all downloads (we can) */
     num_downloads_change = num_downloads_waiting;
     /* also start probes if there is room, but use a lower cap of (mpd/4) + 1 */
-    if (1 + h->max_parallel_downloads / 4 >= (h->active_downloads + num_downloads_change))
-      num_probes_change = GNUNET_MIN (num_probes_waiting,
-                                      (1 + h->max_parallel_downloads / 4) - (h->active_downloads + num_downloads_change));
+    if (1 + h->max_parallel_downloads / 4 >=
+        (h->active_downloads + num_downloads_change))
+      num_probes_change =
+        GNUNET_MIN (num_probes_waiting,
+                    (1 + h->max_parallel_downloads / 4) -
+                      (h->active_downloads + num_downloads_change));
     else
       num_probes_change = 0;
   }
   GNUNET_break (num_downloads_change <= num_downloads_waiting);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Changing %d probes and %d/%u/%u downloads\n",
-             num_probes_change,
-             num_downloads_change,
+              "Changing %d probes and %d/%u/%u downloads\n",
+              num_probes_change,
+              num_downloads_change,
               (unsigned int) h->active_downloads,
               (unsigned int) h->max_parallel_downloads);
   /* actually stop probes */
@@ -250,7 +248,7 @@ process_job_queue (void *cls)
       stop_job (qe);
       num_probes_change++;
       if (0 == num_probes_change)
-       break;
+        break;
     }
   }
   GNUNET_break (0 <= num_probes_change);
@@ -258,9 +256,8 @@ process_job_queue (void *cls)
   /* start some more tasks if we now have empty slots */
   block_limit_hit = GNUNET_NO;
   next = h->pending_head;
-  while ( (NULL != (qe = next)) &&
-         ( (num_probes_change > 0) ||
-           (num_downloads_change > 0) ) )
+  while ((NULL != (qe = next)) &&
+         ((num_probes_change > 0) || (num_downloads_change > 0)))
   {
     next = qe->next;
     switch (qe->priority)
@@ -268,40 +265,40 @@ process_job_queue (void *cls)
     case GNUNET_FS_QUEUE_PRIORITY_PROBE:
       if (num_probes_change > 0)
       {
-       start_job (qe);
-       num_probes_change--;
-       run_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2);
-       restart_at = GNUNET_TIME_relative_min (run_time, restart_at);
+        start_job (qe);
+        num_probes_change--;
+        run_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2);
+        restart_at = GNUNET_TIME_relative_min (run_time, restart_at);
       }
       break;
     case GNUNET_FS_QUEUE_PRIORITY_NORMAL:
-      if ( (num_downloads_change > 0) &&
-          ( (qe->blocks + h->active_blocks <= h->max_parallel_requests) ||
-            ( (qe->blocks > h->max_parallel_requests) &&
-              (0 == h->active_downloads) ) ) )
+      if ((num_downloads_change > 0) &&
+          ((qe->blocks + h->active_blocks <= h->max_parallel_requests) ||
+           ((qe->blocks > h->max_parallel_requests) &&
+            (0 == h->active_downloads))))
       {
-       start_job (qe);
-       num_downloads_change--;
+        start_job (qe);
+        num_downloads_change--;
       }
       else if (num_downloads_change > 0)
-       block_limit_hit = GNUNET_YES;
+        block_limit_hit = GNUNET_YES;
       break;
     default:
       GNUNET_break (0);
       break;
     }
   }
-  GNUNET_break ( (0 == num_downloads_change) ||
-                 (GNUNET_YES == block_limit_hit) );
+  GNUNET_break ((0 == num_downloads_change) || (GNUNET_YES == block_limit_hit));
   GNUNET_break (0 == num_probes_change);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "AD: %u, MP: %u; %d probes and %d downloads to start, will run again in %s\n",
-             h->active_downloads,
-             h->max_parallel_requests,
-             num_probes_change,
-             num_downloads_change,
-             GNUNET_STRINGS_relative_time_to_string (restart_at, GNUNET_YES));
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "AD: %u, MP: %u; %d probes and %d downloads to start, will run again in %s\n",
+    h->active_downloads,
+    h->max_parallel_requests,
+    num_probes_change,
+    num_downloads_change,
+    GNUNET_STRINGS_relative_time_to_string (restart_at, GNUNET_YES));
 
   /* make sure we run again, callbacks might have
      already re-scheduled the job, so cancel such
@@ -309,7 +306,7 @@ process_job_queue (void *cls)
   if (NULL != h->queue_job)
     GNUNET_SCHEDULER_cancel (h->queue_job);
   h->queue_job =
-      GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h);
+    GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h);
 }
 
 
@@ -330,7 +327,7 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
                   GNUNET_SCHEDULER_TaskCallback stop,
                   void *cls,
                   unsigned int blocks,
-                 enum GNUNET_FS_QueuePriority priority)
+                  enum GNUNET_FS_QueuePriority priority)
 {
   struct GNUNET_FS_QueueEntry *qe;
 
@@ -342,14 +339,14 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
   qe->queue_time = GNUNET_TIME_absolute_get ();
   qe->blocks = blocks;
   qe->priority = priority;
-  GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail,
-                                     h->pending_tail, qe);
+  GNUNET_CONTAINER_DLL_insert_after (h->pending_head,
+                                     h->pending_tail,
+                                     h->pending_tail,
+                                     qe);
   if (NULL != h->queue_job)
     GNUNET_SCHEDULER_cancel (h->queue_job);
   h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Queueing job %p\n",
-             qe);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing job %p\n", qe);
   return qe;
 }
 
@@ -365,19 +362,14 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe)
   struct GNUNET_FS_Handle *h;
 
   h = qe->h;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Dequeueing job %p\n",
-             qe);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dequeueing job %p\n", qe);
   if (GNUNET_YES == qe->active)
     stop_job (qe);
-  GNUNET_CONTAINER_DLL_remove (h->pending_head,
-                               h->pending_tail,
-                               qe);
+  GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qe);
   GNUNET_free (qe);
   if (NULL != h->queue_job)
     GNUNET_SCHEDULER_cancel (h->queue_job);
-  h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue,
-                                           h);
+  h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h);
 }
 
 
@@ -399,9 +391,7 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h,
   ret = GNUNET_new (struct TopLevelActivity);
   ret->ssf = ssf;
   ret->ssf_cls = ssf_cls;
-  GNUNET_CONTAINER_DLL_insert (h->top_head,
-                               h->top_tail,
-                               ret);
+  GNUNET_CONTAINER_DLL_insert (h->top_head, h->top_tail, ret);
   return ret;
 }
 
@@ -413,12 +403,9 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h,
  * @param top top level activity entry
  */
 void
-GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
-                   struct TopLevelActivity *top)
+GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
 {
-  GNUNET_CONTAINER_DLL_remove (h->top_head,
-                               h->top_tail,
-                               top);
+  GNUNET_CONTAINER_DLL_remove (h->top_head, h->top_tail, top);
   GNUNET_free (top);
 }
 
@@ -489,33 +476,32 @@ GNUNET_FS_data_reader_file_ (void *cls,
   }
   if (NULL == fi->fd)
   {
-    fi->fd =
-        GNUNET_DISK_file_open (fi->filename,
-                               GNUNET_DISK_OPEN_READ,
-                               GNUNET_DISK_PERM_NONE);
+    fi->fd = GNUNET_DISK_file_open (fi->filename,
+                                    GNUNET_DISK_OPEN_READ,
+                                    GNUNET_DISK_PERM_NONE);
     if (NULL == fi->fd)
     {
       GNUNET_asprintf (emsg,
-                       _("Could not open file `%s': %s"),
+                       _ ("Could not open file `%s': %s"),
                        fi->filename,
-                       STRERROR (errno));
+                       strerror (errno));
       return 0;
     }
   }
-  if ( (GNUNET_SYSERR ==
-       GNUNET_DISK_file_seek (fi->fd, offset, GNUNET_DISK_SEEK_SET)) ||
-       (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))) )
+  if ((GNUNET_SYSERR ==
+       GNUNET_DISK_file_seek (fi->fd, offset, GNUNET_DISK_SEEK_SET)) ||
+      (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))))
   {
     GNUNET_asprintf (emsg,
-                     _("Could not read file `%s': %s"),
+                     _ ("Could not read file `%s': %s"),
                      fi->filename,
-                     STRERROR (errno));
+                     strerror (errno));
     return 0;
   }
   if (ret != max)
   {
     GNUNET_asprintf (emsg,
-                     _("Short read reading from file `%s'!"),
+                     _ ("Short read reading from file `%s'!"),
                      fi->filename);
     return 0;
   }
@@ -604,13 +590,20 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h,
   char *ret;
 
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
-    return NULL;                /* persistence not requested */
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR",
-                                               &basename))
+    return NULL; /* persistence not requested */
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (h->cfg,
+                                                            "fs",
+                                                            "STATE_DIR",
+                                                            &basename))
     return NULL;
-  GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s", basename, DIR_SEPARATOR_STR,
-                   h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR,
+  GNUNET_asprintf (&ret,
+                   "%s%s%s%s%s%s%s",
+                   basename,
+                   DIR_SEPARATOR_STR,
+                   h->client_name,
+                   DIR_SEPARATOR_STR,
+                   ext,
+                   DIR_SEPARATOR_STR,
                    ent);
   GNUNET_free (basename);
   return ret;
@@ -638,14 +631,23 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
   char *ret;
 
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
-    return NULL;                /* persistence not requested */
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR",
-                                               &basename))
+    return NULL; /* persistence not requested */
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (h->cfg,
+                                                            "fs",
+                                                            "STATE_DIR",
+                                                            &basename))
     return NULL;
-  GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s.dir%s%s", basename, DIR_SEPARATOR_STR,
-                   h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR,
-                   uni, DIR_SEPARATOR_STR, ent);
+  GNUNET_asprintf (&ret,
+                   "%s%s%s%s%s%s%s.dir%s%s",
+                   basename,
+                   DIR_SEPARATOR_STR,
+                   h->client_name,
+                   DIR_SEPARATOR_STR,
+                   ext,
+                   DIR_SEPARATOR_STR,
+                   uni,
+                   DIR_SEPARATOR_STR,
+                   ent);
   GNUNET_free (basename);
   return ret;
 }
@@ -660,9 +662,7 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
  * @return NULL on error
  */
 static struct GNUNET_BIO_ReadHandle *
-get_read_handle (struct GNUNET_FS_Handle *h,
-                 const char *ext,
-                 const char *ent)
+get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
 {
   char *fn;
   struct GNUNET_BIO_ReadHandle *ret;
@@ -685,9 +685,7 @@ get_read_handle (struct GNUNET_FS_Handle *h,
  * @return NULL on error
  */
 static struct GNUNET_BIO_WriteHandle *
-get_write_handle (struct GNUNET_FS_Handle *h,
-                  const char *ext,
-                  const char *ent)
+get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
 {
   char *fn;
   struct GNUNET_BIO_WriteHandle *ret;
@@ -712,8 +710,10 @@ get_write_handle (struct GNUNET_FS_Handle *h,
  * @return NULL on error
  */
 static struct GNUNET_BIO_WriteHandle *
-get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
-                         const char *uni, const char *ent)
+get_write_handle_in_dir (struct GNUNET_FS_Handle *h,
+                         const char *ext,
+                         const char *uni,
+                         const char *ent)
 {
   char *fn;
   struct GNUNET_BIO_WriteHandle *ret;
@@ -749,8 +749,7 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
   filename = get_serialization_file_name (h, ext, ent);
   if (NULL != filename)
   {
-    if ( (0 != UNLINK (filename)) &&
-         (ENOENT != errno) )
+    if ((0 != unlink (filename)) && (ENOENT != errno))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
     GNUNET_free (filename);
   }
@@ -768,7 +767,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
 static void
 remove_sync_file_in_dir (struct GNUNET_FS_Handle *h,
                          const char *ext,
-                         const char *uni, const char *ent)
+                         const char *uni,
+                         const char *ent)
 {
   char *filename;
 
@@ -780,7 +780,7 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h,
   filename = get_serialization_file_name_in_dir (h, ext, uni, ent);
   if (NULL == filename)
     return;
-  if (0 != UNLINK (filename))
+  if (0 != unlink (filename))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
   GNUNET_free (filename);
 }
@@ -874,8 +874,7 @@ read_start_time (struct GNUNET_BIO_ReadHandle *rh,
  * @return NULL on error
  */
 static struct GNUNET_FS_FileInformation *
-deserialize_file_information (struct GNUNET_FS_Handle *h,
-                              const char *filename);
+deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename);
 
 
 /**
@@ -915,21 +914,22 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
   filename = NULL;
   if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) ||
       (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) ||
-      ( (NULL != ksks) &&
-       ( (NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) ||
-         (GNUNET_YES != GNUNET_FS_uri_test_ksk (ret->keywords)) ) ) ||
+      ((NULL != ksks) &&
+       ((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) ||
+        (GNUNET_YES != GNUNET_FS_uri_test_ksk (ret->keywords)))) ||
       (GNUNET_OK != GNUNET_BIO_read_string (rh, "chk-uri", &chks, 1024)) ||
-      ( (NULL != chks) &&
-       ( (NULL == (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) ||
-         (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri))) ) ||
+      ((NULL != chks) &&
+       ((NULL == (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) ||
+        (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri)))) ||
       (GNUNET_OK != GNUNET_BIO_read_string (rh, "sks-uri", &skss, 1024)) ||
-      ( (NULL != skss) &&
-       ( (NULL == (ret->sks_uri = GNUNET_FS_uri_parse (skss, NULL))) ||
-         (GNUNET_YES != GNUNET_FS_uri_test_sks (ret->sks_uri))) ) ||
+      ((NULL != skss) &&
+       ((NULL == (ret->sks_uri = GNUNET_FS_uri_parse (skss, NULL))) ||
+        (GNUNET_YES != GNUNET_FS_uri_test_sks (ret->sks_uri)))) ||
       (GNUNET_OK != read_start_time (rh, &ret->start_time)) ||
-      (GNUNET_OK != GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024))
-      || (GNUNET_OK !=
-          GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024)) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) ||
       (GNUNET_OK !=
        GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value_us)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) ||
@@ -941,7 +941,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
   }
   switch (b)
   {
-  case 0:                      /* file-insert */
+  case 0: /* file-insert */
     if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size))
     {
       GNUNET_break (0);
@@ -957,12 +957,13 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
       {
         ret->data.file.reader = &GNUNET_FS_data_reader_copy_;
         ret->data.file.reader_cls =
-            GNUNET_malloc_large (ret->data.file.file_size);
+          GNUNET_malloc_large (ret->data.file.file_size);
         if (ret->data.file.reader_cls == NULL)
           goto cleanup;
-        if (GNUNET_OK !=
-            GNUNET_BIO_read (rh, "file-data", ret->data.file.reader_cls,
-                             ret->data.file.file_size))
+        if (GNUNET_OK != GNUNET_BIO_read (rh,
+                                          "file-data",
+                                          ret->data.file.reader_cls,
+                                          ret->data.file.file_size))
         {
           GNUNET_break (0);
           goto cleanup;
@@ -972,11 +973,11 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
       {
         ret->data.file.reader = &GNUNET_FS_data_reader_file_;
         ret->data.file.reader_cls =
-            GNUNET_FS_make_file_reader_context_ (ret->filename);
+          GNUNET_FS_make_file_reader_context_ (ret->filename);
       }
     }
     break;
-  case 1:                      /* file-index, no hash */
+  case 1: /* file-index, no hash */
     if (NULL == ret->filename)
     {
       GNUNET_break (0);
@@ -993,18 +994,19 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
     ret->data.file.index_start_confirmed = GNUNET_NO;
     ret->data.file.reader = &GNUNET_FS_data_reader_file_;
     ret->data.file.reader_cls =
-        GNUNET_FS_make_file_reader_context_ (ret->filename);
+      GNUNET_FS_make_file_reader_context_ (ret->filename);
     break;
-  case 2:                      /* file-index-with-hash */
+  case 2: /* file-index-with-hash */
     if (NULL == ret->filename)
     {
       GNUNET_break (0);
       goto cleanup;
     }
     if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
-        (GNUNET_OK !=
-         GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id,
-                          sizeof (struct GNUNET_HashCode))))
+        (GNUNET_OK != GNUNET_BIO_read (rh,
+                                       "fileid",
+                                       &ret->data.file.file_id,
+                                       sizeof (struct GNUNET_HashCode))))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -1015,18 +1017,19 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
     ret->data.file.index_start_confirmed = GNUNET_NO;
     ret->data.file.reader = &GNUNET_FS_data_reader_file_;
     ret->data.file.reader_cls =
-        GNUNET_FS_make_file_reader_context_ (ret->filename);
+      GNUNET_FS_make_file_reader_context_ (ret->filename);
     break;
-  case 3:                      /* file-index-with-hash-confirmed */
+  case 3: /* file-index-with-hash-confirmed */
     if (NULL == ret->filename)
     {
       GNUNET_break (0);
       goto cleanup;
     }
     if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
-        (GNUNET_OK !=
-         GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id,
-                          sizeof (struct GNUNET_HashCode))))
+        (GNUNET_OK != GNUNET_BIO_read (rh,
+                                       "fileid",
+                                       &ret->data.file.file_id,
+                                       sizeof (struct GNUNET_HashCode))))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -1037,13 +1040,15 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
     ret->data.file.index_start_confirmed = GNUNET_YES;
     ret->data.file.reader = &GNUNET_FS_data_reader_file_;
     ret->data.file.reader_cls =
-        GNUNET_FS_make_file_reader_context_ (ret->filename);
+      GNUNET_FS_make_file_reader_context_ (ret->filename);
     break;
-  case 4:                      /* directory */
+  case 4: /* directory */
     ret->is_directory = GNUNET_YES;
     if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dsize)) ||
-        (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_completed)) ||
-        (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_size)) ||
+        (GNUNET_OK !=
+         GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_completed)) ||
+        (GNUNET_OK !=
+         GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_size)) ||
         (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) ||
         (GNUNET_OK !=
          GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) ||
@@ -1108,8 +1113,7 @@ cleanup:
  * @return NULL on error
  */
 static struct GNUNET_FS_FileInformation *
-deserialize_file_information (struct GNUNET_FS_Handle *h,
-                             const char *filename)
+deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename)
 {
   struct GNUNET_FS_FileInformation *ret;
   struct GNUNET_BIO_ReadHandle *rh;
@@ -1123,17 +1127,19 @@ deserialize_file_information (struct GNUNET_FS_Handle *h,
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to resume publishing information `%s': %s\n"),
-                filename, emsg);
+                _ ("Failed to resume publishing information `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   if (NULL == ret)
   {
-    fn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename);
+    fn =
+      get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename);
     if (NULL != fn)
     {
-      if (0 != UNLINK (fn))
-       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+      if (0 != unlink (fn))
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
       GNUNET_free (fn);
     }
   }
@@ -1184,15 +1190,14 @@ get_serialization_short_name (const char *fullname)
  * @return NULL on errror
  */
 static char *
-make_serialization_file_name (struct GNUNET_FS_Handle *h,
-                              const char *ext)
+make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext)
 {
   char *fn;
   char *dn;
   char *ret;
 
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
-    return NULL;                /* persistence not requested */
+    return NULL; /* persistence not requested */
   dn = get_serialization_file_name (h, ext, "");
   if (NULL == dn)
     return NULL;
@@ -1204,7 +1209,7 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h,
   fn = GNUNET_DISK_mktemp (dn);
   GNUNET_free (dn);
   if (NULL == fn)
-    return NULL;                /* epic fail */
+    return NULL; /* epic fail */
   ret = get_serialization_short_name (fn);
   GNUNET_free (fn);
   return ret;
@@ -1230,7 +1235,7 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
   char *ret;
 
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
-    return NULL;                /* persistence not requested */
+    return NULL; /* persistence not requested */
   dn = get_serialization_file_name_in_dir (h, ext, uni, "");
   if (NULL == dn)
     return NULL;
@@ -1242,7 +1247,7 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
   fn = GNUNET_DISK_mktemp (dn);
   GNUNET_free (dn);
   if (NULL == fn)
-    return NULL;                /* epic fail */
+    return NULL; /* epic fail */
   ret = get_serialization_short_name (fn);
   GNUNET_free (fn);
   return ret;
@@ -1272,7 +1277,7 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh,
   {
     left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off);
     ret =
-        fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg);
+      fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg);
     if (0 == ret)
     {
       GNUNET_free (emsg);
@@ -1304,11 +1309,11 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
 
   if (NULL == fi->serialization)
     fi->serialization =
-        make_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO);
+      make_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO);
   if (NULL == fi->serialization)
     return;
-  wh = get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO,
-                         fi->serialization);
+  wh =
+    get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization);
   if (NULL == wh)
   {
     GNUNET_free (fi->serialization);
@@ -1363,7 +1368,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
 
   switch (b)
   {
-  case 0:                      /* file-insert */
+  case 0: /* file-insert */
     if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size))
     {
       GNUNET_break (0);
@@ -1376,7 +1381,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
         goto cleanup;
       }
     break;
-  case 1:                      /* file-index, no hash */
+  case 1: /* file-index, no hash */
     if (NULL == fi->filename)
     {
       GNUNET_break (0);
@@ -1388,37 +1393,39 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
       goto cleanup;
     }
     break;
-  case 2:                      /* file-index-with-hash */
-  case 3:                      /* file-index-with-hash-confirmed */
+  case 2: /* file-index-with-hash */
+  case 3: /* file-index-with-hash-confirmed */
     if (NULL == fi->filename)
     {
       GNUNET_break (0);
       goto cleanup;
     }
     if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) ||
-        (GNUNET_OK !=
-         GNUNET_BIO_write (wh, &fi->data.file.file_id,
-                           sizeof (struct GNUNET_HashCode))))
+        (GNUNET_OK != GNUNET_BIO_write (wh,
+                                        &fi->data.file.file_id,
+                                        sizeof (struct GNUNET_HashCode))))
     {
       GNUNET_break (0);
       goto cleanup;
     }
     break;
-  case 4:                      /* directory */
-    if ( (NULL != fi->data.dir.entries) &&
-        (NULL == fi->data.dir.entries->serialization) )
+  case 4: /* directory */
+    if ((NULL != fi->data.dir.entries) &&
+        (NULL == fi->data.dir.entries->serialization))
       GNUNET_FS_file_information_sync_ (fi->data.dir.entries);
     if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) ||
-        (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_completed)) ||
-        (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_size)) ||
         (GNUNET_OK !=
-         GNUNET_BIO_write (wh, fi->data.dir.dir_data,
-                           (uint32_t) fi->data.dir.dir_size)) ||
+         GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_completed)) ||
+        (GNUNET_OK !=
+         GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_size)) ||
+        (GNUNET_OK != GNUNET_BIO_write (wh,
+                                        fi->data.dir.dir_data,
+                                        (uint32_t) fi->data.dir.dir_size)) ||
         (GNUNET_OK !=
          GNUNET_BIO_write_string (wh,
-                                  (fi->data.dir.entries ==
-                                   NULL) ? NULL : fi->data.dir.
-                                  entries->serialization)))
+                                  (fi->data.dir.entries == NULL)
+                                    ? NULL
+                                    : fi->data.dir.entries->serialization)))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -1428,13 +1435,12 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
     GNUNET_assert (0);
     goto cleanup;
   }
-  if ( (NULL != fi->next) &&
-       (NULL == fi->next->serialization) )
+  if ((NULL != fi->next) && (NULL == fi->next->serialization))
     GNUNET_FS_file_information_sync_ (fi->next);
-  if (GNUNET_OK !=
-      GNUNET_BIO_write_string (wh,
-                               (fi->next !=
-                                NULL) ? fi->next->serialization : NULL))
+  if (GNUNET_OK != GNUNET_BIO_write_string (wh,
+                                            (fi->next != NULL)
+                                              ? fi->next->serialization
+                                              : NULL))
   {
     GNUNET_break (0);
     goto cleanup;
@@ -1445,18 +1451,19 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
     GNUNET_break (0);
     goto cleanup;
   }
-  return;                       /* done! */
+  return; /* done! */
 cleanup:
   if (NULL != wh)
     (void) GNUNET_BIO_write_close (wh);
   GNUNET_free_non_null (chks);
   GNUNET_free_non_null (ksks);
   GNUNET_free_non_null (skss);
-  fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO,
+  fn = get_serialization_file_name (fi->h,
+                                    GNUNET_FS_SYNC_PATH_FILE_INFO,
                                     fi->serialization);
   if (NULL != fn)
   {
-    if (0 != UNLINK (fn))
+    if (0 != unlink (fn))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
     GNUNET_free (fn);
   }
@@ -1465,7 +1472,6 @@ cleanup:
 }
 
 
-
 /**
  * Find the entry in the file information struct where the
  * serialization filename matches the given name.
@@ -1475,8 +1481,7 @@ cleanup:
  * @return NULL if srch was not found in this subtree
  */
 static struct GNUNET_FS_FileInformation *
-find_file_position (struct GNUNET_FS_FileInformation *pos,
-                   const char *srch)
+find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch)
 {
   struct GNUNET_FS_FileInformation *r;
 
@@ -1484,8 +1489,8 @@ find_file_position (struct GNUNET_FS_FileInformation *pos,
   {
     if (0 == strcmp (srch, pos->serialization))
       return pos;
-    if ( (GNUNET_YES == pos->is_directory) &&
-        (NULL != (r = find_file_position (pos->data.dir.entries, srch))) )
+    if ((GNUNET_YES == pos->is_directory) &&
+        (NULL != (r = find_file_position (pos->data.dir.entries, srch))))
       return r;
     pos = pos->next;
   }
@@ -1548,8 +1553,7 @@ fip_signal_resume (void *cls,
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
-deserialize_publish_file (void *cls,
-                          const char *filename)
+deserialize_publish_file (void *cls, const char *filename)
 {
   struct GNUNET_FS_Handle *h = cls;
   struct GNUNET_BIO_ReadHandle *rh;
@@ -1573,17 +1577,19 @@ deserialize_publish_file (void *cls,
     GNUNET_break (0);
     goto cleanup;
   }
-  if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024))
-      || (GNUNET_OK !=
-          GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) ||
+  if ((GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &all_done)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &have_ns)) ||
       (GNUNET_OK !=
        GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) ||
-      (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128))
-      || ( (GNUNET_YES == have_ns) &&
-          (GNUNET_OK != GNUNET_BIO_read (rh, "publish-ns", &ns, sizeof (ns)))) )
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) ||
+      ((GNUNET_YES == have_ns) &&
+       (GNUNET_OK != GNUNET_BIO_read (rh, "publish-ns", &ns, sizeof (ns)))))
   {
     GNUNET_break (0);
     goto cleanup;
@@ -1636,20 +1642,19 @@ deserialize_publish_file (void *cls,
   {
     GNUNET_assert (NULL == pc->upload_task);
     pc->upload_task =
-        GNUNET_SCHEDULER_add_with_priority
-        (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-        &GNUNET_FS_publish_main_, pc);
+      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+                                          &GNUNET_FS_publish_main_,
+                                          pc);
   }
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming publishing operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming publishing operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
-  pc->top = GNUNET_FS_make_top (h,
-                                &GNUNET_FS_publish_signal_suspend_,
-                                pc);
+  pc->top = GNUNET_FS_make_top (h, &GNUNET_FS_publish_signal_suspend_, pc);
   return GNUNET_OK;
 cleanup:
   GNUNET_free_non_null (pc->nid);
@@ -1659,13 +1664,14 @@ cleanup:
   if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to resume publishing operation `%s': %s\n"), filename,
+                _ ("Failed to resume publishing operation `%s': %s\n"),
+                filename,
                 emsg);
     GNUNET_free (emsg);
   }
   if (NULL != pc->fi)
     GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
-  if (0 != UNLINK (filename))
+  if (0 != unlink (filename))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
   GNUNET_free (pc->serialization);
   GNUNET_free (pc);
@@ -1689,8 +1695,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
 
   if (NULL == pc->serialization)
     pc->serialization =
-        make_serialization_file_name (pc->h,
-                                      GNUNET_FS_SYNC_PATH_MASTER_PUBLISH);
+      make_serialization_file_name (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH);
   if (NULL == pc->serialization)
     return;
   if (NULL == pc->fi)
@@ -1700,7 +1705,8 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
     GNUNET_break (0);
     return;
   }
-  wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
+  wh = get_write_handle (pc->h,
+                         GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
                          pc->serialization);
   if (NULL == wh)
   {
@@ -1714,13 +1720,15 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
       (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->all_done)) ||
       (GNUNET_OK != GNUNET_BIO_write_int32 (wh, have_ns)) ||
       (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) ||
-      (GNUNET_OK !=
-       GNUNET_BIO_write_string (wh,
-                                (NULL == pc->fi_pos) ? NULL : pc->fi_pos->serialization)) ||
-      ( (NULL != pc->ns) &&
-       (GNUNET_OK != GNUNET_BIO_write (wh,
-                                       pc->ns,
-                                       sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) ) ))
+      (GNUNET_OK != GNUNET_BIO_write_string (wh,
+                                             (NULL == pc->fi_pos)
+                                               ? NULL
+                                               : pc->fi_pos->serialization)) ||
+      ((NULL != pc->ns) &&
+       (GNUNET_OK !=
+        GNUNET_BIO_write (wh,
+                          pc->ns,
+                          sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))))
   {
     GNUNET_break (0);
     goto cleanup;
@@ -1735,7 +1743,8 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
 cleanup:
   if (NULL != wh)
     (void) GNUNET_BIO_write_close (wh);
-  GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
+  GNUNET_FS_remove_sync_file_ (pc->h,
+                               GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
                                pc->serialization);
   GNUNET_free (pc->serialization);
   pc->serialization = NULL;
@@ -1758,11 +1767,11 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
 
   if (NULL == uc->serialization)
     uc->serialization =
-        make_serialization_file_name (uc->h,
-                                      GNUNET_FS_SYNC_PATH_MASTER_UNINDEX);
+      make_serialization_file_name (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX);
   if (NULL == uc->serialization)
     return;
-  wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
+  wh = get_write_handle (uc->h,
+                         GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
                          uc->serialization);
   if (NULL == wh)
   {
@@ -1782,8 +1791,9 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
       (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
       (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->ksk_offset)) ||
       ((uc->state == UNINDEX_STATE_FS_NOTIFY) &&
-       (GNUNET_OK !=
-        GNUNET_BIO_write (wh, &uc->file_id, sizeof (struct GNUNET_HashCode)))) ||
+       (GNUNET_OK != GNUNET_BIO_write (wh,
+                                       &uc->file_id,
+                                       sizeof (struct GNUNET_HashCode)))) ||
       ((uc->state == UNINDEX_STATE_ERROR) &&
        (GNUNET_OK != GNUNET_BIO_write_string (wh, uc->emsg))))
   {
@@ -1800,7 +1810,8 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
 cleanup:
   if (NULL != wh)
     (void) GNUNET_BIO_write_close (wh);
-  GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
+  GNUNET_FS_remove_sync_file_ (uc->h,
+                               GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
                                uc->serialization);
   GNUNET_free (uc->serialization);
   uc->serialization = NULL;
@@ -1854,8 +1865,7 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh)
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) ||
       (dr->num_children > CHK_PER_INODE) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) ||
-      ( (0 == dr->depth) &&
-        (dr->num_children > 0) ) ||
+      ((0 == dr->depth) && (dr->num_children > 0)) ||
       ((dr->depth > 0) && (0 == dr->num_children)))
   {
     GNUNET_break (0);
@@ -1864,7 +1874,7 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh)
   }
   if (dr->num_children > 0)
     dr->children =
-        GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *));
+      GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *));
   switch (dr->state)
   {
   case BRS_INIT:
@@ -1917,9 +1927,9 @@ get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc,
 
   if (dc->parent == NULL)
     return get_serialization_file_name (dc->h,
-                                       (dc->search != NULL) ?
-                                       GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
-                                        GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
+                                        (dc->search != NULL)
+                                          ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
+                                          : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
                                         uni);
   if (NULL == dc->parent->serialization)
     return NULL;
@@ -2028,7 +2038,7 @@ cleanup:
   if (NULL != wh)
     (void) GNUNET_BIO_write_close (wh);
   GNUNET_free_non_null (uris);
-  if (0 != UNLINK (fn))
+  if (0 != unlink (fn))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
   GNUNET_free (fn);
   GNUNET_free (dc->serialization);
@@ -2055,19 +2065,19 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
   uris = NULL;
   if (NULL == sr->serialization)
     sr->serialization =
-        make_serialization_file_name_in_dir (sr->h,
-                                             (sr->sc->psearch_result ==
-                                              NULL) ?
-                                             GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
-                                             GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
-                                             sr->sc->serialization);
+      make_serialization_file_name_in_dir (sr->h,
+                                           (sr->sc->psearch_result == NULL)
+                                             ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                             : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                                           sr->sc->serialization);
   if (NULL == sr->serialization)
     return;
   wh = get_write_handle_in_dir (sr->h,
-                                (sr->sc->psearch_result ==
-                                 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
-                                GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
-                                sr->sc->serialization, sr->serialization);
+                                (sr->sc->psearch_result == NULL)
+                                  ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                  : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                                sr->sc->serialization,
+                                sr->serialization);
   if (NULL == wh)
   {
     GNUNET_break (0);
@@ -2075,28 +2085,31 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
   }
   uris = GNUNET_FS_uri_to_string (sr->uri);
   if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
+      (GNUNET_OK != GNUNET_BIO_write_string (wh,
+                                             sr->download != NULL
+                                               ? sr->download->serialization
+                                               : NULL)) ||
       (GNUNET_OK !=
        GNUNET_BIO_write_string (wh,
-                                sr->download !=
-                                NULL ? sr->download->serialization : NULL)) ||
+                                sr->update_search != NULL
+                                  ? sr->update_search->serialization
+                                  : NULL)) ||
+      (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, sr->meta)) ||
       (GNUNET_OK !=
-       GNUNET_BIO_write_string (wh,
-                                sr->update_search !=
-                                NULL ? sr->update_search->serialization : NULL))
-      || (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, sr->meta)) ||
-      (GNUNET_OK != GNUNET_BIO_write (wh, &sr->key, sizeof (struct GNUNET_HashCode)))
-      || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) ||
+       GNUNET_BIO_write (wh, &sr->key, sizeof (struct GNUNET_HashCode))) ||
+      (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) ||
       (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->optional_support)) ||
       (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->availability_success)) ||
-      (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->availability_trials)) )
+      (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->availability_trials)))
   {
     GNUNET_break (0);
     goto cleanup;
   }
-  if ( (NULL != sr->uri) &&
-       (GNUNET_FS_URI_KSK == sr->sc->uri->type) &&
-       (GNUNET_OK != GNUNET_BIO_write (wh, sr->keyword_bitmap,
-                                      (sr->sc->uri->data.ksk.keywordCount + 7) / 8)) )
+  if ((NULL != sr->uri) && (GNUNET_FS_URI_KSK == sr->sc->uri->type) &&
+      (GNUNET_OK !=
+       GNUNET_BIO_write (wh,
+                         sr->keyword_bitmap,
+                         (sr->sc->uri->data.ksk.keywordCount + 7) / 8)))
   {
     GNUNET_break (0);
     goto cleanup;
@@ -2115,9 +2128,10 @@ cleanup:
     (void) GNUNET_BIO_write_close (wh);
   remove_sync_file_in_dir (sr->h,
                            (NULL == sr->sc->psearch_result)
-                          ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
-                          : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
-                           sr->sc->serialization, sr->serialization);
+                             ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                             : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                           sr->sc->serialization,
+                           sr->serialization);
   GNUNET_free (sr->serialization);
   sr->serialization = NULL;
 }
@@ -2139,10 +2153,8 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc)
   char in_pause;
   const char *category;
 
-  category =
-      (NULL == sc->psearch_result)
-    ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
-    : GNUNET_FS_SYNC_PATH_CHILD_SEARCH;
+  category = (NULL == sc->psearch_result) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                          : GNUNET_FS_SYNC_PATH_CHILD_SEARCH;
   if (NULL == sc->serialization)
     sc->serialization = make_serialization_file_name (sc->h, category);
   if (NULL == sc->serialization)
@@ -2196,8 +2208,7 @@ cleanup:
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
-deserialize_unindex_file (void *cls,
-                          const char *filename)
+deserialize_unindex_file (void *cls, const char *filename)
 {
   struct GNUNET_FS_Handle *h = cls;
   struct GNUNET_BIO_ReadHandle *rh;
@@ -2222,9 +2233,11 @@ deserialize_unindex_file (void *cls,
       (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &uc->file_size)) ||
       (GNUNET_OK != read_start_time (rh, &uc->start_time)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &state)) ||
-      (GNUNET_OK != GNUNET_BIO_read (rh, "uri", &uc->chk, sizeof (struct ContentHashKey))) ||
-      (GNUNET_OK != GNUNET_BIO_read_string (rh, "unindex-kskuri", &uris, 10 * 1024)) ||
-      (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &uc->ksk_offset)) )
+      (GNUNET_OK !=
+       GNUNET_BIO_read (rh, "uri", &uc->chk, sizeof (struct ContentHashKey))) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "unindex-kskuri", &uris, 10 * 1024)) ||
+      (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &uc->ksk_offset)))
   {
     GNUNET_free_non_null (uris);
     GNUNET_break (0);
@@ -2241,9 +2254,9 @@ deserialize_unindex_file (void *cls,
       goto cleanup;
     }
   }
-  if ( (uc->ksk_offset > 0) &&
-       ( (NULL == uc->ksk_uri) ||
-        (uc->ksk_offset > uc->ksk_uri->data.ksk.keywordCount) ) )
+  if ((uc->ksk_offset > 0) &&
+      ((NULL == uc->ksk_uri) ||
+       (uc->ksk_offset > uc->ksk_uri->data.ksk.keywordCount)))
   {
     GNUNET_break (0);
     goto cleanup;
@@ -2254,9 +2267,10 @@ deserialize_unindex_file (void *cls,
   case UNINDEX_STATE_HASHING:
     break;
   case UNINDEX_STATE_FS_NOTIFY:
-    if (GNUNET_OK !=
-        GNUNET_BIO_read (rh, "unindex-hash", &uc->file_id,
-                         sizeof (struct GNUNET_HashCode)))
+    if (GNUNET_OK != GNUNET_BIO_read (rh,
+                                      "unindex-hash",
+                                      &uc->file_id,
+                                      sizeof (struct GNUNET_HashCode)))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -2280,21 +2294,22 @@ deserialize_unindex_file (void *cls,
     GNUNET_break (0);
     goto cleanup;
   }
-  uc->top = GNUNET_FS_make_top (h,
-                                &GNUNET_FS_unindex_signal_suspend_,
-                                uc);
+  uc->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, uc);
   pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME;
   pi.value.unindex.specifics.resume.message = uc->emsg;
-  GNUNET_FS_unindex_make_status_ (&pi, uc,
-                                  (uc->state ==
-                                   UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
+  GNUNET_FS_unindex_make_status_ (&pi,
+                                  uc,
+                                  (uc->state == UNINDEX_STATE_COMPLETE)
+                                    ? uc->file_size
+                                    : 0);
   switch (uc->state)
   {
   case UNINDEX_STATE_HASHING:
-    uc->fhc =
-        GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, uc->filename,
-                                 HASHING_BLOCKSIZE,
-                                 &GNUNET_FS_unindex_process_hash_, uc);
+    uc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                       uc->filename,
+                                       HASHING_BLOCKSIZE,
+                                       &GNUNET_FS_unindex_process_hash_,
+                                       uc);
     break;
   case UNINDEX_STATE_FS_NOTIFY:
     uc->state = UNINDEX_STATE_HASHING;
@@ -2319,8 +2334,9 @@ deserialize_unindex_file (void *cls,
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming unindexing operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming unindexing operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   return GNUNET_OK;
@@ -2329,13 +2345,14 @@ cleanup:
   if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to resume unindexing operation `%s': %s\n"),
+                _ ("Failed to resume unindexing operation `%s': %s\n"),
                 filename,
                 emsg);
     GNUNET_free (emsg);
   }
   if (NULL != uc->serialization)
-    GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
+    GNUNET_FS_remove_sync_file_ (h,
+                                 GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
                                  uc->serialization);
   GNUNET_free_non_null (uc->serialization);
   GNUNET_free (uc);
@@ -2384,8 +2401,7 @@ deserialize_search (struct GNUNET_FS_Handle *h,
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
-deserialize_search_result (void *cls,
-                           const char *filename)
+deserialize_search_result (void *cls, const char *filename)
 {
   struct GNUNET_FS_SearchContext *sc = cls;
   char *ser;
@@ -2405,9 +2421,10 @@ deserialize_search_result (void *cls,
     {
       remove_sync_file_in_dir (sc->h,
                                (NULL == sc->psearch_result)
-                              ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
-                              : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
-                               sc->serialization, ser);
+                                 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                               sc->serialization,
+                               ser);
       GNUNET_free (ser);
     }
     return GNUNET_OK;
@@ -2420,15 +2437,19 @@ deserialize_search_result (void *cls,
   sr->h = sc->h;
   sr->sc = sc;
   sr->serialization = ser;
-  if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024))
-      || (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
-      (GNUNET_OK != GNUNET_BIO_read_string (rh, "download-lnk", &download, 16))
-      || (GNUNET_OK !=
-          GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
-      (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) ||
+  if ((GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024)) ||
+      (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
       (GNUNET_OK !=
-       GNUNET_BIO_read (rh, "result-key", &sr->key, sizeof (struct GNUNET_HashCode)))
-      || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) ||
+       GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
+      (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) ||
+      (GNUNET_OK != GNUNET_BIO_read (rh,
+                                     "result-key",
+                                     &sr->key,
+                                     sizeof (struct GNUNET_HashCode))) ||
+      (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->optional_support)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->availability_success)) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->availability_trials)))
@@ -2438,10 +2459,13 @@ deserialize_search_result (void *cls,
   }
   if (GNUNET_FS_URI_KSK == sr->sc->uri->type)
   {
-    sr->keyword_bitmap = GNUNET_malloc ((sr->sc->uri->data.ksk.keywordCount + 7) / 8); /* round up, count bits */
-    if (GNUNET_OK != GNUNET_BIO_read (rh, "keyword-bitmap",
-                                     sr->keyword_bitmap,
-                                     (sr->sc->uri->data.ksk.keywordCount + 7) / 8))
+    sr->keyword_bitmap = GNUNET_malloc (
+      (sr->sc->uri->data.ksk.keywordCount + 7) / 8); /* round up, count bits */
+    if (GNUNET_OK !=
+        GNUNET_BIO_read (rh,
+                         "keyword-bitmap",
+                         sr->keyword_bitmap,
+                         (sr->sc->uri->data.ksk.keywordCount + 7) / 8))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -2457,7 +2481,7 @@ deserialize_search_result (void *cls,
       if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                    _("Failed to resume sub-download `%s': %s\n"),
+                    _ ("Failed to resume sub-download `%s': %s\n"),
                     download,
                     emsg);
         GNUNET_free (emsg);
@@ -2468,14 +2492,14 @@ deserialize_search_result (void *cls,
   if (NULL != update_srch)
   {
     drh =
-        get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch);
+      get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch);
     if (NULL != drh)
     {
       deserialize_search (sc->h, drh, sr, update_srch);
       if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                    _("Failed to resume sub-search `%s': %s\n"),
+                    _ ("Failed to resume sub-search `%s': %s\n"),
                     update_srch,
                     emsg);
         GNUNET_free (emsg);
@@ -2483,15 +2507,17 @@ deserialize_search_result (void *cls,
     }
     GNUNET_free (update_srch);
   }
-  GNUNET_break (GNUNET_YES ==
-               GNUNET_CONTAINER_multihashmap_put (sc->master_result_map,
-                                                   &sr->key, sr,
-                                                  GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+  GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (
+                                sc->master_result_map,
+                                &sr->key,
+                                sr,
+                                GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming search operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming search operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   return GNUNET_OK;
@@ -2509,8 +2535,9 @@ cleanup:
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming search operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming search operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   return GNUNET_OK;
@@ -2564,9 +2591,7 @@ signal_search_resume (struct GNUNET_FS_SearchContext *sc);
  * @return #GNUNET_YES (we should continue to iterate)
  */
 static int
-signal_result_resume (void *cls,
-                      const struct GNUNET_HashCode *key,
-                      void *value)
+signal_result_resume (void *cls, const struct GNUNET_HashCode *key, void *value)
 {
   struct GNUNET_FS_SearchContext *sc = cls;
   struct GNUNET_FS_ProgressInfo pi;
@@ -2579,11 +2604,11 @@ signal_result_resume (void *cls,
     pi.value.search.specifics.resume_result.uri = sr->uri;
     pi.value.search.specifics.resume_result.result = sr;
     pi.value.search.specifics.resume_result.availability_rank =
-        2 * sr->availability_success - sr->availability_trials;
+      2 * sr->availability_success - sr->availability_trials;
     pi.value.search.specifics.resume_result.availability_certainty =
-        sr->availability_trials;
+      sr->availability_trials;
     pi.value.search.specifics.resume_result.applicability_rank =
-        sr->optional_support;
+      sr->optional_support;
     sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
   }
   if (NULL != sr->download)
@@ -2618,9 +2643,7 @@ free_search_context (struct GNUNET_FS_SearchContext *sc);
  * @return #GNUNET_YES (we should continue to iterate)
  */
 static int
-free_result (void *cls,
-             const struct GNUNET_HashCode *key,
-             void *value)
+free_result (void *cls, const struct GNUNET_HashCode *key, void *value)
 {
   struct GNUNET_FS_SearchResult *sr = value;
 
@@ -2647,14 +2670,14 @@ free_search_context (struct GNUNET_FS_SearchContext *sc)
   if (NULL != sc->serialization)
   {
     GNUNET_FS_remove_sync_file_ (sc->h,
-                                 (sc->psearch_result ==
-                                  NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
-                                 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                                 (sc->psearch_result == NULL)
+                                   ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                   : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
                                  sc->serialization);
     GNUNET_FS_remove_sync_dir_ (sc->h,
-                                (sc->psearch_result ==
-                                 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
-                                GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                                (sc->psearch_result == NULL)
+                                  ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                  : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
                                 sc->serialization);
   }
   GNUNET_free_non_null (sc->serialization);
@@ -2663,7 +2686,8 @@ free_search_context (struct GNUNET_FS_SearchContext *sc)
     GNUNET_FS_uri_destroy (sc->uri);
   if (NULL != sc->master_result_map)
   {
-    GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, &free_result,
+    GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
+                                           &free_result,
                                            sc);
     GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
   }
@@ -2680,8 +2704,7 @@ free_search_context (struct GNUNET_FS_SearchContext *sc)
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
-deserialize_subdownload (void *cls,
-                         const char *filename)
+deserialize_subdownload (void *cls, const char *filename)
 {
   struct GNUNET_FS_DownloadContext *parent = cls;
   char *ser;
@@ -2693,7 +2716,8 @@ deserialize_subdownload (void *cls,
   if (NULL == rh)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to resume sub-download `%s': could not open file `%s'\n"),
+                _ (
+                  "Failed to resume sub-download `%s': could not open file `%s'\n"),
                 ser,
                 filename);
     GNUNET_free (ser);
@@ -2703,7 +2727,7 @@ deserialize_subdownload (void *cls,
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to resume sub-download `%s': %s\n"),
+                _ ("Failed to resume sub-download `%s': %s\n"),
                 ser,
                 emsg);
     GNUNET_free (emsg);
@@ -2735,9 +2759,7 @@ free_download_context (struct GNUNET_FS_DownloadContext *dc)
   GNUNET_free_non_null (dc->serialization);
   while (NULL != (dcc = dc->child_head))
   {
-    GNUNET_CONTAINER_DLL_remove (dc->child_head,
-                                 dc->child_tail,
-                                 dcc);
+    GNUNET_CONTAINER_DLL_remove (dc->child_head, dc->child_tail, dcc);
     free_download_context (dcc);
   }
   GNUNET_FS_free_download_request_ (dc->top_request);
@@ -2781,14 +2803,16 @@ deserialize_download (struct GNUNET_FS_Handle *h,
       (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
       ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) &&
        (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) ||
-      (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta))
-      || (GNUNET_OK !=
-          GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) ||
       (GNUNET_OK !=
-       GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) ||
+       GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta)) ||
+      (GNUNET_OK !=
+       GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) ||
       (GNUNET_OK !=
-       GNUNET_BIO_read_string (rh, "download-tfn", &dc->temp_filename,
-                               10 * 1024)) ||
+       GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) ||
+      (GNUNET_OK != GNUNET_BIO_read_string (rh,
+                                            "download-tfn",
+                                            &dc->temp_filename,
+                                            10 * 1024)) ||
       (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->old_file_size)) ||
       (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->offset)) ||
       (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->length)) ||
@@ -2803,14 +2827,14 @@ deserialize_download (struct GNUNET_FS_Handle *h,
   }
   dc->options = (enum GNUNET_FS_DownloadOptions) options;
   dc->active =
-    GNUNET_CONTAINER_multihashmap_create (1 + 2 * (dc->length / DBLOCK_SIZE), GNUNET_NO);
+    GNUNET_CONTAINER_multihashmap_create (1 + 2 * (dc->length / DBLOCK_SIZE),
+                                          GNUNET_NO);
   dc->has_finished = (int) status;
   dc->treedepth =
-      GNUNET_FS_compute_depth (GNUNET_FS_uri_chk_get_file_size (dc->uri));
+    GNUNET_FS_compute_depth (GNUNET_FS_uri_chk_get_file_size (dc->uri));
   if (GNUNET_FS_uri_test_loc (dc->uri))
     GNUNET_assert (GNUNET_OK ==
-                   GNUNET_FS_uri_loc_get_peer_identity (dc->uri,
-                                                        &dc->target));
+                   GNUNET_FS_uri_loc_get_peer_identity (dc->uri, &dc->target));
   if (NULL == dc->emsg)
   {
     dc->top_request = read_download_request (rh);
@@ -2820,43 +2844,31 @@ deserialize_download (struct GNUNET_FS_Handle *h,
       goto cleanup;
     }
   }
-  dn = get_download_sync_filename (dc,
-                                   dc->serialization,
-                                   ".dir");
+  dn = get_download_sync_filename (dc, dc->serialization, ".dir");
   if (NULL != dn)
   {
-    if (GNUNET_YES ==
-        GNUNET_DISK_directory_test (dn,
-                                    GNUNET_YES))
-      GNUNET_DISK_directory_scan (dn,
-                                  &deserialize_subdownload,
-                                  dc);
+    if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES))
+      GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc);
     GNUNET_free (dn);
   }
   if (NULL != parent)
   {
-    GNUNET_CONTAINER_DLL_insert (parent->child_head,
-                                 parent->child_tail,
-                                 dc);
+    GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc);
   }
   if (NULL != search)
   {
     dc->search = search;
     search->download = dc;
   }
-  if ( (NULL == parent) &&
-       (NULL == search) )
+  if ((NULL == parent) && (NULL == search))
   {
-    dc->top
-      = GNUNET_FS_make_top (dc->h,
-                            &GNUNET_FS_download_signal_suspend_,
-                            dc);
+    dc->top =
+      GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
     signal_download_resume (dc);
   }
   GNUNET_free (uris);
   GNUNET_assert (NULL == dc->job_queue);
-  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_,
-                                       dc);
+  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
   return;
 cleanup:
   GNUNET_free_non_null (uris);
@@ -2879,11 +2891,11 @@ signal_search_resume (struct GNUNET_FS_SearchContext *sc)
   pi.status = GNUNET_FS_STATUS_SEARCH_RESUME;
   pi.value.search.specifics.resume.message = sc->emsg;
   pi.value.search.specifics.resume.is_paused =
-      (NULL == sc->mq) ? GNUNET_YES : GNUNET_NO;
+    (NULL == sc->mq) ? GNUNET_YES : GNUNET_NO;
   sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
   GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
-                                         &signal_result_resume, sc);
-
+                                         &signal_result_resume,
+                                         sc);
 }
 
 
@@ -2942,10 +2954,11 @@ deserialize_search (struct GNUNET_FS_Handle *h,
   sc->options = (enum GNUNET_FS_SearchOptions) options;
   sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO);
   dn = get_serialization_file_name_in_dir (h,
-                                           (NULL == sc->psearch_result) ?
-                                           GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
-                                           GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
-                                           sc->serialization, "");
+                                           (NULL == sc->psearch_result)
+                                             ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
+                                             : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
+                                           sc->serialization,
+                                           "");
   if (NULL != dn)
   {
     if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES))
@@ -2955,8 +2968,9 @@ deserialize_search (struct GNUNET_FS_Handle *h,
   if (('\0' == in_pause) &&
       (GNUNET_OK != GNUNET_FS_search_start_searching_ (sc)))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Could not resume running search, will resume as paused search\n"));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ ("Could not resume running search, will resume as paused search\n"));
   }
   signal_search_resume (sc);
   GNUNET_free (uris);
@@ -2978,8 +2992,7 @@ cleanup:
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
-deserialize_search_file (void *cls,
-                         const char *filename)
+deserialize_search_file (void *cls, const char *filename)
 {
   struct GNUNET_FS_Handle *h = cls;
   char *ser;
@@ -2988,7 +3001,7 @@ deserialize_search_file (void *cls,
   struct GNUNET_FS_SearchContext *sc;
   struct stat buf;
 
-  if (0 != STAT (filename, &buf))
+  if (0 != stat (filename, &buf))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
     return GNUNET_OK;
@@ -3013,8 +3026,9 @@ deserialize_search_file (void *cls,
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming search operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming search operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   return GNUNET_OK;
@@ -3041,7 +3055,7 @@ deserialize_download_file (void *cls, const char *filename)
   rh = GNUNET_BIO_read_open (filename);
   if (NULL == rh)
   {
-    if (0 != UNLINK (filename))
+    if (0 != unlink (filename))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
     GNUNET_free (ser);
     return GNUNET_OK;
@@ -3051,8 +3065,9 @@ deserialize_download_file (void *cls, const char *filename)
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failure while resuming download operation `%s': %s\n"),
-                filename, emsg);
+                _ ("Failure while resuming download operation `%s': %s\n"),
+                filename,
+                emsg);
     GNUNET_free (emsg);
   }
   return GNUNET_OK;
@@ -3068,7 +3083,7 @@ deserialize_download_file (void *cls, const char *filename)
  */
 static void
 deserialization_master (const char *master_path,
-                       GNUNET_FileNameCallback proc,
+                        GNUNET_FileNameCallback proc,
                         struct GNUNET_FS_Handle *h)
 {
   char *dn;
@@ -3098,7 +3113,8 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
                  const char *client_name,
                  GNUNET_FS_ProgressCallback upcb,
                  void *upcb_cls,
-                 enum GNUNET_FS_Flags flags, ...)
+                 enum GNUNET_FS_Flags flags,
+                 ...)
 {
   struct GNUNET_FS_Handle *ret;
   enum GNUNET_FS_OPTIONS opt;
@@ -3112,9 +3128,11 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   ret->flags = flags;
   ret->max_parallel_downloads = DEFAULT_MAX_PARALLEL_DOWNLOADS;
   ret->max_parallel_requests = DEFAULT_MAX_PARALLEL_REQUESTS;
-  ret->avg_block_latency = GNUNET_TIME_UNIT_MINUTES;    /* conservative starting point */
+  ret->avg_block_latency =
+    GNUNET_TIME_UNIT_MINUTES; /* conservative starting point */
   va_start (ap, flags);
-  while (GNUNET_FS_OPTIONS_END != (opt = GNUNET_VA_ARG_ENUM (ap,GNUNET_FS_OPTIONS)))
+  while (GNUNET_FS_OPTIONS_END !=
+         (opt = GNUNET_VA_ARG_ENUM (ap, GNUNET_FS_OPTIONS)))
   {
     switch (opt)
     {
@@ -3138,13 +3156,17 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   if (0 != (GNUNET_FS_FLAGS_PERSISTENCE & flags))
   {
     deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
-                            &deserialize_publish_file, ret);
+                            &deserialize_publish_file,
+                            ret);
     deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
-                            &deserialize_search_file, ret);
+                            &deserialize_search_file,
+                            ret);
     deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
-                            &deserialize_download_file, ret);
+                            &deserialize_download_file,
+                            ret);
     deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
-                            &deserialize_unindex_file, ret);
+                            &deserialize_unindex_file,
+                            ret);
   }
   return ret;
 }
index 115f99391aa1c07f0ce7212ee0f25296b305a684..dd207e2c99f0009af3946b80065d60f751e1fc2c 100644 (file)
@@ -80,13 +80,12 @@ struct GNUNET_FS_DirScanner
   /**
    * Task scheduled when we are done.
    */
-  struct GNUNET_SCHEDULER_Task * stop_task;
+  struct GNUNET_SCHEDULER_Task *stop_task;
 
   /**
    * Arguments for helper.
    */
   char *args[4];
-
 };
 
 
@@ -151,11 +150,9 @@ advance (struct GNUNET_FS_ShareTreeItem *pos)
 
   GNUNET_assert (NULL != pos);
   moved = 0; /* must not terminate, even on file, otherwise "normal" */
-  while ( (pos->is_directory == GNUNET_YES) ||
-         (0 == moved) )
+  while ((pos->is_directory == GNUNET_YES) || (0 == moved))
   {
-    if ( (moved != -1) &&
-        (NULL != pos->children_head) )
+    if ((moved != -1) && (NULL != pos->children_head))
     {
       pos = pos->children_head;
       moved = 1; /* can terminate if file */
@@ -190,8 +187,8 @@ advance (struct GNUNET_FS_ShareTreeItem *pos)
  */
 static struct GNUNET_FS_ShareTreeItem *
 expand_tree (struct GNUNET_FS_ShareTreeItem *parent,
-            const char *filename,
-            int is_directory)
+             const char *filename,
+             int is_directory)
 {
   struct GNUNET_FS_ShareTreeItem *chld;
   size_t slen;
@@ -200,20 +197,19 @@ expand_tree (struct GNUNET_FS_ShareTreeItem *parent,
   chld->parent = parent;
   chld->filename = GNUNET_strdup (filename);
   GNUNET_asprintf (&chld->short_filename,
-                  "%s%s",
-                  GNUNET_STRINGS_get_short_name (filename),
-                  is_directory == GNUNET_YES ? "/" : "");
+                   "%s%s",
+                   GNUNET_STRINGS_get_short_name (filename),
+                   is_directory == GNUNET_YES ? "/" : "");
   /* make sure we do not end with '//' */
   slen = strlen (chld->short_filename);
-  if ( (slen >= 2) &&
-       (chld->short_filename[slen-1] == '/') &&
-       (chld->short_filename[slen-2] == '/') )
-    chld->short_filename[slen-1] = '\0';
+  if ((slen >= 2) && (chld->short_filename[slen - 1] == '/') &&
+      (chld->short_filename[slen - 2] == '/'))
+    chld->short_filename[slen - 1] = '\0';
   chld->is_directory = is_directory;
   if (NULL != parent)
     GNUNET_CONTAINER_DLL_insert (parent->children_head,
-                                parent->children_tail,
-                                chld);
+                                 parent->children_tail,
+                                 chld);
   return chld;
 }
 
@@ -235,8 +231,9 @@ finish_scan (void *cls)
     ds->helper = NULL;
   }
   ds->progress_callback (ds->progress_callback_cls,
-                        NULL, GNUNET_SYSERR,
-                        GNUNET_FS_DIRSCANNER_FINISHED);
+                         NULL,
+                         GNUNET_SYSERR,
+                         GNUNET_FS_DIRSCANNER_FINISHED);
 }
 
 
@@ -251,8 +248,7 @@ finish_scan (void *cls)
  *    #GNUNET_SYSERR to stop further processing with error
  */
 static int
-process_helper_msgs (void *cls,
-                    const struct GNUNET_MessageHeader *msg)
+process_helper_msgs (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct GNUNET_FS_DirScanner *ds = cls;
   const char *filename;
@@ -265,34 +261,31 @@ process_helper_msgs (void *cls,
           (unsigned int) ntohs (msg->type));
 #endif
   left = ntohs (msg->size) - sizeof (struct GNUNET_MessageHeader);
-  filename = (const char*) &msg[1];
+  filename = (const char *) &msg[1];
   switch (ntohs (msg->type))
   {
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE:
-    if (filename[left-1] != '\0')
+    if (filename[left - 1] != '\0')
     {
       GNUNET_break (0);
       break;
     }
     ds->progress_callback (ds->progress_callback_cls,
-                          filename, GNUNET_NO,
-                          GNUNET_FS_DIRSCANNER_FILE_START);
+                           filename,
+                           GNUNET_NO,
+                           GNUNET_FS_DIRSCANNER_FILE_START);
     if (NULL == ds->toplevel)
     {
-      ds->toplevel = expand_tree (ds->pos,
-                                 filename,
-                                 GNUNET_NO);
+      ds->toplevel = expand_tree (ds->pos, filename, GNUNET_NO);
     }
     else
     {
       GNUNET_assert (NULL != ds->pos);
-      (void) expand_tree (ds->pos,
-                         filename,
-                         GNUNET_NO);
+      (void) expand_tree (ds->pos, filename, GNUNET_NO);
     }
     return GNUNET_OK;
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY:
-    if (filename[left-1] != '\0')
+    if (filename[left - 1] != '\0')
     {
       GNUNET_break (0);
       break;
@@ -301,29 +294,29 @@ process_helper_msgs (void *cls,
     {
       if (NULL == ds->pos)
       {
-       GNUNET_break (0);
-       break;
+        GNUNET_break (0);
+        break;
       }
       ds->pos = ds->pos->parent;
       return GNUNET_OK;
     }
     ds->progress_callback (ds->progress_callback_cls,
-                          filename, GNUNET_YES,
-                          GNUNET_FS_DIRSCANNER_FILE_START);
-    ds->pos = expand_tree (ds->pos,
-                          filename,
-                          GNUNET_YES);
+                           filename,
+                           GNUNET_YES,
+                           GNUNET_FS_DIRSCANNER_FILE_START);
+    ds->pos = expand_tree (ds->pos, filename, GNUNET_YES);
     if (NULL == ds->toplevel)
       ds->toplevel = ds->pos;
     return GNUNET_OK;
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR:
     break;
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE:
-    if ('\0' != filename[left-1])
+    if ('\0' != filename[left - 1])
       break;
     ds->progress_callback (ds->progress_callback_cls,
-                          filename, GNUNET_SYSERR,
-                          GNUNET_FS_DIRSCANNER_FILE_IGNORED);
+                           filename,
+                           GNUNET_SYSERR,
+                           GNUNET_FS_DIRSCANNER_FILE_IGNORED);
     return GNUNET_OK;
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE:
     if (0 != left)
@@ -334,65 +327,66 @@ process_helper_msgs (void *cls,
     if (NULL == ds->toplevel)
       break;
     ds->progress_callback (ds->progress_callback_cls,
-                          NULL, GNUNET_SYSERR,
-                          GNUNET_FS_DIRSCANNER_ALL_COUNTED);
+                           NULL,
+                           GNUNET_SYSERR,
+                           GNUNET_FS_DIRSCANNER_ALL_COUNTED);
     ds->pos = ds->toplevel;
     if (GNUNET_YES == ds->pos->is_directory)
       ds->pos = advance (ds->pos);
     return GNUNET_OK;
-  case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA:
-    {
-      size_t nlen;
-      const char *end;
+  case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA: {
+    size_t nlen;
+    const char *end;
 
-      if (NULL == ds->pos)
-      {
-       GNUNET_break (0);
-       break;
-      }
-      end = memchr (filename, 0, left);
-      if (NULL == end)
-      {
-       GNUNET_break (0);
-       break;
-      }
-      end++;
-      nlen = end - filename;
-      left -= nlen;
-      if (0 != strcmp (filename,
-                      ds->pos->filename))
-      {
-       GNUNET_break (0);
-       break;
-      }
-      ds->progress_callback (ds->progress_callback_cls,
-                            filename,
-                            GNUNET_YES,
-                            GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
-      if (0 < left)
+    if (NULL == ds->pos)
+    {
+      GNUNET_break (0);
+      break;
+    }
+    end = memchr (filename, 0, left);
+    if (NULL == end)
+    {
+      GNUNET_break (0);
+      break;
+    }
+    end++;
+    nlen = end - filename;
+    left -= nlen;
+    if (0 != strcmp (filename, ds->pos->filename))
+    {
+      GNUNET_break (0);
+      break;
+    }
+    ds->progress_callback (ds->progress_callback_cls,
+                           filename,
+                           GNUNET_YES,
+                           GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
+    if (0 < left)
+    {
+      ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left);
+      if (NULL == ds->pos->meta)
       {
-       ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end,
-                                                               left);
-       if (NULL == ds->pos->meta)
-       {
-         GNUNET_break (0);
-         break;
-       }
-       /* having full filenames is too dangerous; always make sure we clean them up */
-       GNUNET_CONTAINER_meta_data_delete (ds->pos->meta,
-                                          EXTRACTOR_METATYPE_FILENAME,
-                                          NULL, 0);
-       /* instead, put in our 'safer' original filename */
-       GNUNET_CONTAINER_meta_data_insert (ds->pos->meta, "<libgnunetfs>",
-                                          EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
-                                          EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-                                          ds->pos->short_filename,
-                                          strlen (ds->pos->short_filename) + 1);
+        GNUNET_break (0);
+        break;
       }
-      ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (ds->pos->meta);
-      ds->pos = advance (ds->pos);
-      return GNUNET_OK;
+      /* having full filenames is too dangerous; always make sure we clean them up */
+      GNUNET_CONTAINER_meta_data_delete (ds->pos->meta,
+                                         EXTRACTOR_METATYPE_FILENAME,
+                                         NULL,
+                                         0);
+      /* instead, put in our 'safer' original filename */
+      GNUNET_CONTAINER_meta_data_insert (ds->pos->meta,
+                                         "<libgnunetfs>",
+                                         EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
+                                         EXTRACTOR_METAFORMAT_UTF8,
+                                         "text/plain",
+                                         ds->pos->short_filename,
+                                         strlen (ds->pos->short_filename) + 1);
     }
+    ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (ds->pos->meta);
+    ds->pos = advance (ds->pos);
+    return GNUNET_OK;
+  }
   case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED:
     if (NULL != ds->pos)
     {
@@ -406,16 +400,16 @@ process_helper_msgs (void *cls,
     }
     if (NULL == ds->toplevel)
       break;
-    ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan,
-                                             ds);
+    ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan, ds);
     return GNUNET_OK;
   default:
     GNUNET_break (0);
     break;
   }
   ds->progress_callback (ds->progress_callback_cls,
-                        NULL, GNUNET_SYSERR,
-                        GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
+                         NULL,
+                         GNUNET_SYSERR,
+                         GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
   return GNUNET_OK;
 }
 
@@ -434,8 +428,9 @@ helper_died_cb (void *cls)
   if (NULL != ds->stop_task)
     return; /* normal death, was finished */
   ds->progress_callback (ds->progress_callback_cls,
-                        NULL, GNUNET_SYSERR,
-                        GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
+                         NULL,
+                         GNUNET_SYSERR,
+                         GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
 }
 
 
@@ -452,22 +447,23 @@ helper_died_cb (void *cls)
  */
 struct GNUNET_FS_DirScanner *
 GNUNET_FS_directory_scan_start (const char *filename,
-                               int disable_extractor, const char *ex,
-                               GNUNET_FS_DirScannerProgressCallback cb,
-                               void *cb_cls)
+                                int disable_extractor,
+                                const char *ex,
+                                GNUNET_FS_DirScannerProgressCallback cb,
+                                void *cb_cls)
 {
   struct stat sbuf;
   char *filename_expanded;
   struct GNUNET_FS_DirScanner *ds;
 
-  if (0 != STAT (filename, &sbuf))
+  if (0 != stat (filename, &sbuf))
     return NULL;
   filename_expanded = GNUNET_STRINGS_filename_expand (filename);
   if (NULL == filename_expanded)
     return NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting to scan directory `%s'\n",
-             filename_expanded);
+              "Starting to scan directory `%s'\n",
+              filename_expanded);
   ds = GNUNET_new (struct GNUNET_FS_DirScanner);
   ds->progress_callback = cb;
   ds->progress_callback_cls = cb_cls;
@@ -481,12 +477,13 @@ GNUNET_FS_directory_scan_start (const char *filename,
   ds->args[2] = ds->ex_arg;
   ds->args[3] = NULL;
   ds->helper = GNUNET_HELPER_start (GNUNET_NO,
-                                   "gnunet-helper-fs-publish",
-                                   ds->args,
-                                   &process_helper_msgs,
-                                   &helper_died_cb, ds);
+                                    "gnunet-helper-fs-publish",
+                                    ds->args,
+                                    &process_helper_msgs,
+                                    &helper_died_cb,
+                                    ds);
   if (NULL == ds->helper)
-    {
+  {
     GNUNET_free (filename_expanded);
     GNUNET_free (ds);
     return NULL;
index 2d64bba1120c71da0a3a5bee40539ba14b7a6882..59821f8a5e7370b1d51c4881874c6371575fb383 100644 (file)
@@ -37,15 +37,13 @@ static int
 is_recursive_download (struct GNUNET_FS_DownloadContext *dc)
 {
   return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) &&
-      ( (GNUNET_YES ==
-        GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
-        ( (NULL == dc->meta) &&
-          ( (NULL == dc->filename) ||
-            ( (strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
-              (NULL !=
-               strstr (dc->filename + strlen (dc->filename) -
-                       strlen (GNUNET_FS_DIRECTORY_EXT),
-                       GNUNET_FS_DIRECTORY_EXT)) ) ) ) );
+         ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
+          ((NULL == dc->meta) &&
+           ((NULL == dc->filename) ||
+            ((strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
+             (NULL != strstr (dc->filename + strlen (dc->filename) -
+                                strlen (GNUNET_FS_DIRECTORY_EXT),
+                              GNUNET_FS_DIRECTORY_EXT))))));
 }
 
 
@@ -69,9 +67,9 @@ static uint64_t
 compute_disk_offset (uint64_t fsize, uint64_t off, unsigned int depth)
 {
   unsigned int i;
-  uint64_t lsize;               /* what is the size of all IBlocks for depth "i"? */
-  uint64_t loff;                /* where do IBlocks for depth "i" start? */
-  unsigned int ioff;            /* which IBlock corresponds to "off" at depth "i"? */
+  uint64_t lsize; /* what is the size of all IBlocks for depth "i"? */
+  uint64_t loff; /* where do IBlocks for depth "i" start? */
+  unsigned int ioff; /* which IBlock corresponds to "off" at depth "i"? */
 
   if (0 == depth)
     return off;
@@ -79,8 +77,7 @@ compute_disk_offset (uint64_t fsize, uint64_t off, unsigned int depth)
    * to full DBLOCK_SIZE */
   loff = ((fsize + DBLOCK_SIZE - 1) / DBLOCK_SIZE) * DBLOCK_SIZE;
   lsize =
-      ((fsize + DBLOCK_SIZE -
-        1) / DBLOCK_SIZE) * sizeof (struct ContentHashKey);
+    ((fsize + DBLOCK_SIZE - 1) / DBLOCK_SIZE) * sizeof (struct ContentHashKey);
   GNUNET_assert (0 == (off % DBLOCK_SIZE));
   ioff = (off / DBLOCK_SIZE);
   for (i = 1; i < depth; i++)
@@ -109,19 +106,19 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
   pi->value.download.dc = dc;
   pi->value.download.cctx = dc->client_info;
   pi->value.download.pctx =
-      (NULL == dc->parent) ? NULL : dc->parent->client_info;
+    (NULL == dc->parent) ? NULL : dc->parent->client_info;
   pi->value.download.sctx =
-      (NULL == dc->search) ? NULL : dc->search->client_info;
+    (NULL == dc->search) ? NULL : dc->search->client_info;
   pi->value.download.uri = dc->uri;
   pi->value.download.filename = dc->filename;
   pi->value.download.size = dc->length;
   /* FIXME: Fix duration calculation to account for pauses */
   pi->value.download.duration =
-      GNUNET_TIME_absolute_get_duration (dc->start_time);
+    GNUNET_TIME_absolute_get_duration (dc->start_time);
   pi->value.download.completed = dc->completed;
   pi->value.download.anonymity = dc->anonymity;
   pi->value.download.eta =
-      GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length);
+    GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length);
   pi->value.download.is_active = (NULL == dc->mq) ? GNUNET_NO : GNUNET_YES;
   pi->fsh = dc->h;
   if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
@@ -181,7 +178,6 @@ struct ProcessResultClosure
    * how often did we transmit the query?
    */
   uint32_t num_transmissions;
-
 };
 
 
@@ -196,7 +192,7 @@ struct ProcessResultClosure
  */
 static int
 process_result_with_request (void *cls,
-                             const struct GNUNET_HashCode * key,
+                             const struct GNUNET_HashCode *key,
                              void *value);
 
 
@@ -216,8 +212,10 @@ process_result_with_request (void *cls,
 static int
 encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
                         const struct ContentHashKey *chk,
-                        struct DownloadRequest *dr, const char *block,
-                        size_t len, int do_store)
+                        struct DownloadRequest *dr,
+                        const char *block,
+                        size_t len,
+                        int do_store)
 {
   struct ProcessResultClosure prc;
   char enc[len];
@@ -237,17 +235,18 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Matching %u byte block for `%s' at offset %llu already present, no need for download!\n",
-             (unsigned int) len,
-              dc->filename, (unsigned long long) dr->offset);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Matching %u byte block for `%s' at offset %llu already present, no need for download!\n",
+    (unsigned int) len,
+    dc->filename,
+    (unsigned long long) dr->offset);
   /* already got it! */
   prc.dc = dc;
   prc.data = enc;
   prc.size = len;
-  prc.type =
-      (0 ==
-       dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK;
+  prc.type = (0 == dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK
+                              : GNUNET_BLOCK_TYPE_FS_IBLOCK;
   prc.query = chk->query;
   prc.do_store = do_store;
   prc.last_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
@@ -306,8 +305,10 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
   size = (size_t) size64;
   if (size64 != (uint64_t) size)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_ERROR,
+      _ (
+        "Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
     return;
   }
   if (NULL != dc->filename)
@@ -324,15 +325,12 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
                                GNUNET_DISK_PERM_NONE);
   }
   if (NULL == h)
-    return;                     /* oops */
-  data = GNUNET_DISK_file_map (h,
-                               &m,
-                               GNUNET_DISK_MAP_TYPE_READ,
-                               size);
+    return; /* oops */
+  data = GNUNET_DISK_file_map (h, &m, GNUNET_DISK_MAP_TYPE_READ, size);
   if (NULL == data)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Directory too large for system address space\n"));
+                _ ("Directory too large for system address space\n"));
   }
   else
   {
@@ -343,16 +341,18 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
                                            &trigger_recursive_download,
                                            dc))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _("Failed to access full directroy contents of `%s' for recursive download\n"),
-                  dc->filename);
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_WARNING,
+        _ (
+          "Failed to access full directroy contents of `%s' for recursive download\n"),
+        dc->filename);
     }
     GNUNET_DISK_file_unmap (m);
   }
   GNUNET_DISK_file_close (h);
   if (NULL == dc->filename)
   {
-    if (0 != UNLINK (dc->temp_filename))
+    if (0 != unlink (dc->temp_filename))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                                 "unlink",
                                 dc->temp_filename);
@@ -384,12 +384,10 @@ check_completed (struct GNUNET_FS_DownloadContext *dc)
   /* then, check if children are done already */
   for (pos = dc->child_head; NULL != pos; pos = pos->next)
   {
-    if ( (NULL == pos->emsg) &&
-         (pos->completed < pos->length) )
-      return;                   /* not done yet */
-    if ( (NULL != pos->child_head) &&
-         (pos->has_finished != GNUNET_YES) )
-      return;                   /* not transitively done yet */
+    if ((NULL == pos->emsg) && (pos->completed < pos->length))
+      return; /* not done yet */
+    if ((NULL != pos->child_head) && (pos->has_finished != GNUNET_YES))
+      return; /* not transitively done yet */
   }
   /* All of our children are done, so mark this download done */
   dc->has_finished = GNUNET_YES;
@@ -432,7 +430,9 @@ check_completed (struct GNUNET_FS_DownloadContext *dc)
  */
 static void
 try_match_block (struct GNUNET_FS_DownloadContext *dc,
-                 struct DownloadRequest *dr, const char *data, size_t data_len)
+                 struct DownloadRequest *dr,
+                 const char *data,
+                 size_t data_len)
 {
   struct GNUNET_FS_ProgressInfo pi;
   unsigned int i;
@@ -455,8 +455,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
     return;
   if (dr->depth > 0)
   {
-    if ( (dc->offset > 0) ||
-         (dc->length < GNUNET_ntohll (dc->uri->data.chk.file_length)) )
+    if ((dc->offset > 0) ||
+        (dc->length < GNUNET_ntohll (dc->uri->data.chk.file_length)))
     {
       /* NOTE: this test is not tight, but should suffice; the issue
          here is that 'dr->num_children' may inherently only specify a
@@ -485,16 +485,13 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
   else
   {
     if (dr->offset > data_len)
-      return;                   /* oops */
+      return; /* oops */
     dlen = GNUNET_MIN (data_len - dr->offset, DBLOCK_SIZE);
   }
   GNUNET_CRYPTO_hash (&data[dr->offset], dlen, &in_chk.key);
   GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv);
-  if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset],
-                                             dlen,
-                                             &sk,
-                                             &iv,
-                                             enc))
+  if (-1 ==
+      GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset], dlen, &sk, &iv, enc))
   {
     GNUNET_break (0);
     return;
@@ -507,9 +504,7 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
     dr->state = BRS_RECONSTRUCT_META_UP;
     break;
   case BRS_CHK_SET:
-    if (0 != memcmp (&in_chk,
-                     &dr->chk,
-                     sizeof (struct ContentHashKey)))
+    if (0 != memcmp (&in_chk, &dr->chk, sizeof (struct ContentHashKey)))
     {
       /* other peer provided bogus meta data */
       GNUNET_break_op (0);
@@ -521,17 +516,17 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
     {
       fh = GNUNET_DISK_file_open (fn,
                                   GNUNET_DISK_OPEN_READWRITE |
-                                  GNUNET_DISK_OPEN_CREATE |
-                                  GNUNET_DISK_OPEN_TRUNCATE,
+                                    GNUNET_DISK_OPEN_CREATE |
+                                    GNUNET_DISK_OPEN_TRUNCATE,
                                   GNUNET_DISK_PERM_USER_READ |
-                                  GNUNET_DISK_PERM_USER_WRITE |
-                                  GNUNET_DISK_PERM_GROUP_READ |
-                                  GNUNET_DISK_PERM_OTHER_READ);
+                                    GNUNET_DISK_PERM_USER_WRITE |
+                                    GNUNET_DISK_PERM_GROUP_READ |
+                                    GNUNET_DISK_PERM_OTHER_READ);
       if (NULL == fh)
       {
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
         GNUNET_asprintf (&dc->emsg,
-                         _("Failed to open file `%s' for writing"),
+                         _ ("Failed to open file `%s' for writing"),
                          fn);
         GNUNET_DISK_file_close (fh);
         dr->state = BRS_ERROR;
@@ -543,7 +538,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
       if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len))
       {
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
-        GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
+        GNUNET_asprintf (&dc->emsg,
+                         _ ("Failed to open file `%s' for writing"),
                          fn);
         GNUNET_DISK_file_close (fh);
         dr->state = BRS_ERROR;
@@ -564,13 +560,14 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
     pi.value.download.specifics.progress.data_len = dlen;
     pi.value.download.specifics.progress.depth = 0;
     pi.value.download.specifics.progress.respect_offered = 0;
-    pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
+    pi.value.download.specifics.progress.block_download_duration =
+      GNUNET_TIME_UNIT_ZERO;
     GNUNET_FS_download_make_status_ (&pi, dc);
     if ((NULL != dc->filename) &&
-        (0 !=
-         TRUNCATE (dc->filename,
-                   GNUNET_ntohll (dc->uri->data.chk.file_length))))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
+        (0 != truncate (dc->filename,
+                        GNUNET_ntohll (dc->uri->data.chk.file_length))))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                "truncate",
                                 dc->filename);
     check_completed (dc);
     break;
@@ -601,25 +598,27 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
  * @return 0 to continue extracting, 1 to abort
  */
 static int
-match_full_data (void *cls, const char *plugin_name,
-                 enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
-                 const char *data_mime_type, const char *data, size_t data_len)
+match_full_data (void *cls,
+                 const char *plugin_name,
+                 enum EXTRACTOR_MetaType type,
+                 enum EXTRACTOR_MetaFormat format,
+                 const char *data_mime_type,
+                 const char *data,
+                 size_t data_len)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
 
   if (EXTRACTOR_METATYPE_GNUNET_FULL_DATA != type)
     return 0;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u bytes of FD!\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Found %u bytes of FD!\n",
               (unsigned int) data_len);
   if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len)
   {
     GNUNET_break_op (0);
-    return 1;                   /* bogus meta data */
+    return 1; /* bogus meta data */
   }
-  try_match_block (dc,
-                   dc->top_request,
-                   data,
-                   data_len);
+  try_match_block (dc, dc->top_request, data, data_len);
   return 1;
 }
 
@@ -644,8 +643,7 @@ propagate_up (struct DownloadRequest *dr)
     for (i = 0; i < dr->num_children; i++)
       if (dr->children[i]->state != BRS_DOWNLOAD_UP)
         break;
-  }
-  while (i == dr->num_children);
+  } while (i == dr->num_children);
 }
 
 
@@ -682,20 +680,20 @@ try_top_down_reconstruction (struct GNUNET_FS_DownloadContext *dc,
   GNUNET_assert (len <= DBLOCK_SIZE);
   off = compute_disk_offset (total, dr->offset, dr->depth);
   if (dc->old_file_size < off + len)
-    return;                     /* failure */
+    return; /* failure */
   if (off != GNUNET_DISK_file_seek (dc->rfh, off, GNUNET_DISK_SEEK_SET))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "seek", dc->filename);
-    return;                     /* failure */
+    return; /* failure */
   }
   if (len != GNUNET_DISK_file_read (dc->rfh, block, len))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", dc->filename);
-    return;                     /* failure */
+    return; /* failure */
   }
   GNUNET_CRYPTO_hash (block, len, &key);
   if (0 != memcmp (&key, &dr->chk.key, sizeof (struct GNUNET_HashCode)))
-    return;                     /* mismatch */
+    return; /* mismatch */
   if (GNUNET_OK !=
       encrypt_existing_match (dc, &dr->chk, dr, block, len, GNUNET_NO))
   {
@@ -728,10 +726,10 @@ try_top_down_reconstruction (struct GNUNET_FS_DownloadContext *dc,
       try_top_down_reconstruction (dc, drc);
     }
     if (BRS_DOWNLOAD_UP != drc->state)
-      up_done = GNUNET_NO;      /* children not all done */
+      up_done = GNUNET_NO; /* children not all done */
   }
   if (GNUNET_YES == up_done)
-    propagate_up (dr);          /* children all done (or no children...) */
+    propagate_up (dr); /* children all done (or no children...) */
 }
 
 
@@ -744,17 +742,14 @@ try_top_down_reconstruction (struct GNUNET_FS_DownloadContext *dc,
  * @return #GNUNET_OK
  */
 static int
-retry_entry (void *cls,
-             const struct GNUNET_HashCode *key,
-             void *entry)
+retry_entry (void *cls, const struct GNUNET_HashCode *key, void *entry)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
   struct DownloadRequest *dr = entry;
   struct SearchMessage *sm;
   struct GNUNET_MQ_Envelope *env;
 
-  env = GNUNET_MQ_msg (sm,
-                       GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
+  env = GNUNET_MQ_msg (sm, GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
   if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
     sm->options = htonl (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY);
   else
@@ -766,8 +761,7 @@ retry_entry (void *cls,
   sm->anonymity_level = htonl (dc->anonymity);
   sm->target = dc->target;
   sm->query = dr->chk.query;
-  GNUNET_MQ_send (dc->mq,
-                  env);
+  GNUNET_MQ_send (dc->mq, env);
   return GNUNET_OK;
 }
 
@@ -817,20 +811,17 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
               (unsigned long long) dr->offset,
               dr->depth,
               GNUNET_h2s (&dr->chk.query));
-  if (GNUNET_NO !=
-      GNUNET_CONTAINER_multihashmap_contains_value (dc->active,
-                                                    &dr->chk.query,
-                                                    dr))
-    return;                     /* already active */
+  if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains_value (dc->active,
+                                                                 &dr->chk.query,
+                                                                 dr))
+    return; /* already active */
   GNUNET_CONTAINER_multihashmap_put (dc->active,
                                      &dr->chk.query,
                                      dr,
                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   if (NULL == dc->mq)
-    return;                     /* download not active */
-  retry_entry (dc,
-               &dr->chk.query,
-               dr);
+    return; /* download not active */
+  retry_entry (dc, &dr->chk.query, dr);
 }
 
 
@@ -867,7 +858,7 @@ trigger_recursive_download (void *cls,
   char *sfn;
 
   if (NULL == uri)
-    return;                     /* entry for the directory itself */
+    return; /* entry for the directory itself */
   cpos = dc->child_head;
   while (NULL != cpos)
   {
@@ -877,7 +868,7 @@ trigger_recursive_download (void *cls,
     cpos = cpos->next;
   }
   if (NULL != cpos)
-    return;                     /* already exists */
+    return; /* already exists */
   fn = NULL;
   if (NULL == filename)
   {
@@ -892,7 +883,9 @@ trigger_recursive_download (void *cls,
     {
       ext = fn;
       us = GNUNET_FS_uri_to_string (uri);
-      GNUNET_asprintf (&fn, "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)],
+      GNUNET_asprintf (&fn,
+                       "%s%s",
+                       &us[strlen (GNUNET_FS_URI_CHK_PREFIX)],
                        ext);
       GNUNET_free (ext);
       GNUNET_free (us);
@@ -920,25 +913,28 @@ trigger_recursive_download (void *cls,
   else
   {
     dn = GNUNET_strdup (dc->filename);
-    GNUNET_break ((strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
-                  (NULL !=
-                   strstr (dn + strlen (dn) - strlen (GNUNET_FS_DIRECTORY_EXT),
-                           GNUNET_FS_DIRECTORY_EXT)));
+    GNUNET_break (
+      (strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
+      (NULL != strstr (dn + strlen (dn) - strlen (GNUNET_FS_DIRECTORY_EXT),
+                       GNUNET_FS_DIRECTORY_EXT)));
     sfn = GNUNET_strdup (filename);
     while ((strlen (sfn) > 0) && ('/' == filename[strlen (sfn) - 1]))
       sfn[strlen (sfn) - 1] = '\0';
     if ((strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
-        (NULL !=
-         strstr (dn + strlen (dn) - strlen (GNUNET_FS_DIRECTORY_EXT),
-                 GNUNET_FS_DIRECTORY_EXT)))
+        (NULL != strstr (dn + strlen (dn) - strlen (GNUNET_FS_DIRECTORY_EXT),
+                         GNUNET_FS_DIRECTORY_EXT)))
       dn[strlen (dn) - strlen (GNUNET_FS_DIRECTORY_EXT)] = '\0';
     if ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) &&
         ((strlen (filename) < strlen (GNUNET_FS_DIRECTORY_EXT)) ||
-         (NULL ==
-          strstr (filename + strlen (filename) -
-                  strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT))))
+         (NULL == strstr (filename + strlen (filename) -
+                            strlen (GNUNET_FS_DIRECTORY_EXT),
+                          GNUNET_FS_DIRECTORY_EXT))))
     {
-      GNUNET_asprintf (&full_name, "%s%s%s%s", dn, DIR_SEPARATOR_STR, sfn,
+      GNUNET_asprintf (&full_name,
+                       "%s%s%s%s",
+                       dn,
+                       DIR_SEPARATOR_STR,
+                       sfn,
                        GNUNET_FS_DIRECTORY_EXT);
     }
     else
@@ -952,8 +948,8 @@ trigger_recursive_download (void *cls,
       (GNUNET_OK != GNUNET_DISK_directory_create_for_file (full_name)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _
-                ("Failed to create directory for recursive download of `%s'\n"),
+                _ (
+                  "Failed to create directory for recursive download of `%s'\n"),
                 full_name);
     GNUNET_free (full_name);
     GNUNET_free_non_null (fn);
@@ -964,8 +960,8 @@ trigger_recursive_download (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Triggering recursive download of size %llu with %u bytes MD\n",
               (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
-              (unsigned int)
-              GNUNET_CONTAINER_meta_data_get_serialized_size (meta));
+              (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (
+                meta));
   GNUNET_FS_download_start (dc->h,
                             uri,
                             meta,
@@ -1029,26 +1025,29 @@ process_result_with_request (void *cls,
   int i;
   struct ContentHashKey *chkarr;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received %u byte block `%s' matching pending request at depth %u and offset %llu/%llu\n",
-             (unsigned int) prc->size,
-              GNUNET_h2s (key),
-              dr->depth,
-              (unsigned long long) dr->offset,
-              (unsigned long long) GNUNET_ntohll (dc->uri->data.
-                                                  chk.file_length));
-  bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll
-                                            (dc->uri->data.chk.file_length),
-                                            dr->offset, dr->depth);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Received %u byte block `%s' matching pending request at depth %u and offset %llu/%llu\n",
+    (unsigned int) prc->size,
+    GNUNET_h2s (key),
+    dr->depth,
+    (unsigned long long) dr->offset,
+    (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.file_length));
+  bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll (
+                                              dc->uri->data.chk.file_length),
+                                            dr->offset,
+                                            dr->depth);
   if (prc->size != bs)
   {
-    GNUNET_asprintf (&dc->emsg,
-                     _
-                     ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)"),
-                     bs, dr->depth, (unsigned long long) dr->offset,
-                     (unsigned long long) GNUNET_ntohll (dc->uri->data.
-                                                         chk.file_length),
-                     prc->size);
+    GNUNET_asprintf (
+      &dc->emsg,
+      _ (
+        "Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)"),
+      bs,
+      dr->depth,
+      (unsigned long long) dr->offset,
+      (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.file_length),
+      prc->size);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n", dc->emsg);
     while (NULL != dr->parent)
     {
@@ -1059,69 +1058,61 @@ process_result_with_request (void *cls,
     goto signal_error;
   }
 
-  (void) GNUNET_CONTAINER_multihashmap_remove (dc->active,
-                                               &prc->query,
-                                               dr);
-  GNUNET_CRYPTO_hash_to_aes_key (&dr->chk.key,
-                                 &skey,
-                                 &iv);
-  if (-1 == GNUNET_CRYPTO_symmetric_decrypt (prc->data,
-                                             prc->size,
-                                             &skey,
-                                             &iv,
-                                             pt))
+  (void) GNUNET_CONTAINER_multihashmap_remove (dc->active, &prc->query, dr);
+  GNUNET_CRYPTO_hash_to_aes_key (&dr->chk.key, &skey, &iv);
+  if (-1 ==
+      GNUNET_CRYPTO_symmetric_decrypt (prc->data, prc->size, &skey, &iv, pt))
   {
     GNUNET_break (0);
-    dc->emsg = GNUNET_strdup (_("internal error decrypting content"));
+    dc->emsg = GNUNET_strdup (_ ("internal error decrypting content"));
     goto signal_error;
   }
-  off =
-      compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length),
-                           dr->offset,
-                           dr->depth);
+  off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length),
+                             dr->offset,
+                             dr->depth);
   /* save to disk */
   if ((GNUNET_YES == prc->do_store) &&
       ((NULL != dc->filename) || (is_recursive_download (dc))) &&
       ((dr->depth == dc->treedepth) ||
        (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES))))
   {
-    fh = GNUNET_DISK_file_open (NULL != dc->filename
-                               ? dc->filename : dc->temp_filename,
+    fh = GNUNET_DISK_file_open (NULL != dc->filename ? dc->filename
+                                                     : dc->temp_filename,
                                 GNUNET_DISK_OPEN_READWRITE |
-                                GNUNET_DISK_OPEN_CREATE,
+                                  GNUNET_DISK_OPEN_CREATE,
                                 GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE |
-                                GNUNET_DISK_PERM_GROUP_READ |
-                                GNUNET_DISK_PERM_OTHER_READ);
+                                  GNUNET_DISK_PERM_USER_WRITE |
+                                  GNUNET_DISK_PERM_GROUP_READ |
+                                  GNUNET_DISK_PERM_OTHER_READ);
     if (NULL == fh)
     {
       GNUNET_asprintf (&dc->emsg,
-                       _("Download failed: could not open file `%s': %s"),
-                       dc->filename, STRERROR (errno));
+                       _ ("Download failed: could not open file `%s': %s"),
+                       dc->filename,
+                       strerror (errno));
       goto signal_error;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Saving decrypted block to disk at offset %llu\n",
                 (unsigned long long) off);
-    if ((off != GNUNET_DISK_file_seek (fh,
-                                       off,
-                                       GNUNET_DISK_SEEK_SET)))
+    if ((off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)))
     {
       GNUNET_asprintf (&dc->emsg,
-                       _("Failed to seek to offset %llu in file `%s': %s"),
+                       _ ("Failed to seek to offset %llu in file `%s': %s"),
                        (unsigned long long) off,
                        dc->filename,
-                       STRERROR (errno));
+                       strerror (errno));
       goto signal_error;
     }
     if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size))
     {
-      GNUNET_asprintf (&dc->emsg,
-                       _("Failed to write block of %u bytes at offset %llu in file `%s': %s"),
-                       (unsigned int) prc->size,
-                       (unsigned long long) off,
-                       dc->filename,
-                       STRERROR (errno));
+      GNUNET_asprintf (
+        &dc->emsg,
+        _ ("Failed to write block of %u bytes at offset %llu in file `%s': %s"),
+        (unsigned int) prc->size,
+        (unsigned long long) off,
+        dc->filename,
+        strerror (errno));
       goto signal_error;
     }
     GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
@@ -1153,8 +1144,11 @@ process_result_with_request (void *cls,
      * says it is a directory or if no meta data is given AND filename
      * ends in '.gnd' (top-level case) */
     if (is_recursive_download (dc))
-      GNUNET_FS_directory_list_contents (prc->size, pt, off,
-                                         &trigger_recursive_download, dc);
+      GNUNET_FS_directory_list_contents (prc->size,
+                                         pt,
+                                         off,
+                                         &trigger_recursive_download,
+                                         dc);
   }
   GNUNET_assert (dc->completed <= dc->length);
   dr->state = BRS_DOWNLOAD_DOWN;
@@ -1164,13 +1158,15 @@ process_result_with_request (void *cls,
   pi.value.download.specifics.progress.data_len = prc->size;
   pi.value.download.specifics.progress.depth = dr->depth;
   pi.value.download.specifics.progress.respect_offered = prc->respect_offered;
-  pi.value.download.specifics.progress.num_transmissions = prc->num_transmissions;
-  if (prc->last_transmission.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
-    pi.value.download.specifics.progress.block_download_duration
-      = GNUNET_TIME_absolute_get_duration (prc->last_transmission);
+  pi.value.download.specifics.progress.num_transmissions =
+    prc->num_transmissions;
+  if (prc->last_transmission.abs_value_us !=
+      GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
+    pi.value.download.specifics.progress.block_download_duration =
+      GNUNET_TIME_absolute_get_duration (prc->last_transmission);
   else
-    pi.value.download.specifics.progress.block_download_duration
-      GNUNET_TIME_UNIT_ZERO; /* found locally */
+    pi.value.download.specifics.progress.block_download_duration =
+      GNUNET_TIME_UNIT_ZERO; /* found locally */
   GNUNET_FS_download_make_status_ (&pi, dc);
   if (0 == dr->depth)
     propagate_up (dr);
@@ -1180,15 +1176,15 @@ process_result_with_request (void *cls,
     /* download completed, signal */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Download completed, truncating file to desired length %llu\n",
-                (unsigned long long) GNUNET_ntohll (dc->uri->data.
-                                                    chk.file_length));
+                (unsigned long long) GNUNET_ntohll (
+                  dc->uri->data.chk.file_length));
     /* truncate file to size (since we store IBlocks at the end) */
     if (NULL != dc->filename)
     {
-      if (0 !=
-          TRUNCATE (dc->filename,
-                    GNUNET_ntohll (dc->uri->data.chk.file_length)))
-        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
+      if (0 != truncate (dc->filename,
+                         GNUNET_ntohll (dc->uri->data.chk.file_length)))
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                  "truncate",
                                   dc->filename);
     }
     GNUNET_assert (0 == dr->depth);
@@ -1201,9 +1197,11 @@ process_result_with_request (void *cls,
     return GNUNET_YES;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Triggering downloads of children (this block was at depth %u and offset %llu)\n",
-              dr->depth, (unsigned long long) dr->offset);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Triggering downloads of children (this block was at depth %u and offset %llu)\n",
+    dr->depth,
+    (unsigned long long) dr->offset);
   GNUNET_assert (0 == (prc->size % sizeof (struct ContentHashKey)));
   chkarr = (struct ContentHashKey *) pt;
   for (i = dr->num_children - 1; i >= 0; i--)
@@ -1214,16 +1212,17 @@ process_result_with_request (void *cls,
     case BRS_INIT:
       if ((drc->chk_idx + 1) * sizeof (struct ContentHashKey) > prc->size)
       {
-       /* 'chkarr' does not have enough space for this chk_idx;
+        /* 'chkarr' does not have enough space for this chk_idx;
           internal error! */
-       GNUNET_break (0); GNUNET_assert (0);
-       dc->emsg = GNUNET_strdup (_("internal error decoding tree"));
-       goto signal_error;
+        GNUNET_break (0);
+        GNUNET_assert (0);
+        dc->emsg = GNUNET_strdup (_ ("internal error decoding tree"));
+        goto signal_error;
       }
       drc->chk = chkarr[drc->chk_idx];
       drc->state = BRS_CHK_SET;
       if (GNUNET_YES == dc->issue_requests)
-       schedule_block_download (dc, drc);
+        schedule_block_download (dc, drc);
       break;
     case BRS_RECONSTRUCT_DOWN:
       GNUNET_assert (0);
@@ -1282,8 +1281,7 @@ signal_error:
  * @param msg message received
  */
 static int
-check_put (void *cls,
-           const struct ClientPutMessage *cm)
+check_put (void *cls, const struct ClientPutMessage *cm)
 {
   /* any varsize length is OK */
   return GNUNET_OK;
@@ -1298,8 +1296,7 @@ check_put (void *cls,
  * @param msg message received
  */
 static void
-handle_put (void *cls,
-            const struct ClientPutMessage *cm)
+handle_put (void *cls, const struct ClientPutMessage *cm)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
   uint16_t msize = ntohs (cm->header.size) - sizeof (*cm);
@@ -1313,9 +1310,7 @@ handle_put (void *cls,
   prc.do_store = GNUNET_YES;
   prc.respect_offered = ntohl (cm->respect_offered);
   prc.num_transmissions = ntohl (cm->num_transmissions);
-  GNUNET_CRYPTO_hash (prc.data,
-                      msize,
-                      &prc.query);
+  GNUNET_CRYPTO_hash (prc.data, msize, &prc.query);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received result for query `%s' from FS service\n",
               GNUNET_h2s (&prc.query));
@@ -1335,8 +1330,7 @@ handle_put (void *cls,
  * @param error error code
  */
 static void
-download_mq_error_handler (void *cls,
-                           enum GNUNET_MQ_Error error)
+download_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
 
@@ -1360,13 +1354,12 @@ static void
 do_reconnect (void *cls)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
-  struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_var_size (put,
-                           GNUNET_MESSAGE_TYPE_FS_PUT,
-                           struct ClientPutMessage,
-                           dc),
-    GNUNET_MQ_handler_end ()
-  };
+  struct GNUNET_MQ_MessageHandler handlers[] =
+    {GNUNET_MQ_hd_var_size (put,
+                            GNUNET_MESSAGE_TYPE_FS_PUT,
+                            struct ClientPutMessage,
+                            dc),
+     GNUNET_MQ_handler_end ()};
 
   dc->task = NULL;
   dc->mq = GNUNET_CLIENT_connect (dc->h->cfg,
@@ -1377,13 +1370,12 @@ do_reconnect (void *cls)
   if (NULL == dc->mq)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Connecting to `%s'-service failed, will try again.\n", "FS");
+                "Connecting to `%s'-service failed, will try again.\n",
+                "FS");
     try_reconnect (dc);
     return;
   }
-  GNUNET_CONTAINER_multihashmap_iterate (dc->active,
-                                         &retry_entry,
-                                         dc);
+  GNUNET_CONTAINER_multihashmap_iterate (dc->active, &retry_entry, dc);
 }
 
 
@@ -1411,13 +1403,11 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Will try to reconnect in %s\n",
-             GNUNET_STRINGS_relative_time_to_string (dc->reconnect_backoff,
+              GNUNET_STRINGS_relative_time_to_string (dc->reconnect_backoff,
                                                       GNUNET_YES));
   GNUNET_break (NULL != dc->job_queue);
   dc->task =
-    GNUNET_SCHEDULER_add_delayed (dc->reconnect_backoff,
-                                 &do_reconnect,
-                                 dc);
+    GNUNET_SCHEDULER_add_delayed (dc->reconnect_backoff, &do_reconnect, dc);
 }
 
 
@@ -1437,11 +1427,9 @@ activate_fs_download (void *cls)
   GNUNET_assert (NULL != dc->active);
   do_reconnect (dc);
   if (NULL != dc->mq)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Download activated\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download activated\n");
   pi.status = GNUNET_FS_STATUS_DOWNLOAD_ACTIVE;
-  GNUNET_FS_download_make_status_ (&pi,
-                                   dc);
+  GNUNET_FS_download_make_status_ (&pi, dc);
 }
 
 
@@ -1456,16 +1444,14 @@ deactivate_fs_download (void *cls)
   struct GNUNET_FS_DownloadContext *dc = cls;
   struct GNUNET_FS_ProgressInfo pi;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Download deactivated\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download deactivated\n");
   if (NULL != dc->mq)
   {
     GNUNET_MQ_destroy (dc->mq);
     dc->mq = NULL;
   }
   pi.status = GNUNET_FS_STATUS_DOWNLOAD_INACTIVE;
-  GNUNET_FS_download_make_status_ (&pi,
-                                   dc);
+  GNUNET_FS_download_make_status_ (&pi, dc);
 }
 
 
@@ -1490,8 +1476,8 @@ deactivate_fs_download (void *cls)
  */
 static struct DownloadRequest *
 create_download_request (struct DownloadRequest *parent,
-                        unsigned int chk_idx,
-                        unsigned int depth,
+                         unsigned int chk_idx,
+                         unsigned int depth,
                          uint64_t dr_offset,
                          uint64_t file_start_offset,
                          uint64_t desired_length)
@@ -1523,36 +1509,35 @@ create_download_request (struct DownloadRequest *parent,
   }
 
   /* calculate index of last block at this level that is interesting (rounded up) */
-  dr->num_children = (file_start_offset + desired_length - dr_offset) / child_block_size;
+  dr->num_children =
+    (file_start_offset + desired_length - dr_offset) / child_block_size;
   if (dr->num_children * child_block_size <
       file_start_offset + desired_length - dr_offset)
-    dr->num_children++;       /* round up */
+    dr->num_children++; /* round up */
   GNUNET_assert (dr->num_children > head_skip);
   dr->num_children -= head_skip;
   if (dr->num_children > CHK_PER_INODE)
     dr->num_children = CHK_PER_INODE; /* cap at max */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Block at offset %llu and depth %u has %u children\n",
-             (unsigned long long) dr_offset,
-             depth,
-             dr->num_children);
+              "Block at offset %llu and depth %u has %u children\n",
+              (unsigned long long) dr_offset,
+              depth,
+              dr->num_children);
 
   /* now we can get the total number of *interesting* children for this block */
 
   /* why else would we have gotten here to begin with? (that'd be a bad logic error) */
   GNUNET_assert (dr->num_children > 0);
 
-  dr->children =
-    GNUNET_new_array (dr->num_children,
-                      struct DownloadRequest *);
+  dr->children = GNUNET_new_array (dr->num_children, struct DownloadRequest *);
   for (i = 0; i < dr->num_children; i++)
   {
     dr->children[i] =
       create_download_request (dr,
                                i + head_skip,
                                depth - 1,
-                              dr_offset + (i + head_skip) * child_block_size,
-                              file_start_offset,
+                               dr_offset + (i + head_skip) * child_block_size,
+                               file_start_offset,
                                desired_length);
   }
   return dr;
@@ -1583,8 +1568,7 @@ reconstruct_cont (void *cls)
   }
   /* start "normal" download */
   dc->issue_requests = GNUNET_YES;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting normal download\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting normal download\n");
   schedule_block_download (dc, dc->top_request);
 }
 
@@ -1646,29 +1630,29 @@ reconstruct_cb (void *cls,
     if (chld < dr->children[0]->chk_idx)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Block %u < %u irrelevant for our range\n",
-                 chld,
-                 dr->children[0]->chk_idx);
-      dc->task = GNUNET_SCHEDULER_add_now (&get_next_block,
-                                           dc);
+                  "Block %u < %u irrelevant for our range\n",
+                  chld,
+                  dr->children[0]->chk_idx);
+      dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
       return; /* irrelevant block */
     }
-    if (chld > dr->children[dr->num_children-1]->chk_idx)
+    if (chld > dr->children[dr->num_children - 1]->chk_idx)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Block %u > %u irrelevant for our range\n",
-                 chld,
-                 dr->children[dr->num_children-1]->chk_idx);
+                  "Block %u > %u irrelevant for our range\n",
+                  chld,
+                  dr->children[dr->num_children - 1]->chk_idx);
       dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
       return; /* irrelevant block */
     }
     dr = dr->children[chld - dr->children[0]->chk_idx];
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Matched TE block with request at offset %llu and depth %u in state %d\n",
-             (unsigned long long) dr->offset,
-             dr->depth,
-             dr->state);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Matched TE block with request at offset %llu and depth %u in state %d\n",
+    (unsigned long long) dr->offset,
+    dr->depth,
+    dr->state);
   /* FIXME: this code needs more testing and might
      need to handle more states... */
   switch (dr->state)
@@ -1684,10 +1668,11 @@ reconstruct_cb (void *cls,
   case BRS_CHK_SET:
     if (0 == memcmp (chk, &dr->chk, sizeof (struct ContentHashKey)))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Reconstruction succeeded, can use block at offset %llu, depth %u\n",
-                 (unsigned long long) offset,
-                 depth);
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_DEBUG,
+        "Reconstruction succeeded, can use block at offset %llu, depth %u\n",
+        (unsigned long long) offset,
+        depth);
       /* block matches, hence tree below matches;
        * this request is done! */
       dr->state = BRS_DOWNLOAD_UP;
@@ -1707,32 +1692,34 @@ reconstruct_cb (void *cls,
       pi.value.download.specifics.progress.data_len = 0;
       pi.value.download.specifics.progress.depth = 0;
       pi.value.download.specifics.progress.respect_offered = 0;
-      pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
+      pi.value.download.specifics.progress.block_download_duration =
+        GNUNET_TIME_UNIT_ZERO;
       GNUNET_FS_download_make_status_ (&pi, dc);
       /* FIXME: duplicated code from 'process_result_with_request - refactor */
       if (dc->completed == dc->length)
       {
-       /* download completed, signal */
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Download completed, truncating file to desired length %llu\n",
-                   (unsigned long long) GNUNET_ntohll (dc->uri->data.
-                                                       chk.file_length));
-       /* truncate file to size (since we store IBlocks at the end) */
-       if (NULL != dc->filename)
-       {
-         if (0 !=
-             TRUNCATE (dc->filename,
-                       GNUNET_ntohll (dc->uri->data.chk.file_length)))
-           GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
-                                     dc->filename);
-       }
+        /* download completed, signal */
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Download completed, truncating file to desired length %llu\n",
+                    (unsigned long long) GNUNET_ntohll (
+                      dc->uri->data.chk.file_length));
+        /* truncate file to size (since we store IBlocks at the end) */
+        if (NULL != dc->filename)
+        {
+          if (0 != truncate (dc->filename,
+                             GNUNET_ntohll (dc->uri->data.chk.file_length)))
+            GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                      "truncate",
+                                      dc->filename);
+        }
       }
     }
     else
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Reconstruction failed, need to download block at offset %llu, depth %u\n",
-                 (unsigned long long) offset,
-                 depth);
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_DEBUG,
+        "Reconstruction failed, need to download block at offset %llu, depth %u\n",
+        (unsigned long long) offset,
+        depth);
     break;
   case BRS_DOWNLOAD_DOWN:
     break;
@@ -1744,10 +1731,8 @@ reconstruct_cb (void *cls,
     GNUNET_assert (0);
     break;
   }
-  dc->task = GNUNET_SCHEDULER_add_now (&get_next_block,
-                                       dc);
-  if ( (dr == dc->top_request) &&
-       (dr->state == BRS_DOWNLOAD_UP) )
+  dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
+  if ((dr == dc->top_request) && (dr->state == BRS_DOWNLOAD_UP))
     check_completed (dc);
 }
 
@@ -1803,8 +1788,7 @@ GNUNET_FS_download_start_task_ (void *cls)
   struct GNUNET_FS_ProgressInfo pi;
   struct GNUNET_DISK_FileHandle *fh;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Start task running...\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start task running...\n");
   dc->task = NULL;
   if (0 == dc->length)
   {
@@ -1813,14 +1797,15 @@ GNUNET_FS_download_start_task_ (void *cls)
     {
       fh = GNUNET_DISK_file_open (dc->filename,
                                   GNUNET_DISK_OPEN_READWRITE |
-                                  GNUNET_DISK_OPEN_CREATE |
-                                  ((0 ==
-                                    GNUNET_FS_uri_chk_get_file_size (dc->uri)) ?
-                                   GNUNET_DISK_OPEN_TRUNCATE : 0),
+                                    GNUNET_DISK_OPEN_CREATE |
+                                    ((0 ==
+                                      GNUNET_FS_uri_chk_get_file_size (dc->uri))
+                                       ? GNUNET_DISK_OPEN_TRUNCATE
+                                       : 0),
                                   GNUNET_DISK_PERM_USER_READ |
-                                  GNUNET_DISK_PERM_USER_WRITE |
-                                  GNUNET_DISK_PERM_GROUP_READ |
-                                  GNUNET_DISK_PERM_OTHER_READ);
+                                    GNUNET_DISK_PERM_USER_WRITE |
+                                    GNUNET_DISK_PERM_GROUP_READ |
+                                    GNUNET_DISK_PERM_OTHER_READ);
       GNUNET_DISK_file_close (fh);
     }
     GNUNET_FS_download_sync_ (dc);
@@ -1834,13 +1819,16 @@ GNUNET_FS_download_start_task_ (void *cls)
     return;
   if (NULL == dc->top_request)
   {
-    dc->top_request =
-      create_download_request (NULL, 0, dc->treedepth - 1, 0, dc->offset,
-                              dc->length);
+    dc->top_request = create_download_request (NULL,
+                                               0,
+                                               dc->treedepth - 1,
+                                               0,
+                                               dc->offset,
+                                               dc->length);
     dc->top_request->state = BRS_CHK_SET;
-    dc->top_request->chk =
-        (dc->uri->type ==
-         GNUNET_FS_URI_CHK) ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk;
+    dc->top_request->chk = (dc->uri->type == GNUNET_FS_URI_CHK)
+                             ? dc->uri->data.chk.chk
+                             : dc->uri->data.loc.fi.chk;
     /* signal start */
     GNUNET_FS_download_sync_ (dc);
     if (NULL != dc->search)
@@ -1852,23 +1840,24 @@ GNUNET_FS_download_start_task_ (void *cls)
   GNUNET_FS_download_start_downloading_ (dc);
   /* attempt reconstruction from disk */
   if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename))
-    dc->rfh =
-        GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ,
-                               GNUNET_DISK_PERM_NONE);
+    dc->rfh = GNUNET_DISK_file_open (dc->filename,
+                                     GNUNET_DISK_OPEN_READ,
+                                     GNUNET_DISK_PERM_NONE);
   if (dc->top_request->state == BRS_CHK_SET)
   {
     if (NULL != dc->rfh)
     {
       /* first, try top-down */
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Trying top-down reconstruction for `%s'\n", dc->filename);
+                  "Trying top-down reconstruction for `%s'\n",
+                  dc->filename);
       try_top_down_reconstruction (dc, dc->top_request);
       switch (dc->top_request->state)
       {
       case BRS_CHK_SET:
-        break;                  /* normal */
+        break; /* normal */
       case BRS_DOWNLOAD_DOWN:
-        break;                  /* normal, some blocks already down */
+        break; /* normal, some blocks already down */
       case BRS_DOWNLOAD_UP:
         /* already done entirely, party! */
         if (NULL != dc->rfh)
@@ -1880,7 +1869,7 @@ GNUNET_FS_download_start_task_ (void *cls)
         }
         return;
       case BRS_ERROR:
-        GNUNET_asprintf (&dc->emsg, _("Invalid URI"));
+        GNUNET_asprintf (&dc->emsg, _ ("Invalid URI"));
         GNUNET_FS_download_sync_ (dc);
         pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
         pi.value.download.specifics.error.message = dc->emsg;
@@ -1896,11 +1885,11 @@ GNUNET_FS_download_start_task_ (void *cls)
   if ((GNUNET_FS_uri_chk_get_file_size (dc->uri) <= MAX_INLINE_SIZE) &&
       (NULL != dc->meta))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
-                (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
-                (unsigned int)
-                GNUNET_CONTAINER_meta_data_get_serialized_size (dc->meta));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_DEBUG,
+      "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
+      (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
+      (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (dc->meta));
     GNUNET_CONTAINER_meta_data_iterate (dc->meta, &match_full_data, dc);
     if (BRS_DOWNLOAD_UP == dc->top_request->state)
     {
@@ -1911,24 +1900,24 @@ GNUNET_FS_download_start_task_ (void *cls)
         GNUNET_DISK_file_close (dc->rfh);
         dc->rfh = NULL;
       }
-      return;                   /* finished, status update was already done for us */
+      return; /* finished, status update was already done for us */
     }
   }
   if (NULL != dc->rfh)
   {
     /* finally, actually run bottom-up */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Trying bottom-up reconstruction of file `%s'\n", dc->filename);
+                "Trying bottom-up reconstruction of file `%s'\n",
+                dc->filename);
     dc->te =
       GNUNET_FS_tree_encoder_create (dc->h,
-                                    GNUNET_FS_uri_chk_get_file_size (dc->uri),
-                                    dc,
+                                     GNUNET_FS_uri_chk_get_file_size (dc->uri),
+                                     dc,
                                      &fh_reader,
-                                    &reconstruct_cb,
+                                     &reconstruct_cb,
                                      NULL,
-                                    &reconstruct_cont);
-    dc->task = GNUNET_SCHEDULER_add_now (&get_next_block,
-                                         dc);
+                                     &reconstruct_cont);
+    dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
   }
   else
   {
@@ -1968,7 +1957,8 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
     dc->job_queue = NULL;
   }
   if (NULL != dc->parent)
-    GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail,
+    GNUNET_CONTAINER_DLL_remove (dc->parent->child_head,
+                                 dc->parent->child_tail,
                                  dc);
   if (NULL != dc->task)
   {
@@ -2024,14 +2014,14 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
  */
 struct GNUNET_FS_DownloadContext *
 create_download_context (struct GNUNET_FS_Handle *h,
-                        const struct GNUNET_FS_Uri *uri,
-                        const struct GNUNET_CONTAINER_MetaData *meta,
-                        const char *filename,
+                         const struct GNUNET_FS_Uri *uri,
+                         const struct GNUNET_CONTAINER_MetaData *meta,
+                         const char *filename,
                          const char *tempname,
-                        uint64_t offset,
+                         uint64_t offset,
                          uint64_t length,
                          uint32_t anonymity,
-                        enum GNUNET_FS_DownloadOptions options,
+                         enum GNUNET_FS_DownloadOptions options,
                          void *cctx)
 {
   struct GNUNET_FS_DownloadContext *dc;
@@ -2045,10 +2035,10 @@ create_download_context (struct GNUNET_FS_Handle *h,
   }
   dc = GNUNET_new (struct GNUNET_FS_DownloadContext);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting download %p, %u bytes at offset %llu\n",
-             dc,
-             (unsigned int) length,
-             (unsigned long long) offset);
+              "Starting download %p, %u bytes at offset %llu\n",
+              dc,
+              (unsigned int) length,
+              (unsigned long long) offset);
   dc->h = h;
   dc->uri = GNUNET_FS_uri_dup (uri);
   dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
@@ -2058,7 +2048,10 @@ create_download_context (struct GNUNET_FS_Handle *h,
   {
     dc->filename = GNUNET_strdup (filename);
     if (GNUNET_YES == GNUNET_DISK_file_test (filename))
-      GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES));
+      GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename,
+                                                        &dc->old_file_size,
+                                                        GNUNET_YES,
+                                                        GNUNET_YES));
   }
   if (GNUNET_FS_uri_test_loc (dc->uri))
     GNUNET_assert (GNUNET_OK ==
@@ -2068,9 +2061,10 @@ create_download_context (struct GNUNET_FS_Handle *h,
   dc->anonymity = anonymity;
   dc->options = options;
   dc->active =
-    GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE), GNUNET_NO);
+    GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE),
+                                          GNUNET_NO);
   dc->treedepth =
-      GNUNET_FS_compute_depth (GNUNET_FS_uri_chk_get_file_size (dc->uri));
+    GNUNET_FS_compute_depth (GNUNET_FS_uri_chk_get_file_size (dc->uri));
   if ((NULL == filename) && (is_recursive_download (dc)))
   {
     if (NULL != tempname)
@@ -2079,13 +2073,12 @@ create_download_context (struct GNUNET_FS_Handle *h,
       dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting download `%s' of %llu bytes with tree depth %u\n",
-             filename,
-             (unsigned long long) length,
+              "Starting download `%s' of %llu bytes with tree depth %u\n",
+              filename,
+              (unsigned long long) length,
               dc->treedepth);
   GNUNET_assert (NULL == dc->job_queue);
-  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_,
-                                       dc);
+  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
   return dc;
 }
 
@@ -2140,7 +2133,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
                                 meta,
                                 filename,
                                 tempname,
-                               offset,
+                                offset,
                                 length,
                                 anonymity,
                                 options,
@@ -2150,9 +2143,9 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
   dc->parent = parent;
   if (NULL != parent)
     GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc);
-  else if (0 == (GNUNET_FS_DOWNLOAD_IS_PROBE & options) )
+  else if (0 == (GNUNET_FS_DOWNLOAD_IS_PROBE & options))
     dc->top =
-        GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
+      GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
   return dc;
 }
 
@@ -2214,7 +2207,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
                                 sr->meta,
                                 filename,
                                 tempname,
-                               offset,
+                                offset,
                                 length,
                                 anonymity,
                                 options,
@@ -2248,19 +2241,19 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
   GNUNET_assert (NULL == dc->job_queue);
   GNUNET_assert (NULL == dc->task);
   GNUNET_assert (NULL != dc->active);
-  dc->job_queue
-    GNUNET_FS_queue_ (dc->h,
-                        &activate_fs_download,
-                        &deactivate_fs_download,
-                        dc,
-                        (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
-                       (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
-                       ? GNUNET_FS_QUEUE_PRIORITY_NORMAL
-                       : GNUNET_FS_QUEUE_PRIORITY_PROBE);
+  dc->job_queue =
+    GNUNET_FS_queue_ (dc->h,
+                      &activate_fs_download,
+                      &deactivate_fs_download,
+                      dc,
+                      (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
+                      (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
+                        ? GNUNET_FS_QUEUE_PRIORITY_NORMAL
+                        : GNUNET_FS_QUEUE_PRIORITY_PROBE);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Download %p put into queue as job %p\n",
-             dc,
-             dc->job_queue);
+              "Download %p put into queue as job %p\n",
+              dc,
+              dc->job_queue);
 }
 
 /**
@@ -2271,7 +2264,7 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
 void
 GNUNET_FS_download_suspend (struct GNUNET_FS_DownloadContext *dc)
 {
-  deactivate_fs_download(dc);
+  deactivate_fs_download (dc);
 }
 
 
@@ -2289,15 +2282,15 @@ GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc)
   GNUNET_FS_download_make_status_ (&pi, dc);
 
   GNUNET_assert (NULL == dc->task);
-  dc->job_queue
-    = GNUNET_FS_queue_ (dc->h,
-                        &activate_fs_download,
-                        &deactivate_fs_download,
-                        dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
-                        (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
+  dc->job_queue =
+    GNUNET_FS_queue_ (dc->h,
+                      &activate_fs_download,
+                      &deactivate_fs_download,
+                      dc,
+                      (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
+                      (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
                         ? GNUNET_FS_QUEUE_PRIORITY_NORMAL
                         : GNUNET_FS_QUEUE_PRIORITY_PROBE);
-
 }
 
 
@@ -2308,8 +2301,7 @@ GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc)
  * @param do_delete delete files of incomplete downloads
  */
 void
-GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
-                         int do_delete)
+GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
 {
   struct GNUNET_FS_ProgressInfo pi;
   int have_children;
@@ -2348,14 +2340,15 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
                                  dc);
   if (NULL != dc->serialization)
     GNUNET_FS_remove_sync_file_ (dc->h,
-                                 ((NULL != dc->parent) ||
-                                  (! search_was_null)) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
-                                 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
+                                 ((NULL != dc->parent) || (! search_was_null))
+                                   ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
+                                   : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
                                  dc->serialization);
   if ((GNUNET_YES == have_children) && (NULL == dc->parent))
     GNUNET_FS_remove_sync_dir_ (dc->h,
-                                (! search_was_null) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
-                                GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
+                                (! search_was_null)
+                                  ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
+                                  : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
                                 dc->serialization);
   pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
   GNUNET_FS_download_make_status_ (&pi, dc);
@@ -2370,8 +2363,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
   {
     if ((dc->completed != dc->length) && (GNUNET_YES == do_delete))
     {
-      if ( (0 != UNLINK (dc->filename)) &&
-          (ENOENT != errno) )
+      if ((0 != unlink (dc->filename)) && (ENOENT != errno))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                                   "unlink",
                                   dc->filename);
@@ -2382,7 +2374,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
   GNUNET_FS_uri_destroy (dc->uri);
   if (NULL != dc->temp_filename)
   {
-    if (0 != UNLINK (dc->temp_filename))
+    if (0 != unlink (dc->temp_filename))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
                                 "unlink",
                                 dc->temp_filename);
index 49cfc1a683e77ac2b2296fc8ad86505dff6e09ca..fbf3181eff20617f7e8a3912f3a83d9ac2e1ded2 100644 (file)
@@ -97,16 +97,14 @@ GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s,
  * @return publish structure entry for the file
  */
 struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
-                                             void *client_info,
-                                             const char *filename,
-                                             const struct GNUNET_FS_Uri
-                                             *keywords,
-                                             const struct
-                                             GNUNET_CONTAINER_MetaData *meta,
-                                             int do_index,
-                                             const struct GNUNET_FS_BlockOptions
-                                             *bo)
+GNUNET_FS_file_information_create_from_file (
+  struct GNUNET_FS_Handle *h,
+  void *client_info,
+  const char *filename,
+  const struct GNUNET_FS_Uri *keywords,
+  const struct GNUNET_CONTAINER_MetaData *meta,
+  int do_index,
+  const struct GNUNET_FS_BlockOptions *bo)
 {
   struct FileInfo *fi;
   uint64_t fsize;
@@ -119,7 +117,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
 #endif
 
   /* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
-  if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
+  if (GNUNET_OK !=
+      GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
     return NULL;
@@ -131,16 +130,20 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
     return NULL;
   }
   ret =
-      GNUNET_FS_file_information_create_from_reader (h, client_info,
-                                                     fsize,
-                                                     &GNUNET_FS_data_reader_file_,
-                                                     fi, keywords, meta,
-                                                     do_index, bo);
+    GNUNET_FS_file_information_create_from_reader (h,
+                                                   client_info,
+                                                   fsize,
+                                                   &GNUNET_FS_data_reader_file_,
+                                                   fi,
+                                                   keywords,
+                                                   meta,
+                                                   do_index,
+                                                   bo);
   if (ret == NULL)
     return NULL;
   ret->h = h;
   ret->filename = GNUNET_strdup (filename);
-#if !WINDOWS
+#if ! WINDOWS
   fn = filename;
 #else
   plibc_conv_to_win_path (filename, fn_conv);
@@ -151,16 +154,22 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
 /* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
  * this should be changed to EXTRACTOR_METAFORMAT_UTF8
  */
-#if !WINDOWS
-  GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
+#if ! WINDOWS
+  GNUNET_CONTAINER_meta_data_insert (ret->meta,
+                                     "<gnunet>",
                                      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
                                      EXTRACTOR_METAFORMAT_C_STRING,
-                                     "text/plain", fn, strlen (fn) + 1);
+                                     "text/plain",
+                                     fn,
+                                     strlen (fn) + 1);
 #else
-  GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
+  GNUNET_CONTAINER_meta_data_insert (ret->meta,
+                                     "<gnunet>",
                                      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
                                      EXTRACTOR_METAFORMAT_UTF8,
-                                     "text/plain", fn, strlen (fn) + 1);
+                                     "text/plain",
+                                     fn,
+                                     strlen (fn) + 1);
 #endif
   return ret;
 }
@@ -183,26 +192,30 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
  * @return publish structure entry for the file
  */
 struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
-                                             void *client_info, uint64_t length,
-                                             void *data,
-                                             const struct GNUNET_FS_Uri
-                                             *keywords,
-                                             const struct
-                                             GNUNET_CONTAINER_MetaData *meta,
-                                             int do_index,
-                                             const struct GNUNET_FS_BlockOptions
-                                             *bo)
+GNUNET_FS_file_information_create_from_data (
+  struct GNUNET_FS_Handle *h,
+  void *client_info,
+  uint64_t length,
+  void *data,
+  const struct GNUNET_FS_Uri *keywords,
+  const struct GNUNET_CONTAINER_MetaData *meta,
+  int do_index,
+  const struct GNUNET_FS_BlockOptions *bo)
 {
   if (GNUNET_YES == do_index)
   {
     GNUNET_break (0);
     return NULL;
   }
-  return GNUNET_FS_file_information_create_from_reader (h, client_info, length,
+  return GNUNET_FS_file_information_create_from_reader (h,
+                                                        client_info,
+                                                        length,
                                                         &GNUNET_FS_data_reader_copy_,
-                                                        data, keywords, meta,
-                                                        do_index, bo);
+                                                        data,
+                                                        keywords,
+                                                        meta,
+                                                        do_index,
+                                                        bo);
 }
 
 
@@ -223,18 +236,16 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
  * @return publish structure entry for the file
  */
 struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
-                                               void *client_info,
-                                               uint64_t length,
-                                               GNUNET_FS_DataReader reader,
-                                               void *reader_cls,
-                                               const struct GNUNET_FS_Uri
-                                               *keywords,
-                                               const struct
-                                               GNUNET_CONTAINER_MetaData *meta,
-                                               int do_index,
-                                               const struct
-                                               GNUNET_FS_BlockOptions *bo)
+GNUNET_FS_file_information_create_from_reader (
+  struct GNUNET_FS_Handle *h,
+  void *client_info,
+  uint64_t length,
+  GNUNET_FS_DataReader reader,
+  void *reader_cls,
+  const struct GNUNET_FS_Uri *keywords,
+  const struct GNUNET_CONTAINER_MetaData *meta,
+  int do_index,
+  const struct GNUNET_FS_BlockOptions *bo)
 {
   struct GNUNET_FS_FileInformation *ret;
 
@@ -266,8 +277,8 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
  * @return #GNUNET_YES if so, #GNUNET_NO if not
  */
 int
-GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation
-                                         *ent)
+GNUNET_FS_file_information_is_directory (
+  const struct GNUNET_FS_FileInformation *ent)
 {
   return ent->is_directory;
 }
@@ -286,16 +297,13 @@ GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation
  * @return publish structure entry for the directory , NULL on error
  */
 struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
-                                                   void *client_info,
-                                                   const struct GNUNET_FS_Uri
-                                                   *keywords,
-                                                   const struct
-                                                   GNUNET_CONTAINER_MetaData
-                                                   *meta,
-                                                   const struct
-                                                   GNUNET_FS_BlockOptions *bo,
-                                                   const char *filename)
+GNUNET_FS_file_information_create_empty_directory (
+  struct GNUNET_FS_Handle *h,
+  void *client_info,
+  const struct GNUNET_FS_Uri *keywords,
+  const struct GNUNET_CONTAINER_MetaData *meta,
+  const struct GNUNET_FS_BlockOptions *bo,
+  const char *filename)
 {
   struct GNUNET_FS_FileInformation *ret;
 
@@ -327,7 +335,8 @@ int
 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
                                 struct GNUNET_FS_FileInformation *ent)
 {
-  if ((ent->dir != NULL) || (ent->next != NULL) || (dir->is_directory != GNUNET_YES))
+  if ((ent->dir != NULL) || (ent->next != NULL) ||
+      (dir->is_directory != GNUNET_YES))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -364,10 +373,13 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
 
   no = GNUNET_NO;
   if (GNUNET_OK !=
-      proc (proc_cls, dir,
-            (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size : dir->data.
-            file.file_size,
-           dir->meta, &dir->keywords, &dir->bo,
+      proc (proc_cls,
+            dir,
+            (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size
+                                              : dir->data.file.file_size,
+            dir->meta,
+            &dir->keywords,
+            &dir->bo,
             (dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
             &dir->client_info))
     return;
@@ -378,10 +390,15 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
   {
     no = GNUNET_NO;
     if (GNUNET_OK !=
-        proc (proc_cls, pos,
-              (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size : pos->data.
-              file.file_size, pos->meta, &pos->keywords, &pos->bo,
-              (pos->is_directory == GNUNET_YES) ? &no : &pos->data.file.do_index,
+        proc (proc_cls,
+              pos,
+              (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size
+                                                : pos->data.file.file_size,
+              pos->meta,
+              &pos->keywords,
+              &pos->bo,
+              (pos->is_directory == GNUNET_YES) ? &no
+                                                : &pos->data.file.do_index,
               &pos->client_info))
       break;
     pos = pos->next;
@@ -418,8 +435,14 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
     }
     /* clean up client-info */
     if (NULL != cleaner)
-      cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords,
-               &fi->bo, &no, &fi->client_info);
+      cleaner (cleaner_cls,
+               fi,
+               fi->data.dir.dir_size,
+               fi->meta,
+               &fi->keywords,
+               &fi->bo,
+               &no,
+               &fi->client_info);
     GNUNET_free_non_null (fi->data.dir.dir_data);
   }
   else
@@ -432,19 +455,25 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
     }
     /* clean up client-info */
     if (NULL != cleaner)
-      cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
-               &fi->keywords, &fi->bo, &fi->data.file.do_index,
+      cleaner (cleaner_cls,
+               fi,
+               fi->data.file.file_size,
+               fi->meta,
+               &fi->keywords,
+               &fi->bo,
+               &fi->data.file.do_index,
                &fi->client_info);
   }
   GNUNET_free_non_null (fi->filename);
   GNUNET_free_non_null (fi->emsg);
   if (NULL != fi->sks_uri)
-      GNUNET_FS_uri_destroy (fi->sks_uri);
+    GNUNET_FS_uri_destroy (fi->sks_uri);
   if (NULL != fi->chk_uri)
-      GNUNET_FS_uri_destroy (fi->chk_uri);
+    GNUNET_FS_uri_destroy (fi->chk_uri);
   /* clean up serialization */
-  if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization)))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
+  if ((NULL != fi->serialization) && (0 != unlink (fi->serialization)))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                              "unlink",
                               fi->serialization);
   if (NULL != fi->keywords)
     GNUNET_FS_uri_destroy (fi->keywords);
index 675253b90933af296723197a98bd490dc0f451cb..11a137a096bc7f96930efba6e0df2410fec865eb 100644 (file)
@@ -69,7 +69,6 @@ struct NamespaceUpdateNode
    * TREE this entry belongs to (if nug is current).
    */
   unsigned int tree_id;
-
 };
 
 
@@ -126,8 +125,9 @@ struct GNUNET_FS_UpdateInformationGraph
  * @return NULL on error, otherwise the name of the directory
  */
 static char *
-get_update_information_directory (struct GNUNET_FS_Handle *h,
-                                 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
+get_update_information_directory (
+  struct GNUNET_FS_Handle *h,
+  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
 {
   char *dn;
   char *ret;
@@ -136,21 +136,19 @@ get_update_information_directory (struct GNUNET_FS_Handle *h,
   struct GNUNET_CRYPTO_HashAsciiEncoded enc;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR",
-                                               &dn))
+      GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR", &dn))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "fs", "UPDATE_DIR");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "fs", "UPDATE_DIR");
     return NULL;
   }
   GNUNET_CRYPTO_ecdsa_key_get_public (ns, &pub);
   GNUNET_CRYPTO_hash (&pub, sizeof (pub), &hc);
-  GNUNET_CRYPTO_hash_to_enc (&hc,
-                            &enc);
-  GNUNET_asprintf (&ret, "%s%s%s",
-                  dn,
-                  DIR_SEPARATOR_STR,
-                  (const char *) enc.encoding);
+  GNUNET_CRYPTO_hash_to_enc (&hc, &enc);
+  GNUNET_asprintf (&ret,
+                   "%s%s%s",
+                   dn,
+                   DIR_SEPARATOR_STR,
+                   (const char *) enc.encoding);
   GNUNET_free (dn);
   return ret;
 }
@@ -176,8 +174,7 @@ free_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
     GNUNET_free (nsn->update);
     GNUNET_free (nsn);
   }
-  GNUNET_array_grow (uig->update_nodes, uig->update_node_count,
-                    0);
+  GNUNET_array_grow (uig->update_nodes, uig->update_node_count, 0);
   if (NULL != uig->update_map)
     GNUNET_CONTAINER_multihashmap_destroy (uig->update_map);
   GNUNET_free (uig);
@@ -198,15 +195,14 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
   struct NamespaceUpdateNode *n;
   char *uris;
 
-  fn = get_update_information_directory (uig->h,
-                                        &uig->ns);
+  fn = get_update_information_directory (uig->h, &uig->ns);
   wh = GNUNET_BIO_write_open (fn);
   if (NULL == wh)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to open `%s' for writing: %s\n"),
+                _ ("Failed to open `%s' for writing: %s\n"),
                 fn,
-                STRERROR (errno));
+                strerror (errno));
     GNUNET_free (fn);
     return;
   }
@@ -229,9 +225,9 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
 END:
   if (GNUNET_OK != GNUNET_BIO_write_close (wh))
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to write `%s': %s\n"),
+                _ ("Failed to write `%s': %s\n"),
                 fn,
-                STRERROR (errno));
+                strerror (errno));
   GNUNET_free (fn);
 }
 
@@ -245,7 +241,7 @@ END:
  */
 static struct GNUNET_FS_UpdateInformationGraph *
 read_update_information_graph (struct GNUNET_FS_Handle *h,
-                              const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
+                               const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
 {
   struct GNUNET_FS_UpdateInformationGraph *uig;
   char *fn;
@@ -289,8 +285,9 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
   for (i = 0; i < count; i++)
   {
     n = GNUNET_new (struct NamespaceUpdateNode);
-    if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024))
-        || (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
+    if ((GNUNET_OK !=
+         GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) ||
+        (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
         (GNUNET_OK !=
          GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) ||
         (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2)))
@@ -318,11 +315,13 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
     uig->update_nodes[i] = n;
   }
   uig->update_node_count = i;
- END:
+END:
   if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read `%s': %s\n"),
-               fn, emsg);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _ ("Failed to read `%s': %s\n"),
+                fn,
+                emsg);
     GNUNET_free (emsg);
   }
   GNUNET_free (fn);
@@ -387,8 +386,7 @@ struct GNUNET_FS_PublishSksContext
  * @param msg error message (or NULL)
  */
 static void
-sks_publish_cont (void *cls,
-                 const char *msg)
+sks_publish_cont (void *cls, const char *msg)
 {
   struct GNUNET_FS_PublishSksContext *psc = cls;
   struct GNUNET_FS_UpdateInformationGraph *uig;
@@ -406,11 +404,8 @@ sks_publish_cont (void *cls,
     /* FIXME: this can be done much more
      * efficiently by simply appending to the
      * file and overwriting the 4-byte header */
-    uig = read_update_information_graph (psc->h,
-                                        &psc->ns);
-    GNUNET_array_append (uig->update_nodes,
-                        uig->update_node_count,
-                        psc->nsn);
+    uig = read_update_information_graph (psc->h, &psc->ns);
+    GNUNET_array_append (uig->update_nodes, uig->update_node_count, psc->nsn);
     psc->nsn = NULL;
     write_update_information_graph (uig);
     free_update_information_graph (uig);
@@ -439,12 +434,14 @@ sks_publish_cont (void *cls,
 struct GNUNET_FS_PublishSksContext *
 GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
                        const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
-                       const char *identifier, const char *update,
+                       const char *identifier,
+                       const char *update,
                        const struct GNUNET_CONTAINER_MetaData *meta,
                        const struct GNUNET_FS_Uri *uri,
                        const struct GNUNET_FS_BlockOptions *bo,
                        enum GNUNET_FS_PublishOptions options,
-                       GNUNET_FS_PublishContinuation cont, void *cont_cls)
+                       GNUNET_FS_PublishContinuation cont,
+                       void *cont_cls)
 {
   struct GNUNET_FS_PublishSksContext *psc;
   struct GNUNET_FS_Uri *sks_uri;
@@ -452,8 +449,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
   sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
   sks_uri->type = GNUNET_FS_URI_SKS;
   sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
-  GNUNET_CRYPTO_ecdsa_key_get_public (ns,
-                                   &sks_uri->data.sks.ns);
+  GNUNET_CRYPTO_ecdsa_key_get_public (ns, &sks_uri->data.sks.ns);
 
   psc = GNUNET_new (struct GNUNET_FS_PublishSksContext);
   psc->h = h;
@@ -466,8 +462,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
     psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
     if (NULL == psc->dsh)
     {
-      sks_publish_cont (psc,
-                       _("Failed to connect to datastore."));
+      sks_publish_cont (psc, _ ("Failed to connect to datastore."));
       return NULL;
     }
   }
@@ -480,16 +475,16 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
     psc->nsn->uri = GNUNET_FS_uri_dup (uri);
   }
   psc->uc = GNUNET_FS_publish_ublock_ (h,
-                                      psc->dsh,
-                                      identifier,
-                                      update,
-                                      ns,
-                                      meta,
-                                      uri,
-                                      bo,
-                                      options,
-                                      &sks_publish_cont,
-                                      psc);
+                                       psc->dsh,
+                                       identifier,
+                                       update,
+                                       ns,
+                                       meta,
+                                       uri,
+                                       bo,
+                                       options,
+                                       &sks_publish_cont,
+                                       psc);
   return psc;
 }
 
@@ -553,18 +548,12 @@ struct ProcessUpdateClosure
  *         GNUNET_NO if not.
  */
 static int
-process_update_node (void *cls,
-                    const struct GNUNET_HashCode *key,
-                    void *value)
+process_update_node (void *cls, const struct GNUNET_HashCode *key, void *value)
 {
   struct ProcessUpdateClosure *pc = cls;
   struct NamespaceUpdateNode *nsn = value;
 
-  pc->ip (pc->ip_cls,
-         nsn->id,
-         nsn->uri,
-         nsn->md,
-         nsn->update);
+  pc->ip (pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
   return GNUNET_YES;
 }
 
@@ -622,9 +611,7 @@ struct FindTreeClosure
  *         GNUNET_NO if not.
  */
 static int
-find_trees (void *cls,
-           const struct GNUNET_HashCode *key,
-           void *value)
+find_trees (void *cls, const struct GNUNET_HashCode *key, void *value)
 {
   struct FindTreeClosure *fc = cls;
   struct NamespaceUpdateNode *nsn = value;
@@ -633,26 +620,28 @@ find_trees (void *cls,
   if (nsn->nug == fc->nug)
   {
     if (UINT_MAX == nsn->tree_id)
-      return GNUNET_YES;        /* circular */
+      return GNUNET_YES; /* circular */
     GNUNET_assert (nsn->tree_id < fc->tree_array_size);
     if (fc->tree_array[nsn->tree_id] != nsn)
-      return GNUNET_YES;        /* part of "another" (directed) TREE,
+      return GNUNET_YES; /* part of "another" (directed) TREE,
                                  * and not root of it, end trace */
     if (nsn->tree_id == fc->id)
-      return GNUNET_YES;        /* that's our own root (can this be?) */
+      return GNUNET_YES; /* that's our own root (can this be?) */
     /* merge existing TREE, we have a root for both */
     fc->tree_array[nsn->tree_id] = NULL;
     if (UINT_MAX == fc->id)
-      fc->id = nsn->tree_id;    /* take over ID */
+      fc->id = nsn->tree_id; /* take over ID */
   }
   else
   {
     nsn->nug = fc->nug;
-    nsn->tree_id = UINT_MAX;    /* mark as undef */
+    nsn->tree_id = UINT_MAX; /* mark as undef */
     /* trace */
     GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
-    GNUNET_CONTAINER_multihashmap_get_multiple (fc->uig->update_map, &hc,
-                                                &find_trees, fc);
+    GNUNET_CONTAINER_multihashmap_get_multiple (fc->uig->update_map,
+                                                &hc,
+                                                &find_trees,
+                                                fc);
   }
   return GNUNET_YES;
 }
@@ -682,11 +671,12 @@ find_trees (void *cls,
  * @param ip_cls closure for ip
  */
 void
-GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
-                                    const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
-                                     const char *next_id,
-                                     GNUNET_FS_IdentifierProcessor ip,
-                                     void *ip_cls)
+GNUNET_FS_namespace_list_updateable (
+  struct GNUNET_FS_Handle *h,
+  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
+  const char *next_id,
+  GNUNET_FS_IdentifierProcessor ip,
+  void *ip_cls)
 {
   unsigned int i;
   unsigned int nug;
@@ -700,29 +690,33 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
   if (NULL == uig->update_nodes)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "No updateable nodes found for ID `%s'\n", next_id);
+                "No updateable nodes found for ID `%s'\n",
+                next_id);
     free_update_information_graph (uig);
-    return;                     /* no nodes */
+    return; /* no nodes */
   }
   uig->update_map =
-    GNUNET_CONTAINER_multihashmap_create (2 +
-                                         3 * uig->update_node_count /
-                                         4,
-                                         GNUNET_NO);
+    GNUNET_CONTAINER_multihashmap_create (2 + 3 * uig->update_node_count / 4,
+                                          GNUNET_NO);
   for (i = 0; i < uig->update_node_count; i++)
   {
     nsn = uig->update_nodes[i];
     GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
-    GNUNET_CONTAINER_multihashmap_put (uig->update_map, &hc, nsn,
-                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+    GNUNET_CONTAINER_multihashmap_put (
+      uig->update_map,
+      &hc,
+      nsn,
+      GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   }
   if (NULL != next_id)
   {
     GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
     pc.ip = ip;
     pc.ip_cls = ip_cls;
-    GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map, &hc,
-                                                &process_update_node, &pc);
+    GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map,
+                                                &hc,
+                                                &process_update_node,
+                                                &pc);
     free_update_information_graph (uig);
     return;
   }
@@ -738,9 +732,11 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
     nsn = uig->update_nodes[i];
     if (nsn->nug == nug)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "TREE of node `%s' is %u\n",
+                  nsn->id,
                   nsn->nug);
-      continue;                 /* already placed in TREE */
+      continue; /* already placed in TREE */
     }
     GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
     nsn->nug = nug;
@@ -748,8 +744,10 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
     fc.id = UINT_MAX;
     fc.nug = nug;
     fc.uig = uig;
-    GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map, &hc,
-                                                &find_trees, &fc);
+    GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map,
+                                                &hc,
+                                                &find_trees,
+                                                &fc);
     if (UINT_MAX == fc.id)
     {
       /* start new TREE */
@@ -768,15 +766,18 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
         nsn->tree_id = fc.id;
       }
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Starting new TREE %u with node `%s'\n", nsn->tree_id,
+                  "Starting new TREE %u with node `%s'\n",
+                  nsn->tree_id,
                   nsn->id);
       /* put all nodes with same identifier into this TREE */
       GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
       fc.id = nsn->tree_id;
       fc.nug = nug;
       fc.uig = uig;
-      GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map, &hc,
-                                                  &find_trees, &fc);
+      GNUNET_CONTAINER_multihashmap_get_multiple (uig->update_map,
+                                                  &hc,
+                                                  &find_trees,
+                                                  &fc);
     }
     else
     {
@@ -785,7 +786,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
       nsn->tree_id = fc.id;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "TREE of node `%s' is %u\n", nsn->id,
+                "TREE of node `%s' is %u\n",
+                nsn->id,
                 fc.id);
   }
   for (i = 0; i < fc.tree_array_size; i++)
@@ -793,7 +795,9 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
     nsn = fc.tree_array[i];
     if (NULL != nsn)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Root of TREE %u is node `%s'\n", i,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Root of TREE %u is node `%s'\n",
+                  i,
                   nsn->id);
       ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
     }
index 9097d9884b566533fa545da69579f7cfa4e5b837..5a67afbc0d5691dcb940d77e560bc8b42863d9bc 100644 (file)
@@ -91,7 +91,6 @@
 #include <unistdio.h>
 
 
-
 /**
  * Get a unique key from a URI.  This is for putting URIs
  * into HashMaps.  The key may change between FS implementations.
  */
 int
 GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
-                     struct GNUNET_HashCode *key)
+                      struct GNUNET_HashCode *key)
 {
   switch (uri->type)
   {
@@ -112,14 +111,14 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
   case GNUNET_FS_URI_SKS:
     GNUNET_CRYPTO_hash (uri->data.sks.identifier,
                         strlen (uri->data.sks.identifier),
-                       key);
+                        key);
     return GNUNET_OK;
   case GNUNET_FS_URI_KSK:
     if (uri->data.ksk.keywordCount > 0)
     {
       GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0],
                           strlen (uri->data.ksk.keywords[0]),
-                         key);
+                          key);
       return GNUNET_OK;
     }
     else
@@ -131,7 +130,7 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
   case GNUNET_FS_URI_LOC:
     GNUNET_CRYPTO_hash (&uri->data.loc.fi,
                         sizeof (struct FileIdentifier) +
-                        sizeof (struct GNUNET_PeerIdentity),
+                          sizeof (struct GNUNET_PeerIdentity),
                         key);
     return GNUNET_OK;
   default:
@@ -213,8 +212,7 @@ GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri)
  * @return decodded string with leading space (or preserved plus)
  */
 static char *
-percent_decode_keyword (const char *in,
-                        char **emsg)
+percent_decode_keyword (const char *in, char **emsg)
 {
   char *out;
   char *ret;
@@ -229,16 +227,17 @@ percent_decode_keyword (const char *in,
   {
     if (out[rpos] == '%')
     {
-      if (1 != SSCANF (&out[rpos + 1], "%2X", &hx))
+      if (1 != sscanf (&out[rpos + 1], "%2X", &hx))
       {
         GNUNET_free (out);
-        *emsg = GNUNET_strdup (_(/* xgettext:no-c-format */
-                                "Malformed KSK URI (`%' must be followed by HEX number)"));
+        *emsg = GNUNET_strdup (
+          _ (/* xgettext:no-c-format */
+             "Malformed KSK URI (`%' must be followed by HEX number)"));
         return NULL;
       }
       rpos += 3;
       if (hx == '"')
-        continue;               /* skip double quote */
+        continue; /* skip double quote */
       out[wpos++] = (char) hx;
     }
     else
@@ -272,8 +271,7 @@ percent_decode_keyword (const char *in,
  * @return NULL on error, otherwise the KSK URI
  */
 static struct GNUNET_FS_Uri *
-uri_ksk_parse (const char *s,
-               char **emsg)
+uri_ksk_parse (const char *s, char **emsg)
 {
   struct GNUNET_FS_Uri *ret;
   char **keywords;
@@ -288,11 +286,11 @@ uri_ksk_parse (const char *s,
   slen = strlen (s);
   pos = strlen (GNUNET_FS_URI_KSK_PREFIX);
   if ((slen <= pos) || (0 != strncmp (s, GNUNET_FS_URI_KSK_PREFIX, pos)))
-    return NULL;                /* not KSK URI */
+    return NULL; /* not KSK URI */
   if ((s[slen - 1] == '+') || (s[pos] == '+'))
   {
     *emsg =
-        GNUNET_strdup (_("Malformed KSK URI (must not begin or end with `+')"));
+      GNUNET_strdup (_ ("Malformed KSK URI (must not begin or end with `+')"));
     return NULL;
   }
   max = 1;
@@ -310,20 +308,19 @@ uri_ksk_parse (const char *s,
       max++;
       if (s[i - 1] == '+')
       {
-        *emsg = GNUNET_strdup (_("Malformed KSK URI (`++' not allowed)"));
+        *emsg = GNUNET_strdup (_ ("Malformed KSK URI (`++' not allowed)"));
         return NULL;
       }
     }
   }
   if (saw_quote == 1)
   {
-    *emsg = GNUNET_strdup (_("Malformed KSK URI (quotes not balanced)"));
+    *emsg = GNUNET_strdup (_ ("Malformed KSK URI (quotes not balanced)"));
     return NULL;
   }
   iret = max;
   dup = GNUNET_strdup (s);
-  keywords = GNUNET_new_array (max,
-                               char *);
+  keywords = GNUNET_new_array (max, char *);
   for (i = slen - 1; i >= (int) pos; i--)
   {
     if ((s[i] == '%') && (&s[i] == strstr (&s[i], "%22")))
@@ -368,8 +365,7 @@ CLEANUP:
  * @return NULL on error, SKS URI otherwise
  */
 static struct GNUNET_FS_Uri *
-uri_sks_parse (const char *s,
-               char **emsg)
+uri_sks_parse (const char *s, char **emsg)
 {
   struct GNUNET_FS_Uri *ret;
   struct GNUNET_CRYPTO_EcdsaPublicKey ns;
@@ -378,16 +374,15 @@ uri_sks_parse (const char *s,
 
   pos = strlen (GNUNET_FS_URI_SKS_PREFIX);
   if ((strlen (s) <= pos) || (0 != strncmp (s, GNUNET_FS_URI_SKS_PREFIX, pos)))
-    return NULL;                /* not an SKS URI */
+    return NULL; /* not an SKS URI */
   end = strchr (&s[pos], '/');
-  if ( (NULL == end) ||
-       (GNUNET_OK !=
-       GNUNET_STRINGS_string_to_data (&s[pos],
-                                      end - &s[pos],
-                                      &ns,
-                                      sizeof (ns))) )
+  if ((NULL == end) ||
+      (GNUNET_OK != GNUNET_STRINGS_string_to_data (&s[pos],
+                                                   end - &s[pos],
+                                                   &ns,
+                                                   sizeof (ns))))
   {
-    *emsg = GNUNET_strdup (_("Malformed SKS URI (wrong syntax)"));
+    *emsg = GNUNET_strdup (_ ("Malformed SKS URI (wrong syntax)"));
     return NULL; /* malformed */
   }
   end++; /* skip over '/' */
@@ -409,8 +404,7 @@ uri_sks_parse (const char *s,
  * @return NULL on error, CHK URI otherwise
  */
 static struct GNUNET_FS_Uri *
-uri_chk_parse (const char *s,
-               char **emsg)
+uri_chk_parse (const char *s, char **emsg)
 {
   struct GNUNET_FS_Uri *ret;
   struct FileIdentifier fi;
@@ -424,26 +418,28 @@ uri_chk_parse (const char *s,
   pos = strlen (GNUNET_FS_URI_CHK_PREFIX);
   if ((slen < pos + 2 * sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1) ||
       (0 != strncmp (s, GNUNET_FS_URI_CHK_PREFIX, pos)))
-    return NULL;                /* not a CHK URI */
+    return NULL; /* not a CHK URI */
   if ((s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '.') ||
       (s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2 - 1] != '.'))
   {
-    *emsg = GNUNET_strdup (_("Malformed CHK URI (wrong syntax)"));
+    *emsg = GNUNET_strdup (_ ("Malformed CHK URI (wrong syntax)"));
     return NULL;
   }
   GNUNET_memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
   h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
-  GNUNET_memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
-          sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
+  GNUNET_memcpy (h2,
+                 &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
+                 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
   h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
 
   if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &fi.chk.key)) ||
       (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &fi.chk.query)) ||
       (1 !=
-       SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
-               "%llu", &flen)))
+       sscanf (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
+               "%llu",
+               &flen)))
   {
-    *emsg = GNUNET_strdup (_("Malformed CHK URI (failed to decode CHK)"));
+    *emsg = GNUNET_strdup (_ ("Malformed CHK URI (failed to decode CHK)"));
     return NULL;
   }
   fi.file_length = GNUNET_htonll (flen);
@@ -481,7 +477,6 @@ struct LocUriAssembly
    * Peer offering the file.
    */
   struct GNUNET_PeerIdentity peer;
-
 };
 GNUNET_NETWORK_STRUCT_END
 
@@ -499,8 +494,7 @@ GNUNET_NETWORK_STRUCT_END
  * @return NULL on error, valid LOC URI otherwise
  */
 static struct GNUNET_FS_Uri *
-uri_loc_parse (const char *s,
-               char **emsg)
+uri_loc_parse (const char *s, char **emsg)
 {
   struct GNUNET_FS_Uri *uri;
   char h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)];
@@ -518,26 +512,28 @@ uri_loc_parse (const char *s,
   pos = strlen (GNUNET_FS_URI_LOC_PREFIX);
   if ((slen < pos + 2 * sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1) ||
       (0 != strncmp (s, GNUNET_FS_URI_LOC_PREFIX, pos)))
-    return NULL;                /* not a LOC URI */
+    return NULL; /* not a LOC URI */
   if ((s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '.') ||
       (s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2 - 1] != '.'))
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (wrong syntax)"));
+    *emsg = GNUNET_strdup (_ ("LOC URI malformed (wrong syntax)"));
     return NULL;
   }
   GNUNET_memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
   h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
-  GNUNET_memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
-          sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
+  GNUNET_memcpy (h2,
+                 &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
+                 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
   h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
 
   if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &ass.fi.chk.key)) ||
       (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &ass.fi.chk.query)) ||
       (1 !=
-       SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
-               "%llu", &flen)))
+       sscanf (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
+               "%llu",
+               &flen)))
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (no CHK)"));
+    *emsg = GNUNET_strdup (_ ("LOC URI malformed (no CHK)"));
     return NULL;
   }
   ass.fi.file_length = GNUNET_htonll (flen);
@@ -547,56 +543,61 @@ uri_loc_parse (const char *s,
     npos++;
   if (s[npos] == '\0')
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (missing LOC)"));
+    *emsg = GNUNET_strdup (_ ("LOC URI malformed (missing LOC)"));
     goto ERR;
   }
   npos++;
-  if ( (strlen (&s[npos]) <= GNUNET_CRYPTO_PKEY_ASCII_LENGTH + 1) ||
-       ('.' != s[npos+GNUNET_CRYPTO_PKEY_ASCII_LENGTH]) )
+  if ((strlen (&s[npos]) <= GNUNET_CRYPTO_PKEY_ASCII_LENGTH + 1) ||
+      ('.' != s[npos + GNUNET_CRYPTO_PKEY_ASCII_LENGTH]))
   {
     *emsg =
-      GNUNET_strdup (_("LOC URI malformed (wrong syntax for public key)"));
+      GNUNET_strdup (_ ("LOC URI malformed (wrong syntax for public key)"));
   }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_eddsa_public_key_from_string (&s[npos],
-                                                  GNUNET_CRYPTO_PKEY_ASCII_LENGTH,
-                                                  &ass.peer.public_key))
+  if (
+    GNUNET_OK !=
+    GNUNET_CRYPTO_eddsa_public_key_from_string (&s[npos],
+                                                GNUNET_CRYPTO_PKEY_ASCII_LENGTH,
+                                                &ass.peer.public_key))
   {
     *emsg =
-        GNUNET_strdup (_("LOC URI malformed (could not decode public key)"));
+      GNUNET_strdup (_ ("LOC URI malformed (could not decode public key)"));
     goto ERR;
   }
   npos += GNUNET_CRYPTO_PKEY_ASCII_LENGTH;
   if (s[npos++] != '.')
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (could not find signature)"));
+    *emsg = GNUNET_strdup (_ ("LOC URI malformed (could not find signature)"));
     goto ERR;
   }
-  if ( (strlen (&s[npos]) <= SIGNATURE_ASCII_LENGTH + 1) ||
-       ('.' != s[npos + SIGNATURE_ASCII_LENGTH]) )
+  if ((strlen (&s[npos]) <= SIGNATURE_ASCII_LENGTH + 1) ||
+      ('.' != s[npos + SIGNATURE_ASCII_LENGTH]))
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (wrong syntax for signature)"));
+    *emsg =
+      GNUNET_strdup (_ ("LOC URI malformed (wrong syntax for signature)"));
     goto ERR;
   }
   if (GNUNET_OK !=
       GNUNET_STRINGS_string_to_data (&s[npos],
                                      SIGNATURE_ASCII_LENGTH,
                                      &sig,
-                                     sizeof (struct GNUNET_CRYPTO_EddsaSignature)))
+                                     sizeof (
+                                       struct GNUNET_CRYPTO_EddsaSignature)))
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (could not decode signature)"));
+    *emsg =
+      GNUNET_strdup (_ ("LOC URI malformed (could not decode signature)"));
     goto ERR;
   }
   npos += SIGNATURE_ASCII_LENGTH;
   if (s[npos++] != '.')
   {
-    *emsg = GNUNET_strdup (_("LOC URI malformed (wrong syntax for expiration time)"));
+    *emsg = GNUNET_strdup (
+      _ ("LOC URI malformed (wrong syntax for expiration time)"));
     goto ERR;
   }
-  if (1 != SSCANF (&s[npos], "%llu", &exptime))
+  if (1 != sscanf (&s[npos], "%llu", &exptime))
   {
     *emsg =
-        GNUNET_strdup (_("LOC URI malformed (could not parse expiration time)"));
+      GNUNET_strdup (_ ("LOC URI malformed (could not parse expiration time)"));
     goto ERR;
   }
   ass.purpose.size = htonl (sizeof (struct LocUriAssembly));
@@ -605,10 +606,12 @@ uri_loc_parse (const char *s,
   ass.exptime = GNUNET_TIME_absolute_hton (et);
   if (GNUNET_OK !=
       GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT,
-                                  &ass.purpose, &sig, &ass.peer.public_key))
+                                  &ass.purpose,
+                                  &sig,
+                                  &ass.peer.public_key))
   {
     *emsg =
-        GNUNET_strdup (_("LOC URI malformed (signature failed validation)"));
+      GNUNET_strdup (_ ("LOC URI malformed (signature failed validation)"));
     goto ERR;
   }
   uri = GNUNET_new (struct GNUNET_FS_Uri);
@@ -632,8 +635,7 @@ ERR:
  * @return NULL on error
  */
 struct GNUNET_FS_Uri *
-GNUNET_FS_uri_parse (const char *uri,
-                     char **emsg)
+GNUNET_FS_uri_parse (const char *uri, char **emsg)
 {
   struct GNUNET_FS_Uri *ret;
   char *msg;
@@ -642,7 +644,7 @@ GNUNET_FS_uri_parse (const char *uri,
   {
     GNUNET_break (0);
     if (NULL != emsg)
-      *emsg = GNUNET_strdup (_("invalid argument"));
+      *emsg = GNUNET_strdup (_ ("invalid argument"));
     return NULL;
   }
   if (NULL == emsg)
@@ -654,7 +656,7 @@ GNUNET_FS_uri_parse (const char *uri,
       (NULL != (ret = uri_loc_parse (uri, emsg))))
     return ret;
   if (NULL == *emsg)
-    *emsg = GNUNET_strdup (_("Unrecognized URI type"));
+    *emsg = GNUNET_strdup (_ ("Unrecognized URI type"));
   if (emsg == &msg)
     GNUNET_free (msg);
   return NULL;
@@ -789,8 +791,9 @@ GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri,
     if (0 == strcmp (&old[1], keyword))
     {
       uri->data.ksk.keywords[i] =
-          uri->data.ksk.keywords[uri->data.ksk.keywordCount - 1];
-      GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount,
+        uri->data.ksk.keywords[uri->data.ksk.keywordCount - 1];
+      GNUNET_array_grow (uri->data.ksk.keywords,
+                         uri->data.ksk.keywordCount,
                          uri->data.ksk.keywordCount - 1);
       GNUNET_free (old);
       return;
@@ -877,8 +880,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *base_uri,
     return NULL;
   /* we round expiration time to full seconds for SKS URIs */
   et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL;
-  GNUNET_CRYPTO_eddsa_key_get_public (sign_key,
-                                      &my_public_key);
+  GNUNET_CRYPTO_eddsa_key_get_public (sign_key, &my_public_key);
   ass.purpose.size = htonl (sizeof (struct LocUriAssembly));
   ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
   ass.exptime = GNUNET_TIME_absolute_hton (et);
@@ -906,7 +908,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *base_uri,
  */
 struct GNUNET_FS_Uri *
 GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EcdsaPublicKey *ns,
-                         const char *id)
+                          const char *id)
 {
   struct GNUNET_FS_Uri *ns_uri;
 
@@ -951,8 +953,7 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1,
     return NULL;
   }
   kc = u1->data.ksk.keywordCount;
-  kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount,
-                         char *);
+  kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount, char *);
   for (i = 0; i < u1->data.ksk.keywordCount; i++)
     kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]);
   for (i = 0; i < u2->data.ksk.keywordCount; i++)
@@ -1006,14 +1007,13 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
     }
     if (ret->data.ksk.keywordCount > 0)
     {
-      ret->data.ksk.keywords
-        = GNUNET_new_array (ret->data.ksk.keywordCount,
-                            char *);
+      ret->data.ksk.keywords =
+        GNUNET_new_array (ret->data.ksk.keywordCount, char *);
       for (i = 0; i < ret->data.ksk.keywordCount; i++)
         ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]);
     }
     else
-      ret->data.ksk.keywords = NULL;    /* just to be sure */
+      ret->data.ksk.keywords = NULL; /* just to be sure */
     break;
   case GNUNET_FS_URI_SKS:
     ret->data.sks.identifier = GNUNET_strdup (uri->data.sks.identifier);
@@ -1045,8 +1045,7 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
  *  if keywords is not legal (i.e. empty).
  */
 struct GNUNET_FS_Uri *
-GNUNET_FS_uri_ksk_create (const char *keywords,
-                          char **emsg)
+GNUNET_FS_uri_ksk_create (const char *keywords, char **emsg)
 {
   char **keywordarr;
   unsigned int num_Words;
@@ -1058,7 +1057,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
 
   if (keywords == NULL)
   {
-    *emsg = GNUNET_strdup (_("No keywords specified!\n"));
+    *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
     GNUNET_break (0);
     return NULL;
   }
@@ -1085,17 +1084,16 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
   if (num_Words == 0)
   {
     GNUNET_free (searchString);
-    *emsg = GNUNET_strdup (_("No keywords specified!\n"));
+    *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
     return NULL;
   }
   if (saw_quote != 0)
   {
     GNUNET_free (searchString);
-    *emsg = GNUNET_strdup (_("Number of double-quotes not balanced!\n"));
+    *emsg = GNUNET_strdup (_ ("Number of double-quotes not balanced!\n"));
     return NULL;
   }
-  keywordarr = GNUNET_new_array (num_Words,
-                                 char *);
+  keywordarr = GNUNET_new_array (num_Words, char *);
   num_Words = 0;
   inWord = 0;
   pos = searchString;
@@ -1117,8 +1115,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
     pos++;
   }
   uri =
-      GNUNET_FS_uri_ksk_create_from_args (num_Words,
-                                          (const char **) keywordarr);
+    GNUNET_FS_uri_ksk_create_from_args (num_Words, (const char **) keywordarr);
   GNUNET_free (keywordarr);
   GNUNET_free (searchString);
   return uri;
@@ -1143,8 +1140,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
  *  if keywords is not legal (i.e. empty).
  */
 struct GNUNET_FS_Uri *
-GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
-                                    const char **argv)
+GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv)
 {
   unsigned int i;
   struct GNUNET_FS_Uri *uri;
@@ -1160,16 +1156,16 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
    * handle accordingly */
   emsg = NULL;
   if ((argc == 1) && (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) &&
-      (0 ==
-       strncmp (argv[0], GNUNET_FS_URI_PREFIX, strlen (GNUNET_FS_URI_PREFIX)))
-      && (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg))))
+      (0 == strncmp (argv[0],
+                     GNUNET_FS_URI_PREFIX,
+                     strlen (GNUNET_FS_URI_PREFIX))) &&
+      (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg))))
     return uri;
   GNUNET_free_non_null (emsg);
   uri = GNUNET_new (struct GNUNET_FS_Uri);
   uri->type = GNUNET_FS_URI_KSK;
   uri->data.ksk.keywordCount = argc;
-  uri->data.ksk.keywords = GNUNET_new_array (argc,
-                                             char *);
+  uri->data.ksk.keywords = GNUNET_new_array (argc, char *);
   for (i = 0; i < argc; i++)
   {
     keyword = argv[i];
@@ -1220,9 +1216,9 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
       return GNUNET_YES;
     return GNUNET_NO;
   case GNUNET_FS_URI_SKS:
-    if ((0 ==
-         memcmp (&u1->data.sks.ns, &u2->data.sks.ns,
-                 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) &&
+    if ((0 == memcmp (&u1->data.sks.ns,
+                      &u2->data.sks.ns,
+                      sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) &&
         (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier)))
 
       return GNUNET_YES;
@@ -1246,12 +1242,12 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
     }
     return GNUNET_YES;
   case GNUNET_FS_URI_LOC:
-    if (memcmp
-        (&u1->data.loc, &u2->data.loc,
-         sizeof (struct FileIdentifier) +
-         sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
-         sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) +
-         sizeof (unsigned short)) != 0)
+    if (memcmp (&u1->data.loc,
+                &u2->data.loc,
+                sizeof (struct FileIdentifier) +
+                  sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
+                  sizeof (struct GNUNET_TIME_Absolute) +
+                  sizeof (unsigned short) + sizeof (unsigned short)) != 0)
       return GNUNET_NO;
     return GNUNET_YES;
   default:
@@ -1285,7 +1281,7 @@ int
 GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
                                  struct GNUNET_CRYPTO_EcdsaPublicKey *pseudonym)
 {
-  if (!GNUNET_FS_uri_test_sks (uri))
+  if (! GNUNET_FS_uri_test_sks (uri))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1304,7 +1300,7 @@ GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
 char *
 GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri)
 {
-  if (!GNUNET_FS_uri_test_sks (uri))
+  if (! GNUNET_FS_uri_test_sks (uri))
   {
     GNUNET_break (0);
     return NULL;
@@ -1327,7 +1323,7 @@ GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri)
 
   if (uri->type == GNUNET_FS_URI_KSK)
   {
-    for (i=0;i < uri->data.ksk.keywordCount; i++)
+    for (i = 0; i < uri->data.ksk.keywordCount; i++)
       GNUNET_assert (uri->data.ksk.keywords[i] != NULL);
   }
 #endif
@@ -1356,7 +1352,7 @@ GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri)
  * @return size of the file as specified in the CHK URI
  */
 uint64_t
-GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri * uri)
+GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri)
 {
   switch (uri->type)
   {
@@ -1367,7 +1363,7 @@ GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri * uri)
   default:
     GNUNET_assert (0);
   }
-  return 0;                     /* unreachable */
+  return 0; /* unreachable */
 }
 
 
@@ -1394,9 +1390,7 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri)
  * @param index offset where to add the keyword
  */
 static void
-insert_non_mandatory_keyword (const char *s,
-                              char **array,
-                              int index)
+insert_non_mandatory_keyword (const char *s, char **array, int index)
 {
   char *nkword;
 
@@ -1417,9 +1411,7 @@ insert_non_mandatory_keyword (const char *s,
  * @return #GNUNET_YES if the keyword exists, #GNUNET_NO if not
  */
 static int
-find_duplicate (const char *s,
-                const char **array,
-                int array_length)
+find_duplicate (const char *s, const char **array, int array_length)
 {
   int j;
 
@@ -1455,12 +1447,19 @@ normalize_metadata (enum EXTRACTOR_MetaFormat format,
   }
   if (format == EXTRACTOR_METAFORMAT_C_STRING)
   {
-    free_str = u8_strconv_from_encoding (data, locale_charset (), iconveh_escape_sequence);
+    free_str = u8_strconv_from_encoding (data,
+                                         locale_charset (),
+                                         iconveh_escape_sequence);
     if (free_str == NULL)
       return NULL;
   }
 
-  normalized = u8_tolower (str_to_normalize, strlen ((char *) str_to_normalize), NULL, UNINORM_NFD, NULL, &r_len);
+  normalized = u8_tolower (str_to_normalize,
+                           strlen ((char *) str_to_normalize),
+                           NULL,
+                           UNINORM_NFD,
+                           NULL,
+                           &r_len);
   /* free_str is allocated by libunistring internally, use free() */
   if (free_str != NULL)
     free (free_str);
@@ -1512,9 +1511,7 @@ u8_strcount (const uint8_t *s)
  *         were duplicates (when extracting).
  */
 static int
-get_keywords_from_parens (const char *s,
-                          char **array,
-                          int index)
+get_keywords_from_parens (const char *s, char **array, int index)
 {
   int count = 0;
   char *open_paren;
@@ -1564,28 +1561,33 @@ get_keywords_from_parens (const char *s,
       {
         char *normalized;
         if (GNUNET_NO == find_duplicate ((const char *) &open_paren[1],
-            (const char **) array, index + count))
+                                         (const char **) array,
+                                         index + count))
         {
-         insert_non_mandatory_keyword ((const char *) &open_paren[1], array,
-                                       index + count);
+          insert_non_mandatory_keyword ((const char *) &open_paren[1],
+                                        array,
+                                        index + count);
           count++;
         }
         normalized = normalize_metadata (EXTRACTOR_METAFORMAT_UTF8,
-            &open_paren[1], close_paren - &open_paren[1]);
+                                         &open_paren[1],
+                                         close_paren - &open_paren[1]);
         if (normalized != NULL)
         {
           if (GNUNET_NO == find_duplicate ((const char *) normalized,
-              (const char **) array, index + count))
+                                           (const char **) array,
+                                           index + count))
           {
-           insert_non_mandatory_keyword ((const char *) normalized, array,
-                                         index + count);
+            insert_non_mandatory_keyword ((const char *) normalized,
+                                          array,
+                                          index + count);
             count++;
           }
           GNUNET_free (normalized);
         }
       }
       else
-       count++;
+        count++;
       close_paren[0] = tmp;
     }
   }
@@ -1614,9 +1616,7 @@ get_keywords_from_parens (const char *s,
  *         duplicates (when extracting).
  */
 static int
-get_keywords_from_tokens (const char *s,
-                          char **array,
-                          int index)
+get_keywords_from_tokens (const char *s, char **array, int index)
 {
   char *p;
   char *ss;
@@ -1633,19 +1633,20 @@ get_keywords_from_tokens (const char *s,
       char *normalized;
       if (GNUNET_NO == find_duplicate (p, (const char **) array, index + seps))
       {
-        insert_non_mandatory_keyword (p, array,
-                                     index + seps);
-       seps++;
+        insert_non_mandatory_keyword (p, array, index + seps);
+        seps++;
       }
-      normalized = normalize_metadata (EXTRACTOR_METAFORMAT_UTF8,
-          p, strlen (p));
+      normalized =
+        normalize_metadata (EXTRACTOR_METAFORMAT_UTF8, p, strlen (p));
       if (normalized != NULL)
       {
         if (GNUNET_NO == find_duplicate ((const char *) normalized,
-            (const char **) array, index + seps))
+                                         (const char **) array,
+                                         index + seps))
         {
-          insert_non_mandatory_keyword ((const char *) normalized, array,
-                                 index + seps);
+          insert_non_mandatory_keyword ((const char *) normalized,
+                                        array,
+                                        index + seps);
           seps++;
         }
         GNUNET_free (normalized);
@@ -1678,7 +1679,8 @@ get_keywords_from_tokens (const char *s,
  * @return 0 (always)
  */
 static int
-gather_uri_data (void *cls, const char *plugin_name,
+gather_uri_data (void *cls,
+                 const char *plugin_name,
                  enum EXTRACTOR_MetaType type,
                  enum EXTRACTOR_MetaFormat format,
                  const char *data_mime_type,
@@ -1699,16 +1701,12 @@ gather_uri_data (void *cls, const char *plugin_name,
    */
   if (u8_strcount ((const uint8_t *) data) <= 2)
     return 0;
-  if ( (EXTRACTOR_METATYPE_MIMETYPE == type) &&
-       (NULL != (sep = memchr (data, '/', data_len))) &&
-       (sep != data) )
+  if ((EXTRACTOR_METATYPE_MIMETYPE == type) &&
+      (NULL != (sep = memchr (data, '/', data_len))) && (sep != data))
   {
     char *xtra;
 
-    GNUNET_asprintf (&xtra,
-                     "mimetype:%.*s",
-                     (int) (sep - data),
-                     data);
+    GNUNET_asprintf (&xtra, "mimetype:%.*s", (int) (sep - data), data);
     if (! find_duplicate (xtra,
                           (const char **) uri->data.ksk.keywords,
                           uri->data.ksk.keywordCount))
@@ -1727,17 +1725,19 @@ gather_uri_data (void *cls, const char *plugin_name,
                         uri->data.ksk.keywordCount))
   {
     insert_non_mandatory_keyword (data,
-                                 uri->data.ksk.keywords, uri->data.ksk.keywordCount);
+                                  uri->data.ksk.keywords,
+                                  uri->data.ksk.keywordCount);
     uri->data.ksk.keywordCount++;
   }
   if (NULL != normalized_data)
-    {
+  {
     if (! find_duplicate (normalized_data,
                           (const char **) uri->data.ksk.keywords,
                           uri->data.ksk.keywordCount))
     {
       insert_non_mandatory_keyword (normalized_data,
-                                   uri->data.ksk.keywords, uri->data.ksk.keywordCount);
+                                    uri->data.ksk.keywords,
+                                    uri->data.ksk.keywordCount);
       uri->data.ksk.keywordCount++;
     }
     GNUNET_free (normalized_data);
@@ -1755,7 +1755,8 @@ gather_uri_data (void *cls, const char *plugin_name,
  * @return NULL on error, otherwise a KSK URI
  */
 struct GNUNET_FS_Uri *
-GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData *md)
+GNUNET_FS_uri_ksk_create_from_meta_data (
+  const struct GNUNET_CONTAINER_MetaData *md)
 {
   struct GNUNET_FS_Uri *ret;
   char *filename;
@@ -1772,8 +1773,10 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
   ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL);
   if (ent > 0)
   {
-    full_name = GNUNET_CONTAINER_meta_data_get_first_by_types (md,
-        EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, -1);
+    full_name = GNUNET_CONTAINER_meta_data_get_first_by_types (
+      md,
+      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
+      -1);
     if (NULL != full_name)
     {
       filename = full_name;
@@ -1784,19 +1787,20 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
     }
     /* x3 because there might be a normalized variant of every keyword,
        plus theoretically one more for mime... */
-    ret->data.ksk.keywords
-      = GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3,
-                          char *);
+    ret->data.ksk.keywords =
+      GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
     GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret);
   }
   if (tok_keywords > 0)
-    ret->data.ksk.keywordCount += get_keywords_from_tokens (filename,
-                                                            ret->data.ksk.keywords,
-                                                            ret->data.ksk.keywordCount);
+    ret->data.ksk.keywordCount +=
+      get_keywords_from_tokens (filename,
+                                ret->data.ksk.keywords,
+                                ret->data.ksk.keywordCount);
   if (paren_keywords > 0)
-    ret->data.ksk.keywordCount += get_keywords_from_parens (filename,
-                                                            ret->data.ksk.keywords,
-                                                            ret->data.ksk.keywordCount);
+    ret->data.ksk.keywordCount +=
+      get_keywords_from_parens (filename,
+                                ret->data.ksk.keywords,
+                                ret->data.ksk.keywordCount);
   if (ent > 0)
     GNUNET_free_non_null (full_name);
   return ret;
@@ -1810,9 +1814,8 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
 static int
 needs_percent (char c)
 {
-  return (!
-          ((isalnum ((unsigned char) c)) || (c == '-') || (c == '_') ||
-           (c == '.') || (c == '~')));
+  return (! ((isalnum ((unsigned char) c)) || (c == '-') || (c == '_') ||
+             (c == '.') || (c == '~')));
 }
 
 
@@ -1851,10 +1854,10 @@ uri_ksk_to_string (const struct GNUNET_FS_Uri *uri)
       if ((j == 0) && (keyword[j] == ' '))
       {
         n--;
-        continue;               /* skip leading space */
+        continue; /* skip leading space */
       }
       if (needs_percent (keyword[j]))
-        n += 2;                 /* will use %-encoding */
+        n += 2; /* will use %-encoding */
     }
   }
   ret = GNUNET_malloc (n);
@@ -1868,7 +1871,7 @@ uri_ksk_to_string (const struct GNUNET_FS_Uri *uri)
     for (j = 0; j < slen; j++)
     {
       if ((j == 0) && (keyword[j] == ' '))
-        continue;               /* skip leading space */
+        continue; /* skip leading space */
       if (needs_percent (keyword[j]))
       {
         sprintf (&ret[wpos], "%%%02X", (unsigned char) keyword[j]);
@@ -1900,15 +1903,19 @@ uri_sks_to_string (const struct GNUNET_FS_Uri *uri)
 
   if (GNUNET_FS_URI_SKS != uri->type)
     return NULL;
-  ret = GNUNET_STRINGS_data_to_string (&uri->data.sks.ns,
-                                      sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
-                                      buf,
-                                      sizeof (buf));
+  ret =
+    GNUNET_STRINGS_data_to_string (&uri->data.sks.ns,
+                                   sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
+                                   buf,
+                                   sizeof (buf));
   GNUNET_assert (NULL != ret);
   ret[0] = '\0';
-  GNUNET_asprintf (&ret, "%s%s%s/%s", GNUNET_FS_URI_PREFIX,
-                   GNUNET_FS_URI_SKS_INFIX, buf,
-                  uri->data.sks.identifier);
+  GNUNET_asprintf (&ret,
+                   "%s%s%s/%s",
+                   GNUNET_FS_URI_PREFIX,
+                   GNUNET_FS_URI_SKS_INFIX,
+                   buf,
+                   uri->data.sks.identifier);
   return ret;
 }
 
@@ -1933,9 +1940,13 @@ uri_chk_to_string (const struct GNUNET_FS_Uri *uri)
   GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash);
   GNUNET_CRYPTO_hash_to_enc (&fi->chk.query, &queryhash);
 
-  GNUNET_asprintf (&ret, "%s%s%s.%s.%llu", GNUNET_FS_URI_PREFIX,
-                   GNUNET_FS_URI_CHK_INFIX, (const char *) &keyhash,
-                   (const char *) &queryhash, GNUNET_ntohll (fi->file_length));
+  GNUNET_asprintf (&ret,
+                   "%s%s%s.%s.%llu",
+                   GNUNET_FS_URI_PREFIX,
+                   GNUNET_FS_URI_CHK_INFIX,
+                   (const char *) &keyhash,
+                   (const char *) &queryhash,
+                   GNUNET_ntohll (fi->file_length));
   return ret;
 }
 
@@ -1959,20 +1970,25 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
   GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash);
   peer_id =
     GNUNET_CRYPTO_eddsa_public_key_to_string (&uri->data.loc.peer.public_key);
-  GNUNET_assert (NULL !=
-                 GNUNET_STRINGS_data_to_string (&uri->data.loc.contentSignature,
-                                                sizeof (struct GNUNET_CRYPTO_EddsaSignature),
-                                                peer_sig,
-                                                sizeof (peer_sig)));
+  GNUNET_assert (
+    NULL !=
+    GNUNET_STRINGS_data_to_string (&uri->data.loc.contentSignature,
+                                   sizeof (struct GNUNET_CRYPTO_EddsaSignature),
+                                   peer_sig,
+                                   sizeof (peer_sig)));
   GNUNET_asprintf (&ret,
-                  "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX,
-                   GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash,
+                   "%s%s%s.%s.%llu.%s.%s.%llu",
+                   GNUNET_FS_URI_PREFIX,
+                   GNUNET_FS_URI_LOC_INFIX,
+                   (const char *) &keyhash,
                    (const char *) &queryhash,
-                   (unsigned long long) GNUNET_ntohll (uri->data.loc.
-                                                       fi.file_length),
+                   (unsigned long long) GNUNET_ntohll (
+                     uri->data.loc.fi.file_length),
                    peer_id,
                    peer_sig,
-                   (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000000LL);
+                   (unsigned long long)
+                       uri->data.loc.expirationTime.abs_value_us /
+                     1000000LL);
   GNUNET_free (peer_id);
   return ret;
 }
index ba28c5c2347b5da55e553f08fe2f6eecc10695f4..8b04e474d93fb50afb4db17be01b5876df39620c 100644 (file)
@@ -512,7 +512,7 @@ determine_id (void *cls, const char *filename)
   struct GNUNET_HashCode fx[2];
   struct GNUNET_HashCode ft;
 
-  if (0 != STAT (filename, &sbuf))
+  if (0 != stat (filename, &sbuf))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
     return GNUNET_OK;
index 097dd4406a1fb84bdb0ccab83d688b40da425986..4cce69d72ec50587017d05169b60df29be2021c9 100644 (file)
@@ -50,7 +50,7 @@ item_printer (void *cls,
 {
   if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
   {
-    printf (_("\t<original file embedded in %u bytes of meta data>\n"),
+    printf (_ ("\t<original file embedded in %u bytes of meta data>\n"),
             (unsigned int) data_size);
     return 0;
   }
@@ -63,17 +63,14 @@ item_printer (void *cls,
   printf ("\t%20s: %s\n",
           dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN,
                     EXTRACTOR_metatype_to_string (type)),
-    data);
-#else
-  printf ("\t%20d: %s\n",
-          type,
           data);
+#else
+  printf ("\t%20d: %s\n", type, data);
 #endif
   return 0;
 }
 
 
-
 /**
  * Print an entry in a directory.
  *
@@ -90,22 +87,25 @@ item_printer (void *cls,
  * @param data data available for the file (length bytes)
  */
 static void
-print_entry (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
-             const struct GNUNET_CONTAINER_MetaData *meta, size_t length,
+print_entry (void *cls,
+             const char *filename,
+             const struct GNUNET_FS_Uri *uri,
+             const struct GNUNET_CONTAINER_MetaData *meta,
+             size_t length,
              const void *data)
 {
   char *string;
   char *name;
 
-  name =
-      GNUNET_CONTAINER_meta_data_get_by_type (meta,
-                                              EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+  name = GNUNET_CONTAINER_meta_data_get_by_type (
+    meta,
+    EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
   if (uri == NULL)
   {
-    printf (_("Directory `%s' meta data:\n"), name ? name : "");
+    printf (_ ("Directory `%s' meta data:\n"), name ? name : "");
     GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL);
     printf ("\n");
-    printf (_("Directory `%s' contents:\n"), name ? name : "");
+    printf (_ ("Directory `%s' contents:\n"), name ? name : "");
     GNUNET_free_non_null (name);
     return;
   }
@@ -127,7 +127,9 @@ print_entry (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
  * @param cfg configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_DISK_MapHandle *map;
@@ -140,20 +142,21 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   if (NULL == args[0])
   {
-    FPRINTF (stderr, "%s",  _("You must specify a filename to inspect.\n"));
+    fprintf (stderr, "%s", _ ("You must specify a filename to inspect.\n"));
     ret = 1;
     return;
   }
   i = 0;
   while (NULL != (filename = args[i++]))
   {
-    if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) ||
-        (NULL ==
-         (h =
-          GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
-                                 GNUNET_DISK_PERM_NONE))))
+    if ((GNUNET_OK !=
+         GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) ||
+        (NULL == (h = GNUNET_DISK_file_open (filename,
+                                             GNUNET_DISK_OPEN_READ,
+                                             GNUNET_DISK_PERM_NONE))))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read directory `%s'\n"),
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Failed to read directory `%s'\n"),
                   filename);
       ret = 1;
       continue;
@@ -161,9 +164,9 @@ run (void *cls, char *const *args, const char *cfgfile,
     len = (size_t) size;
     data = GNUNET_DISK_file_map (h, &map, GNUNET_DISK_MAP_TYPE_READ, len);
     GNUNET_assert (NULL != data);
-    if (GNUNET_OK != GNUNET_FS_directory_list_contents (len, data, 0, &print_entry, NULL))
-      fprintf (stdout, _("`%s' is not a GNUnet directory\n"),
-              filename);
+    if (GNUNET_OK !=
+        GNUNET_FS_directory_list_contents (len, data, 0, &print_entry, NULL))
+      fprintf (stdout, _ ("`%s' is not a GNUnet directory\n"), filename);
     else
       printf ("\n");
     GNUNET_DISK_file_unmap (map);
@@ -182,18 +185,23 @@ int
 main (int argc, char *const *argv)
 {
   static struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-directory [OPTIONS] FILENAME",
-                            gettext_noop
-                            ("Display contents of a GNUnet directory"),
-                            options, &run, NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+         GNUNET_PROGRAM_run (argc,
+                             argv,
+                             "gnunet-directory [OPTIONS] FILENAME",
+                             gettext_noop (
+                               "Display contents of a GNUnet directory"),
+                             options,
+                             &run,
+                             NULL))
+          ? ret
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 31e62c603f531e16073c8dff6a2d5bcf192c6f9d..00e8336a2a2a22fcdf96a46ca876a0990bfcfc15 100644 (file)
@@ -80,33 +80,30 @@ shutdown_task (void *cls)
  * @param w desired number of steps in the progress bar
  */
 static void
-display_bar (unsigned long long x,
-            unsigned long long n,
-            unsigned int w)
+display_bar (unsigned long long x, unsigned long long n, unsigned int w)
 {
   char buf[w + 20];
   unsigned int p;
   unsigned int endeq;
   float ratio_complete;
 
-#if !WINDOWS
+#if ! WINDOWS
   if (0 == isatty (1))
     return;
 #else
   if (FILE_TYPE_CHAR != GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
     return;
 #endif
-  ratio_complete = x/(float)n;
+  ratio_complete = x / (float) n;
   endeq = ratio_complete * w;
-  GNUNET_snprintf (buf, sizeof (buf),
-                  "%3d%% [", (int)(ratio_complete*100) );
-  for (p=0; p<endeq; p++)
+  GNUNET_snprintf (buf, sizeof (buf), "%3d%% [", (int) (ratio_complete * 100));
+  for (p = 0; p < endeq; p++)
     strcat (buf, "=");
-  for (p=endeq; p<w; p++)
+  for (p = endeq; p < w; p++)
     strcat (buf, " ");
   strcat (buf, "]\r");
   printf ("%s", buf);
-  fflush(stdout);
+  fflush (stdout);
 }
 
 
@@ -124,8 +121,7 @@ display_bar (unsigned long long x,
  *         field in the `struct GNUNET_FS_ProgressInfo`
  */
 static void *
-progress_cb (void *cls,
-            const struct GNUNET_FS_ProgressInfo *info)
+progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 {
   char *s;
   const char *s2;
@@ -135,71 +131,75 @@ progress_cb (void *cls,
   {
   case GNUNET_FS_STATUS_DOWNLOAD_START:
     if (verbose > 1)
-      FPRINTF (stderr,
-              _("Starting download `%s'.\n"),
+      fprintf (stderr,
+               _ ("Starting download `%s'.\n"),
                info->value.download.filename);
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
     if (verbose)
     {
-      s = GNUNET_strdup (GNUNET_STRINGS_relative_time_to_string (info->value.download.eta,
-                                                                GNUNET_YES));
-      if (info->value.download.specifics.progress.block_download_duration.rel_value_us
-          == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
-        s2 = _("<unknown time>");
+      s = GNUNET_strdup (
+        GNUNET_STRINGS_relative_time_to_string (info->value.download.eta,
+                                                GNUNET_YES));
+      if (info->value.download.specifics.progress.block_download_duration
+            .rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
+        s2 = _ ("<unknown time>");
       else
-        s2 = GNUNET_STRINGS_relative_time_to_string (info->value.download.specifics.progress.block_download_duration,
-                                                    GNUNET_YES);
-      t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
-                                          1000LL /
-                                          (info->value.download.
-                                           duration.rel_value_us + 1));
-      FPRINTF (stdout,
-               _("Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block took %s to download\n"),
-               info->value.download.filename,
-               (unsigned long long) info->value.download.completed,
-               (unsigned long long) info->value.download.size,
-              s,
-              t,
-              s2);
+        s2 = GNUNET_STRINGS_relative_time_to_string (info->value.download
+                                                       .specifics.progress
+                                                       .block_download_duration,
+                                                     GNUNET_YES);
+      t = GNUNET_STRINGS_byte_size_fancy (
+        info->value.download.completed * 1000LL /
+        (info->value.download.duration.rel_value_us + 1));
+      fprintf (
+        stdout,
+        _ (
+          "Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block took %s to download\n"),
+        info->value.download.filename,
+        (unsigned long long) info->value.download.completed,
+        (unsigned long long) info->value.download.size,
+        s,
+        t,
+        s2);
       GNUNET_free (s);
       GNUNET_free (t);
     }
     else
     {
       display_bar (info->value.download.completed,
-                  info->value.download.size,
-                  60);
+                   info->value.download.size,
+                   60);
     }
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
-#if !WINDOWS
+#if ! WINDOWS
     if (0 != isatty (1))
       fprintf (stdout, "\n");
 #else
-    if (FILE_TYPE_CHAR ==
-       GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
+    if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
       fprintf (stdout, "\n");
 #endif
-    FPRINTF (stderr, _("Error downloading: %s.\n"),
+    fprintf (stderr,
+             _ ("Error downloading: %s.\n"),
              info->value.download.specifics.error.message);
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
-    s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 /
-                                        (info->value.download.
-                                         duration.rel_value_us + 1));
-#if !WINDOWS
+    s = GNUNET_STRINGS_byte_size_fancy (
+      info->value.download.completed * 1000 /
+      (info->value.download.duration.rel_value_us + 1));
+#if ! WINDOWS
     if (0 != isatty (1))
       fprintf (stdout, "\n");
 #else
-    if (FILE_TYPE_CHAR ==
-       GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
+    if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
       fprintf (stdout, "\n");
 #endif
-    FPRINTF (stdout,
-            _("Downloading `%s' done (%s/s).\n"),
-             info->value.download.filename, s);
+    fprintf (stdout,
+             _ ("Downloading `%s' done (%s/s).\n"),
+             info->value.download.filename,
+             s);
     GNUNET_free (s);
     if (info->value.download.dc == dc)
       GNUNET_SCHEDULER_shutdown ();
@@ -212,9 +212,7 @@ progress_cb (void *cls,
   case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
     break;
   default:
-    FPRINTF (stderr,
-            _("Unexpected status: %d\n"),
-            info->status);
+    fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
     break;
   }
   return NULL;
@@ -241,55 +239,45 @@ run (void *cls,
 
   if (NULL == args[0])
   {
-    FPRINTF (stderr,
-            "%s",
-            _("You need to specify a URI argument.\n"));
+    fprintf (stderr, "%s", _ ("You need to specify a URI argument.\n"));
     return;
   }
   uri = GNUNET_FS_uri_parse (args[0], &emsg);
   if (NULL == uri)
   {
-    FPRINTF (stderr,
-            _("Failed to parse URI: %s\n"),
-            emsg);
+    fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg);
     GNUNET_free (emsg);
     ret = 1;
     return;
   }
-  if ( (! GNUNET_FS_uri_test_chk (uri)) &&
-       (! GNUNET_FS_uri_test_loc (uri)))
+  if ((! GNUNET_FS_uri_test_chk (uri)) && (! GNUNET_FS_uri_test_loc (uri)))
   {
-    FPRINTF (stderr,
-            "%s",
-            _("Only CHK or LOC URIs supported.\n"));
+    fprintf (stderr, "%s", _ ("Only CHK or LOC URIs supported.\n"));
     ret = 1;
     GNUNET_FS_uri_destroy (uri);
     return;
   }
   if (NULL == filename)
   {
-    FPRINTF (stderr,
-            "%s",
-            _("Target filename must be specified.\n"));
+    fprintf (stderr, "%s", _ ("Target filename must be specified.\n"));
     ret = 1;
     GNUNET_FS_uri_destroy (uri);
     return;
   }
   cfg = c;
   ctx = GNUNET_FS_start (cfg,
-                        "gnunet-download",
-                        &progress_cb, NULL,
-                        GNUNET_FS_FLAGS_NONE,
-                        GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM,
-                        parallelism,
-                        GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
-                        request_parallelism,
-                        GNUNET_FS_OPTIONS_END);
+                         "gnunet-download",
+                         &progress_cb,
+                         NULL,
+                         GNUNET_FS_FLAGS_NONE,
+                         GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM,
+                         parallelism,
+                         GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
+                         request_parallelism,
+                         GNUNET_FS_OPTIONS_END);
   if (NULL == ctx)
   {
-    FPRINTF (stderr,
-            _("Could not initialize `%s' subsystem.\n"),
-            "FS");
+    fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
     GNUNET_FS_uri_destroy (uri);
     ret = 1;
     return;
@@ -300,16 +288,16 @@ run (void *cls,
   if (local_only)
     options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
   dc = GNUNET_FS_download_start (ctx,
-                                uri,
-                                NULL,
-                                filename,
-                                NULL,
-                                0,
+                                 uri,
+                                 NULL,
+                                 filename,
+                                 NULL,
+                                 0,
                                  GNUNET_FS_uri_chk_get_file_size (uri),
                                  anonymity,
-                                options,
-                                NULL,
-                                NULL);
+                                 options,
+                                 NULL,
+                                 NULL);
   GNUNET_FS_uri_destroy (uri);
   if (dc == NULL)
   {
@@ -317,8 +305,7 @@ run (void *cls,
     ctx = NULL;
     return;
   }
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
@@ -332,61 +319,73 @@ run (void *cls,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_uint ('a',
-                              "anonymity",
-                              "LEVEL",
-                              gettext_noop ("set the desired LEVEL of receiver-anonymity"),
-                              &anonymity),
-
-    GNUNET_GETOPT_option_flag ('D',
-                              "delete-incomplete",
-                              gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
-                              &delete_incomplete),
-
-    GNUNET_GETOPT_option_flag ('n',
-                              "no-network",
-                              gettext_noop ("only search the local peer (no P2P network search)"),
-                              &local_only), 
-    GNUNET_GETOPT_option_string ('o',
-                                 "output",
-                                 "FILENAME",
-                                 gettext_noop ("write the file to FILENAME"),
-                                 &filename),
-    GNUNET_GETOPT_option_uint ('p',
-                              "parallelism",
-                              "DOWNLOADS",
-                              gettext_noop ("set the maximum number of parallel downloads that is allowed"),
-                              &parallelism),
-    GNUNET_GETOPT_option_uint ('r',
-                              "request-parallelism",
-                              "REQUESTS",
-                              gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"),
-                              &request_parallelism), 
-    GNUNET_GETOPT_option_flag ('R',
-                              "recursive",
-                              gettext_noop ("download a GNUnet directory recursively"),
-                              &do_recursive),
-    GNUNET_GETOPT_option_increment_uint ('V',
-                                        "verbose",
-                                        gettext_noop ("be verbose (print progress information)"),
-                                        &verbose), 
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_uint ('a',
+                                "anonymity",
+                                "LEVEL",
+                                gettext_noop (
+                                  "set the desired LEVEL of receiver-anonymity"),
+                                &anonymity),
+
+     GNUNET_GETOPT_option_flag (
+       'D',
+       "delete-incomplete",
+       gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
+       &delete_incomplete),
+
+     GNUNET_GETOPT_option_flag (
+       'n',
+       "no-network",
+       gettext_noop ("only search the local peer (no P2P network search)"),
+       &local_only),
+     GNUNET_GETOPT_option_string ('o',
+                                  "output",
+                                  "FILENAME",
+                                  gettext_noop ("write the file to FILENAME"),
+                                  &filename),
+     GNUNET_GETOPT_option_uint (
+       'p',
+       "parallelism",
+       "DOWNLOADS",
+       gettext_noop (
+         "set the maximum number of parallel downloads that is allowed"),
+       &parallelism),
+     GNUNET_GETOPT_option_uint (
+       'r',
+       "request-parallelism",
+       "REQUESTS",
+       gettext_noop (
+         "set the maximum number of parallel requests for blocks that is allowed"),
+       &request_parallelism),
+     GNUNET_GETOPT_option_flag ('R',
+                                "recursive",
+                                gettext_noop (
+                                  "download a GNUnet directory recursively"),
+                                &do_recursive),
+     GNUNET_GETOPT_option_increment_uint (
+       'V',
+       "verbose",
+       gettext_noop ("be verbose (print progress information)"),
+       &verbose),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv,
-                            "gnunet-download [OPTIONS] URI",
-                            gettext_noop
-                            ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"),
-                            options,
-                            &run, NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+  ret =
+    (GNUNET_OK ==
+     GNUNET_PROGRAM_run (
+       argc,
+       argv,
+       "gnunet-download [OPTIONS] URI",
+       gettext_noop (
+         "Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"),
+       options,
+       &run,
+       NULL))
+      ? ret
+      : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 26970c06ad6ae077e137f27a4f8b7bdd3fd41ccb..ad2a8d6c5391f79b5d595d5ee09e64bfeb44c3b3 100644 (file)
@@ -55,7 +55,9 @@ static unsigned int verbose;
  * @return GNUNET_OK to continue iteration
  */
 static int
-print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * file_id)
+print_indexed (void *cls,
+               const char *filename,
+               const struct GNUNET_HashCode *file_id)
 {
   if (NULL == filename)
   {
@@ -64,9 +66,9 @@ print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * f
     return GNUNET_OK;
   }
   if (verbose)
-    FPRINTF (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
+    fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
   else
-    FPRINTF (stdout, "%s\n", filename);
+    fprintf (stdout, "%s\n", filename);
   return GNUNET_OK;
 }
 
@@ -80,12 +82,18 @@ print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * f
  * @param cfg configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   if (list_indexed_files)
   {
-    fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE,
+    fs = GNUNET_FS_start (cfg,
+                          "gnunet-fs",
+                          NULL,
+                          NULL,
+                          GNUNET_FS_FLAGS_NONE,
                           GNUNET_FS_OPTIONS_END);
     if (NULL == fs)
     {
@@ -115,21 +123,27 @@ main (int argc, char *const *argv)
   struct GNUNET_GETOPT_CommandLineOption options[] = {
 
     GNUNET_GETOPT_option_flag ('i',
-                                  "list-indexed",
-                                  gettext_noop ("print a list of all indexed files"),
-                                  &list_indexed_files),
+                               "list-indexed",
+                               gettext_noop (
+                                 "print a list of all indexed files"),
+                               &list_indexed_files),
 
     GNUNET_GETOPT_option_verbose (&verbose),
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
-                            gettext_noop ("Special file-sharing operations"),
-                            options, &run, NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+         GNUNET_PROGRAM_run (argc,
+                             argv,
+                             "gnunet-fs [OPTIONS]",
+                             gettext_noop ("Special file-sharing operations"),
+                             options,
+                             &run,
+                             NULL))
+          ? ret
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index fefb33e147da1a2dee47779f08d4ce24ceb48c40..dcb4b47cdd30c90ef44645dabb7c2dac33d60842 100644 (file)
@@ -78,7 +78,6 @@ struct ScanTreeNode
    * #GNUNET_YES if this is a directory
    */
   int is_directory;
-
 };
 
 
@@ -124,20 +123,30 @@ add_to_md (void *cls,
 {
   struct GNUNET_CONTAINER_MetaData *md = cls;
 
-  if ( ((EXTRACTOR_METAFORMAT_UTF8 == format) ||
-       (EXTRACTOR_METAFORMAT_C_STRING == format)) &&
-       ('\0' != data[data_len - 1]) )
+  if (((EXTRACTOR_METAFORMAT_UTF8 == format) ||
+       (EXTRACTOR_METAFORMAT_C_STRING == format)) &&
+      ('\0' != data[data_len - 1]))
   {
     char zdata[data_len + 1];
     GNUNET_memcpy (zdata, data, data_len);
     zdata[data_len] = '\0';
-    (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format,
-                                             data_mime_type, zdata, data_len + 1);
+    (void) GNUNET_CONTAINER_meta_data_insert (md,
+                                              plugin_name,
+                                              type,
+                                              format,
+                                              data_mime_type,
+                                              zdata,
+                                              data_len + 1);
   }
   else
   {
-    (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format,
-                                             data_mime_type, data, data_len);
+    (void) GNUNET_CONTAINER_meta_data_insert (md,
+                                              plugin_name,
+                                              type,
+                                              format,
+                                              data_mime_type,
+                                              data,
+                                              data_len);
   }
   return 0;
 }
@@ -158,8 +167,8 @@ free_tree (struct ScanTreeNode *tree)
     free_tree (pos);
   if (NULL != tree->parent)
     GNUNET_CONTAINER_DLL_remove (tree->parent->children_head,
-                                tree->parent->children_tail,
-                                tree);
+                                 tree->parent->children_tail,
+                                 tree);
   GNUNET_free (tree->filename);
   GNUNET_free (tree);
 }
@@ -173,8 +182,7 @@ free_tree (struct ScanTreeNode *tree)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 static int
-write_all (const void *buf,
-          size_t size)
+write_all (const void *buf, size_t size)
 {
   const char *cbuf = buf;
   size_t total;
@@ -183,16 +191,14 @@ write_all (const void *buf,
   total = 0;
   do
   {
-    wr = write (output_stream,
-               &cbuf[total],
-               size - total);
+    wr = write (output_stream, &cbuf[total], size - total);
     if (wr > 0)
       total += wr;
-  } while ( (wr > 0) && (total < size) );
+  } while ((wr > 0) && (total < size));
   if (wr <= 0)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Failed to write to stdout: %s\n",
-               strerror (errno));
+                "Failed to write to stdout: %s\n",
+                strerror (errno));
   return (total == size) ? GNUNET_OK : GNUNET_SYSERR;
 }
 
@@ -206,9 +212,7 @@ write_all (const void *buf,
  * @return #GNUNET_SYSERR to stop scanning (the pipe was broken somehow)
  */
 static int
-write_message (uint16_t message_type,
-              const char *data,
-              size_t data_length)
+write_message (uint16_t message_type, const char *data, size_t data_length)
 {
   struct GNUNET_MessageHeader hdr;
 
@@ -220,12 +224,8 @@ write_message (uint16_t message_type,
 #endif
   hdr.type = htons (message_type);
   hdr.size = htons (sizeof (struct GNUNET_MessageHeader) + data_length);
-  if ( (GNUNET_OK !=
-       write_all (&hdr,
-                  sizeof (hdr))) ||
-       (GNUNET_OK !=
-       write_all (data,
-                  data_length)) )
+  if ((GNUNET_OK != write_all (&hdr, sizeof (hdr))) ||
+      (GNUNET_OK != write_all (data, data_length)))
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
@@ -242,8 +242,7 @@ write_message (uint16_t message_type,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 static int
-preprocess_file (const char *filename,
-                struct ScanTreeNode **dst);
+preprocess_file (const char *filename, struct ScanTreeNode **dst);
 
 
 /**
@@ -273,15 +272,12 @@ struct RecursionContext
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 static int
-scan_callback (void *cls,
-              const char *filename)
+scan_callback (void *cls, const char *filename)
 {
   struct RecursionContext *rc = cls;
   struct ScanTreeNode *chld;
 
-  if (GNUNET_OK !=
-      preprocess_file (filename,
-                      &chld))
+  if (GNUNET_OK != preprocess_file (filename, &chld))
   {
     rc->stop = GNUNET_YES;
     return GNUNET_SYSERR;
@@ -290,8 +286,8 @@ scan_callback (void *cls,
     return GNUNET_OK;
   chld->parent = rc->parent;
   GNUNET_CONTAINER_DLL_insert (rc->parent->children_head,
-                              rc->parent->children_tail,
-                              chld);
+                               rc->parent->children_tail,
+                               chld);
   return GNUNET_OK;
 }
 
@@ -307,22 +303,23 @@ scan_callback (void *cls,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 static int
-preprocess_file (const char *filename,
-                struct ScanTreeNode **dst)
+preprocess_file (const char *filename, struct ScanTreeNode **dst)
 {
   struct ScanTreeNode *item;
   struct stat sbuf;
   uint64_t fsize = 0;
 
-  if ((0 != STAT (filename, &sbuf)) ||
-      ((!S_ISDIR (sbuf.st_mode)) && (GNUNET_OK != GNUNET_DISK_file_size (
-      filename, &fsize, GNUNET_NO, GNUNET_YES))))
+  if ((0 != stat (filename, &sbuf)) ||
+      ((! S_ISDIR (sbuf.st_mode)) &&
+       (GNUNET_OK !=
+        GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))))
   {
     /* If the file doesn't exist (or is not stat-able for any other reason)
        skip it (but report it), but do continue. */
     if (GNUNET_OK !=
-       write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE,
-                      filename, strlen (filename) + 1))
+        write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE,
+                       filename,
+                       strlen (filename) + 1))
       return GNUNET_SYSERR;
     /* recoverable error, store 'NULL' in *dst */
     *dst = NULL;
@@ -330,11 +327,13 @@ preprocess_file (const char *filename,
   }
 
   /* Report the progress */
-  if (GNUNET_OK !=
-      write_message (S_ISDIR (sbuf.st_mode)
-                    ? GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY
-                    : GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE,
-                    filename, strlen (filename) + 1))
+  if (
+    GNUNET_OK !=
+    write_message (S_ISDIR (sbuf.st_mode)
+                     ? GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY
+                     : GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE,
+                   filename,
+                   strlen (filename) + 1))
     return GNUNET_SYSERR;
   item = GNUNET_new (struct ScanTreeNode);
   item->filename = GNUNET_strdup (filename);
@@ -346,13 +345,13 @@ preprocess_file (const char *filename,
 
     rc.parent = item;
     rc.stop = GNUNET_NO;
-    GNUNET_DISK_directory_scan (filename,
-                               &scan_callback,
-                               &rc);
-    if ( (GNUNET_YES == rc.stop) ||
-        (GNUNET_OK !=
-         write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY,
-                        "..", 3)) )
+    GNUNET_DISK_directory_scan (filename, &scan_callback, &rc);
+    if (
+      (GNUNET_YES == rc.stop) ||
+      (GNUNET_OK !=
+       write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY,
+                      "..",
+                      3)))
     {
       free_tree (item);
       return GNUNET_SYSERR;
@@ -383,20 +382,15 @@ extract_files (struct ScanTreeNode *item)
     struct ScanTreeNode *pos;
 
     for (pos = item->children_head; NULL != pos; pos = pos->next)
-      if (GNUNET_OK !=
-         extract_files (pos))
-       return GNUNET_SYSERR;
+      if (GNUNET_OK != extract_files (pos))
+        return GNUNET_SYSERR;
     return GNUNET_OK;
   }
 
   /* this is the expensive operation, *afterwards* we'll check for aborts */
   meta = GNUNET_CONTAINER_meta_data_create ();
 #if HAVE_LIBEXTRACTOR
-  EXTRACTOR_extract (plugins,
-                     item->filename,
-                     NULL, 0,
-                     &add_to_md,
-                     meta);
+  EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta);
 #endif
   slen = strlen (item->filename) + 1;
   size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
@@ -405,8 +399,9 @@ extract_files (struct ScanTreeNode *item)
     /* no meta data */
     GNUNET_CONTAINER_meta_data_destroy (meta);
     if (GNUNET_OK !=
-       write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
-                      item->filename, slen))
+        write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
+                       item->filename,
+                       slen))
       return GNUNET_SYSERR;
     return GNUNET_OK;
   }
@@ -420,9 +415,11 @@ extract_files (struct ScanTreeNode *item)
     char *dst = &buf[slen];
 
     GNUNET_memcpy (buf, item->filename, slen);
-    size = GNUNET_CONTAINER_meta_data_serialize (meta,
-                                                &dst, size,
-                                                GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+    size = GNUNET_CONTAINER_meta_data_serialize (
+      meta,
+      &dst,
+      size,
+      GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
     if (size < 0)
     {
       GNUNET_break (0);
@@ -430,9 +427,9 @@ extract_files (struct ScanTreeNode *item)
     }
     GNUNET_CONTAINER_meta_data_destroy (meta);
     if (GNUNET_OK !=
-       write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
-                      buf,
-                      slen + size))
+        write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
+                       buf,
+                       slen + size))
       return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -453,13 +450,14 @@ ignore_sigpipe ()
   sig.sa_handler = SIG_IGN;
   sigemptyset (&sig.sa_mask);
 #ifdef SA_INTERRUPT
-  sig.sa_flags = SA_INTERRUPT;  /* SunOS */
+  sig.sa_flags = SA_INTERRUPT; /* SunOS */
 #else
   sig.sa_flags = SA_RESTART;
 #endif
   if (0 != sigaction (SIGPIPE, &sig, &oldsig))
     fprintf (stderr,
-             "Failed to install SIGPIPE handler: %s\n", strerror (errno));
+             "Failed to install SIGPIPE handler: %s\n",
+             strerror (errno));
 }
 
 
@@ -470,8 +468,7 @@ ignore_sigpipe ()
  * @param flags flags to use (O_RDONLY or O_WRONLY)
  */
 static void
-make_dev_zero (int fd,
-              int flags)
+make_dev_zero (int fd, int flags)
 {
   int z;
 
@@ -498,8 +495,7 @@ make_dev_zero (int fd,
  * @return 0 on success
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
   const char *filename_expanded;
   const char *ex;
@@ -524,79 +520,83 @@ main (int argc,
 #endif
 
   /* parse command line */
-  if ( (3 != argc) && (2 != argc) )
+  if ((3 != argc) && (2 != argc))
   {
-    FPRINTF (stderr,
-            "%s",
-            "gnunet-helper-fs-publish needs exactly one or two arguments\n");
+    fprintf (stderr,
+             "%s",
+             "gnunet-helper-fs-publish needs exactly one or two arguments\n");
 #if WINDOWS
-    GNUNET_free ((void*) argv);
+    GNUNET_free ((void *) argv);
 #endif
     return 1;
   }
   filename_expanded = argv[1];
   ex = argv[2];
-  if ( (NULL == ex) ||
-       (0 != strcmp (ex, "-")) )
+  if ((NULL == ex) || (0 != strcmp (ex, "-")))
   {
 #if HAVE_LIBEXTRACTOR
     plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
     if (NULL != ex)
-      plugins = EXTRACTOR_plugin_add_config (plugins, ex,
-                                            EXTRACTOR_OPTION_DEFAULT_POLICY);
+      plugins = EXTRACTOR_plugin_add_config (plugins,
+                                             ex,
+                                             EXTRACTOR_OPTION_DEFAULT_POLICY);
 #endif
   }
 
   /* scan tree to find out how much work there is to be done */
-  if (GNUNET_OK != preprocess_file (filename_expanded,
-                                   &root))
+  if (GNUNET_OK != preprocess_file (filename_expanded, &root))
   {
     (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
 #if HAVE_LIBEXTRACTOR
     EXTRACTOR_plugin_remove_all (plugins);
 #endif
 #if WINDOWS
-    GNUNET_free ((void*) argv);
+    GNUNET_free ((void *) argv);
 #endif
     return 2;
   }
   /* signal that we're done counting files, so that a percentage of
      progress can now be calculated */
   if (GNUNET_OK !=
-      write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0))
+      write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE,
+                     NULL,
+                     0))
   {
 #if HAVE_LIBEXTRACTOR
     EXTRACTOR_plugin_remove_all (plugins);
 #endif
 #if WINDOWS
-    GNUNET_free ((void*) argv);
+    GNUNET_free ((void *) argv);
 #endif
     return 3;
   }
   if (NULL != root)
   {
-    if (GNUNET_OK !=
-       extract_files (root))
+    if (GNUNET_OK != extract_files (root))
     {
-      (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0);
+      (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR,
+                            NULL,
+                            0);
       free_tree (root);
 #if HAVE_LIBEXTRACTOR
       EXTRACTOR_plugin_remove_all (plugins);
 #endif
 #if WINDOWS
-      GNUNET_free ((void*) argv);
+      GNUNET_free ((void *) argv);
 #endif
       return 4;
     }
     free_tree (root);
   }
   /* enable "clean" shutdown by telling parent that we are done */
-  (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0);
+  (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED,
+                        NULL,
+                        0);
 #if HAVE_LIBEXTRACTOR
   EXTRACTOR_plugin_remove_all (plugins);
 #endif
 #if WINDOWS
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
 #endif
   return 0;
 }
index fbf32c2a7ff2aebb217065cc495e3de968e62598..84cbf0aacb92efd2f43b1d246808bc2b466a76cc 100644 (file)
@@ -67,7 +67,7 @@ static struct GNUNET_FS_Uri *topKeywords;
 /**
  * Options we set for published blocks.
  */
-static struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 };
+static struct GNUNET_FS_BlockOptions bo = {{0LL}, 1, 365, 1};
 
 /**
  * Value of URI provided on command-line (when not publishing
@@ -200,8 +200,7 @@ do_stop_task (void *cls)
  *         field in the GNUNET_FS_ProgressInfo struct.
  */
 static void *
-progress_cb (void *cls,
-             const struct GNUNET_FS_ProgressInfo *info)
+progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 {
   const char *s;
   char *suri;
@@ -214,50 +213,51 @@ progress_cb (void *cls,
     if (verbose)
     {
       s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
-                                                 GNUNET_YES);
-      FPRINTF (stdout,
-               _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
+                                                  GNUNET_YES);
+      fprintf (stdout,
+               _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
                info->value.publish.filename,
                (unsigned long long) info->value.publish.completed,
-               (unsigned long long) info->value.publish.size, s);
+               (unsigned long long) info->value.publish.size,
+               s);
     }
     break;
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY:
     if (verbose)
     {
-      s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics.progress_directory.eta,
-                                                 GNUNET_YES);
-      FPRINTF (stdout,
-               _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
+      s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics
+                                                    .progress_directory.eta,
+                                                  GNUNET_YES);
+      fprintf (stdout,
+               _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
                info->value.publish.filename,
-               (unsigned long long) info->value.publish.specifics.progress_directory.completed,
-               (unsigned long long) info->value.publish.specifics.progress_directory.total, s);
+               (unsigned long long)
+                 info->value.publish.specifics.progress_directory.completed,
+               (unsigned long long)
+                 info->value.publish.specifics.progress_directory.total,
+               s);
     }
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr,
-             _("Error publishing: %s.\n"),
+    fprintf (stderr,
+             _ ("Error publishing: %s.\n"),
              info->value.publish.specifics.error.message);
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
-    FPRINTF (stdout,
-             _("Publishing `%s' done.\n"),
+    fprintf (stdout,
+             _ ("Publishing `%s' done.\n"),
              info->value.publish.filename);
-    suri = GNUNET_FS_uri_to_string (info->value.publish.specifics.
-                                    completed.chk_uri);
-    FPRINTF (stdout,
-             _("URI is `%s'.\n"),
-             suri);
+    suri =
+      GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
+    fprintf (stdout, _ ("URI is `%s'.\n"), suri);
     GNUNET_free (suri);
     if (NULL != info->value.publish.specifics.completed.sks_uri)
     {
-      suri = GNUNET_FS_uri_to_string (info->value.publish.specifics.
-                                      completed.sks_uri);
-      FPRINTF (stdout,
-               _("Namespace URI is `%s'.\n"),
-               suri);
+      suri = GNUNET_FS_uri_to_string (
+        info->value.publish.specifics.completed.sks_uri);
+      fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri);
       GNUNET_free (suri);
     }
     if (NULL == info->value.publish.pctx)
@@ -270,33 +270,25 @@ progress_cb (void *cls,
     GNUNET_break (NULL == pc);
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_START:
-    FPRINTF (stderr,
-             "%s",
-             _("Starting cleanup after abort\n"));
+    fprintf (stderr, "%s", _ ("Starting cleanup after abort\n"));
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
-    FPRINTF (stderr,
-             "%s",
-             _("Cleanup after abort completed.\n"));
+    fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n"));
     GNUNET_FS_unindex_stop (info->value.unindex.uc);
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
-    FPRINTF (stderr,
-             "%s",
-             _("Cleanup after abort failed.\n"));
+    fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n"));
     GNUNET_FS_unindex_stop (info->value.unindex.uc);
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
     return NULL;
   default:
-    FPRINTF (stderr,
-             _("Unexpected status: %d\n"),
-             info->status);
+    fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
     return NULL;
   }
-  return "";                    /* non-null */
+  return ""; /* non-null */
 }
 
 
@@ -319,7 +311,8 @@ meta_printer (void *cls,
               enum EXTRACTOR_MetaType type,
               enum EXTRACTOR_MetaFormat format,
               const char *data_mime_type,
-              const char *data, size_t data_size)
+              const char *data,
+              size_t data_size)
 {
   if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
       (EXTRACTOR_METAFORMAT_C_STRING != format))
@@ -327,15 +320,9 @@ meta_printer (void *cls,
   if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type)
     return 0;
 #if HAVE_LIBEXTRACTOR
-  FPRINTF (stdout,
-           "\t%s - %s\n",
-           EXTRACTOR_metatype_to_string (type),
-           data);
+  fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
 #else
-  FPRINTF (stdout,
-           "\t%d - %s\n",
-           type,
-           data);
+  fprintf (stdout, "\t%d - %s\n", type, data);
 #endif
   return 0;
 }
@@ -350,11 +337,9 @@ meta_printer (void *cls,
  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort
  */
 static int
-keyword_printer (void *cls,
-                 const char *keyword,
-                 int is_mandatory)
+keyword_printer (void *cls, const char *keyword, int is_mandatory)
 {
-  FPRINTF (stdout, "\t%s\n", keyword);
+  fprintf (stdout, "\t%s\n", keyword);
   return GNUNET_OK;
 }
 
@@ -392,8 +377,7 @@ publish_inspector (void *cls,
 
   if (cls == fi)
     return GNUNET_OK;
-  if ( (disable_extractor) &&
-       (NULL != *uri) )
+  if ((disable_extractor) && (NULL != *uri))
   {
     GNUNET_FS_uri_destroy (*uri);
     *uri = NULL;
@@ -423,29 +407,21 @@ publish_inspector (void *cls,
     GNUNET_CONTAINER_meta_data_add_publication_date (m);
   if (extract_only)
   {
-    fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
-                                                 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+    fn = GNUNET_CONTAINER_meta_data_get_by_type (
+      m,
+      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
     fs = GNUNET_STRINGS_byte_size_fancy (length);
-    FPRINTF (stdout,
-             _("Meta data for file `%s' (%s)\n"),
-             fn,
-             fs);
+    fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
     GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
-    FPRINTF (stdout,
-             _("Keywords for file `%s' (%s)\n"),
-             fn,
-             fs);
+    fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
     GNUNET_free (fn);
     GNUNET_free (fs);
     if (NULL != *uri)
       GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL);
-    FPRINTF (stdout,
-             "%s",
-             "\n");
+    fprintf (stdout, "%s", "\n");
   }
   if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
-    GNUNET_FS_file_information_inspect (fi,
-                                        &publish_inspector, fi);
+    GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi);
   return GNUNET_OK;
 }
 
@@ -466,9 +442,7 @@ uri_sks_continuation (void *cls,
 {
   if (NULL != emsg)
   {
-    FPRINTF (stderr,
-             "%s\n",
-             emsg);
+    fprintf (stderr, "%s\n", emsg);
     ret = 1;
   }
   GNUNET_SCHEDULER_shutdown ();
@@ -493,9 +467,7 @@ uri_ksk_continuation (void *cls,
 
   if (NULL != emsg)
   {
-    FPRINTF (stderr,
-             "%s\n",
-             emsg);
+    fprintf (stderr, "%s\n", emsg);
     ret = 1;
   }
   if (NULL == namespace)
@@ -505,15 +477,15 @@ uri_ksk_continuation (void *cls,
   }
   priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
   GNUNET_FS_publish_sks (ctx,
-                        priv,
-                        this_id,
-                        next_id,
-                        meta,
-                        uri,
-                        &bo,
-                        GNUNET_FS_PUBLISH_OPTION_NONE,
-                        &uri_sks_continuation,
-                        NULL);
+                         priv,
+                         this_id,
+                         next_id,
+                         meta,
+                         uri,
+                         &bo,
+                         GNUNET_FS_PUBLISH_OPTION_NONE,
+                         &uri_sks_continuation,
+                         NULL);
 }
 
 
@@ -536,8 +508,9 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
     if (NULL == item->meta)
       item->meta = GNUNET_CONTAINER_meta_data_create ();
     GNUNET_CONTAINER_meta_data_delete (item->meta,
-                                      EXTRACTOR_METATYPE_MIMETYPE,
-                                      NULL, 0);
+                                       EXTRACTOR_METATYPE_MIMETYPE,
+                                       NULL,
+                                       0);
     GNUNET_FS_meta_data_make_directory (item->meta);
     if (NULL == item->ksk_uri)
     {
@@ -545,12 +518,15 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
       item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime);
     }
     else
-      GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
-                                    GNUNET_NO);
-    fi = GNUNET_FS_file_information_create_empty_directory (ctx, NULL,
-                                                           item->ksk_uri,
-                                                           item->meta,
-                                                           &bo, item->filename);
+      GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri,
+                                     GNUNET_FS_DIRECTORY_MIME,
+                                     GNUNET_NO);
+    fi = GNUNET_FS_file_information_create_empty_directory (ctx,
+                                                            NULL,
+                                                            item->ksk_uri,
+                                                            item->meta,
+                                                            &bo,
+                                                            item->filename);
     for (child = item->children_head; child; child = child->next)
     {
       fic = get_file_information (child);
@@ -559,11 +535,13 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
   }
   else
   {
-    fi = GNUNET_FS_file_information_create_from_file (ctx, NULL,
-                                                     item->filename,
-                                                     item->ksk_uri, item->meta,
-                                                     !do_insert,
-                                                     &bo);
+    fi = GNUNET_FS_file_information_create_from_file (ctx,
+                                                      NULL,
+                                                      item->filename,
+                                                      item->ksk_uri,
+                                                      item->meta,
+                                                      ! do_insert,
+                                                      &bo);
   }
   return fi;
 }
@@ -585,9 +563,7 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
   GNUNET_FS_share_tree_free (directory_scan_result);
   if (NULL == fi)
   {
-    FPRINTF (stderr,
-             "%s",
-             _("Could not publish\n"));
+    fprintf (stderr, "%s", _ ("Could not publish\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -603,16 +579,17 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
     priv = NULL;
   else
     priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
-  pc = GNUNET_FS_publish_start (ctx, fi,
-                               priv, this_id, next_id,
-                                (do_simulate) ?
-                                GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY :
-                                GNUNET_FS_PUBLISH_OPTION_NONE);
+  pc = GNUNET_FS_publish_start (ctx,
+                                fi,
+                                priv,
+                                this_id,
+                                next_id,
+                                (do_simulate)
+                                  ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
+                                  : GNUNET_FS_PUBLISH_OPTION_NONE);
   if (NULL == pc)
   {
-    FPRINTF (stderr,
-             "%s",
-             _("Could not start publishing.\n"));
+    fprintf (stderr, "%s", _ ("Could not start publishing.\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -633,9 +610,9 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
  */
 static void
 directory_scan_cb (void *cls,
-                  const char *filename,
-                  int is_directory,
-                  enum GNUNET_FS_DirScannerProgressUpdateReason reason)
+                   const char *filename,
+                   int is_directory,
+                   enum GNUNET_FS_DirScannerProgressUpdateReason reason)
 {
   struct GNUNET_FS_ShareTreeItem *directory_scan_result;
 
@@ -645,46 +622,36 @@ directory_scan_cb (void *cls,
     if (verbose > 1)
     {
       if (is_directory == GNUNET_YES)
-       FPRINTF (stdout,
-                 _("Scanning directory `%s'.\n"),
-                 filename);
+        fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename);
       else
-       FPRINTF (stdout,
-                 _("Scanning file `%s'.\n"),
-                 filename);
+        fprintf (stdout, _ ("Scanning file `%s'.\n"), filename);
     }
     break;
   case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
-    FPRINTF (stderr,
-            _("There was trouble processing file `%s', skipping it.\n"),
-            filename);
+    fprintf (stderr,
+             _ ("There was trouble processing file `%s', skipping it.\n"),
+             filename);
     break;
   case GNUNET_FS_DIRSCANNER_ALL_COUNTED:
     if (verbose)
-      FPRINTF (stdout,
-               "%s",
-               _("Preprocessing complete.\n"));
+      fprintf (stdout, "%s", _ ("Preprocessing complete.\n"));
     break;
   case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
     if (verbose > 2)
-      FPRINTF (stdout,
-               _("Extracting meta data from file `%s' complete.\n"),
+      fprintf (stdout,
+               _ ("Extracting meta data from file `%s' complete.\n"),
                filename);
     break;
   case GNUNET_FS_DIRSCANNER_FINISHED:
     if (verbose > 1)
-      FPRINTF (stdout,
-               "%s",
-               _("Meta data extraction has finished.\n"));
+      fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n"));
     directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
     ds = NULL;
     GNUNET_FS_share_tree_trim (directory_scan_result);
     directory_trim_complete (directory_scan_result);
     break;
   case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
-    FPRINTF (stdout,
-             "%s",
-             _("Error scanning directory.\n"));
+    fprintf (stdout, "%s", _ ("Error scanning directory.\n"));
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     break;
@@ -708,12 +675,9 @@ identity_continuation (const char *args0)
   char *ex;
   char *emsg;
 
-  if ( (NULL != pseudonym) &&
-       (NULL == namespace) )
+  if ((NULL != pseudonym) && (NULL == namespace))
   {
-    FPRINTF (stderr,
-             _("Selected pseudonym `%s' unknown\n"),
-             pseudonym);
+    fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym);
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -723,17 +687,16 @@ identity_continuation (const char *args0)
     emsg = NULL;
     if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
     {
-      FPRINTF (stderr,
-               _("Failed to parse URI: %s\n"),
-               emsg);
+      fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg);
       GNUNET_free (emsg);
       ret = 1;
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
     GNUNET_FS_publish_ksk (ctx,
-                          topKeywords,
-                           meta, uri,
+                           topKeywords,
+                           meta,
+                           uri,
                            &bo,
                            GNUNET_FS_PUBLISH_OPTION_NONE,
                            &uri_ksk_continuation,
@@ -743,24 +706,27 @@ identity_continuation (const char *args0)
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
     ex = NULL;
-  if (0 != ACCESS (args0, R_OK))
+  if (0 != access (args0, R_OK))
   {
-    FPRINTF (stderr,
-            _("Failed to access `%s': %s\n"),
-            args0,
-            STRERROR (errno));
+    fprintf (stderr,
+             _ ("Failed to access `%s': %s\n"),
+             args0,
+             strerror (errno));
     GNUNET_free_non_null (ex);
     return;
   }
   ds = GNUNET_FS_directory_scan_start (args0,
-                                      disable_extractor,
-                                      ex,
-                                      &directory_scan_cb, NULL);
+                                       disable_extractor,
+                                       ex,
+                                       &directory_scan_cb,
+                                       NULL);
   if (NULL == ds)
   {
-    FPRINTF (stderr,
-            "%s",
-             _("Failed to start meta directory scanner.  Is gnunet-helper-publish-fs installed?\n"));
+    fprintf (
+      stderr,
+      "%s",
+      _ (
+        "Failed to start meta directory scanner.  Is gnunet-helper-publish-fs installed?\n"));
     GNUNET_free_non_null (ex);
     return;
   }
@@ -781,9 +747,9 @@ identity_continuation (const char *args0)
  */
 static void
 identity_cb (void *cls,
-            struct GNUNET_IDENTITY_Ego *ego,
-            void **ctx,
-            const char *name)
+             struct GNUNET_IDENTITY_Ego *ego,
+             void **ctx,
+             const char *name)
 {
   const char *args0 = cls;
 
@@ -795,7 +761,7 @@ identity_cb (void *cls,
   if (NULL == name)
     return;
   if (0 == strcmp (name, pseudonym))
-    namespace = ego;
+  namespace = ego;
 }
 
 
@@ -816,20 +782,20 @@ run (void *cls,
   /* check arguments */
   if ((NULL != uri_string) && (extract_only))
   {
-    printf (_("Cannot extract metadata from a URI!\n"));
+    printf (_ ("Cannot extract metadata from a URI!\n"));
     ret = -1;
     return;
   }
   if (((NULL == uri_string) || (extract_only)) &&
       ((NULL == args[0]) || (NULL != args[1])))
   {
-    printf (_("You must specify one and only one filename for insertion.\n"));
+    printf (_ ("You must specify one and only one filename for insertion.\n"));
     ret = -1;
     return;
   }
   if ((NULL != uri_string) && (NULL != args[0]))
   {
-    printf (_("You must NOT specify an URI and a filename.\n"));
+    printf (_ ("You must NOT specify an URI and a filename.\n"));
     ret = -1;
     return;
   }
@@ -837,49 +803,51 @@ run (void *cls,
   {
     if (NULL == this_id)
     {
-      FPRINTF (stderr, _("Option `%s' is required when using option `%s'.\n"),
-               "-t", "-P");
+      fprintf (stderr,
+               _ ("Option `%s' is required when using option `%s'.\n"),
+               "-t",
+               "-P");
       ret = -1;
       return;
     }
   }
   else
-  {                             /* ordinary insertion checks */
+  { /* ordinary insertion checks */
     if (NULL != next_id)
     {
-      FPRINTF (stderr,
-               _("Option `%s' makes no sense without option `%s'.\n"),
-               "-N", "-P");
+      fprintf (stderr,
+               _ ("Option `%s' makes no sense without option `%s'.\n"),
+               "-N",
+               "-P");
       ret = -1;
       return;
     }
     if (NULL != this_id)
     {
-      FPRINTF (stderr,
-               _("Option `%s' makes no sense without option `%s'.\n"),
-               "-t", "-P");
+      fprintf (stderr,
+               _ ("Option `%s' makes no sense without option `%s'.\n"),
+               "-t",
+               "-P");
       ret = -1;
       return;
     }
   }
   cfg = c;
-  ctx =
-      GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL,
-                       GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
+  ctx = GNUNET_FS_start (cfg,
+                         "gnunet-publish",
+                         &progress_cb,
+                         NULL,
+                         GNUNET_FS_FLAGS_NONE,
+                         GNUNET_FS_OPTIONS_END);
   if (NULL == ctx)
   {
-    FPRINTF (stderr,
-             _("Could not initialize `%s' subsystem.\n"),
-             "FS");
+    fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
     ret = 1;
     return;
   }
-  GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_stop_task, NULL);
   if (NULL != pseudonym)
-    identity = GNUNET_IDENTITY_connect (cfg,
-                                       &identity_cb,
-                                        args[0]);
+    identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, args[0]);
   else
     identity_continuation (args[0]);
 }
@@ -893,104 +861,120 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_uint ('a',
-                               "anonymity",
-                               "LEVEL",
-                               gettext_noop ("set the desired LEVEL of sender-anonymity"),
-                               &bo.anonymity_level),
-    GNUNET_GETOPT_option_flag ('D',
-                               "disable-extractor",
-                               gettext_noop ("do not use libextractor to add keywords or metadata"),
-                               &disable_extractor),
-    GNUNET_GETOPT_option_flag ('E',
-                               "enable-creation-time",
-                               gettext_noop ("enable adding the creation time to the "
-                                             "metadata of the uploaded file"),
-                               &enable_creation_time),
-    GNUNET_GETOPT_option_flag ('e',
-                               "extract",
-                               gettext_noop ("print list of extracted keywords that would "
-                                             "be used, but do not perform upload"),
-                               &extract_only),
-    GNUNET_FS_GETOPT_KEYWORDS ('k',
-                               "key",
-                               "KEYWORD",
-                               gettext_noop ("add an additional keyword for the top-level "
-                                             "file or directory (this option can be specified multiple times)"),
-                               &topKeywords),
-    GNUNET_FS_GETOPT_METADATA ('m',
-                               "meta",
-                               "TYPE:VALUE",
-                               gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
-                               &meta),
-    GNUNET_GETOPT_option_flag ('n',
-                              "noindex",
-                              gettext_noop ("do not index, perform full insertion (stores "
-                                            "entire file in encrypted form in GNUnet database)"),
-                              &do_insert),
-    GNUNET_GETOPT_option_string ('N',
-                                 "next",
-                                 "ID",
-                                 gettext_noop ("specify ID of an updated version to be "
-                                               "published in the future (for namespace insertions only)"),
-                                 &next_id),
-    GNUNET_GETOPT_option_uint ('p',
-                              "priority",
-                              "PRIORITY",
-                              gettext_noop ("specify the priority of the content"),
-                              &bo.content_priority),
-    GNUNET_GETOPT_option_string ('P',
-                                 "pseudonym",
-                                 "NAME",
-                                 gettext_noop ("publish the files under the pseudonym "
-                                               "NAME (place file into namespace)"),
-                                 &pseudonym),
-    GNUNET_GETOPT_option_uint ('r',
-                               "replication",
-                               "LEVEL",
-                               gettext_noop ("set the desired replication LEVEL"),
-                               &bo.replication_level),
-    GNUNET_GETOPT_option_flag ('s',
-                               "simulate-only",
-                               gettext_noop ("only simulate the process but do not do "
-                                             "any actual publishing (useful to compute URIs)"),
-                               &do_simulate),
-    GNUNET_GETOPT_option_string ('t',
-                                 "this",
-                                 "ID",
-                                 gettext_noop ("set the ID of this version of the publication "
-                                               "(for namespace insertions only)"),
-                                 &this_id),
-    GNUNET_GETOPT_option_string ('u',
-                                 "uri",
-                                 "URI",
-                                 gettext_noop ("URI to be published (can be used instead of passing a "
-                                               "file to add keywords to the file with the respective URI)"),
-                                 &uri_string),
-
-    GNUNET_GETOPT_option_verbose (&verbose),
-
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_uint ('a',
+                                "anonymity",
+                                "LEVEL",
+                                gettext_noop (
+                                  "set the desired LEVEL of sender-anonymity"),
+                                &bo.anonymity_level),
+     GNUNET_GETOPT_option_flag (
+       'D',
+       "disable-extractor",
+       gettext_noop ("do not use libextractor to add keywords or metadata"),
+       &disable_extractor),
+     GNUNET_GETOPT_option_flag ('E',
+                                "enable-creation-time",
+                                gettext_noop (
+                                  "enable adding the creation time to the "
+                                  "metadata of the uploaded file"),
+                                &enable_creation_time),
+     GNUNET_GETOPT_option_flag ('e',
+                                "extract",
+                                gettext_noop (
+                                  "print list of extracted keywords that would "
+                                  "be used, but do not perform upload"),
+                                &extract_only),
+     GNUNET_FS_GETOPT_KEYWORDS (
+       'k',
+       "key",
+       "KEYWORD",
+       gettext_noop (
+         "add an additional keyword for the top-level "
+         "file or directory (this option can be specified multiple times)"),
+       &topKeywords),
+     GNUNET_FS_GETOPT_METADATA (
+       'm',
+       "meta",
+       "TYPE:VALUE",
+       gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
+       &meta),
+     GNUNET_GETOPT_option_flag (
+       'n',
+       "noindex",
+       gettext_noop ("do not index, perform full insertion (stores "
+                     "entire file in encrypted form in GNUnet database)"),
+       &do_insert),
+     GNUNET_GETOPT_option_string (
+       'N',
+       "next",
+       "ID",
+       gettext_noop ("specify ID of an updated version to be "
+                     "published in the future (for namespace insertions only)"),
+       &next_id),
+     GNUNET_GETOPT_option_uint ('p',
+                                "priority",
+                                "PRIORITY",
+                                gettext_noop (
+                                  "specify the priority of the content"),
+                                &bo.content_priority),
+     GNUNET_GETOPT_option_string ('P',
+                                  "pseudonym",
+                                  "NAME",
+                                  gettext_noop (
+                                    "publish the files under the pseudonym "
+                                    "NAME (place file into namespace)"),
+                                  &pseudonym),
+     GNUNET_GETOPT_option_uint ('r',
+                                "replication",
+                                "LEVEL",
+                                gettext_noop (
+                                  "set the desired replication LEVEL"),
+                                &bo.replication_level),
+     GNUNET_GETOPT_option_flag ('s',
+                                "simulate-only",
+                                gettext_noop (
+                                  "only simulate the process but do not do "
+                                  "any actual publishing (useful to compute URIs)"),
+                                &do_simulate),
+     GNUNET_GETOPT_option_string ('t',
+                                  "this",
+                                  "ID",
+                                  gettext_noop (
+                                    "set the ID of this version of the publication "
+                                    "(for namespace insertions only)"),
+                                  &this_id),
+     GNUNET_GETOPT_option_string (
+       'u',
+       "uri",
+       "URI",
+       gettext_noop (
+         "URI to be published (can be used instead of passing a "
+         "file to add keywords to the file with the respective URI)"),
+       &uri_string),
+
+     GNUNET_GETOPT_option_verbose (&verbose),
+
+     GNUNET_GETOPT_OPTION_END};
   bo.expiration_time =
-      GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2);
+    GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2);
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc,
-                            argv,
-                            "gnunet-publish [OPTIONS] FILENAME",
-                            gettext_noop
-                            ("Publish a file or directory on GNUnet"),
-                            options,
-                            &run,
-                            NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+  ret =
+    (GNUNET_OK ==
+     GNUNET_PROGRAM_run (argc,
+                         argv,
+                         "gnunet-publish [OPTIONS] FILENAME",
+                         gettext_noop ("Publish a file or directory on GNUnet"),
+                         options,
+                         &run,
+                         NULL))
+      ? ret
+      : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 3995b1b5b405161ff3c31a989fb789f6ab6ce682..7d6ff4c6b732549a9cd382ffe510e573a609066c 100644 (file)
@@ -92,11 +92,10 @@ item_printer (void *cls,
 #if HAVE_LIBEXTRACTOR
   printf ("\t%20s: %s\n",
           dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN,
-                    EXTRACTOR_metatype_to_string (type)), data);
-#else
-  printf ("\t%20d: %s\n",
-          type,
+                    EXTRACTOR_metatype_to_string (type)),
           data);
+#else
+  printf ("\t%20d: %s\n", type, data);
 #endif
   return 0;
 }
@@ -118,13 +117,14 @@ clean_task (void *cls)
     GNUNET_free (output_filename);
     return;
   }
-  if (dsize !=
-      GNUNET_DISK_fn_write (output_filename, ddata, dsize,
-                            GNUNET_DISK_PERM_USER_READ |
-                            GNUNET_DISK_PERM_USER_WRITE))
+  if (dsize != GNUNET_DISK_fn_write (output_filename,
+                                     ddata,
+                                     dsize,
+                                     GNUNET_DISK_PERM_USER_READ |
+                                       GNUNET_DISK_PERM_USER_WRITE))
   {
-    FPRINTF (stderr,
-             _("Failed to write directory with search results to `%s'\n"),
+    fprintf (stderr,
+             _ ("Failed to write directory with search results to `%s'\n"),
              output_filename);
   }
   GNUNET_free_non_null (ddata);
@@ -165,31 +165,35 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
                                        NULL);
     uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri);
     printf ("#%u:\n", ++cnt);
-    filename =
-        GNUNET_CONTAINER_meta_data_get_by_type (info->value.search.
-                                                specifics.result.meta,
-                                                EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
-    is_directory =
-        GNUNET_FS_meta_data_test_for_directory (info->value.search.
-                                                specifics.result.meta);
+    filename = GNUNET_CONTAINER_meta_data_get_by_type (
+      info->value.search.specifics.result.meta,
+      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
+    is_directory = GNUNET_FS_meta_data_test_for_directory (
+      info->value.search.specifics.result.meta);
     if (NULL != filename)
     {
-      while ( (filename[0] != '\0') &&
-             ('/' == filename[strlen(filename)-1]) )
-       filename[strlen(filename)-1] = '\0';
+      while ((filename[0] != '\0') && ('/' == filename[strlen (filename) - 1]))
+        filename[strlen (filename) - 1] = '\0';
       GNUNET_DISK_filename_canonicalize (filename);
       if (GNUNET_YES == is_directory)
-        printf ("gnunet-download -o \"%s%s\" -R %s\n", filename, GNUNET_FS_DIRECTORY_EXT, uri);
+        printf ("gnunet-download -o \"%s%s\" -R %s\n",
+                filename,
+                GNUNET_FS_DIRECTORY_EXT,
+                uri);
       else
         printf ("gnunet-download -o \"%s\" %s\n", filename, uri);
     }
     else if (GNUNET_YES == is_directory)
-      printf ("gnunet-download -o \"collection%s\" -R %s\n", GNUNET_FS_DIRECTORY_EXT, uri);
+      printf ("gnunet-download -o \"collection%s\" -R %s\n",
+              GNUNET_FS_DIRECTORY_EXT,
+              uri);
     else
       printf ("gnunet-download %s\n", uri);
     if (verbose)
-      GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics.
-                                          result.meta, &item_printer, NULL);
+      GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics.result
+                                            .meta,
+                                          &item_printer,
+                                          NULL);
     printf ("\n");
     fflush (stdout);
     GNUNET_free_non_null (filename);
@@ -204,7 +208,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
     /* ignore */
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, _("Error searching: %s.\n"),
+    fprintf (stderr,
+             _ ("Error searching: %s.\n"),
              info->value.search.specifics.error.message);
     GNUNET_SCHEDULER_shutdown ();
     break;
@@ -212,7 +217,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
     GNUNET_SCHEDULER_add_now (&clean_task, NULL);
     break;
   default:
-    FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+    fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
     break;
   }
   return NULL;
@@ -247,7 +252,9 @@ timeout_task (void *cls)
  * @param c configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   struct GNUNET_FS_Uri *uri;
@@ -260,17 +267,22 @@ run (void *cls, char *const *args, const char *cfgfile,
   uri = GNUNET_FS_uri_ksk_create_from_args (argc, (const char **) args);
   if (NULL == uri)
   {
-    FPRINTF (stderr, "%s",  _("Could not create keyword URI from arguments.\n"));
+    fprintf (stderr,
+             "%s",
+             _ ("Could not create keyword URI from arguments.\n"));
     ret = 1;
     return;
   }
   cfg = c;
-  ctx =
-      GNUNET_FS_start (cfg, "gnunet-search", &progress_cb, NULL,
-                       GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
+  ctx = GNUNET_FS_start (cfg,
+                         "gnunet-search",
+                         &progress_cb,
+                         NULL,
+                         GNUNET_FS_FLAGS_NONE,
+                         GNUNET_FS_OPTIONS_END);
   if (NULL == ctx)
   {
-    FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
+    fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
     GNUNET_FS_uri_destroy (uri);
     ret = 1;
     return;
@@ -284,17 +296,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_FS_uri_destroy (uri);
   if (NULL == sc)
   {
-    FPRINTF (stderr, "%s",  _("Could not start searching.\n"));
+    fprintf (stderr, "%s", _ ("Could not start searching.\n"));
     GNUNET_FS_stop (ctx);
     ret = 1;
     return;
   }
   if (0 != timeout.rel_value_us)
-    tt = GNUNET_SCHEDULER_add_delayed (timeout,
-                                      &timeout_task,
-                                      NULL);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+    tt = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
@@ -308,49 +317,55 @@ run (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_uint ('a',
-                              "anonymity",
-                              "LEVEL",
-                              gettext_noop ("set the desired LEVEL of receiver-anonymity"),
-                              &anonymity),
-    GNUNET_GETOPT_option_flag ('n',
-                              "no-network",
-                              gettext_noop ("only search the local peer (no P2P network search)"),
-                              &local_only),                                 
-    GNUNET_GETOPT_option_string ('o',
-                                 "output",
-                                 "PREFIX",
-                                 gettext_noop ("write search results to file starting with PREFIX"),
-                                 &output_filename),                              
-    GNUNET_GETOPT_option_relative_time ('t', 
-                                       "timeout",
-                                       "DELAY",
-                                       gettext_noop ("automatically terminate search after DELAY"),
-                                       &timeout),
-    GNUNET_GETOPT_option_verbose (&verbose),
-    GNUNET_GETOPT_option_uint ('N',
-                              "results",
-                              "VALUE",
-                              gettext_noop ("automatically terminate search "
-                                            "after VALUE results are found"),
-                              &results_limit),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_uint ('a',
+                                "anonymity",
+                                "LEVEL",
+                                gettext_noop (
+                                  "set the desired LEVEL of receiver-anonymity"),
+                                &anonymity),
+     GNUNET_GETOPT_option_flag (
+       'n',
+       "no-network",
+       gettext_noop ("only search the local peer (no P2P network search)"),
+       &local_only),
+     GNUNET_GETOPT_option_string (
+       'o',
+       "output",
+       "PREFIX",
+       gettext_noop ("write search results to file starting with PREFIX"),
+       &output_filename),
+     GNUNET_GETOPT_option_relative_time (
+       't',
+       "timeout",
+       "DELAY",
+       gettext_noop ("automatically terminate search after DELAY"),
+       &timeout),
+     GNUNET_GETOPT_option_verbose (&verbose),
+     GNUNET_GETOPT_option_uint ('N',
+                                "results",
+                                "VALUE",
+                                gettext_noop ("automatically terminate search "
+                                              "after VALUE results are found"),
+                                &results_limit),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc,
-                            argv,
-                            "gnunet-search [OPTIONS] KEYWORD",
-                            gettext_noop
-                            ("Search GNUnet for files that were published on GNUnet"),
-                            options, &run, NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+  ret =
+    (GNUNET_OK ==
+     GNUNET_PROGRAM_run (argc,
+                         argv,
+                         "gnunet-search [OPTIONS] KEYWORD",
+                         gettext_noop (
+                           "Search GNUnet for files that were published on GNUnet"),
+                         options,
+                         &run,
+                         NULL))
+      ? ret
+      : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 0e8e62fc7ee457316fe1a9813d4e635e335aecca..df5f70b3dd36ff7f2c07c00eb37ad830afd930b5 100644 (file)
@@ -73,7 +73,6 @@ struct IndexInfo
    * Hash of the contents of the file.
    */
   struct GNUNET_HashCode file_id;
-
 };
 
 
@@ -118,12 +117,10 @@ write_index_list ()
   struct IndexInfo *pos;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg, "FS",
-                                               "INDEXDB",
-                                               &fn))
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "FS", "INDEXDB", &fn))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                              "fs",
+                               "fs",
                                "INDEXDB");
     return;
   }
@@ -131,24 +128,21 @@ write_index_list ()
   if (NULL == wh)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                _("Could not open `%s'.\n"),
+                _ ("Could not open `%s'.\n"),
                 fn);
     GNUNET_free (fn);
     return;
   }
   for (pos = indexed_files_head; NULL != pos; pos = pos->next)
-    if ((GNUNET_OK !=
-         GNUNET_BIO_write (wh,
-                           &pos->file_id,
-                           sizeof (struct GNUNET_HashCode))) ||
-        (GNUNET_OK !=
-         GNUNET_BIO_write_string (wh,
-                                  pos->filename)))
+    if ((GNUNET_OK != GNUNET_BIO_write (wh,
+                                        &pos->file_id,
+                                        sizeof (struct GNUNET_HashCode))) ||
+        (GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename)))
       break;
   if (GNUNET_OK != GNUNET_BIO_write_close (wh))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                _("Error writing `%s'.\n"),
+                _ ("Error writing `%s'.\n"),
                 fn);
     GNUNET_free (fn);
     return;
@@ -172,13 +166,10 @@ read_index_list ()
   char *emsg;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               "FS",
-                                               "INDEXDB",
-                                               &fn))
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "FS", "INDEXDB", &fn))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                              "fs",
+                               "fs",
                                "INDEXDB");
     return;
   }
@@ -192,39 +183,36 @@ read_index_list ()
   if (NULL == rh)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
-                _("Could not open `%s'.\n"),
+                _ ("Could not open `%s'.\n"),
                 fn);
     GNUNET_free (fn);
     return;
   }
-  while ( (GNUNET_OK ==
-           GNUNET_BIO_read (rh,
-                            "Hash of indexed file",
-                            &hc,
-                            sizeof (struct GNUNET_HashCode))) &&
-          (GNUNET_OK ==
-           GNUNET_BIO_read_string (rh,
-                                   "Name of indexed file",
-                                   &fname,
-                                   1024 * 16)) &&
-          (fname != NULL) )
+  while (
+    (GNUNET_OK == GNUNET_BIO_read (rh,
+                                   "Hash of indexed file",
+                                   &hc,
+                                   sizeof (struct GNUNET_HashCode))) &&
+    (GNUNET_OK ==
+     GNUNET_BIO_read_string (rh, "Name of indexed file", &fname, 1024 * 16)) &&
+    (fname != NULL))
   {
     slen = strlen (fname) + 1;
     pos = GNUNET_malloc (sizeof (struct IndexInfo) + slen);
     pos->file_id = hc;
     pos->filename = (const char *) &pos[1];
     GNUNET_memcpy (&pos[1], fname, slen);
-    if (GNUNET_SYSERR ==
-        GNUNET_CONTAINER_multihashmap_put (ifm, &pos->file_id, pos,
-                                           GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+    if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (
+                           ifm,
+                           &pos->file_id,
+                           pos,
+                           GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
     {
       GNUNET_free (pos);
     }
     else
     {
-      GNUNET_CONTAINER_DLL_insert (indexed_files_head,
-                                  indexed_files_tail,
-                                  pos);
+      GNUNET_CONTAINER_DLL_insert (indexed_files_head, indexed_files_tail, pos);
     }
     GNUNET_free (fname);
   }
@@ -244,13 +232,15 @@ read_index_list ()
  * @param msg error message
  */
 static void
-remove_cont (void *cls, int success,
-            struct GNUNET_TIME_Absolute min_expiration,
-            const char *msg)
+remove_cont (void *cls,
+             int success,
+             struct GNUNET_TIME_Absolute min_expiration,
+             const char *msg)
 {
   if (GNUNET_OK != success)
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to delete bogus block: %s\n"), msg);
+                _ ("Failed to delete bogus block: %s\n"),
+                msg);
 }
 
 
@@ -275,7 +265,7 @@ remove_cont (void *cls, int success,
  * @return GNUNET_OK on success
  */
 int
-GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode * key,
+GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode *key,
                                   uint32_t size,
                                   const void *data,
                                   enum GNUNET_BLOCK_Type type,
@@ -303,19 +293,12 @@ GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode * key,
   if (size != sizeof (struct OnDemandBlock))
   {
     GNUNET_break (0);
-    GNUNET_DATASTORE_remove (dsh,
-                             key,
-                             size,
-                             data,
-                             -1,
-                             -1,
-                             &remove_cont, NULL);
+    GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, &remove_cont, NULL);
     return GNUNET_SYSERR;
   }
   odb = (const struct OnDemandBlock *) data;
   off = GNUNET_ntohll (odb->offset);
-  ii = GNUNET_CONTAINER_multihashmap_get (ifm,
-                                          &odb->file_id);
+  ii = GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id);
   if (NULL == ii)
   {
     GNUNET_break (0);
@@ -325,83 +308,46 @@ GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode * key,
     return GNUNET_SYSERR;
   }
   fn = ii->filename;
-  if ((NULL == fn) || (0 != ACCESS (fn, R_OK)))
+  if ((NULL == fn) || (0 != access (fn, R_OK)))
   {
-    GNUNET_STATISTICS_update (GSF_stats,
-                              gettext_noop ("# index blocks removed: original file inaccessible"),
-                              1,
-                              GNUNET_YES);
-    GNUNET_DATASTORE_remove (dsh,
-                             key,
-                             size,
-                             data,
-                             -1,
-                             -1,
-                             &remove_cont,
-                             NULL);
+    GNUNET_STATISTICS_update (
+      GSF_stats,
+      gettext_noop ("# index blocks removed: original file inaccessible"),
+      1,
+      GNUNET_YES);
+    GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, &remove_cont, NULL);
     return GNUNET_SYSERR;
   }
-  if ( (NULL ==
-        (fh =
-         GNUNET_DISK_file_open (fn,
-                                GNUNET_DISK_OPEN_READ,
-                                GNUNET_DISK_PERM_NONE))) ||
-       (off != GNUNET_DISK_file_seek (fh,
-                                      off,
-                                      GNUNET_DISK_SEEK_SET)) ||
-      (-1 == (nsize = GNUNET_DISK_file_read (fh,
-                                             ndata,
-                                             sizeof (ndata)))) )
+  if ((NULL == (fh = GNUNET_DISK_file_open (fn,
+                                            GNUNET_DISK_OPEN_READ,
+                                            GNUNET_DISK_PERM_NONE))) ||
+      (off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)) ||
+      (-1 == (nsize = GNUNET_DISK_file_read (fh, ndata, sizeof (ndata)))))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Could not access indexed file `%s' (%s) at offset %llu: %s\n"),
+                _ (
+                  "Could not access indexed file `%s' (%s) at offset %llu: %s\n"),
                 GNUNET_h2s (&odb->file_id),
                 fn,
                 (unsigned long long) off,
-                (fn == NULL) ? _("not indexed") : STRERROR (errno));
+                (fn == NULL) ? _ ("not indexed") : strerror (errno));
     if (fh != NULL)
       GNUNET_DISK_file_close (fh);
-    GNUNET_DATASTORE_remove (dsh,
-                             key,
-                             size,
-                             data,
-                             -1,
-                             -1,
-                             &remove_cont,
-                             NULL);
+    GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, &remove_cont, NULL);
     return GNUNET_SYSERR;
   }
   GNUNET_DISK_file_close (fh);
-  GNUNET_CRYPTO_hash (ndata,
-                      nsize,
-                      &nkey);
-  GNUNET_CRYPTO_hash_to_aes_key (&nkey,
-                                 &skey,
-                                 &iv);
-  GNUNET_CRYPTO_symmetric_encrypt (ndata,
-                                   nsize,
-                                   &skey,
-                                   &iv,
-                                   edata);
-  GNUNET_CRYPTO_hash (edata,
-                      nsize,
-                      &query);
-  if (0 != memcmp (&query,
-                   key,
-                   sizeof (struct GNUNET_HashCode)))
+  GNUNET_CRYPTO_hash (ndata, nsize, &nkey);
+  GNUNET_CRYPTO_hash_to_aes_key (&nkey, &skey, &iv);
+  GNUNET_CRYPTO_symmetric_encrypt (ndata, nsize, &skey, &iv, edata);
+  GNUNET_CRYPTO_hash (edata, nsize, &query);
+  if (0 != memcmp (&query, key, sizeof (struct GNUNET_HashCode)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Indexed file `%s' changed at offset %llu\n"),
+                _ ("Indexed file `%s' changed at offset %llu\n"),
                 fn,
                 (unsigned long long) off);
-    GNUNET_DATASTORE_remove (dsh,
-                             key,
-                             size,
-                             data,
-                             -1,
-                             -1,
-                             &remove_cont,
-                             NULL);
+    GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, &remove_cont, NULL);
     return GNUNET_SYSERR;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -440,27 +386,20 @@ GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq)
   {
     fn = pos->filename;
     slen = strlen (fn) + 1;
-    if (slen + sizeof (struct IndexInfoMessage) >=
-        GNUNET_MAX_MESSAGE_SIZE)
+    if (slen + sizeof (struct IndexInfoMessage) >= GNUNET_MAX_MESSAGE_SIZE)
     {
       GNUNET_break (0);
       break;
     }
-    env = GNUNET_MQ_msg_extra (iim,
-                               slen,
-                               GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY);
+    env =
+      GNUNET_MQ_msg_extra (iim, slen, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY);
     iim->reserved = 0;
     iim->file_id = pos->file_id;
-    GNUNET_memcpy (&iim[1],
-                   fn,
-                   slen);
-    GNUNET_MQ_send (mq,
-                    env);
+    GNUNET_memcpy (&iim[1], fn, slen);
+    GNUNET_MQ_send (mq, env);
   }
-  env = GNUNET_MQ_msg (iem,
-                       GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END);
-  GNUNET_MQ_send (mq,
-                  env);
+  env = GNUNET_MQ_msg (iem, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END);
+  GNUNET_MQ_send (mq, env);
 }
 
 
@@ -477,17 +416,12 @@ GNUNET_FS_indexing_do_unindex (const struct GNUNET_HashCode *fid)
 
   for (pos = indexed_files_head; NULL != pos; pos = pos->next)
   {
-    if (0 == memcmp (&pos->file_id,
-                     fid,
-                     sizeof (struct GNUNET_HashCode)))
+    if (0 == memcmp (&pos->file_id, fid, sizeof (struct GNUNET_HashCode)))
     {
-      GNUNET_CONTAINER_DLL_remove (indexed_files_head,
-                                  indexed_files_tail,
-                                  pos);
-      GNUNET_break (GNUNET_OK ==
-                    GNUNET_CONTAINER_multihashmap_remove (ifm,
-                                                          &pos->file_id,
-                                                         pos));
+      GNUNET_CONTAINER_DLL_remove (indexed_files_head, indexed_files_tail, pos);
+      GNUNET_break (
+        GNUNET_OK ==
+        GNUNET_CONTAINER_multihashmap_remove (ifm, &pos->file_id, pos));
       GNUNET_free (pos);
       write_index_list ();
       return GNUNET_YES;
@@ -510,14 +444,15 @@ GNUNET_FS_add_to_index (const char *filename,
   struct IndexInfo *ii;
   size_t slen;
 
-  ii = GNUNET_CONTAINER_multihashmap_get (ifm,
-                                          file_id);
+  ii = GNUNET_CONTAINER_multihashmap_get (ifm, file_id);
   if (NULL != ii)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Index request received for file `%s' is already indexed as `%s'.  Permitting anyway.\n"),
-                filename,
-               ii->filename);
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_INFO,
+      _ (
+        "Index request received for file `%s' is already indexed as `%s'.  Permitting anyway.\n"),
+      filename,
+      ii->filename);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -528,17 +463,14 @@ GNUNET_FS_add_to_index (const char *filename,
   ii = GNUNET_malloc (sizeof (struct IndexInfo) + slen);
   ii->file_id = *file_id;
   ii->filename = (const char *) &ii[1];
-  GNUNET_memcpy (&ii[1],
-                 filename,
-                 slen);
-  GNUNET_CONTAINER_DLL_insert (indexed_files_head,
-                              indexed_files_tail,
-                              ii);
+  GNUNET_memcpy (&ii[1], filename, slen);
+  GNUNET_CONTAINER_DLL_insert (indexed_files_head, indexed_files_tail, ii);
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONTAINER_multihashmap_put (ifm,
-                                                    &ii->file_id,
-                                                    ii,
-                                                    GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                 GNUNET_CONTAINER_multihashmap_put (
+                   ifm,
+                   &ii->file_id,
+                   ii,
+                   GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   write_index_list ();
 }
 
@@ -553,15 +485,12 @@ GNUNET_FS_indexing_done ()
 
   while (NULL != (pos = indexed_files_head))
   {
-    GNUNET_CONTAINER_DLL_remove (indexed_files_head,
-                                indexed_files_tail,
-                                pos);
+    GNUNET_CONTAINER_DLL_remove (indexed_files_head, indexed_files_tail, pos);
     if (pos->fhc != NULL)
       GNUNET_CRYPTO_hash_file_cancel (pos->fhc);
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_CONTAINER_multihashmap_remove (ifm,
-                                                       &pos->file_id,
-                                                        pos));
+    GNUNET_break (
+      GNUNET_OK ==
+      GNUNET_CONTAINER_multihashmap_remove (ifm, &pos->file_id, pos));
     GNUNET_free (pos);
   }
   GNUNET_CONTAINER_multihashmap_destroy (ifm);
@@ -582,8 +511,7 @@ GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c,
 {
   cfg = c;
   dsh = d;
-  ifm = GNUNET_CONTAINER_multihashmap_create (128,
-                                              GNUNET_YES);
+  ifm = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES);
   read_index_list ();
   return GNUNET_OK;
 }
index f9a3f8f3a342b600e3051661a7cddab5417210da..4d13e7ef3f80d411e0de3467ea26fbc3e3d7be66 100644 (file)
@@ -85,26 +85,30 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
     if (verbose)
     {
-      s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta, GNUNET_YES);
-      FPRINTF (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"),
+      s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta,
+                                                  GNUNET_YES);
+      fprintf (stdout,
+               _ ("Unindexing at %llu/%llu (%s remaining)\n"),
                (unsigned long long) info->value.unindex.completed,
-               (unsigned long long) info->value.unindex.size, s);
+               (unsigned long long) info->value.unindex.size,
+               s);
     }
     break;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
-    FPRINTF (stderr, _("Error unindexing: %s.\n"),
+    fprintf (stderr,
+             _ ("Error unindexing: %s.\n"),
              info->value.unindex.specifics.error.message);
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
-    FPRINTF (stdout, "%s",  _("Unindexing done.\n"));
+    fprintf (stdout, "%s", _ ("Unindexing done.\n"));
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
     GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
     break;
   default:
-    FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+    fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
     break;
   }
   return NULL;
@@ -120,35 +124,39 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
  * @param c configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   /* check arguments */
   if ((args[0] == NULL) || (args[1] != NULL))
   {
-    printf (_("You must specify one and only one filename for unindexing.\n"));
+    printf (_ ("You must specify one and only one filename for unindexing.\n"));
     ret = -1;
     return;
   }
   cfg = c;
-  ctx =
-      GNUNET_FS_start (cfg, "gnunet-unindex", &progress_cb, NULL,
-                       GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
+  ctx = GNUNET_FS_start (cfg,
+                         "gnunet-unindex",
+                         &progress_cb,
+                         NULL,
+                         GNUNET_FS_FLAGS_NONE,
+                         GNUNET_FS_OPTIONS_END);
   if (NULL == ctx)
   {
-    FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
+    fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
     ret = 1;
     return;
   }
   uc = GNUNET_FS_unindex_start (ctx, args[0], NULL);
   if (NULL == uc)
   {
-    FPRINTF (stderr, "%s",  _("Could not start unindex operation.\n"));
+    fprintf (stderr, "%s", _ ("Could not start unindex operation.\n"));
     GNUNET_FS_stop (ctx);
     return;
   }
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
@@ -166,18 +174,24 @@ main (int argc, char *const *argv)
 
     GNUNET_GETOPT_option_verbose (&verbose),
 
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-unindex [OPTIONS] FILENAME",
-                            gettext_noop
-                            ("Unindex a file that was previously indexed with gnunet-publish."),
-                            options, &run, NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+         GNUNET_PROGRAM_run (
+           argc,
+           argv,
+           "gnunet-unindex [OPTIONS] FILENAME",
+           gettext_noop (
+             "Unindex a file that was previously indexed with gnunet-publish."),
+           options,
+           &run,
+           NULL))
+          ? ret
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 61f8592355b9f5dd18458046d34963e1bb617948..0d76dfc3ddb2a37e13a15b679f9c51fedfc7ef99 100644 (file)
@@ -116,7 +116,7 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
 {
   struct StatMaster *sm = cls;
 
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Peer %2u: %12s/%50s = %12llu\n",
            sm->daemon,
            subsystem,
@@ -267,7 +267,7 @@ do_report (void *cls)
   fancy =
     GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                    1000000LL / del.rel_value_us);
-  FPRINTF (stdout,
+  fprintf (stdout,
            "Download speed was %s/s\n",
            fancy);
   GNUNET_free (fancy);
index afde310a0d2b1bf92ce8398240a3a9d00243da51..9b14b9eb6cd6c362981fac2f1dd3ab90888f4884 100644 (file)
@@ -168,7 +168,7 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
 {
   struct StatMaster *sm = cls;
 
-  FPRINTF (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
+  fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
            name, (unsigned long long) value);
   return GNUNET_OK;
 }
@@ -304,7 +304,7 @@ do_report (void *cls)
   fancy =
     GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                    1000000LL / del.rel_value_us);
-  FPRINTF (stderr, "Download speed of type `%s' was %s/s\n", type, fancy);
+  fprintf (stderr, "Download speed of type `%s' was %s/s\n", type, fancy);
   GNUNET_free (fancy);
   if (NUM_DAEMONS != ++download_counter)
     return;                   /* more downloads to come */
index 95368f108726be65e0416fe0b39ac0ec81161197..e88c74464d67866b950353791fe42f7500377c45 100644 (file)
@@ -226,7 +226,7 @@ FAILURE:
     GNUNET_FSUI_stop (ctx);
   if (filename != NULL)
   {
-    UNLINK (filename);
+    unlink (filename);
     GNUNET_free (filename);
   }
   if (download != NULL)
@@ -236,7 +236,7 @@ FAILURE:
   }
   filename = makeName (43);
   /* TODO: verify file 'filename(42)' == file 'filename(43)' */
-  UNLINK (filename);
+  unlink (filename);
   GNUNET_free (filename);
 
 #if START_DAEMON
index a2d131ca139d880d753cd77e8f224e50008fa017..5cdbd9d07e258250f85e96c6a0616348b0b8b42d 100644 (file)
@@ -59,7 +59,7 @@ processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
       return;
     }
   }
-  FPRINTF (stderr, "Error at %s:%d\n", __FILE__, __LINE__);
+  fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__);
 }
 
 static int
@@ -136,7 +136,7 @@ testDirectory (unsigned int i)
   s = GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration
                                               (start),
                                              GNUNET_YES);
-  FPRINTF (stdout,
+  fprintf (stdout,
            "Creating directory with %u entires and total size %llu took %s\n",
            i, (unsigned long long) dlen, s);
   if (i < 100)
index 135e2d37865e6a74f94f5c82f548cfe20261bca5..242e6f1aa17e6580016cef6a402b6cf37fbe8dc7 100644 (file)
@@ -195,14 +195,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
                progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
-    FPRINTF (stderr, "Error downloading file: %s\n",
+    fprintf (stderr, "Error downloading file: %s\n",
              event->value.download.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
     GNUNET_SCHEDULER_shutdown ();
@@ -342,7 +342,7 @@ main (int argc, char *argv[])
     return 1;
   if (NULL != fn1)
   {
-    UNLINK (fn1);
+    unlink (fn1);
     GNUNET_free (fn1);
   }
   return err;
index 183a407e01c54ad2629a2a3698c85f99840d37f3..97c2a338c774c3c04904f3e27137bafad89b1d1a 100644 (file)
@@ -198,13 +198,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
                progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
-    FPRINTF (stderr, "Error downloading file: %s\n",
+    fprintf (stderr, "Error downloading file: %s\n",
              event->value.download.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
     break;
index 03de383a49ee3b7cc594721c62c73101c08c2e71..3562069e11e10ac4cc4d6972df5f354866b4ea0e 100644 (file)
@@ -32,6 +32,6 @@ main (int argc, char *argv[])
   GNUNET_log_setup ("test_fs_getopt",
                     "WARNING",
                     NULL);
-  FPRINTF (stderr, "%s",  "WARNING: testcase not yet written.\n");
+  fprintf (stderr, "%s",  "WARNING: testcase not yet written.\n");
   return 0;                     /* testcase passed */
 }
index 632cba43e7d07090a52d88e16b784942b920cf1b..a4e7eb53f55bab62599f5e8005d319fbc859d5ae 100644 (file)
@@ -117,7 +117,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     ret = event->value.publish.cctx;
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     err = 1;
     if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
index 56a36825ce0a823a17954052ddaba8d4fd5194b5..43c899b72baf03eaad024550ee8fdb1ac1dccf07 100644 (file)
@@ -85,7 +85,7 @@ static void
 do_timeout (void *cls)
 {
   err = 1;
-  FPRINTF (stderr, "%s",  "Operation timed out\n");
+  fprintf (stderr, "%s",  "Operation timed out\n");
   kill_task = NULL;
   abort_sks_search_task (NULL);
   abort_ksk_search_task (NULL);
@@ -103,7 +103,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
       if (!GNUNET_FS_uri_test_equal
           (sks_expect_uri, event->value.search.specifics.result.uri))
       {
-        FPRINTF (stderr, "%s",  "Wrong result for sks search!\n");
+        fprintf (stderr, "%s",  "Wrong result for sks search!\n");
         err = 1;
       }
       /* give system 1ms to initiate update search! */
@@ -115,19 +115,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
       if (!GNUNET_FS_uri_test_equal
           (ksk_expect_uri, event->value.search.specifics.result.uri))
       {
-        FPRINTF (stderr, "%s",  "Wrong result for ksk search!\n");
+        fprintf (stderr, "%s",  "Wrong result for ksk search!\n");
         err = 1;
       }
       GNUNET_SCHEDULER_add_now (&abort_ksk_search_task, NULL);
     }
     else
     {
-      FPRINTF (stderr, "%s",  "Unexpected search result received!\n");
+      fprintf (stderr, "%s",  "Unexpected search result received!\n");
       GNUNET_break (0);
     }
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, "Error searching file: %s\n",
+    fprintf (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     if (sks_search == event->value.search.sc)
       GNUNET_SCHEDULER_add_now (&abort_sks_search_task, NULL);
@@ -152,7 +152,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
     return NULL;
   default:
-    FPRINTF (stderr, "Unexpected event: %d\n", event->status);
+    fprintf (stderr, "Unexpected event: %d\n", event->status);
     break;
   }
   return event->value.search.cctx;
@@ -170,7 +170,7 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
 
   if (NULL != emsg)
   {
-    FPRINTF (stderr, "Error publishing: %s\n", emsg);
+    fprintf (stderr, "Error publishing: %s\n", emsg);
     err = 1;
     GNUNET_FS_stop (fs);
     return;
@@ -182,7 +182,7 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
   sks_uri = GNUNET_FS_uri_parse (sbuf, &msg);
   if (NULL == sks_uri)
   {
-    FPRINTF (stderr, "failed to parse URI `%s': %s\n", sbuf, msg);
+    fprintf (stderr, "failed to parse URI `%s': %s\n", sbuf, msg);
     err = 1;
     GNUNET_FS_stop (fs);
     GNUNET_free_non_null (msg);
@@ -239,7 +239,7 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 
   if (NULL != emsg)
   {
-    FPRINTF (stderr, "Error publishing: %s\n", emsg);
+    fprintf (stderr, "Error publishing: %s\n", emsg);
     err = 1;
     GNUNET_FS_stop (fs);
     return;
index bc38d316a9e70df6adf45fa8d01b74574dd485a7..fe54bb552efcc9366d3c7f3bce457597abe3f58a 100644 (file)
@@ -105,12 +105,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     ret = event->value.publish.cctx;
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     err = 1;
     if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
     {
-      FPRINTF (stderr, "Scheduling abort task for error on `%s'\n",
+      fprintf (stderr, "Scheduling abort task for error on `%s'\n",
                (const char *) event->value.publish.cctx);
       GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     }
index 4d27b15095294bbbb2cd3a29a48b5a704edab0a4..6242e66f8627092d448f5d2fc063976ff805f8d4 100644 (file)
@@ -177,7 +177,7 @@ progress_cb (void *cls,
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     ret = event->value.publish.cctx;
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     err = 1;
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
index 2377cb1a2bffdf488e63315225d2defc0ec3c653..2a7f4b1ddc98f99cf756878e9f9861786d7114ee 100644 (file)
@@ -140,13 +140,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, "Error searching file: %s\n",
+    fprintf (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
@@ -176,7 +176,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
-    FPRINTF (stderr, "Unexpected event: %d\n", event->status);
+    fprintf (stderr, "Unexpected event: %d\n", event->status);
     break;
   }
   return NULL;
index a0483e723f2f28f4dd118a581bfac9905bf632f5..68e3a4a62212fc90c7695ad7058c716bdadcc620 100644 (file)
@@ -187,13 +187,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, "Error searching file: %s\n",
+    fprintf (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
@@ -237,7 +237,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     search = NULL;
     break;
   default:
-    FPRINTF (stderr, "Unexpected event: %d\n", event->status);
+    fprintf (stderr, "Unexpected event: %d\n", event->status);
     break;
   }
   return NULL;
index ca504c08e79f298b6350568d62da1ea86e10fbed..c6564910824b80d679c694cddf8d2113472bf094 100644 (file)
@@ -137,13 +137,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Search complete.\n");
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, "Error searching file: %s\n",
+    fprintf (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
@@ -178,7 +178,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Unexpected event: %d\n",
              event->status);
     break;
index daaf38a198750acf81a9929394dee7bb02e6d71f..f1072a4a1907ae5fafaafe82a23d2d88a36ed71f 100644 (file)
@@ -153,13 +153,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
-    FPRINTF (stderr, "Error searching file: %s\n",
+    fprintf (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
@@ -189,7 +189,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
-    FPRINTF (stderr, "Unexpected event: %d\n", event->status);
+    fprintf (stderr, "Unexpected event: %d\n", event->status);
     break;
   }
   return NULL;
index 9e358dade1c72783d8aef2cb93c89ee2aac56e35..b4bdc1b8042e8cb18a66b851bdcbe7902fa70403 100644 (file)
@@ -121,13 +121,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
                progress.offset);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
-    FPRINTF (stderr, "Error unindexing file: %s\n",
+    fprintf (stderr, "Error unindexing file: %s\n",
              event->value.unindex.specifics.error.message);
     GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL);
     break;
index 4d6d63c6aa5a3542140869f7620ae194e3082168..50d45708a007aba207b7bf086d6a19490d0771cc 100644 (file)
@@ -183,7 +183,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
     unindex = event->value.unindex.uc;
     return "unindex";
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
-    FPRINTF (stderr, "Error publishing file: %s\n",
+    fprintf (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
     GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
index d4ee8c302f94eff0599fb7da608cf5e967be388a..e0a2ecea7a44be5f57acffcca48acfd12b5daa4a 100644 (file)
@@ -314,11 +314,11 @@ main (int argc, char *argv[])
   failureCount += testLocation ();
   for (i = 0; i < 255; i++)
   {
-    /* FPRINTF (stderr, "%s",  "."); */
+    /* fprintf (stderr, "%s",  "."); */
     failureCount += testNamespace (i);
     failureCount += testFile (i);
   }
-  /* FPRINTF (stderr, "%s",  "\n"); */
+  /* fprintf (stderr, "%s",  "\n"); */
   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-uri");
   if (failureCount != 0)
     return 1;
index 4a3bf67c71f178c4c3480cc660560d56d341becd..f7daf6b1a395ca0b0ee38bfa8f406224522421c6 100644 (file)
@@ -86,7 +86,7 @@ do_stop (void *cls)
     fancy =
         GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                         1000000LL / del.rel_value_us);
-    FPRINTF (stdout,
+    fprintf (stdout,
              "Download speed was %s/s\n",
              fancy);
     GNUNET_free (fancy);
index e33df8502948501927e200a9a89bba45a41c1521..2050b0835c3df7c45cb0e2a8683f3fa968ffd16c 100644 (file)
@@ -77,7 +77,7 @@ do_stop (void *cls)
     fancy =
       GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                      1000000LL / del.rel_value_us);
-    FPRINTF (stdout,
+    fprintf (stdout,
              "Download speed was %s/s\n",
              fancy);
     GNUNET_free (fancy);
index 30981abc53be74956b4d7c862b48f9ebf8c0c457..3b17b6917e39c7caa13a9d7e79803c68059fc21b 100644 (file)
@@ -84,7 +84,7 @@ main (int argc, char *argv[])
   GNUNET_BLOCK_context_destroy (ctx);
   GNUNET_CONFIGURATION_destroy (cfg);
   if (ret != 0)
-    FPRINTF (stderr, "Tests failed: %d\n", ret);
+    fprintf (stderr, "Tests failed: %d\n", ret);
   return ret;
 }
 
index f3249eee0eb5b3efc9cce9b4419f880b19cc18ee..7906ffd4d4d059becd831a53b0fca27ab5113ea2 100644 (file)
@@ -179,7 +179,7 @@ access_handler_callback (void *cls,
       return MHD_NO;
     }
     GNUNET_asprintf (&deffile, "%s%s%s", tmp, DIR_SEPARATOR_STR, "def.tex");
-    f = FOPEN (deffile, "w");
+    f = fopen (deffile, "w");
     if (NULL == f)
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", deffile);
@@ -194,9 +194,9 @@ access_handler_callback (void *cls,
                                                      MHD_GET_ARGUMENT_KIND,
                                                      map[i].formname);
       if (NULL != val)
-        FPRINTF (f, "\\def\\%s{%s}\n", map[i].texname, val);
+        fprintf (f, "\\def\\%s{%s}\n", map[i].texname, val);
       else
-        FPRINTF (f, "\\def\\%s{}\n", map[i].texname);
+        fprintf (f, "\\def\\%s{}\n", map[i].texname);
     }
     if (NULL != gpg_fp)
     {
@@ -206,15 +206,15 @@ access_handler_callback (void *cls,
       slen = strlen (gpg_fp);
       gpg1 = GNUNET_strndup (gpg_fp, slen / 2);
       gpg2 = GNUNET_strdup (&gpg_fp[slen / 2]);
-      FPRINTF (f, "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n", gpg1, gpg2);
+      fprintf (f, "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n", gpg1, gpg2);
       GNUNET_free (gpg2);
       GNUNET_free (gpg1);
     }
-    FPRINTF (f,
+    fprintf (f,
              "\\def\\gns{%s/%s}\n",
              gnskey,
              (NULL == gns_nick) ? "" : gns_nick);
-    FCLOSE (f);
+    fclose (f);
     GNUNET_asprintf (
       &p,
       "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null",
diff --git a/src/gns/gnutls_ca.cfg b/src/gns/gnutls_ca.cfg
new file mode 100644 (file)
index 0000000..f551ae8
--- /dev/null
@@ -0,0 +1,25 @@
+# This template file specifies that the certificate is a certificate
+# authority that will be used to sign other certificates, and
+# certificate revocations.  Set additional properties (e.g. a CRL URI)
+# as appropriate.
+
+# Certificate authority template
+organization = "Example"
+cn = "Your CA name here"
+expiration_days = 3650
+
+# This CA can not issue subsidiary CAs
+path_len = 0
+
+# Is a CA
+ca
+
+# Signs certificates and certificate revocation lists
+cert_signing_key
+crl_signing_key
+
+# Name constraints (recommended); new in GnuTLS 3.3.x
+# Setting this will allow this CA to only issue
+# certificates for this domain
+nc_permit_dns = "example.com"
+#nc_exclude_dns = "test.example.com"
index ebba0db47c6218e7ad7d4066006a4df9e37dc42e..8cb76cffe4a525a68cda90142a072c35df7617ea 100644 (file)
@@ -61,85 +61,68 @@ gns_value_to_string (void *cls,
     return GNUNET_strndup (data, data_size);
   case GNUNET_GNSRECORD_TYPE_LEHO:
     return GNUNET_strndup (data, data_size);
-  case GNUNET_GNSRECORD_TYPE_GNS2DNS:
+  case GNUNET_GNSRECORD_TYPE_GNS2DNS: {
+    char *ns;
+    char *ip;
+    size_t off;
+    char *nstr;
+
+    off = 0;
+    ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
+    ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
+    if ((NULL == ns) || (NULL == ip) || (off != data_size))
     {
-      char *ns;
-      char *ip;
-      size_t off;
-      char *nstr;
-
-      off = 0;
-      ns = GNUNET_DNSPARSER_parse_name (data,
-                                       data_size,
-                                       &off);
-      ip = GNUNET_DNSPARSER_parse_name (data,
-                                       data_size,
-                                       &off);
-      if ( (NULL == ns) ||
-           (NULL == ip) ||
-          (off != data_size) )
-      {
-       GNUNET_break_op (0);
-       GNUNET_free_non_null (ns);
-       GNUNET_free_non_null (ip);
-       return NULL;
-      }
-      GNUNET_asprintf (&nstr,
-                       "%s@%s",
-                       ns,
-                       ip);
+      GNUNET_break_op (0);
       GNUNET_free_non_null (ns);
       GNUNET_free_non_null (ip);
-      return nstr;
-    }
-  case GNUNET_GNSRECORD_TYPE_VPN:
-    {
-      struct GNUNET_TUN_GnsVpnRecord vpn;
-      char* vpn_str;
-
-      cdata = data;
-      if ( (data_size <= sizeof (vpn)) ||
-          ('\0' != cdata[data_size - 1]) )
-       return NULL; /* malformed */
-      /* need to memcpy for alignment */
-      GNUNET_memcpy (&vpn,
-                     data,
-                     sizeof (vpn));
-      GNUNET_asprintf (&vpn_str,
-                       "%u %s %s",
-                       (unsigned int) ntohs (vpn.proto),
-                       (const char*) GNUNET_i2s_full (&vpn.peer),
-                       (const char*) &cdata[sizeof (vpn)]);
-      return vpn_str;
-    }
-  case GNUNET_GNSRECORD_TYPE_BOX:
-    {
-      struct GNUNET_GNSRECORD_BoxRecord box;
-      uint32_t rt;
-      char *box_str;
-      char *ival;
-
-      cdata = data;
-      if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord))
-       return NULL; /* malformed */
-      GNUNET_memcpy (&box,
-                     data,
-                     sizeof (box));
-      rt = ntohl (box.record_type);
-      ival = GNUNET_GNSRECORD_value_to_string (rt,
-                                               &cdata[sizeof (box)],
-                                               data_size - sizeof (box));
-      if (NULL == ival)
-        return NULL; /* malformed */
-      GNUNET_asprintf (&box_str,
-                       "%u %u %u %s",
-                       (unsigned int) ntohs (box.protocol),
-                       (unsigned int) ntohs (box.service),
-                       (unsigned int) rt,
-                       ival);
-      GNUNET_free (ival);
-      return box_str;
+      return NULL;
     }
+    GNUNET_asprintf (&nstr, "%s@%s", ns, ip);
+    GNUNET_free_non_null (ns);
+    GNUNET_free_non_null (ip);
+    return nstr;
+  }
+  case GNUNET_GNSRECORD_TYPE_VPN: {
+    struct GNUNET_TUN_GnsVpnRecord vpn;
+    char *vpn_str;
+
+    cdata = data;
+    if ((data_size <= sizeof (vpn)) || ('\0' != cdata[data_size - 1]))
+      return NULL; /* malformed */
+    /* need to memcpy for alignment */
+    GNUNET_memcpy (&vpn, data, sizeof (vpn));
+    GNUNET_asprintf (&vpn_str,
+                     "%u %s %s",
+                     (unsigned int) ntohs (vpn.proto),
+                     (const char *) GNUNET_i2s_full (&vpn.peer),
+                     (const char *) &cdata[sizeof (vpn)]);
+    return vpn_str;
+  }
+  case GNUNET_GNSRECORD_TYPE_BOX: {
+    struct GNUNET_GNSRECORD_BoxRecord box;
+    uint32_t rt;
+    char *box_str;
+    char *ival;
+
+    cdata = data;
+    if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord))
+      return NULL; /* malformed */
+    GNUNET_memcpy (&box, data, sizeof (box));
+    rt = ntohl (box.record_type);
+    ival = GNUNET_GNSRECORD_value_to_string (rt,
+                                             &cdata[sizeof (box)],
+                                             data_size - sizeof (box));
+    if (NULL == ival)
+      return NULL; /* malformed */
+    GNUNET_asprintf (&box_str,
+                     "%u %u %u %s",
+                     (unsigned int) ntohs (box.protocol),
+                     (unsigned int) ntohs (box.service),
+                     (unsigned int) rt,
+                     ival);
+    GNUNET_free (ival);
+    return box_str;
+  }
   default:
     return NULL;
   }
@@ -171,154 +154,128 @@ gns_string_to_value (void *cls,
   switch (type)
   {
 
-    case GNUNET_GNSRECORD_TYPE_PKEY:
-      if (GNUNET_OK !=
-          GNUNET_CRYPTO_ecdsa_public_key_from_string (s,
-                                                     strlen (s),
-                                                     &pkey))
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _("Unable to parse PKEY record `%s'\n"),
-                    s);
-        return GNUNET_SYSERR;
-      }
-      *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
-      GNUNET_memcpy (*data,
-                    &pkey,
-                    sizeof (pkey));
-      *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
-      return GNUNET_OK;
-
-    case GNUNET_GNSRECORD_TYPE_NICK:
-      *data = GNUNET_strdup (s);
-      *data_size = strlen (s);
-      return GNUNET_OK;
-    case GNUNET_GNSRECORD_TYPE_LEHO:
-      *data = GNUNET_strdup (s);
-      *data_size = strlen (s);
-      return GNUNET_OK;
-    case GNUNET_GNSRECORD_TYPE_GNS2DNS:
-      {
-        char nsbuf[514];
-        char *cpy;
-        char *at;
-        size_t off;
-
-        cpy = GNUNET_strdup (s);
-        at = strchr (cpy, '@');
-        if (NULL == at)
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("Unable to parse GNS2DNS record `%s'\n"),
-                      s);
-          GNUNET_free (cpy);
-          return GNUNET_SYSERR;
-        }
-        *at = '\0';
-        at++;
-
-        off = 0;
-        if ( (GNUNET_OK !=
-              GNUNET_DNSPARSER_builder_add_name (nsbuf,
-                                                 sizeof (nsbuf),
-                                                 &off,
-                                                 cpy)) ||
-             (GNUNET_OK !=
-              GNUNET_DNSPARSER_builder_add_name (nsbuf,
-                                                 sizeof (nsbuf),
-                                                 &off,
-                                                 at)) )
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("Failed to serialize GNS2DNS record with value `%s'\n"),
-                      s);
-          GNUNET_free (cpy);
-          return GNUNET_SYSERR;
-        }
-        GNUNET_free (cpy);
-        *data_size = off;
-        *data = GNUNET_malloc (off);
-        GNUNET_memcpy (*data,
-                      nsbuf,
-                      off);
-        return GNUNET_OK;
-      }
-    case GNUNET_GNSRECORD_TYPE_VPN:
-      {
-        struct GNUNET_TUN_GnsVpnRecord *vpn;
-        char s_peer[103 + 1];
-        char s_serv[253 + 1];
-        unsigned int proto;
-
-        if (3 != SSCANF (s,
-                         "%u %103s %253s",
-                         &proto, s_peer, s_serv))
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("Unable to parse VPN record string `%s'\n"),
-                      s);
-          return GNUNET_SYSERR;
-        }
-        *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
-        *data = vpn = GNUNET_malloc (*data_size);
-        if (GNUNET_OK !=
-            GNUNET_CRYPTO_eddsa_public_key_from_string ((char*) s_peer,
-                                                        strlen (s_peer),
-                                                        &vpn->peer.public_key))
-        {
-          GNUNET_free (vpn);
-          *data_size = 0;
-          return GNUNET_SYSERR;
-        }
-        vpn->proto = htons ((uint16_t) proto);
-        strcpy ((char*)&vpn[1], s_serv);
-        return GNUNET_OK;
-      }
-    case GNUNET_GNSRECORD_TYPE_BOX:
-      {
-        struct GNUNET_GNSRECORD_BoxRecord *box;
-        size_t rest;
-        unsigned int protocol;
-        unsigned int service;
-        unsigned int record_type;
-        void *bval;
-        size_t bval_size;
-
-        if (3 != SSCANF (s,
-                         "%u %u %u ",
-                         &protocol,
-                         &service,
-                         &record_type))
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("Unable to parse BOX record string `%s'\n"),
-                      s);
-          return GNUNET_SYSERR;
-        }
-        rest = snprintf (NULL, 0,
-                         "%u %u %u ",
-                         protocol,
-                         service,
-                         record_type);
-        if (GNUNET_OK !=
-            GNUNET_GNSRECORD_string_to_value (record_type,
-                                              &s[rest],
-                                              &bval,
-                                              &bval_size))
-          return GNUNET_SYSERR;
-        *data_size = sizeof (struct GNUNET_GNSRECORD_BoxRecord) + bval_size;
-        *data = box = GNUNET_malloc (*data_size);
-        box->protocol = htons (protocol);
-        box->service = htons (service);
-        box->record_type = htonl (record_type);
-        GNUNET_memcpy (&box[1],
-                       bval,
-                       bval_size);
-        GNUNET_free (bval);
-        return GNUNET_OK;
-      }
-    default:
+  case GNUNET_GNSRECORD_TYPE_PKEY:
+    if (GNUNET_OK !=
+        GNUNET_CRYPTO_ecdsa_public_key_from_string (s, strlen (s), &pkey))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Unable to parse PKEY record `%s'\n"),
+                  s);
+      return GNUNET_SYSERR;
+    }
+    *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
+    GNUNET_memcpy (*data, &pkey, sizeof (pkey));
+    *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
+    return GNUNET_OK;
+
+  case GNUNET_GNSRECORD_TYPE_NICK:
+    *data = GNUNET_strdup (s);
+    *data_size = strlen (s);
+    return GNUNET_OK;
+  case GNUNET_GNSRECORD_TYPE_LEHO:
+    *data = GNUNET_strdup (s);
+    *data_size = strlen (s);
+    return GNUNET_OK;
+  case GNUNET_GNSRECORD_TYPE_GNS2DNS: {
+    char nsbuf[514];
+    char *cpy;
+    char *at;
+    size_t off;
+
+    cpy = GNUNET_strdup (s);
+    at = strchr (cpy, '@');
+    if (NULL == at)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Unable to parse GNS2DNS record `%s'\n"),
+                  s);
+      GNUNET_free (cpy);
+      return GNUNET_SYSERR;
+    }
+    *at = '\0';
+    at++;
+
+    off = 0;
+    if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf,
+                                                         sizeof (nsbuf),
+                                                         &off,
+                                                         cpy)) ||
+        (GNUNET_OK !=
+         GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof (nsbuf), &off, at)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Failed to serialize GNS2DNS record with value `%s'\n"),
+                  s);
+      GNUNET_free (cpy);
       return GNUNET_SYSERR;
+    }
+    GNUNET_free (cpy);
+    *data_size = off;
+    *data = GNUNET_malloc (off);
+    GNUNET_memcpy (*data, nsbuf, off);
+    return GNUNET_OK;
+  }
+  case GNUNET_GNSRECORD_TYPE_VPN: {
+    struct GNUNET_TUN_GnsVpnRecord *vpn;
+    char s_peer[103 + 1];
+    char s_serv[253 + 1];
+    unsigned int proto;
+
+    if (3 != sscanf (s, "%u %103s %253s", &proto, s_peer, s_serv))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Unable to parse VPN record string `%s'\n"),
+                  s);
+      return GNUNET_SYSERR;
+    }
+    *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
+    *data = vpn = GNUNET_malloc (*data_size);
+    if (GNUNET_OK !=
+        GNUNET_CRYPTO_eddsa_public_key_from_string ((char *) s_peer,
+                                                    strlen (s_peer),
+                                                    &vpn->peer.public_key))
+    {
+      GNUNET_free (vpn);
+      *data_size = 0;
+      return GNUNET_SYSERR;
+    }
+    vpn->proto = htons ((uint16_t) proto);
+    strcpy ((char *) &vpn[1], s_serv);
+    return GNUNET_OK;
+  }
+  case GNUNET_GNSRECORD_TYPE_BOX: {
+    struct GNUNET_GNSRECORD_BoxRecord *box;
+    size_t rest;
+    unsigned int protocol;
+    unsigned int service;
+    unsigned int record_type;
+    void *bval;
+    size_t bval_size;
+
+    if (3 != sscanf (s, "%u %u %u ", &protocol, &service, &record_type))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _ ("Unable to parse BOX record string `%s'\n"),
+                  s);
+      return GNUNET_SYSERR;
+    }
+    rest = snprintf (NULL, 0, "%u %u %u ", protocol, service, record_type);
+    if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (record_type,
+                                                       &s[rest],
+                                                       &bval,
+                                                       &bval_size))
+      return GNUNET_SYSERR;
+    *data_size = sizeof (struct GNUNET_GNSRECORD_BoxRecord) + bval_size;
+    *data = box = GNUNET_malloc (*data_size);
+    box->protocol = htons (protocol);
+    box->service = htons (service);
+    box->record_type = htonl (record_type);
+    GNUNET_memcpy (&box[1], bval, bval_size);
+    GNUNET_free (bval);
+    return GNUNET_OK;
+  }
+  default:
+    return GNUNET_SYSERR;
   }
 }
 
@@ -327,18 +284,17 @@ gns_string_to_value (void *cls,
  * Mapping of record type numbers to human-readable
  * record type names.
  */
-static struct {
+static struct
+{
   const char *name;
   uint32_t number;
-} gns_name_map[] = {
-  { "PKEY",  GNUNET_GNSRECORD_TYPE_PKEY },
-  { "NICK",  GNUNET_GNSRECORD_TYPE_NICK },
-  { "LEHO",  GNUNET_GNSRECORD_TYPE_LEHO },
-  { "VPN", GNUNET_GNSRECORD_TYPE_VPN },
-  { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS },
-  { "BOX", GNUNET_GNSRECORD_TYPE_BOX },
-  { NULL, UINT32_MAX }
-};
+} gns_name_map[] = {{"PKEY", GNUNET_GNSRECORD_TYPE_PKEY},
+                    {"NICK", GNUNET_GNSRECORD_TYPE_NICK},
+                    {"LEHO", GNUNET_GNSRECORD_TYPE_LEHO},
+                    {"VPN", GNUNET_GNSRECORD_TYPE_VPN},
+                    {"GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS},
+                    {"BOX", GNUNET_GNSRECORD_TYPE_BOX},
+                    {NULL, UINT32_MAX}};
 
 
 /**
@@ -349,15 +305,13 @@ static struct {
  * @return corresponding number, UINT32_MAX on error
  */
 static uint32_t
-gns_typename_to_number (void *cls,
-                        const char *gns_typename)
+gns_typename_to_number (void *cls, const char *gns_typename)
 {
   unsigned int i;
 
-  i=0;
-  while ( (NULL != gns_name_map[i].name) &&
-          (0 != strcasecmp (gns_typename,
-                            gns_name_map[i].name)) )
+  i = 0;
+  while ((NULL != gns_name_map[i].name) &&
+         (0 != strcasecmp (gns_typename, gns_name_map[i].name)))
     i++;
   return gns_name_map[i].number;
 }
@@ -371,14 +325,12 @@ gns_typename_to_number (void *cls,
  * @return corresponding typestring, NULL on error
  */
 static const char *
-gns_number_to_typename (void *cls,
-                        uint32_t type)
+gns_number_to_typename (void *cls, uint32_t type)
 {
   unsigned int i;
 
-  i=0;
-  while ( (NULL != gns_name_map[i].name) &&
-          (type != gns_name_map[i].number) )
+  i = 0;
+  while ((NULL != gns_name_map[i].name) && (type != gns_name_map[i].number))
     i++;
   return gns_name_map[i].name;
 }
index 636a734030f2ad1f94cbcdd50c2b54cb947c3a2c..3f62d3d77cf9360f158c999bf0c498c2f2d6dac2 100644 (file)
@@ -415,13 +415,13 @@ dns_string_to_value (void *cls,
     typep = strtok (sdup, " ");
     if ((NULL == typep) ||
         ((0 == (type = rfc4398_mnemonic_to_value (typep))) &&
-         ((1 != SSCANF (typep, "%u", &type)) || (type > UINT16_MAX))))
+         ((1 != sscanf (typep, "%u", &type)) || (type > UINT16_MAX))))
     {
       GNUNET_free (sdup);
       return GNUNET_SYSERR;
     }
     keyp = strtok (NULL, " ");
-    if ((NULL == keyp) || (1 != SSCANF (keyp, "%u", &key)) ||
+    if ((NULL == keyp) || (1 != sscanf (keyp, "%u", &key)) ||
         (key > UINT16_MAX))
     {
       GNUNET_free (sdup);
@@ -486,7 +486,7 @@ dns_string_to_value (void *cls,
     unsigned int soa_min;
     size_t off;
 
-    if (7 != SSCANF (s,
+    if (7 != sscanf (s,
                      "rname=%253s mname=%253s %u,%u,%u,%u,%u",
                      soa_rname,
                      soa_mname,
@@ -549,7 +549,7 @@ dns_string_to_value (void *cls,
     unsigned int mx_pref;
     size_t off;
 
-    if (2 != SSCANF (s, "%u,%253s", &mx_pref, mxhost))
+    if (2 != sscanf (s, "%u,%253s", &mx_pref, mxhost))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _ ("Unable to parse MX record `%s'\n"),
@@ -582,7 +582,7 @@ dns_string_to_value (void *cls,
     unsigned int port;
     size_t off;
 
-    if (4 != SSCANF (s, "%u %u %u %253s", &priority, &weight, &port, srvtarget))
+    if (4 != sscanf (s, "%u %u %u %253s", &priority, &weight, &port, srvtarget))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _ ("Unable to parse SRV record `%s'\n"),
@@ -630,7 +630,7 @@ dns_string_to_value (void *cls,
     size_t slen = strlen (s) + 1;
     char hex[slen];
 
-    if (4 != SSCANF (s, "%u %u %u %s", &usage, &selector, &matching_type, hex))
+    if (4 != sscanf (s, "%u %u %u %s", &usage, &selector, &matching_type, hex))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _ ("Unable to parse TLSA record string `%s'\n"),
@@ -662,7 +662,7 @@ dns_string_to_value (void *cls,
     char tag[15]; //Max tag length 15
     char value[strlen (s) + 1]; //Should be more than enough
 
-    if (3 != SSCANF (s, "%u %s %[^\n]", &flags, tag, value))
+    if (3 != sscanf (s, "%u %s %[^\n]", &flags, tag, value))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _ ("Unable to parse CAA record string `%s'\n"),
index 0b176ac79667af4c81b3301062ade6d60caa72b4..612b5110a1111c14f6dbc19e34e6bbc4a4c21037 100644 (file)
@@ -67,13 +67,13 @@ add_to_buf (void *cls,
   size_t ret;
 
   ret = GNUNET_HELLO_add_address (address,
-                                 GNUNET_TIME_UNIT_FOREVER_ABS,
-                                 ac->buf,
-                                 ac->max);
+                                  GNUNET_TIME_UNIT_FOREVER_ABS,
+                                  ac->buf,
+                                  ac->max);
   ac->buf += ret;
   ac->max -= ret;
   ac->ret += ret;
-  address_count ++;
+  address_count++;
   return GNUNET_OK;
 }
 
@@ -87,9 +87,7 @@ add_to_buf (void *cls,
  * @return number of bytes added, 0 to terminate
  */
 static ssize_t
-add_from_hello (void *cls,
-                size_t max,
-                void *buf)
+add_from_hello (void *cls, size_t max, void *buf)
 {
   struct GNUNET_HELLO_Message **orig = cls;
   struct AddContext ac;
@@ -99,10 +97,9 @@ add_from_hello (void *cls,
   ac.buf = buf;
   ac.max = max;
   ac.ret = 0;
-  GNUNET_assert (NULL ==
-                GNUNET_HELLO_iterate_addresses (*orig,
-                                                GNUNET_NO, &add_to_buf,
-                                                &ac));
+  GNUNET_assert (
+    NULL ==
+    GNUNET_HELLO_iterate_addresses (*orig, GNUNET_NO, &add_to_buf, &ac));
   *orig = NULL;
   return ac.ret;
 }
@@ -121,67 +118,58 @@ main (int argc, char *argv[])
   GNUNET_log_setup ("gnunet-hello", "INFO", NULL);
   if (argc != 2)
   {
-    FPRINTF (stderr,
-            "%s",
-            _("Call with name of HELLO file to modify.\n"));
+    fprintf (stderr, "%s", _ ("Call with name of HELLO file to modify.\n"));
     return 1;
   }
-  if (GNUNET_OK != GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES, GNUNET_YES))
+  if (GNUNET_OK !=
+      GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES, GNUNET_YES))
   {
-    FPRINTF (stderr,
-            _("Error accessing file `%s': %s\n"),
-            argv[1],
-            STRERROR (errno));
+    fprintf (stderr,
+             _ ("Error accessing file `%s': %s\n"),
+             argv[1],
+             strerror (errno));
     return 1;
   }
   if (fsize > 65536)
   {
-    FPRINTF (stderr,
-            _("File `%s' is too big to be a HELLO\n"),
-            argv[1]);
+    fprintf (stderr, _ ("File `%s' is too big to be a HELLO\n"), argv[1]);
     return 1;
   }
   if (fsize < sizeof (struct GNUNET_MessageHeader))
   {
-    FPRINTF (stderr,
-            _("File `%s' is too small to be a HELLO\n"),
-            argv[1]);
+    fprintf (stderr, _ ("File `%s' is too small to be a HELLO\n"), argv[1]);
     return 1;
   }
   fh = GNUNET_DISK_file_open (argv[1],
-                             GNUNET_DISK_OPEN_READ,
-                             GNUNET_DISK_PERM_USER_READ);
+                              GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_PERM_USER_READ);
   if (NULL == fh)
   {
-    FPRINTF (stderr,
-            _("Error opening file `%s': %s\n"),
-            argv[1],
-            STRERROR (errno));
+    fprintf (stderr,
+             _ ("Error opening file `%s': %s\n"),
+             argv[1],
+             strerror (errno));
     return 1;
   }
   {
     char buf[fsize] GNUNET_ALIGN;
 
-    GNUNET_assert (fsize ==
-                  GNUNET_DISK_file_read (fh, buf, fsize));
+    GNUNET_assert (fsize == GNUNET_DISK_file_read (fh, buf, fsize));
     GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
     orig = (struct GNUNET_HELLO_Message *) buf;
-    if ( (fsize < GNUNET_HELLO_size (orig)) ||
-        (GNUNET_OK != GNUNET_HELLO_get_id (orig,
-                                            &pid)) )
+    if ((fsize < GNUNET_HELLO_size (orig)) ||
+        (GNUNET_OK != GNUNET_HELLO_get_id (orig, &pid)))
     {
-      FPRINTF (stderr,
-              _("Did not find well-formed HELLO in file `%s'\n"),
-              argv[1]);
+      fprintf (stderr,
+               _ ("Did not find well-formed HELLO in file `%s'\n"),
+               argv[1]);
       return 1;
     }
     {
       char *pids;
 
       pids = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid.public_key);
-      fprintf (stdout,
-               "Processing HELLO for peer `%s'\n",
-               pids);
+      fprintf (stdout, "Processing HELLO for peer `%s'\n", pids);
       GNUNET_free (pids);
     }
     result = GNUNET_HELLO_create (&pid.public_key,
@@ -189,34 +177,34 @@ main (int argc, char *argv[])
                                   &orig,
                                   GNUNET_HELLO_is_friend_only (orig));
     GNUNET_assert (NULL != result);
-     fh = GNUNET_DISK_file_open (argv[1],
-                                GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE,
-                                GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
-     if (NULL == fh)
-     {
-       FPRINTF (stderr,
-               _("Error opening file `%s': %s\n"),
-               argv[1],
-               STRERROR (errno));
-       GNUNET_free (result);
-       return 1;
-     }
-     fsize = GNUNET_HELLO_size (result);
-     if (fsize != GNUNET_DISK_file_write (fh,
-                                         result,
-                                         fsize))
-     {
-       FPRINTF (stderr,
-               _("Error writing HELLO to file `%s': %s\n"),
-               argv[1],
-               STRERROR (errno));
-       (void) GNUNET_DISK_file_close (fh);
-       return 1;
-     }
+    fh =
+      GNUNET_DISK_file_open (argv[1],
+                             GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE,
+                             GNUNET_DISK_PERM_USER_READ |
+                               GNUNET_DISK_PERM_USER_WRITE);
+    if (NULL == fh)
+    {
+      fprintf (stderr,
+               _ ("Error opening file `%s': %s\n"),
+               argv[1],
+               strerror (errno));
+      GNUNET_free (result);
+      return 1;
+    }
+    fsize = GNUNET_HELLO_size (result);
+    if (fsize != GNUNET_DISK_file_write (fh, result, fsize))
+    {
+      fprintf (stderr,
+               _ ("Error writing HELLO to file `%s': %s\n"),
+               argv[1],
+               strerror (errno));
+      (void) GNUNET_DISK_file_close (fh);
+      return 1;
+    }
     GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
   }
-  FPRINTF (stderr,
-           _("Modified %u addresses, wrote %u bytes\n"),
+  fprintf (stderr,
+           _ ("Modified %u addresses, wrote %u bytes\n"),
            address_count,
            (unsigned int) fsize);
   return 0;
index 79df4dfe8fb3d5153a7f090d11eeabd4cde7c744..19d031c3e4b40c47fb3b5f36660d0475765518ab 100644 (file)
Binary files a/src/hostlist/hostlists_learn_peer2.file and b/src/hostlist/hostlists_learn_peer2.file differ
index f9221567978db63d8a7e5f1ccf68e2551f9501b4..a18255e6dbedde7be2d46426cb152d396f089204 100644 (file)
@@ -424,7 +424,7 @@ setup_learn_peer (struct PeerContext *p,
   {
     if (GNUNET_YES == GNUNET_DISK_file_test (filename))
     {
-      result = UNLINK (filename);
+      result = unlink (filename);
       if (result == 0)
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     _("Hostlist file `%s' was removed\n"),
@@ -577,7 +577,7 @@ main (int argc, char *argv[])
   if (GNUNET_YES ==
       GNUNET_DISK_file_test ("hostlists_learn_peer.file"))
   {
-    if (0 == UNLINK ("hostlists_learn_peer.file"))
+    if (0 == unlink ("hostlists_learn_peer.file"))
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Hostlist file hostlists_learn_peer.file was removed\n");
   }
index 28b2db0dead825a66ebef66ea51006c1c7c4dd8a..6aaa7ae2e6d1d6ce1b85968f4036a3420f4b6117 100644 (file)
@@ -237,7 +237,7 @@ main (int argcx, char *argvx[])
                       &ok);
   if (0 == ok)
   {
-    FPRINTF (stderr, "%s", ".");
+    fprintf (stderr, "%s", ".");
     /* now do it again */
     ok = 1;
     GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
@@ -247,7 +247,7 @@ main (int argcx, char *argvx[])
                         options,
                         &run,
                         &ok);
-    FPRINTF (stderr, "%s", ".\n");
+    fprintf (stderr, "%s", ".\n");
   }
   GNUNET_DISK_purge_cfg_dir ("test_gnunet_daemon_hostlist_peer1.conf",
                              "GNUNET_TEST_HOME");
index 3e92a04cd56a0f1066a7e9d7ccd8ae37e2050f01..34fad3272ed6b4da14e0a513975367bd5e31e031 100644 (file)
@@ -64,7 +64,6 @@ struct Ego
    * String identifier for the ego.
    */
   char *identifier;
-
 };
 
 
@@ -122,10 +121,10 @@ get_ego_filename (struct Ego *ego)
   char *filename;
 
   GNUNET_asprintf (&filename,
-                  "%s%s%s",
-                  ego_directory,
-                  DIR_SEPARATOR_STR,
-                  ego->identifier);
+                   "%s%s%s",
+                   ego_directory,
+                   DIR_SEPARATOR_STR,
+                   ego->identifier);
   return filename;
 }
 
@@ -141,9 +140,7 @@ client_disconnect_cb (void *cls,
                       struct GNUNET_SERVICE_Client *client,
                       void *app_ctx)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Client %p disconnected\n",
-              client);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
 }
 
 
@@ -208,8 +205,8 @@ shutdown_task (void *cls)
  */
 static void
 send_result_code (struct GNUNET_SERVICE_Client *client,
-                 uint32_t result_code,
-                 const char *emsg)
+                  uint32_t result_code,
+                  const char *emsg)
 {
   struct ResultCodeMessage *rcm;
   struct GNUNET_MQ_Envelope *env;
@@ -219,9 +216,8 @@ send_result_code (struct GNUNET_SERVICE_Client *client,
     elen = 0;
   else
     elen = strlen (emsg) + 1;
-  env = GNUNET_MQ_msg_extra (rcm,
-                             elen,
-                             GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
+  env =
+    GNUNET_MQ_msg_extra (rcm, elen, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
   rcm->result_code = htonl (result_code);
   if (0 < elen)
     GNUNET_memcpy (&rcm[1], emsg, elen);
@@ -247,9 +243,7 @@ create_update_message (struct Ego *ego)
   size_t name_len;
 
   name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
-  env = GNUNET_MQ_msg_extra (um,
-                             name_len,
-                             GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
+  env = GNUNET_MQ_msg_extra (um, name_len, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
   um->name_len = htons (name_len);
   um->end_of_list = htons (GNUNET_NO);
   um->private_key = *ego->pk;
@@ -266,8 +260,7 @@ create_update_message (struct Ego *ego)
  * @return corresponding set default message
  */
 static struct GNUNET_MQ_Envelope *
-create_set_default_message (struct Ego *ego,
-                            const char *servicename)
+create_set_default_message (struct Ego *ego, const char *servicename)
 {
   struct SetDefaultMessage *sdm;
   struct GNUNET_MQ_Envelope *env;
@@ -295,31 +288,26 @@ create_set_default_message (struct Ego *ego,
  * @param message the message received
  */
 static void
-handle_start_message (void *cls,
-                      const struct GNUNET_MessageHeader *message)
+handle_start_message (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct UpdateMessage *ume;
   struct GNUNET_MQ_Envelope *env;
   struct Ego *ego;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received START message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
   GNUNET_SERVICE_client_mark_monitor (client);
   GNUNET_SERVICE_client_disable_continue_warning (client);
-  GNUNET_notification_context_add (nc,
-                                   GNUNET_SERVICE_client_get_mq(client));
+  GNUNET_notification_context_add (nc, GNUNET_SERVICE_client_get_mq (client));
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
     env = create_update_message (ego);
-    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(client), env);
+    GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   }
-  env = GNUNET_MQ_msg_extra (ume,
-                             0,
-                             GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
+  env = GNUNET_MQ_msg_extra (ume, 0, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
   ume->end_of_list = htons (GNUNET_YES);
   ume->name_len = htons (0);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(client), env);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -333,8 +321,7 @@ handle_start_message (void *cls,
  * @return #GNUNET_SYSERR if message was ill-formed
  */
 static int
-check_lookup_message (void *cls,
-                       const struct LookupMessage *message)
+check_lookup_message (void *cls, const struct LookupMessage *message)
 {
   GNUNET_MQ_check_zero_termination (message);
   return GNUNET_OK;
@@ -349,30 +336,25 @@ check_lookup_message (void *cls,
  * @param message the message received
  */
 static void
-handle_lookup_message (void *cls,
-                       const struct LookupMessage *message)
+handle_lookup_message (void *cls, const struct LookupMessage *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   const char *name;
   struct GNUNET_MQ_Envelope *env;
   struct Ego *ego;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received LOOKUP message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received LOOKUP message from client\n");
   name = (const char *) &message[1];
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 != strcasecmp (name,
-                         ego->identifier))
+    if (0 != strcasecmp (name, ego->identifier))
       continue;
     env = create_update_message (ego);
     GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
     GNUNET_SERVICE_client_continue (client);
     return;
   }
-  send_result_code (client,
-                    0,
-                    "ego not found");
+  send_result_code (client, 0, "ego not found");
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -386,8 +368,7 @@ handle_lookup_message (void *cls,
  * @return #GNUNET_SYSERR if message was ill-formed
  */
 static int
-check_lookup_by_suffix_message (void *cls,
-                               const struct LookupMessage *message)
+check_lookup_by_suffix_message (void *cls, const struct LookupMessage *message)
 {
   GNUNET_MQ_check_zero_termination (message);
   return GNUNET_OK;
@@ -402,8 +383,7 @@ check_lookup_by_suffix_message (void *cls,
  * @param message the message received
  */
 static void
-handle_lookup_by_suffix_message (void *cls,
-                                const struct LookupMessage *message)
+handle_lookup_by_suffix_message (void *cls, const struct LookupMessage *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   const char *name;
@@ -419,10 +399,9 @@ handle_lookup_by_suffix_message (void *cls,
 
     if ((strlen (ego->identifier) <= strlen (name)) &&
         (0 == strcmp (ego->identifier,
-                     &name[strlen (name) - strlen (ego->identifier)])) &&
+                      &name[strlen (name) - strlen (ego->identifier)])) &&
         ((strlen (name) == strlen (ego->identifier)) ||
-         ('.' == name[strlen (name) -
-                     strlen (ego->identifier) - 1])) &&
+         ('.' == name[strlen (name) - strlen (ego->identifier) - 1])) &&
         ((NULL == lprefix) ||
          (strlen (ego->identifier) > strlen (lprefix->identifier))))
     {
@@ -437,9 +416,7 @@ handle_lookup_by_suffix_message (void *cls,
     GNUNET_SERVICE_client_continue (client);
     return;
   }
-  send_result_code (client,
-                    0,
-                    "ego not found");
+  send_result_code (client, 0, "ego not found");
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -452,8 +429,7 @@ handle_lookup_by_suffix_message (void *cls,
  * @return #GNUNET_OK if @a msg is well-formed
  */
 static int
-check_get_default_message (void *cls,
-                           const struct GetDefaultMessage *msg)
+check_get_default_message (void *cls, const struct GetDefaultMessage *msg)
 {
   uint16_t size;
   uint16_t name_len;
@@ -467,9 +443,8 @@ check_get_default_message (void *cls,
   }
   name = (const char *) &msg[1];
   name_len = ntohs (msg->name_len);
-  if ( (name_len + sizeof (struct GetDefaultMessage) != size) ||
-       (0 != ntohs (msg->reserved)) ||
-       ('\0' != name[name_len - 1]) )
+  if ((name_len + sizeof (struct GetDefaultMessage) != size) ||
+      (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -487,8 +462,7 @@ check_get_default_message (void *cls,
  * @param message the message received
  */
 static void
-handle_get_default_message (void *cls,
-                            const struct GetDefaultMessage *gdm)
+handle_get_default_message (void *cls, const struct GetDefaultMessage *gdm)
 {
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_SERVICE_Client *client = cls;
@@ -502,11 +476,10 @@ handle_get_default_message (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received GET_DEFAULT for service `%s' from client\n",
               name);
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
-                                             name,
-                                             "DEFAULT_IDENTIFIER",
-                                             &identifier))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
+                                                          name,
+                                                          "DEFAULT_IDENTIFIER",
+                                                          &identifier))
   {
     send_result_code (client, 1, gettext_noop ("no default known"));
     GNUNET_SERVICE_client_continue (client);
@@ -515,11 +488,9 @@ handle_get_default_message (void *cls,
   }
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == strcmp (ego->identifier,
-                     identifier))
+    if (0 == strcmp (ego->identifier, identifier))
     {
-      env = create_set_default_message (ego,
-                                        name);
+      env = create_set_default_message (ego, name);
       GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
       GNUNET_SERVICE_client_continue (client);
       GNUNET_free (identifier);
@@ -528,12 +499,12 @@ handle_get_default_message (void *cls,
     }
   }
   GNUNET_free (identifier);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Failed to find ego `%s'\n",
-              name);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to find ego `%s'\n", name);
   GNUNET_free (name);
-  send_result_code (client, 1,
-                    gettext_noop ("default configured, but ego unknown (internal error)"));
+  send_result_code (client,
+                    1,
+                    gettext_noop (
+                      "default configured, but ego unknown (internal error)"));
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -560,8 +531,7 @@ key_cmp (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1,
  * @return #GNUNET_OK if @a msg is well-formed
  */
 static int
-check_set_default_message (void *cls,
-                           const struct SetDefaultMessage *msg)
+check_set_default_message (void *cls, const struct SetDefaultMessage *msg)
 {
   uint16_t size;
   uint16_t name_len;
@@ -598,8 +568,7 @@ check_set_default_message (void *cls,
  * @param message the message received
  */
 static void
-handle_set_default_message (void *cls,
-                            const struct SetDefaultMessage *sdm)
+handle_set_default_message (void *cls, const struct SetDefaultMessage *sdm)
 {
   struct Ego *ego;
   struct GNUNET_SERVICE_Client *client = cls;
@@ -613,26 +582,27 @@ handle_set_default_message (void *cls,
               str);
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == key_cmp (ego->pk,
-                      &sdm->private_key))
+    if (0 == key_cmp (ego->pk, &sdm->private_key))
     {
       GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
                                              str,
                                              "DEFAULT_IDENTIFIER",
                                              ego->identifier);
       if (GNUNET_OK !=
-          GNUNET_CONFIGURATION_write (subsystem_cfg,
-                                      subsystem_cfg_file))
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _("Failed to write subsystem default identifier map to `%s'.\n"),
-                    subsystem_cfg_file);
+          GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_ERROR,
+          ("Failed to write subsystem default identifier map to `%s'.\n"),
+          subsystem_cfg_file);
       send_result_code (client, 0, NULL);
       GNUNET_SERVICE_client_continue (client);
       GNUNET_free (str);
       return;
     }
   }
-  send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
+  send_result_code (client,
+                    1,
+                    _ ("Unknown ego specified for service (internal error)"));
   GNUNET_free (str);
   GNUNET_SERVICE_client_continue (client);
 }
@@ -657,9 +627,7 @@ notify_listeners (struct Ego *ego)
   um->end_of_list = htons (GNUNET_NO);
   um->private_key = *ego->pk;
   GNUNET_memcpy (&um[1], ego->identifier, name_len);
-  GNUNET_notification_context_broadcast (nc,
-                                         &um->header,
-                                         GNUNET_NO);
+  GNUNET_notification_context_broadcast (nc, &um->header, GNUNET_NO);
   GNUNET_free (um);
 }
 
@@ -671,10 +639,9 @@ notify_listeners (struct Ego *ego)
  * @return #GNUNET_OK if @a msg is well-formed
  */
 static int
-check_create_message (void *cls,
-                      const struct CreateRequestMessage *msg)
+check_create_message (void *cls, const struct CreateRequestMessage *msg)
 {
-  
+
   uint16_t size;
   uint16_t name_len;
   const char *str;
@@ -699,7 +666,7 @@ check_create_message (void *cls,
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
-} 
+}
 
 /**
  * Handler for CREATE message from client, creates
@@ -710,24 +677,24 @@ check_create_message (void *cls,
  * @param message the message received
  */
 static void
-handle_create_message (void *cls,
-                       const struct CreateRequestMessage *crm)
+handle_create_message (void *cls, const struct CreateRequestMessage *crm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct Ego *ego;
   char *str;
   char *fn;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received CREATE message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n");
   str = GNUNET_strdup ((const char *) &crm[1]);
   GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str);
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == strcmp (ego->identifier,
-                     str))
+    if (0 == strcmp (ego->identifier, str))
     {
-      send_result_code (client, 1, gettext_noop ("identifier already in use for another ego"));
+      send_result_code (client,
+                        1,
+                        gettext_noop (
+                          "identifier already in use for another ego"));
       GNUNET_SERVICE_client_continue (client);
       GNUNET_free (str);
       return;
@@ -737,9 +704,7 @@ handle_create_message (void *cls,
   ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
   *ego->pk = crm->private_key;
   ego->identifier = GNUNET_strdup (str);
-  GNUNET_CONTAINER_DLL_insert (ego_head,
-                               ego_tail,
-                               ego);
+  GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego);
   send_result_code (client, 0, NULL);
   fn = get_ego_filename (ego);
   (void) GNUNET_DISK_directory_create_for_file (fn);
@@ -748,9 +713,8 @@ handle_create_message (void *cls,
                             &crm->private_key,
                             sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
                             GNUNET_DISK_PERM_USER_READ |
-                            GNUNET_DISK_PERM_USER_WRITE))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                              "write", fn);
+                              GNUNET_DISK_PERM_USER_WRITE))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
   GNUNET_free (fn);
   GNUNET_free (str);
   notify_listeners (ego);
@@ -782,17 +746,15 @@ struct RenameContext
  * @param section a section in the configuration to process
  */
 static void
-handle_ego_rename (void *cls,
-                   const char *section)
+handle_ego_rename (void *cls, const char *section)
 {
   struct RenameContext *rc = cls;
   char *id;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
-                                             section,
-                                             "DEFAULT_IDENTIFIER",
-                                             &id))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
+                                                          section,
+                                                          "DEFAULT_IDENTIFIER",
+                                                          &id))
     return;
   if (0 != strcmp (id, rc->old_name))
   {
@@ -814,8 +776,7 @@ handle_ego_rename (void *cls,
  * @return #GNUNET_OK if @a msg is well-formed
  */
 static int
-check_rename_message (void *cls,
-                      const struct RenameMessage *msg)
+check_rename_message (void *cls, const struct RenameMessage *msg)
 {
   uint16_t size;
   uint16_t old_name_len;
@@ -833,9 +794,9 @@ check_rename_message (void *cls,
   new_name_len = ntohs (msg->new_name_len);
   old_name = (const char *) &msg[1];
   new_name = &old_name[old_name_len];
-  if ( (old_name_len + new_name_len + sizeof (struct RenameMessage) != size) ||
-       ('\0' != old_name[old_name_len - 1]) ||
-       ('\0' != new_name[new_name_len - 1]) )
+  if ((old_name_len + new_name_len + sizeof (struct RenameMessage) != size) ||
+      ('\0' != old_name[old_name_len - 1]) ||
+      ('\0' != new_name[new_name_len - 1]))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -843,7 +804,7 @@ check_rename_message (void *cls,
 
   return GNUNET_OK;
 }
+
 
 /**
  * Handler for RENAME message from client, creates
@@ -854,8 +815,7 @@ check_rename_message (void *cls,
  * @param message the message received
  */
 static void
-handle_rename_message (void *cls,
-                       const struct RenameMessage *rm)
+handle_rename_message (void *cls, const struct RenameMessage *rm)
 {
   uint16_t old_name_len;
   struct Ego *ego;
@@ -867,8 +827,7 @@ handle_rename_message (void *cls,
   char *fn_new;
   const char *old_name_tmp;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received RENAME message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n");
   old_name_len = ntohs (rm->old_name_len);
   old_name_tmp = (const char *) &rm[1];
   old_name = GNUNET_strdup (old_name_tmp);
@@ -879,8 +838,7 @@ handle_rename_message (void *cls,
   /* check if new name is already in use */
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == strcmp (ego->identifier,
-                     new_name))
+    if (0 == strcmp (ego->identifier, new_name))
     {
       send_result_code (client, 1, gettext_noop ("target name already exists"));
       GNUNET_SERVICE_client_continue (client);
@@ -893,8 +851,7 @@ handle_rename_message (void *cls,
   /* locate old name and, if found, perform rename */
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == strcmp (ego->identifier,
-                     old_name))
+    if (0 == strcmp (ego->identifier, old_name))
     {
       fn_old = get_ego_filename (ego);
       GNUNET_free (ego->identifier);
@@ -904,14 +861,14 @@ handle_rename_message (void *cls,
                                              &handle_ego_rename,
                                              &rename_ctx);
       if (GNUNET_OK !=
-          GNUNET_CONFIGURATION_write (subsystem_cfg,
-                                      subsystem_cfg_file))
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _("Failed to write subsystem default identifier map to `%s'.\n"),
-                    subsystem_cfg_file);
+          GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_ERROR,
+          ("Failed to write subsystem default identifier map to `%s'.\n"),
+          subsystem_cfg_file);
       ego->identifier = GNUNET_strdup (new_name);
       fn_new = get_ego_filename (ego);
-      if (0 != RENAME (fn_old, fn_new))
+      if (0 != rename (fn_old, fn_new))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old);
       GNUNET_free (fn_old);
       GNUNET_free (fn_new);
@@ -940,17 +897,15 @@ handle_rename_message (void *cls,
  * @param section a section in the configuration to process
  */
 static void
-handle_ego_delete (void *cls,
-                   const char *section)
+handle_ego_delete (void *cls, const char *section)
 {
   const char *identifier = cls;
   char *id;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
-                                             section,
-                                             "DEFAULT_IDENTIFIER",
-                                             &id))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
+                                                          section,
+                                                          "DEFAULT_IDENTIFIER",
+                                                          &id))
     return;
   if (0 != strcmp (id, identifier))
   {
@@ -972,8 +927,7 @@ handle_ego_delete (void *cls,
  * @return #GNUNET_OK if @a msg is well-formed
  */
 static int
-check_delete_message (void *cls,
-                      const struct DeleteMessage *msg)
+check_delete_message (void *cls, const struct DeleteMessage *msg)
 {
   uint16_t size;
   uint16_t name_len;
@@ -987,9 +941,8 @@ check_delete_message (void *cls,
   }
   name = (const char *) &msg[1];
   name_len = ntohs (msg->name_len);
-  if ( (name_len + sizeof (struct DeleteMessage) != size) ||
-       (0 != ntohs (msg->reserved)) ||
-       ('\0' != name[name_len - 1]) )
+  if ((name_len + sizeof (struct DeleteMessage) != size) ||
+      (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1007,38 +960,33 @@ check_delete_message (void *cls,
  * @param message the message received
  */
 static void
-handle_delete_message (void *cls,
-                       const struct DeleteMessage *dm)
+handle_delete_message (void *cls, const struct DeleteMessage *dm)
 {
   struct Ego *ego;
   char *name;
   char *fn;
   struct GNUNET_SERVICE_Client *client = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received DELETE message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received DELETE message from client\n");
   name = GNUNET_strdup ((const char *) &dm[1]);
   GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
 
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
-    if (0 == strcmp (ego->identifier,
-                     name))
+    if (0 == strcmp (ego->identifier, name))
     {
-      GNUNET_CONTAINER_DLL_remove (ego_head,
-                                   ego_tail,
-                                   ego);
+      GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, ego);
       GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg,
                                              &handle_ego_delete,
                                              ego->identifier);
       if (GNUNET_OK !=
-          GNUNET_CONFIGURATION_write (subsystem_cfg,
-                                      subsystem_cfg_file))
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    _("Failed to write subsystem default identifier map to `%s'.\n"),
-                    subsystem_cfg_file);
+          GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_ERROR,
+          ("Failed to write subsystem default identifier map to `%s'.\n"),
+          subsystem_cfg_file);
       fn = get_ego_filename (ego);
-      if (0 != UNLINK (fn))
+      if (0 != unlink (fn))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
       GNUNET_free (fn);
       GNUNET_free (ego->identifier);
@@ -1070,8 +1018,7 @@ handle_delete_message (void *cls,
  *  #GNUNET_SYSERR to abort iteration with error!
  */
 static int
-process_ego_file (void *cls,
-                  const char *filename)
+process_ego_file (void *cls, const char *filename)
 {
   struct Ego *ego;
   const char *fn;
@@ -1088,17 +1035,13 @@ process_ego_file (void *cls,
   {
     GNUNET_free (ego);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to parse ego information in `%s'\n"),
+                _ ("Failed to parse ego information in `%s'\n"),
                 filename);
     return GNUNET_OK;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Loaded ego `%s'\n",
-              fn + 1);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded ego `%s'\n", fn + 1);
   ego->identifier = GNUNET_strdup (fn + 1);
-  GNUNET_CONTAINER_DLL_insert (ego_head,
-                               ego_tail,
-                               ego);
+  GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego);
   return GNUNET_OK;
 }
 
@@ -1117,21 +1060,24 @@ run (void *cls,
 {
   cfg = c;
   nc = GNUNET_notification_context_create (1);
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg, "identity",
-                                               "EGODIR",
-                                               &ego_directory))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                            "identity",
+                                                            "EGODIR",
+                                                            &ego_directory))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "EGODIR");
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg, "identity",
+      GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                               "identity",
                                                "SUBSYSTEM_CFG",
                                                &subsystem_cfg_file))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "SUBSYSTEM_CFG");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "identity",
+                               "SUBSYSTEM_CFG");
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
@@ -1139,78 +1085,72 @@ run (void *cls,
               "Loading subsystem configuration `%s'\n",
               subsystem_cfg_file);
   subsystem_cfg = GNUNET_CONFIGURATION_create ();
-  if ( (GNUNET_YES ==
-        GNUNET_DISK_file_test (subsystem_cfg_file)) &&
-       (GNUNET_OK !=
-        GNUNET_CONFIGURATION_parse (subsystem_cfg,
-                                    subsystem_cfg_file)) )
+  if ((GNUNET_YES == GNUNET_DISK_file_test (subsystem_cfg_file)) &&
+      (GNUNET_OK !=
+       GNUNET_CONFIGURATION_parse (subsystem_cfg, subsystem_cfg_file)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to parse subsystem identity configuration file `%s'\n"),
+                _ (
+                  "Failed to parse subsystem identity configuration file `%s'\n"),
                 subsystem_cfg_file);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   stats = GNUNET_STATISTICS_create ("identity", cfg);
-  if (GNUNET_OK !=
-      GNUNET_DISK_directory_create (ego_directory))
+  if (GNUNET_OK != GNUNET_DISK_directory_create (ego_directory))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to create directory `%s' for storing egos\n"),
+                _ ("Failed to create directory `%s' for storing egos\n"),
                 ego_directory);
   }
-  GNUNET_DISK_directory_scan (ego_directory,
-                              &process_ego_file,
-                              NULL);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
+  GNUNET_DISK_directory_scan (ego_directory, &process_ego_file, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
 /**
  * Define "main" method using service macro.
  */
-GNUNET_SERVICE_MAIN
-("identity",
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_fixed_size (start_message,
-                          GNUNET_MESSAGE_TYPE_IDENTITY_START,
-                          struct GNUNET_MessageHeader,
-                          NULL),
- GNUNET_MQ_hd_var_size (lookup_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP,
-                        struct LookupMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX,
-                        struct LookupMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (get_default_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
-                        struct GetDefaultMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (set_default_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
-                        struct SetDefaultMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (create_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_CREATE,
-                        struct CreateRequestMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (rename_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_RENAME,
-                        struct RenameMessage,
-                        NULL),
- GNUNET_MQ_hd_var_size (delete_message,
-                        GNUNET_MESSAGE_TYPE_IDENTITY_DELETE,
-                        struct DeleteMessage,
-                        NULL),
- GNUNET_MQ_handler_end());
-
+GNUNET_SERVICE_MAIN (
+  "identity",
+  GNUNET_SERVICE_OPTION_NONE,
+  &run,
+  &client_connect_cb,
+  &client_disconnect_cb,
+  NULL,
+  GNUNET_MQ_hd_fixed_size (start_message,
+                           GNUNET_MESSAGE_TYPE_IDENTITY_START,
+                           struct GNUNET_MessageHeader,
+                           NULL),
+  GNUNET_MQ_hd_var_size (lookup_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP,
+                         struct LookupMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX,
+                         struct LookupMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (get_default_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
+                         struct GetDefaultMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (set_default_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
+                         struct SetDefaultMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (create_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_CREATE,
+                         struct CreateRequestMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (rename_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_RENAME,
+                         struct RenameMessage,
+                         NULL),
+  GNUNET_MQ_hd_var_size (delete_message,
+                         GNUNET_MESSAGE_TYPE_IDENTITY_DELETE,
+                         struct DeleteMessage,
+                         NULL),
+  GNUNET_MQ_handler_end ());
 
 
 /* end of gnunet-service-identity.c */
index 3525a06076e4a6e344c9b2eb76b98627a82d2b82..775257768a5cf76ef6e58967c9ab2cd365c26411 100644 (file)
@@ -25,7 +25,7 @@ gnunetinclude_HEADERS = \
 else
 
 gnunetinclude_HEADERS = \
-  platform.h plibc.h $(WINPROC) gettext.h \
+  platform.h $(WINPROC) gettext.h \
   compat.h \
   gnunet_applications.h \
   gnunet_arm_service.h \
index 66d0b8ac3314e9041a1a12a17862d203eb8686fa..6eed12ddbbeb9234cc1a32cd5c39b8ee32a07ab7 100644 (file)
@@ -964,7 +964,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
                 cmd,                                         \
                 __FILE__,                                    \
                 __LINE__,                                    \
-                STRERROR (errno));                           \
+                strerror (errno));                           \
   } while (0)
 
 
@@ -983,7 +983,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
                      cmd,                                         \
                      __FILE__,                                    \
                      __LINE__,                                    \
-                     STRERROR (errno));                           \
+                     strerror (errno));                           \
   } while (0)
 
 
@@ -1002,7 +1002,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
                 filename,                                                 \
                 __FILE__,                                                 \
                 __LINE__,                                                 \
-                STRERROR (errno));                                        \
+                strerror (errno));                                        \
   } while (0)
 
 
@@ -1022,7 +1022,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
                      filename,                                                 \
                      __FILE__,                                                 \
                      __LINE__,                                                 \
-                     STRERROR (errno));                                        \
+                     strerror (errno));                                        \
   } while (0)
 
 /* ************************* endianess conversion ****************** */
index 0e3144ee87eab347702c8f84c6c4d6128b3b34ed..6a3e8e4b8c030090f25214d068ddca0a5952e098 100644 (file)
 #include <sys/endian.h>
 #endif
 
-#include "plibc.h"
+/* From plibc. */
+#ifdef Q_OS_WIN32
+#define WINDOWS 1
+#endif
+
+#ifndef WINDOWS
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_STR "/"
+#define PATH_SEPARATOR ':'
+#define PATH_SEPARATOR_STR ":"
+#define NEWLINE "\n"
+#else
+#define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_STR "\\"
+#define PATH_SEPARATOR ';'
+#define PATH_SEPARATOR_STR ";"
+#define NEWLINE "\r\n"
+#endif
+
 #include "compat.h"
 
 #include <locale.h>
diff --git a/src/include/plibc.h b/src/include/plibc.h
deleted file mode 100644 (file)
index 9c1d954..0000000
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
-     This file is part of PlibC.
-     Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Nils Durner (and other contributing authors)
-
-          This library is free software; you can redistribute it and/or
-          modify it under the terms of the GNU Lesser General Public
-          License as published by the Free Software Foundation; either
-          version 2.1 of the License, or (at your option) any later version.
-
-          This library is distributed in the hope that it will be useful,
-          but WITHOUT ANY WARRANTY; without even the implied warranty of
-          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-          Lesser General Public License for more details.
-
-          You should have received a copy of the GNU Lesser General Public
-          License along with this library; if not, write to the Free Software
-          Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-/**
- * @file
- * PlibC header
- *
- * @attention This file is usually not installed under Unix,
- *            so ship it with your application
- *
- * @version $Revision: 158 $
- */
-
-#ifndef _PLIBC_H_
-#define _PLIBC_H_
-
-#ifndef SIGALRM
- #define SIGALRM 14
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-#ifdef Q_OS_WIN32
- #define WINDOWS 1
-#endif
-
-#define HAVE_PLIBC_FD 0
-
-#ifdef WINDOWS
-
-#if ENABLE_NLS
-  #include "langinfo.h"
-#endif
-
-#include <ws2tcpip.h>
-#include <windows.h>
-#include <sys/types.h>
-#include <time.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <errno.h>
-#include <stdarg.h>
-
-#define __BYTE_ORDER BYTE_ORDER
-#define __BIG_ENDIAN BIG_ENDIAN
-
-/* Conflicts with our definitions */
-#define __G_WIN32_H__
-
-/* Convert LARGE_INTEGER to double */
-#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
-  (double)((x).LowPart))
-#ifndef HAVE_DECL__STATI64
-struct _stati64
-{
-    _dev_t st_dev;
-    _ino_t st_ino;
-    _mode_t st_mode;
-    short st_nlink;
-    short st_uid;
-    short st_gid;
-    _dev_t st_rdev;
-    __int64 st_size;
-    time_t st_atime;
-    time_t st_mtime;
-    time_t st_ctime;
-};
-#endif
-typedef unsigned int sa_family_t;
-
-struct sockaddr_un {
-  short sun_family; /*AF_UNIX*/
-  char sun_path[108]; /*path name */
-};
-
-#ifndef pid_t
-  #define pid_t DWORD
-#endif
-
-#ifndef error_t
-  #define error_t int
-#endif
-
-#ifndef WEXITSTATUS
-       #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
-#endif
-
-#ifndef MSG_DONTWAIT
-  #define MSG_DONTWAIT 0
-#endif
-
-enum
-{
-  _SC_PAGESIZE = 30,
-  _SC_PAGE_SIZE = 30
-};
-
-#if !defined(EACCESS)
-#  define EACCESS EACCES
-#endif
-
-/* Thanks to the Cygwin project */
-#if !defined(ENOCSI)
-#  define ENOCSI 43    /* No CSI structure available */
-#endif
-#if !defined(EL2HLT)
-#  define EL2HLT 44    /* Level 2 halted */
-#endif
-#if !defined(EDEADLK)
-#  define EDEADLK 45   /* Deadlock condition */
-#endif
-#if !defined(ENOLCK)
-#  define ENOLCK 46    /* No record locks available */
-#endif
-#if !defined(EBADE)
-#  define EBADE 50     /* Invalid exchange */
-#endif
-#if !defined(EBADR)
-#  define EBADR 51     /* Invalid request descriptor */
-#endif
-#if !defined(EXFULL)
-#  define EXFULL 52    /* Exchange full */
-#endif
-#if !defined(ENOANO)
-#  define ENOANO 53    /* No anode */
-#endif
-#if !defined(EBADRQC)
-#  define EBADRQC 54   /* Invalid request code */
-#endif
-#if !defined(EBADSLT)
-#  define EBADSLT 55   /* Invalid slot */
-#endif
-#if !defined(EDEADLOCK)
-#  define EDEADLOCK EDEADLK    /* File locking deadlock error */
-#endif
-#if !defined(EBFONT)
-#  define EBFONT 57    /* Bad font file fmt */
-#endif
-#if !defined(ENOSTR)
-#  define ENOSTR 60    /* Device not a stream */
-#endif
-#if !defined(ENODATA)
-#  define ENODATA 61   /* No data (for no delay io) */
-#endif
-#if !defined(ETIME)
-#  define ETIME 62     /* Timer expired */
-#endif
-#if !defined(ENOSR)
-#  define ENOSR 63     /* Out of streams resources */
-#endif
-#if !defined(ENONET)
-#  define ENONET 64    /* Machine is not on the network */
-#endif
-#if !defined(ENOPKG)
-#  define ENOPKG 65    /* Package not installed */
-#endif
-#if !defined(EREMOTE)
-#  define EREMOTE 66   /* The object is remote */
-#endif
-#if !defined(ENOLINK)
-#  define ENOLINK 67   /* The link has been severed */
-#endif
-#if !defined(EADV)
-#  define EADV 68              /* Advertise error */
-#endif
-#if !defined(ESRMNT)
-#  define ESRMNT 69    /* Srmount error */
-#endif
-#if !defined(ECOMM)
-#  define ECOMM 70     /* Communication error on send */
-#endif
-#if !defined(EMULTIHOP)
-#  define EMULTIHOP 74 /* Multihop attempted */
-#endif
-#if !defined(ELBIN)
-#  define ELBIN 75     /* Inode is remote (not really error) */
-#endif
-#if !defined(EDOTDOT)
-#  define EDOTDOT 76   /* Cross mount point (not really error) */
-#endif
-#if !defined(EBADMSG)
-#  define EBADMSG 77   /* Trying to read unreadable message */
-#endif
-#if !defined(ENOTUNIQ)
-#  define ENOTUNIQ 80  /* Given log. name not unique */
-#endif
-#if !defined(EBADFD)
-#  define EBADFD 81    /* f.d. invalid for this operation */
-#endif
-#if !defined(EREMCHG)
-#  define EREMCHG 82   /* Remote address changed */
-#endif
-#if !defined(ELIBACC)
-#  define ELIBACC 83   /* Can't access a needed shared lib */
-#endif
-#if !defined(ELIBBAD)
-#  define ELIBBAD 84   /* Accessing a corrupted shared lib */
-#endif
-#if !defined(ELIBSCN)
-#  define ELIBSCN 85   /* .lib section in a.out corrupted */
-#endif
-#if !defined(ELIBMAX)
-#  define ELIBMAX 86   /* Attempting to link in too many libs */
-#endif
-#if !defined(ELIBEXEC)
-#  define ELIBEXEC 87  /* Attempting to exec a shared library */
-#endif
-#if !defined(ENOSYS)
-#  define ENOSYS 88    /* Function not implemented */
-#endif
-#if !defined(ENMFILE)
-#  define ENMFILE 89      /* No more files */
-#endif
-#if !defined(ENOTEMPTY)
-#  define ENOTEMPTY 90 /* Directory not empty */
-#endif
-#if !defined(ENAMETOOLONG)
-#  define ENAMETOOLONG 91      /* File or path name too long */
-#endif
-#if !defined(EPFNOSUPPORT)
-#  define EPFNOSUPPORT 96 /* Protocol family not supported */
-#endif
-#if !defined(ENOSHARE)
-#  define ENOSHARE 97        /* No such host or network path */
-#endif
-#if !defined(ENOMEDIUM)
-#  define ENOMEDIUM 98       /* No medium (in tape drive) */
-#endif
-#if !defined(ESHUTDOWN)
-#  define ESHUTDOWN 99 /* Can't send after socket shutdown */
-#endif
-#if !defined(EADDRINUSE)
-#  define EADDRINUSE 100               /* Address already in use */
-#endif
-#if !defined(EADDRNOTAVAIL)
-#  define EADDRNOTAVAIL 101    /* Address not available */
-#endif
-#if !defined(EAFNOSUPPORT)
-#  define EAFNOSUPPORT 102 /* Address family not supported by protocol family */
-#endif
-#if !defined(EALREADY)
-#  define EALREADY 103         /* Socket already connected */
-#endif
-#if !defined(ECANCELED)
-#  define ECANCELED 105        /* Connection cancelled */
-#endif
-#if !defined(ECONNABORTED)
-#  define ECONNABORTED 106     /* Connection aborted */
-#endif
-#if !defined(ECONNREFUSED)
-#  define ECONNREFUSED 107     /* Connection refused */
-#endif
-#if !defined(ECONNRESET)
-#  define ECONNRESET 108  /* Connection reset by peer */
-#endif
-#if !defined(EDESTADDRREQ)
-#  define EDESTADDRREQ 109     /* Destination address required */
-#endif
-#if !defined(EHOSTUNREACH)
-#  define EHOSTUNREACH 110     /* Host is unreachable */
-#endif
-#if !defined(ECONNABORTED)
-#  define ECONNABORTED 111     /* Connection aborted */
-#endif
-#if !defined(EINPROGRESS)
-#  define EINPROGRESS 112              /* Connection already in progress */
-#endif
-#if !defined(EISCONN)
-#  define EISCONN 113              /* Socket is already connected */
-#endif
-#if !defined(ELOOP)
-#  define ELOOP 114    /* Too many symbolic links */
-#endif
-#if !defined(EMSGSIZE)
-#  define EMSGSIZE 115         /* Message too long */
-#endif
-#if !defined(ENETDOWN)
-#  define ENETDOWN 116         /* Network interface is not configured */
-#endif
-#if !defined(ENETRESET)
-#  define ENETRESET 117                /* Connection aborted by network */
-#endif
-#if !defined(ENETUNREACH)
-#  define ENETUNREACH 118              /* Network is unreachable */
-#endif
-#if !defined(ENOBUFS)
-#  define ENOBUFS 119  /* No buffer space available */
-#endif
-#if !defined(EHOSTDOWN)
-#  define EHOSTDOWN 120                /* Host is down */
-#endif
-#if !defined(EPROCLIM)
-#  define EPROCLIM 121         /* Too many processes */
-#endif
-#if !defined(EDQUOT)
-#  define EDQUOT 122                   /* Disk quota exceeded */
-#endif
-#if !defined(ENOPROTOOPT)
-#  define ENOPROTOOPT 123      /* Protocol not available */
-#endif
-#if !defined(ESOCKTNOSUPPORT)
-#  define ESOCKTNOSUPPORT 124  /* Socket type not supported */
-#endif
-#if !defined(ESTALE)
-#  define ESTALE 125          /* Unknown error */
-#endif
-#if !defined(ENOTCONN)
-#  define ENOTCONN 126         /* Socket is not connected */
-#endif
-#if !defined(ETOOMANYREFS)
-#  define ETOOMANYREFS 127     /* Too many references: cannot splice */
-#endif
-#if !defined(ENOTSOCK)
-#  define ENOTSOCK 128 /* Socket operation on non-socket */
-#endif
-#if !defined(ENOTSUP)
-#  define ENOTSUP 129              /* Not supported */
-#endif
-#if !defined(EOPNOTSUPP)
-#  define EOPNOTSUPP 130       /* Operation not supported on transport endpoint */
-#endif
-#if !defined(EUSERS)
-#  define EUSERS 131                   /* Too many users */
-#endif
-#if !defined(EOVERFLOW)
-#  define EOVERFLOW 132 /* Value too large for defined data type */
-#endif
-#if !defined(EOWNERDEAD)
-#  define EOWNERDEAD 133          /* Unknown error */
-#endif
-#if !defined(EPROTO)
-#  define EPROTO 134   /* Protocol error */
-#endif
-#if !defined(EPROTONOSUPPORT)
-#  define EPROTONOSUPPORT 135  /* Unknown protocol */
-#endif
-#if !defined(EPROTOTYPE)
-#  define EPROTOTYPE 136       /* Protocol wrong type for socket */
-#endif
-#if !defined(ECASECLASH)
-#  define ECASECLASH 137      /* Filename exists with different case */
-#endif
-#if !defined(ETIMEDOUT)
-/* Make sure it's the same as WSATIMEDOUT */
-#  define ETIMEDOUT 138                /* Connection timed out */
-#endif
-#if !defined(EWOULDBLOCK) || EWOULDBLOCK == 140
-#  undef EWOULDBLOCK /* MinGW-w64 defines it as 140, but we want it as EAGAIN */
-#  define EWOULDBLOCK EAGAIN   /* Operation would block */
-#endif
-
-#undef HOST_NOT_FOUND
-#define HOST_NOT_FOUND 1
-#undef TRY_AGAIN
-#define TRY_AGAIN 2
-#undef NO_RECOVERY
-#define NO_RECOVERY 3
-#undef NO_ADDRESS
-#define NO_ADDRESS 4
-
-#define PROT_READ   0x1
-#define PROT_WRITE  0x2
-#define MAP_SHARED  0x1
-#define MAP_PRIVATE 0x2 /* unsupported */
-#define MAP_FIXED   0x10
-#define MAP_ANONYMOUS 0x20 /* unsupported */
-#define MAP_FAILED  ((void *)-1)
-
-#define MS_ASYNC        1       /* sync memory asynchronously */
-#define MS_INVALIDATE   2       /* invalidate the caches */
-#define MS_SYNC         4       /* synchronous memory sync */
-
-struct statfs
-{
-  long f_type;                  /* type of filesystem (see below) */
-  long f_bsize;                 /* optimal transfer block size */
-  long f_blocks;                /* total data blocks in file system */
-  long f_bfree;                 /* free blocks in fs */
-  long f_bavail;                /* free blocks avail to non-superuser */
-  long f_files;                 /* total file nodes in file system */
-  long f_ffree;                 /* free file nodes in fs */
-  long f_fsid;                  /* file system id */
-  long f_namelen;               /* maximum length of filenames */
-  long f_spare[6];              /* spare for later */
-};
-#define sleep(secs) (Sleep(secs * 1000))
-
-/*********************** statfs *****************************/
-/* fake block size */
-#define FAKED_BLOCK_SIZE 512
-
-/* linux-compatible values for fs type */
-#define MSDOS_SUPER_MAGIC     0x4d44
-#define NTFS_SUPER_MAGIC      0x5346544E
-
-/*********************** End of statfs ***********************/
-
-#define SHUT_RDWR SD_BOTH
-
-/* Operations for flock() */
-#define LOCK_SH  1       /* shared lock */
-#define LOCK_EX  2       /* exclusive lock */
-#define LOCK_NB  4       /* or'd with one of the above to prevent
-                            blocking */
-#define LOCK_UN  8       /* remove lock */
-
-/* Not supported under MinGW */
-#ifndef S_IRGRP
-#define S_IRGRP 0
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 0
-#endif
-#ifndef S_IROTH
-#define S_IROTH 0
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 0
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0
-#endif
-#ifndef S_ISUID
-#define S_ISUID 0
-#endif
-#ifndef S_ISGID
-#define S_ISGID 0
-#endif
-#ifndef S_ISVTX
-#define S_ISVTX 0
-#endif
-#ifndef S_IRWXG
-#define S_IRWXG 0
-#endif
-#ifndef S_IRWXO
-#define S_IRWXO 0
-#endif
-
-#define SHUT_WR SD_SEND
-#define SHUT_RD SD_RECEIVE
-#define SHUT_RDWR SD_BOTH
-
-#define SIGKILL 9
-#define SIGTERM 15
-
-#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
-
-BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
-BOOL _plibc_CreateShortcutW(const wchar_t *pwszSrc, const wchar_t *pwszDest);
-BOOL _plibc_DereferenceShortcut(char *pszShortcut);
-BOOL _plibc_DereferenceShortcutW(wchar_t *pwszShortcut);
-char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
-wchar_t *plibc_ChooseDirW(wchar_t *pwszTitle, unsigned long ulFlags);
-char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags);
-wchar_t *plibc_ChooseFileW(wchar_t *pwszTitle, unsigned long ulFlags);
-
-long QueryRegistry(HKEY hMainKey, const char *pszKey, const char *pszSubKey,
-              char *pszBuffer, long *pdLength);
-long QueryRegistryW(HKEY hMainKey, const wchar_t *pszKey, const wchar_t *pszSubKey,
-              wchar_t *pszBuffer, long *pdLength);
-
-BOOL __win_IsHandleMarkedAsBlocking(int hHandle);
-void __win_SetHandleBlockingMode(int s, BOOL bBlocking);
-void __win_DiscardHandleBlockingMode(int s);
-int _win_isSocketValid(int s);
-int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
-int plibc_conv_to_win_pathw(const wchar_t *pszUnix, wchar_t *pwszWindows);
-
-int plibc_conv_to_win_pathwconv(const char *pszUnix, wchar_t *pwszWindows);
-int plibc_conv_to_win_pathwconv_ex(const char *pszUnix, wchar_t *pszWindows, int derefLinks);
-
-unsigned plibc_get_handle_count();
-
-typedef void (*TPanicProc) (int, char *);
-void plibc_set_panic_proc(TPanicProc proc);
-void plibc_set_stat_size_size(int iLength);
-void plibc_set_stat_time_size(int iLength);
-
-int flock(int fd, int operation);
-int fsync(int fildes);
-int inet_pton(int af, const char *src, void *dst);
-int inet_pton4(const char *src, u_char *dst, int pton);
-#if USE_IPV6
-int inet_pton6(const char *src, u_char *dst);
-#endif
-int statfs(const char *path, struct statfs *buf);
-const char *hstrerror(int err);
-int mkstemp(char *tmplate);
-char *strptime (const char *buf, const char *format, struct tm *tm);
-const char *inet_ntop(int af, const void *src, char *dst, size_t size);
-#ifndef gmtime_r
-struct tm *gmtime_r(const time_t *clock, struct tm *result);
-#endif
-
-int plibc_init(char *pszOrg, char *pszApp);
-int plibc_init_utf8(char *pszOrg, char *pszApp, int utf8_mode);
-void plibc_shutdown();
-int plibc_initialized();
-
-void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
-void SetErrnoFromWinsockError(long lWinError);
-void SetHErrnoFromWinError(long lWinError);
-void SetErrnoFromHRESULT(HRESULT hRes);
-int GetErrnoFromWinsockError(long lWinError);
-FILE *_win_fopen(const char *filename, const char *mode);
-int _win_fclose(FILE *);
-DIR *_win_opendir(const char *dirname);
-struct dirent *_win_readdir(DIR *dirp);
-int _win_closedir(DIR *dirp);
-int _win_open(const char *filename, int oflag, ...);
-#ifdef ENABLE_NLS
-char *_win_bindtextdomain(const char *domainname, const char *dirname);
-#endif
-int _win_chdir(const char *path);
-int _win_close(int fd);
-int _win_creat(const char *path, mode_t mode);
-char *_win_ctime(const time_t *clock);
-char *_win_ctime_r(const time_t *clock, char *buf);
-int _win_fstat(int handle, struct stat *buffer);
-int _win_ftruncate(int fildes, off_t length);
-int _win_truncate(const char *fname, int distance);
-int _win_kill(pid_t pid, int sig);
-int _win_pipe(int *phandles);
-int _win_mkfifo(const char *path, mode_t mode);
-int _win_rmdir(const char *path);
-int _win_access( const char *path, int mode );
-int _win_chmod(const char *filename, int pmode);
-char *realpath(const char *file_name, char *resolved_name);
-long _win_random(void);
-void _win_srandom(unsigned int seed);
-int _win_remove(const char *path);
-int _win_rename(const char *oldname, const char *newname);
-int _win_stat(const char *path, struct stat *buffer);
-int _win_stati64(const char *path, struct _stati64 *buffer);
-long _win_sysconf(int name);
-int _win_unlink(const char *filename);
-int _win_write(int fildes, const void *buf, size_t nbyte);
-int _win_read(int fildes, void *buf, size_t nbyte);
-size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
-size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
-int _win_symlink(const char *path1, const char *path2);
-void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
-                unsigned long long offset);
-int _win_msync(void *start, size_t length, int flags);
-int _win_munmap(void *start, size_t length);
-int _win_lstat(const char *path, struct stat *buf);
-int _win_lstati64(const char *path, struct _stati64 *buf);
-int _win_readlink(const char *path, char *buf, size_t bufsize);
-int _win_accept(int s, struct sockaddr *addr, int *addrlen);
-
-pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
-int _win_bind(int s, const struct sockaddr *name, int namelen);
-int _win_connect(int s,const struct sockaddr *name, int namelen);
-int _win_getpeername(int s, struct sockaddr *name,
-                int *namelen);
-int _win_getsockname(int s, struct sockaddr *name,
-                int *namelen);
-int _win_getsockopt(int s, int level, int optname, char *optval,
-                               int *optlen);
-int _win_listen(int s, int backlog);
-int _win_recv(int s, char *buf, int len, int flags);
-int _win_recvfrom(int s, void *buf, int len, int flags,
-             struct sockaddr *from, int *fromlen);
-int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
-                const struct timeval *tv);
-int _win_send(int s, const char *buf, int len, int flags);
-int _win_sendto(int s, const char *buf, int len, int flags,
-                const struct sockaddr *to, int tolen);
-int _win_setsockopt(int s, int level, int optname, const void *optval,
-                    int optlen);
-int _win_shutdown(int s, int how);
-int _win_socket(int af, int type, int protocol);
-int _win_socketpair(int af, int type, int protocol, int socket_vector[2]);
-struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
-struct hostent *_win_gethostbyname(const char *name);
-struct hostent *gethostbyname2(const char *name, int af);
-char *_win_strerror(int errnum);
-int IsWinNT();
-char *index(const char *s, int c);
-char *_win_strtok_r (char *ptr, const char *sep, char **end);
-
-#if !HAVE_STRNDUP
-char *strndup (const char *s, size_t n);
-#endif
-#if !HAVE_STRNLEN && (!defined(__MINGW64_VERSION_MAJOR) || !defined(_INC_STRING))
-size_t strnlen (const char *str, size_t maxlen);
-#endif
-char *stpcpy(char *dest, const char *src);
-char *strcasestr(const char *haystack_start, const char *needle_start);
-#ifndef __MINGW64_VERSION_MAJOR
-#define strcasecmp(a, b) stricmp(a, b)
-#define strncasecmp(a, b, c) strnicmp(a, b, c)
-#endif
-#ifndef wcscasecmp
-#define wcscasecmp(a, b) wcsicmp(a, b)
-#endif
-#ifndef wcsncasecmp
-#define wcsncasecmp(a, b, c) wcsnicmp(a, b, c)
-#endif
-#ifndef strtok_r /* winpthreads defines it in pthread.h */
-#define strtok_r _win_strtok_r
-#endif
-#endif /* WINDOWS */
-
-#ifndef WINDOWS
- #define DIR_SEPARATOR '/'
- #define DIR_SEPARATOR_STR "/"
- #define PATH_SEPARATOR ':'
- #define PATH_SEPARATOR_STR ":"
- #define NEWLINE "\n"
-
-#ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
-#endif
- #define CREAT(p, m) creat(p, m)
- #define PLIBC_CTIME(c) ctime(c)
- #define CTIME_R(c, b) ctime_r(c, b)
- #undef FOPEN
- #define FOPEN(f, m) fopen(f, m)
- #define FCLOSE(f) fclose(f)
- #define FTRUNCATE(f, l) ftruncate(f, l)
- #define TRUNCATE(f, l) truncate(f, l)
- #define OPENDIR(d) opendir(d)
- #define CLOSEDIR(d) closedir(d)
- #define READDIR(d) readdir(d)
- #define OPEN open
- #define CHDIR(d) chdir(d)
- #define CLOSE(f) close(f)
- #define LSEEK(f, o, w) lseek(f, o, w)
- #define RMDIR(f) rmdir(f)
- #define ACCESS(p, m) access(p, m)
- #define CHMOD(f, p) chmod(f, p)
- #define FSTAT(h, b) fstat(h, b)
- #define PLIBC_KILL(p, s) kill(p, s)
- #define PIPE(h) pipe(h)
- #define REMOVE(p) remove(p)
- #define RENAME(o, n) rename(o, n)
- #define STAT(p, b) stat(p, b)
- #define STAT64(p, b) stat64(p, b)
- #define SYSCONF(n) sysconf(n)
- #define UNLINK(f) unlink(f)
- #define WRITE(f, b, n) write(f, b, n)
- #define READ(f, b, n) read(f, b, n)
- #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
- #define SYMLINK(a, b) symlink(a, b)
- #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
- #define MKFIFO(p, m) mkfifo(p, m)
- #define MSYNC(s, l, f) msync(s, l, f)
- #define MUNMAP(s, l) munmap(s, l)
- #define STRERROR(i) strerror(i)
- #define RANDOM() random()
- #define SRANDOM(s) srandom(s)
- #define READLINK(p, b, s) readlink(p, b, s)
- #define LSTAT(p, b) lstat(p, b)
- #define LSTAT64(p, b) lstat64(p, b)
- #define PRINTF printf
- #define FPRINTF fprintf
- #define VPRINTF(f, a) vprintf(f, a)
- #define VFPRINTF(s, f, a) vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
- #define _REAL_SNPRINTF snprintf
- #define SPRINTF sprintf
- #define VSSCANF(s, f, a) vsscanf(s, f, a)
- #define SSCANF sscanf
- #define VFSCANF(s, f, a) vfscanf(s, f, a)
- #define VSCANF(f, a) vscanf(f, a)
- #define SCANF scanf
- #define FSCANF fscanf
- #define WAITPID(p, s, o) waitpid(p, s, o)
- #define ACCEPT(s, a, l) accept(s, a, l)
- #define BIND(s, n, l) bind(s, n, l)
- #define CONNECT(s, n, l) connect(s, n, l)
- #define GETPEERNAME(s, n, l) getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) listen(s, b)
- #define RECV(s, b, l, f) recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
- #define SEND(s, b, l, f) send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) shutdown(s, h)
- #define SOCKET(a, t, p) socket(a, t, p)
- #define SOCKETPAIR(a, t, p, v) socketpair(a, t, p, v)
- #define GETHOSTBYADDR(a, l, t) gethostbyaddr(a, l, t)
- #define GETHOSTBYNAME(n) gethostbyname(n)
- #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
- #define INSQUE(e, p) insque(e, p)
- #define REMQUE(e) remque(e)
- #define HSEARCH(i, a) hsearch(i, a)
- #define HCREATE(n) hcreate(n)
- #define HDESTROY() hdestroy()
- #define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h)
- #define HCREATE_R(n, h) hcreate_r(n, h)
- #define HDESTROY_R(h) hdestroy_r(h)
- #define TSEARCH(k, r, c) tsearch(k, r, c)
- #define TFIND(k, r, c) tfind(k, r, c)
- #define TDELETE(k, r, c) tdelete(k, r, c)
- #define TWALK(r, a) twalk(r, a)
- #define TDESTROY(r, f) tdestroy(r, f)
- #define LFIND(k, b, n, s, c) lfind(k, b, n, s, c)
- #define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c)
- #define STRUCT_STAT64 struct stat64
-#else
- #define DIR_SEPARATOR '\\'
- #define DIR_SEPARATOR_STR "\\"
- #define PATH_SEPARATOR ';'
- #define PATH_SEPARATOR_STR ";"
- #define NEWLINE "\r\n"
-
-#ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
-#endif
- #define CREAT(p, m) _win_creat(p, m)
- #define PLIBC_CTIME(c) _win_ctime(c)
- #define CTIME_R(c, b) _win_ctime_r(c, b)
- #define FOPEN(f, m) _win_fopen(f, m)
- #define FCLOSE(f) _win_fclose(f)
- #define FTRUNCATE(f, l) _win_ftruncate(f, l)
- #define TRUNCATE(f, l) _win_truncate(f, l)
- #define OPENDIR(d) _win_opendir(d)
- #define CLOSEDIR(d) _win_closedir(d)
- #define READDIR(d) _win_readdir(d)
- #define OPEN _win_open
- #define CHDIR(d) _win_chdir(d)
- #define CLOSE(f) _win_close(f)
- #define PLIBC_KILL(p, s) _win_kill(p, s)
- #define LSEEK(f, o, w) lseek(f, o, w)
- #define FSTAT(h, b) _win_fstat(h, b)
- #define RMDIR(f) _win_rmdir(f)
- #define ACCESS(p, m) _win_access(p, m)
- #define CHMOD(f, p) _win_chmod(f, p)
- #define PIPE(h) _win_pipe(h)
- #define RANDOM() _win_random()
- #define SRANDOM(s) _win_srandom(s)
- #define REMOVE(p) _win_remove(p)
- #define RENAME(o, n) _win_rename(o, n)
- #define STAT(p, b) _win_stat(p, b)
- #define STAT64(p, b) _win_stati64(p, b)
- #define SYSCONF(n) _win_sysconf(n)
- #define UNLINK(f) _win_unlink(f)
- #define WRITE(f, b, n) _win_write(f, b, n)
- #define READ(f, b, n) _win_read(f, b, n)
- #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
- #define SYMLINK(a, b) _win_symlink(a, b)
- #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
- #define MKFIFO(p, m) _win_mkfifo(p, m)
- #define MSYNC(s, l, f) _win_msync(s, l, f)
- #define MUNMAP(s, l) _win_munmap(s, l)
- #define STRERROR(i) _win_strerror(i)
- #define READLINK(p, b, s) _win_readlink(p, b, s)
- #define LSTAT(p, b) _win_lstat(p, b)
- #define LSTAT64(p, b) _win_lstati64(p, b)
- #define PRINTF printf
- #define FPRINTF fprintf
- #define VPRINTF(f, a) vprintf(f, a)
- #define VFPRINTF(s, f, a) vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
- #define _REAL_SNPRINTF snprintf
- #define SPRINTF sprintf
- #define VSSCANF(s, f, a) vsscanf(s, f, a)
- #define SSCANF sscanf
- #define VFSCANF(s, f, a) vfscanf(s, f, a)
- #define VSCANF(f, a) vscanf(f, a)
- #define SCANF scanf
- #define FSCANF fscanf
- #define WAITPID(p, s, o) _win_waitpid(p, s, o)
- #define ACCEPT(s, a, l) _win_accept(s, a, l)
- #define BIND(s, n, l) _win_bind(s, n, l)
- #define CONNECT(s, n, l) _win_connect(s, n, l)
- #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) _win_listen(s, b)
- #define RECV(s, b, l, f) _win_recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
- #define SEND(s, b, l, f) _win_send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) _win_shutdown(s, h)
- #define SOCKET(a, t, p) _win_socket(a, t, p)
- #define SOCKETPAIR(a, t, p, v) _win_socketpair(a, t, p, v)
- #define GETHOSTBYADDR(a, l, t) _win_gethostbyaddr(a, l, t)
- #define GETHOSTBYNAME(n) _win_gethostbyname(n)
- #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
- #define INSQUE(e, p) _win_insque(e, p)
- #define REMQUE(e) _win_remque(e)
- #define HSEARCH(i, a) _win_hsearch(i, a)
- #define HCREATE(n) _win_hcreate(n)
- #define HDESTROY() _win_hdestroy()
- #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
- #define HCREATE_R(n, h) _win_hcreate_r(n, h)
- #define HDESTROY_R(h) _win_hdestroy_r(h)
- #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
- #define TFIND(k, r, c) _win_tfind(k, r, c)
- #define TDELETE(k, r, c) _win_tdelete(k, r, c)
- #define TWALK(r, a) _win_twalk(r, a)
- #define TDESTROY(r, f) _win_tdestroy(r, f)
- #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
- #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
- #define STRUCT_STAT64 struct _stati64
-#endif
-
-/* search.h */
-
-/* Prototype structure for a linked-list data structure.
-   This is the type used by the `insque' and `remque' functions.  */
-
-struct PLIBC_SEARCH_QELEM
-  {
-    struct qelem *q_forw;
-    struct qelem *q_back;
-    char q_data[1];
-  };
-
-
-/* Insert ELEM into a doubly-linked list, after PREV.  */
-void _win_insque (void *__elem, void *__prev);
-
-/* Unlink ELEM from the doubly-linked list that it is in.  */
-void _win_remque (void *__elem);
-
-
-/* For use with hsearch(3).  */
-typedef int (*PLIBC_SEARCH__compar_fn_t) (__const void *, __const void *);
-
-typedef PLIBC_SEARCH__compar_fn_t _win_comparison_fn_t;
-
-/* Action which shall be performed in the call the hsearch.  */
-typedef enum
-  {
-    PLIBC_SEARCH_FIND,
-    PLIBC_SEARCH_ENTER
-  }
-PLIBC_SEARCH_ACTION;
-
-typedef struct PLIBC_SEARCH_entry
-  {
-    char *key;
-    void *data;
-  }
-PLIBC_SEARCH_ENTRY;
-
-/* The reentrant version has no static variables to maintain the state.
-   Instead the interface of all functions is extended to take an argument
-   which describes the current status.  */
-typedef struct _PLIBC_SEARCH_ENTRY
-{
-  unsigned int used;
-  PLIBC_SEARCH_ENTRY entry;
-}
-_PLIBC_SEARCH_ENTRY;
-
-
-/* Family of hash table handling functions.  The functions also
-   have reentrant counterparts ending with _r.  The non-reentrant
-   functions all work on a signle internal hashing table.  */
-
-/* Search for entry matching ITEM.key in internal hash table.  If
-   ACTION is `FIND' return found entry or signal error by returning
-   NULL.  If ACTION is `ENTER' replace existing data (if any) with
-   ITEM.data.  */
-PLIBC_SEARCH_ENTRY *_win_hsearch (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action);
-
-/* Create a new hashing table which will at most contain NEL elements.  */
-int _win_hcreate (size_t __nel);
-
-/* Destroy current internal hashing table.  */
-void _win_hdestroy (void);
-
-/* Data type for reentrant functions.  */
-struct PLIBC_SEARCH_hsearch_data
-  {
-    struct _PLIBC_SEARCH_ENTRY *table;
-    unsigned int size;
-    unsigned int filled;
-  };
-
-/* Reentrant versions which can handle multiple hashing tables at the
-   same time.  */
-int _win_hsearch_r (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action, PLIBC_SEARCH_ENTRY **__retval,
-          struct PLIBC_SEARCH_hsearch_data *__htab);
-int _win_hcreate_r (size_t __nel, struct PLIBC_SEARCH_hsearch_data *__htab);
-void _win_hdestroy_r (struct PLIBC_SEARCH_hsearch_data *__htab);
-
-
-/* The tsearch routines are very interesting. They make many
-   assumptions about the compiler.  It assumes that the first field
-   in node must be the "key" field, which points to the datum.
-   Everything depends on that.  */
-/* For tsearch */
-typedef enum
-{
-  PLIBC_SEARCH_preorder,
-  PLIBC_SEARCH_postorder,
-  PLIBC_SEARCH_endorder,
-  PLIBC_SEARCH_leaf
-}
-PLIBC_SEARCH_VISIT;
-
-/* Search for an entry matching the given KEY in the tree pointed to
-   by *ROOTP and insert a new element if not found.  */
-void *_win_tsearch (__const void *__key, void **__rootp,
-          PLIBC_SEARCH__compar_fn_t __compar);
-
-/* Search for an entry matching the given KEY in the tree pointed to
-   by *ROOTP.  If no matching entry is available return NULL.  */
-void *_win_tfind (__const void *__key, void *__const *__rootp,
-        PLIBC_SEARCH__compar_fn_t __compar);
-
-/* Remove the element matching KEY from the tree pointed to by *ROOTP.  */
-void *_win_tdelete (__const void *__restrict __key,
-          void **__restrict __rootp,
-          PLIBC_SEARCH__compar_fn_t __compar);
-
-typedef void (*PLIBC_SEARCH__action_fn_t) (__const void *__nodep, PLIBC_SEARCH_VISIT __value,
-             int __level);
-
-/* Walk through the whole tree and call the ACTION callback for every node
-   or leaf.  */
-void _win_twalk (__const void *__root, PLIBC_SEARCH__action_fn_t __action);
-
-/* Callback type for function to free a tree node.  If the keys are atomic
-   data this function should do nothing.  */
-typedef void (*PLIBC_SEARCH__free_fn_t) (void *__nodep);
-
-/* Destroy the whole tree, call FREEFCT for each node or leaf.  */
-void _win_tdestroy (void *__root, PLIBC_SEARCH__free_fn_t __freefct);
-
-
-/* Perform linear search for KEY by comparing by COMPAR in an array
-   [BASE,BASE+NMEMB*SIZE).  */
-void *_win_lfind (__const void *__key, __const void *__base,
-        size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
-
-/* Perform linear search for KEY by comparing by COMPAR function in
-   array [BASE,BASE+NMEMB*SIZE) and insert entry if not found.  */
-void *_win_lsearch (__const void *__key, void *__base,
-          size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //_PLIBC_H_
-
-/* end of plibc.h */
index 068214f4effe7b77c61edb6b0299b80d1b5cfbd6..fe6117c207b507526d91ef5e646a41878bc4f26f 100644 (file)
@@ -129,7 +129,7 @@ set_json (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   *json = json_loads (value, JSON_REJECT_DUPLICATES, &error);
   if (NULL == *json)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("Failed to parse JSON in option `%s': %s (%s)\n"),
              option,
              error.text,
index d1927934d0d2fb52b7c9466179e44dedbdf52c6c..509f86fc026d548ecba5a7fe5818cdb2669b404f 100644 (file)
@@ -94,8 +94,8 @@ do_shutdown (void *cls)
  */
 static void
 display_records_from_block (void *cls,
-                           unsigned int rd_len,
-                           const struct GNUNET_GNSRECORD_Data *rd)
+                            unsigned int rd_len,
+                            const struct GNUNET_GNSRECORD_Data *rd)
 {
   const char *typestring;
   char *s;
@@ -103,33 +103,27 @@ display_records_from_block (void *cls,
 
   if (0 == rd_len)
   {
-    FPRINTF (stdout,
-            _("No records found for `%s'"),
-            name);
+    fprintf (stdout, _ ("No records found for `%s'"), name);
     return;
   }
-  FPRINTF (stdout,
-          "%s:\n",
-          name);
-  for (i=0;i<rd_len;i++)
+  fprintf (stdout, "%s:\n", name);
+  for (i = 0; i < rd_len; i++)
   {
     typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
     s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
-                                         rd[i].data,
-                                         rd[i].data_size);
+                                          rd[i].data,
+                                          rd[i].data_size);
     if (NULL == s)
     {
-      FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"),
-              (unsigned int) rd[i].record_type);
+      fprintf (stdout,
+               _ ("\tCorrupt or unsupported record of type %u\n"),
+               (unsigned int) rd[i].record_type);
       continue;
     }
-    FPRINTF (stdout,
-            "\t%s: %s\n",
-            typestring,
-            s);
+    fprintf (stdout, "\t%s: %s\n", typestring, s);
     GNUNET_free (s);
   }
-  FPRINTF (stdout, "%s", "\n");
+  fprintf (stdout, "%s", "\n");
 }
 
 
@@ -140,24 +134,21 @@ display_records_from_block (void *cls,
  * @param block NULL if not found
  */
 static void
-handle_block (void *cls,
-             const struct GNUNET_GNSRECORD_Block *block)
+handle_block (void *cls, const struct GNUNET_GNSRECORD_Block *block)
 {
   qe = NULL;
   if (NULL == block)
   {
-    fprintf (stderr,
-            "No matching block found\n");
+    fprintf (stderr, "No matching block found\n");
   }
   else if (GNUNET_OK !=
-          GNUNET_GNSRECORD_block_decrypt (block,
-                                          &pubkey,
-                                          name,
-                                          &display_records_from_block,
-                                          NULL))
+           GNUNET_GNSRECORD_block_decrypt (block,
+                                           &pubkey,
+                                           name,
+                                           &display_records_from_block,
+                                           NULL))
   {
-    fprintf (stderr,
-            "Failed to decrypt block!\n");
+    fprintf (stderr, "Failed to decrypt block!\n");
   }
   GNUNET_SCHEDULER_shutdown ();
 }
@@ -172,46 +163,36 @@ handle_block (void *cls,
  * @param cfg configuration
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_HashCode dhash;
 
   if (NULL == pkey)
   {
-    fprintf (stderr,
-            _("You must specify which zone should be accessed\n"));
+    fprintf (stderr, _ ("You must specify which zone should be accessed\n"));
     return;
   }
 
   if (GNUNET_OK !=
-      GNUNET_CRYPTO_ecdsa_public_key_from_string (pkey,
-                                                  strlen (pkey),
-                                                  &pubkey))
+      GNUNET_CRYPTO_ecdsa_public_key_from_string (pkey, strlen (pkey), &pubkey))
   {
-    fprintf (stderr,
-             _("Invalid public key for zone `%s'\n"),
-             pkey);
+    fprintf (stderr, _ ("Invalid public key for zone `%s'\n"), pkey);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   if (NULL == name)
   {
-    fprintf (stderr,
-             _("You must specify a name\n"));
+    fprintf (stderr, _ ("You must specify a name\n"));
     return;
   }
 
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
   ns = GNUNET_NAMECACHE_connect (cfg);
-  GNUNET_GNSRECORD_query_from_public_key (&pubkey,
-                                          name,
-                                          &dhash);
-  qe = GNUNET_NAMECACHE_lookup_block (ns,
-                                      &dhash,
-                                      &handle_block,
-                                      NULL);
+  GNUNET_GNSRECORD_query_from_public_key (&pubkey, name, &dhash);
+  qe = GNUNET_NAMECACHE_lookup_block (ns, &dhash, &handle_block, NULL);
 }
 
 
@@ -225,36 +206,39 @@ run (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_string ('n',
-                                 "name",
-                                 "NAME",
-                                 gettext_noop ("name of the record to add/delete/display"),
-                                 &name),
-
-    GNUNET_GETOPT_option_string ('z',
-                                 "zone",
-                                 "PKEY",
-                                 gettext_noop ("specifies the public key of the zone to look in"),
-                                 &pkey),
-
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_string ('n',
+                                  "name",
+                                  "NAME",
+                                  gettext_noop (
+                                    "name of the record to add/delete/display"),
+                                  &name),
+
+     GNUNET_GETOPT_option_string (
+       'z',
+       "zone",
+       "PKEY",
+       gettext_noop ("specifies the public key of the zone to look in"),
+       &pkey),
+
+     GNUNET_GETOPT_OPTION_END};
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   GNUNET_log_setup ("gnunet-namecache", "WARNING", NULL);
-  if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv, "gnunet-namecache",
-                         _("GNUnet zone manipulation tool"),
-                         options,
-                         &run, NULL))
+  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
+                                       argv,
+                                       "gnunet-namecache",
+                                       _ ("GNUnet zone manipulation tool"),
+                                       options,
+                                       &run,
+                                       NULL))
   {
-    GNUNET_free ((void*) argv);
+    GNUNET_free ((void *) argv);
     return 1;
   }
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 20900a3f60948eca6b575618d474174fdb03a744..4939bc4b696e84547da7809bb6ff28bd4fe71233 100644 (file)
@@ -70,7 +70,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
   GNUNET_asprintf (&libname, "libgnunet_plugin_namecache_%s", plugin_name);
   if (NULL == (ret = GNUNET_PLUGIN_load (libname, (void*) cfg)))
   {
-    FPRINTF (stderr, "Failed to load plugin `%s'!\n", plugin_name);
+    fprintf (stderr, "Failed to load plugin `%s'!\n", plugin_name);
     GNUNET_free (libname);
     return NULL;
   }
@@ -89,7 +89,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   nsp = load_plugin (cfg);
   if (NULL == nsp)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
             "Failed to initialize namecache.  Database likely not setup, skipping test.\n");
     return;
@@ -123,7 +123,7 @@ main (int argc, char *argv[])
   GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
                       "test-plugin-namecache", "nohelp", options, &run, NULL);
   if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %d\n", ok);
+    fprintf (stderr, "Missed some testcases: %d\n", ok);
   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namecache-sqlite");
   return ok;
 }
index 5d292525e4ca06494ff0570741aa860a2a90f4a7..2b814206b78cebcaac77df6c47777482fb7a6083 100644 (file)
@@ -437,7 +437,7 @@ display_record (const char *rname,
   }
   if (GNUNET_NO == have_record)
     return;
-  FPRINTF (stdout, "%s:\n", rname);
+  fprintf (stdout, "%s:\n", rname);
   if (NULL != typestring)
     type = GNUNET_GNSRECORD_typename_to_number (typestring);
   else
@@ -455,7 +455,7 @@ display_record (const char *rname,
                                           rd[i].data_size);
     if (NULL == s)
     {
-      FPRINTF (stdout,
+      fprintf (stdout,
                _ ("\tCorrupt or unsupported record of type %u\n"),
                (unsigned int) rd[i].record_type);
       continue;
@@ -470,7 +470,7 @@ display_record (const char *rname,
       at.abs_value_us = rd[i].expiration_time;
       ets = GNUNET_STRINGS_absolute_time_to_string (at);
     }
-    FPRINTF (stdout,
+    fprintf (stdout,
              "\t%s: %s (%s)\t%s\t%s\n",
              typestr,
              s,
@@ -481,7 +481,7 @@ display_record (const char *rname,
                                                                       : "");
     GNUNET_free (s);
   }
-  FPRINTF (stdout, "%s", "\n");
+  fprintf (stdout, "%s", "\n");
 }
 
 
@@ -564,7 +564,7 @@ static void
 sync_cb (void *cls)
 {
   (void) cls;
-  FPRINTF (stdout, "%s", "Monitor is now in sync.\n");
+  fprintf (stdout, "%s", "Monitor is now in sync.\n");
 }
 
 
@@ -577,7 +577,7 @@ static void
 monitor_error_cb (void *cls)
 {
   (void) cls;
-  FPRINTF (stderr, "%s", "Monitor disconnected and out of sync.\n");
+  fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
 }
 
 
@@ -591,7 +591,7 @@ lookup_error_cb (void *cls)
 {
   (void) cls;
   get_qe = NULL;
-  FPRINTF (stderr, "%s", "Failed to lookup record.\n");
+  fprintf (stderr, "%s", "Failed to lookup record.\n");
   test_finished ();
 }
 
@@ -761,7 +761,7 @@ reverse_error_cb (void *cls)
 {
   (void) cls;
   reverse_qe = NULL;
-  FPRINTF (stdout, "%s.zkey\n", reverse_pkey);
+  fprintf (stdout, "%s.zkey\n", reverse_pkey);
 }
 
 
@@ -788,9 +788,9 @@ handle_reverse_lookup (void *cls,
   (void) rd;
   reverse_qe = NULL;
   if (NULL == label)
-    FPRINTF (stdout, "%s\n", reverse_pkey);
+    fprintf (stdout, "%s\n", reverse_pkey);
   else
-    FPRINTF (stdout, "%s.%s\n", label, ego_name);
+    fprintf (stdout, "%s.%s\n", label, ego_name);
   test_finished ();
 }
 
@@ -837,7 +837,7 @@ del_monitor (void *cls,
   del_qe = NULL;
   if (0 == rd_count)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ (
                "There are no records under label `%s' that could be deleted.\n"),
              label);
@@ -879,7 +879,7 @@ del_monitor (void *cls,
   if (rd_count == rd_left)
   {
     /* nothing got deleted */
-    FPRINTF (
+    fprintf (
       stderr,
       _ (
         "There are no records under label `%s' that match the request for deletion.\n"),
index 0cb99dcb9b578971f54402b97eaf4afa3780cbe6..b4ed4c70db63bc8dee53891f95e163f6b5968d0c 100644 (file)
@@ -73,7 +73,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
   GNUNET_asprintf (&libname, "libgnunet_plugin_namestore_%s", plugin_name);
   if (NULL == (ret = GNUNET_PLUGIN_load (libname, (void *) cfg)))
   {
-    FPRINTF (stderr, "Failed to load plugin `%s'!\n", plugin_name);
+    fprintf (stderr, "Failed to load plugin `%s'!\n", plugin_name);
     GNUNET_free (libname);
     return NULL;
   }
@@ -159,7 +159,7 @@ run (void *cls,
   nsp = load_plugin (cfg);
   if (NULL == nsp)
   {
-    FPRINTF (
+    fprintf (
       stderr,
       "%s",
       "Failed to initialize namestore.  Database likely not setup, skipping test.\n");
@@ -195,7 +195,7 @@ main (int argc, char *argv[])
                       NULL);
   GNUNET_DISK_purge_cfg_dir (cfg_name, "GNUNET_TMP");
   if (ok != 0)
-    FPRINTF (stderr, "Missed some testcases: %d\n", ok);
+    fprintf (stderr, "Missed some testcases: %d\n", ok);
   return ok;
 }
 
index bd8f4ff45d0495c70af36b47199e3ed08eef5004..106d60228f5d8ef03e54c257bce161853891c0fe 100644 (file)
@@ -116,14 +116,9 @@ auto_conf_iter (void *cls,
 {
   struct GNUNET_CONFIGURATION_Handle *new_cfg = cls;
 
-  PRINTF ("%s: %s\n",
-         option,
-         value);
+  printf ("%s: %s\n", option, value);
   if (NULL != new_cfg)
-    GNUNET_CONFIGURATION_set_value_string (new_cfg,
-                                          section,
-                                          option,
-                                          value);
+    GNUNET_CONFIGURATION_set_value_string (new_cfg, section, option, value);
 }
 
 
@@ -138,9 +133,9 @@ auto_conf_iter (void *cls,
  */
 static void
 auto_config_cb (void *cls,
-               const struct GNUNET_CONFIGURATION_Handle *diff,
-               enum GNUNET_NAT_StatusCode result,
-               enum GNUNET_NAT_Type type)
+                const struct GNUNET_CONFIGURATION_Handle *diff,
+                enum GNUNET_NAT_StatusCode result,
+                enum GNUNET_NAT_Type type)
 {
   const char *nat_type;
   char unknown_type[64];
@@ -162,24 +157,21 @@ auto_config_cb (void *cls,
     nat_type = "NAT but UPNP opened the ports";
     break;
   default:
-    SPRINTF (unknown_type,
-            "NAT unknown, type %u",
-            type);
+    sprintf (unknown_type, "NAT unknown, type %u", type);
     nat_type = unknown_type;
     break;
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-             "NAT status: %s/%s\n",
-             GNUNET_NAT_AUTO_status2string (result),
-             nat_type);
+              "NAT status: %s/%s\n",
+              GNUNET_NAT_AUTO_status2string (result),
+              nat_type);
 
   if (NULL == diff)
     return;
 
   /* Shortcut: if there are no changes suggested, bail out early. */
-  if (GNUNET_NO ==
-      GNUNET_CONFIGURATION_is_dirty (diff))
+  if (GNUNET_NO == GNUNET_CONFIGURATION_is_dirty (diff))
   {
     test_finished ();
     return;
@@ -190,7 +182,7 @@ auto_config_cb (void *cls,
   new_cfg = write_cfg ? GNUNET_CONFIGURATION_dup (cfg) : NULL;
 
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              _("Suggested configuration changes:\n"));
+              _ ("Suggested configuration changes:\n"));
   GNUNET_CONFIGURATION_iterate_section_values (diff,
                                                "nat",
                                                &auto_conf_iter,
@@ -202,29 +194,22 @@ auto_config_cb (void *cls,
   {
     struct GNUNET_CONFIGURATION_Handle *def_cfg;
 
-    GNUNET_CONFIGURATION_set_value_string (new_cfg,
-                                          "ARM",
-                                          "CONFIG",
-                                          NULL);
+    GNUNET_CONFIGURATION_set_value_string (new_cfg, "ARM", "CONFIG", NULL);
     def_cfg = GNUNET_CONFIGURATION_create ();
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_load (def_cfg,
-                                            NULL));
+    GNUNET_break (GNUNET_OK == GNUNET_CONFIGURATION_load (def_cfg, NULL));
     if (GNUNET_OK !=
-       GNUNET_CONFIGURATION_write_diffs (def_cfg,
-                                         new_cfg,
-                                         cfg_file))
+        GNUNET_CONFIGURATION_write_diffs (def_cfg, new_cfg, cfg_file))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 _("Failed to write configuration to `%s'\n"),
-                 cfg_file);
+                  _ ("Failed to write configuration to `%s'\n"),
+                  cfg_file);
       global_ret = 1;
     }
     else
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 _("Wrote updated configuration to `%s'\n"),
-                 cfg_file);
+                  _ ("Wrote updated configuration to `%s'\n"),
+                  cfg_file);
     }
     GNUNET_CONFIGURATION_destroy (def_cfg);
   }
@@ -243,12 +228,10 @@ auto_config_cb (void *cls,
  * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
  */
 static void
-test_report_cb (void *cls,
-               enum GNUNET_NAT_StatusCode result)
+test_report_cb (void *cls, enum GNUNET_NAT_StatusCode result)
 {
   nt = NULL;
-  PRINTF ("NAT test result: %s\n",
-         GNUNET_NAT_AUTO_status2string (result));
+  printf ("NAT test result: %s\n", GNUNET_NAT_AUTO_status2string (result));
   test_finished ();
 }
 
@@ -291,22 +274,18 @@ run (void *cls,
   cfg_file = cfgfile;
   cfg = c;
 
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
 
   if (do_auto)
   {
-    ah = GNUNET_NAT_AUTO_autoconfig_start (c,
-                                           &auto_config_cb,
-                                           NULL);
+    ah = GNUNET_NAT_AUTO_autoconfig_start (c, &auto_config_cb, NULL);
   }
 
   if (use_tcp && use_udp)
   {
     if (do_auto)
       return;
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-               "Cannot use TCP and UDP\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Cannot use TCP and UDP\n");
     global_ret = 1;
     return;
   }
@@ -319,10 +298,10 @@ run (void *cls,
   if (NULL != section_name)
   {
     nt = GNUNET_NAT_AUTO_test_start (c,
-                                    proto,
-                                    section_name,
-                                    &test_report_cb,
-                                    NULL);
+                                     proto,
+                                     section_name,
+                                     &test_report_cb,
+                                     NULL);
   }
   test_finished ();
 }
@@ -336,53 +315,47 @@ run (void *cls,
  * @return 0 on success, -1 on error
  */
 int
-main (int argc,
-      char *const argv[])
+main (int argc, char *const argv[])
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('a',
-                                  "auto",
-                                  gettext_noop ("run autoconfiguration"),
-                                  &do_auto),
-
-    GNUNET_GETOPT_option_string ('S',
-                                 "section",
-                                 "NAME",
-                                 gettext_noop ("section name providing the configuration for the adapter"),
-                                 &section_name),
-
-    GNUNET_GETOPT_option_flag ('t',
-                                   "tcp",
-                                   gettext_noop ("use TCP"),
-                                   &use_tcp),
-
-    GNUNET_GETOPT_option_flag ('u',
-                                   "udp",
-                                   gettext_noop ("use UDP"),
-                                   &use_udp),
-
-    GNUNET_GETOPT_option_flag ('w',
-                                   "write",
-                                   gettext_noop ("write configuration file (for autoconfiguration)"),
-                                   &write_cfg),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('a',
+                                "auto",
+                                gettext_noop ("run autoconfiguration"),
+                                &do_auto),
+
+     GNUNET_GETOPT_option_string (
+       'S',
+       "section",
+       "NAME",
+       gettext_noop (
+         "section name providing the configuration for the adapter"),
+       &section_name),
+
+     GNUNET_GETOPT_option_flag ('t', "tcp", gettext_noop ("use TCP"), &use_tcp),
+
+     GNUNET_GETOPT_option_flag ('u', "udp", gettext_noop ("use UDP"), &use_udp),
+
+     GNUNET_GETOPT_option_flag (
+       'w',
+       "write",
+       gettext_noop ("write configuration file (for autoconfiguration)"),
+       &write_cfg),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv,
-                         "gnunet-nat-auto [options]",
-                          _("GNUnet NAT traversal autoconfiguration"),
-                         options,
+      GNUNET_PROGRAM_run (argc,
+                          argv,
+                          "gnunet-nat-auto [options]",
+                          _ ("GNUnet NAT traversal autoconfiguration"),
+                          options,
                           &run,
-                         NULL))
+                          NULL))
   {
     global_ret = 1;
   }
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
   return global_ret;
 }
 
index 1511d91baa86baf1e0b3eb7c842c7629f3d6036f..56a2b8d725e632d2ff9b00d42839db381a2e10cb 100644 (file)
 #include "gnunet_nat_auto_service.h"
 #include "nat-auto.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "nat-auto", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "nat-auto", __VA_ARGS__)
 
-#define NAT_SERVER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define NAT_SERVER_TIMEOUT \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
 /**
  * Entry we keep for each incoming connection.
@@ -88,7 +89,6 @@ struct ClientActivity
    * Handle to overall NAT test.
    */
   struct GNUNET_NAT_AUTO_Test *h;
-
 };
 
 
@@ -184,9 +184,7 @@ struct GNUNET_NAT_AUTO_Test
  * @param addrlen actual lenght of the @a addr
  */
 static void
-reversal_cb (void *cls,
-             const struct sockaddr *addr,
-             socklen_t addrlen)
+reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen)
 {
   struct GNUNET_NAT_AUTO_Test *h = cls;
   const struct sockaddr_in *sa;
@@ -198,11 +196,10 @@ reversal_cb (void *cls,
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Received connection reversal request for wrong port\n");
-    return;                     /* wrong port */
+    return; /* wrong port */
   }
   /* report success */
-  h->report (h->report_cls,
-             GNUNET_NAT_ERROR_SUCCESS);
+  h->report (h->report_cls, GNUNET_NAT_ERROR_SUCCESS);
 }
 
 
@@ -220,22 +217,17 @@ do_udp_read (void *cls)
   const struct GNUNET_SCHEDULER_TaskContext *tc;
 
   tc = GNUNET_SCHEDULER_get_task_context ();
-  tst->ltask =
-      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     tst->lsock,
-                                     &do_udp_read,
-                                     tst);
+  tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                              tst->lsock,
+                                              &do_udp_read,
+                                              tst);
   if ((NULL != tc->write_ready) &&
-      (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                   tst->lsock)) &&
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, tst->lsock)) &&
       (sizeof (data) ==
-       GNUNET_NETWORK_socket_recv (tst->lsock,
-                                   &data,
-                                   sizeof (data))))
+       GNUNET_NETWORK_socket_recv (tst->lsock, &data, sizeof (data))))
   {
     if (data == tst->data)
-      tst->report (tst->report_cls,
-                   GNUNET_NAT_ERROR_SUCCESS);
+      tst->report (tst->report_cls, GNUNET_NAT_ERROR_SUCCESS);
     else
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Received data mismatches expected value\n");
@@ -263,20 +255,14 @@ do_read (void *cls)
   tc = GNUNET_SCHEDULER_get_task_context ();
   na->rtask = NULL;
   tst = na->h;
-  GNUNET_CONTAINER_DLL_remove (tst->na_head,
-                              tst->na_tail,
-                              na);
+  GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na);
   if ((NULL != tc->write_ready) &&
-      (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                   na->sock)) &&
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) &&
       (sizeof (data) ==
-       GNUNET_NETWORK_socket_recv (na->sock,
-                                   &data,
-                                   sizeof (data))))
+       GNUNET_NETWORK_socket_recv (na->sock, &data, sizeof (data))))
   {
     if (data == tst->data)
-      tst->report (tst->report_cls,
-                   GNUNET_NAT_ERROR_SUCCESS);
+      tst->report (tst->report_cls, GNUNET_NAT_ERROR_SUCCESS);
     else
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Received data does not match expected value\n");
@@ -306,28 +292,22 @@ do_accept (void *cls)
                                               tst->lsock,
                                               &do_accept,
                                               tst);
-  s = GNUNET_NETWORK_socket_accept (tst->lsock,
-                                    NULL,
-                                    NULL);
+  s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL);
   if (NULL == s)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO,
-                         "accept");
-    return;                     /* odd error */
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept");
+    return; /* odd error */
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Got an inbound connection, waiting for data\n");
   wl = GNUNET_new (struct NatActivity);
   wl->sock = s;
   wl->h = tst;
-  wl->rtask =
-    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                   wl->sock,
-                                   &do_read,
-                                   wl);
-  GNUNET_CONTAINER_DLL_insert (tst->na_head,
-                              tst->na_tail,
-                              wl);
+  wl->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                             wl->sock,
+                                             &do_read,
+                                             wl);
+  GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl);
 }
 
 
@@ -339,15 +319,12 @@ do_accept (void *cls)
  * @param error error code
  */
 static void
-mq_error_handler (void *cls,
-                  enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 {
   struct ClientActivity *ca = cls;
   struct GNUNET_NAT_AUTO_Test *tst = ca->h;
 
-  GNUNET_CONTAINER_DLL_remove (tst->ca_head,
-                               tst->ca_tail,
-                               ca);
+  GNUNET_CONTAINER_DLL_remove (tst->ca_head, tst->ca_tail, ca);
   GNUNET_MQ_destroy (ca->mq);
   GNUNET_free (ca);
 }
@@ -367,7 +344,7 @@ mq_error_handler (void *cls,
  */
 static void
 addr_cb (void *cls,
-        void **app_ctx,
+         void **app_ctx,
          int add_remove,
          enum GNUNET_NAT_AddressClass ac,
          const struct sockaddr *addr,
@@ -385,15 +362,13 @@ addr_cb (void *cls,
   if (addrlen != sizeof (struct sockaddr_in))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "NAT test ignores IPv6 address `%s' returned from NAT library\n",
-        GNUNET_a2s (addr,
-                     addrlen));
-    return;                     /* ignore IPv6 here */
+         "NAT test ignores IPv6 address `%s' returned from NAT library\n",
+         GNUNET_a2s (addr, addrlen));
+    return; /* ignore IPv6 here */
   }
   LOG (GNUNET_ERROR_TYPE_INFO,
        "Asking gnunet-nat-server to connect to `%s'\n",
-       GNUNET_a2s (addr,
-                   addrlen));
+       GNUNET_a2s (addr, addrlen));
 
   ca = GNUNET_new (struct ClientActivity);
   ca->h = h;
@@ -406,21 +381,17 @@ addr_cb (void *cls,
   {
     GNUNET_free (ca);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to connect to `gnunet-nat-server'\n"));
+                _ ("Failed to connect to `gnunet-nat-server'\n"));
     return;
   }
-  GNUNET_CONTAINER_DLL_insert (h->ca_head,
-                               h->ca_tail,
-                               ca);
+  GNUNET_CONTAINER_DLL_insert (h->ca_head, h->ca_tail, ca);
   sa = (const struct sockaddr_in *) addr;
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_NAT_TEST);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NAT_TEST);
   msg->dst_ipv4 = sa->sin_addr.s_addr;
   msg->dport = sa->sin_port;
   msg->data = h->data;
   msg->is_tcp = htonl ((uint32_t) (h->proto == IPPROTO_TCP));
-  GNUNET_MQ_send (ca->mq,
-                  env);
+  GNUNET_MQ_send (ca->mq, env);
 }
 
 
@@ -437,8 +408,7 @@ do_fail (void *cls)
   struct GNUNET_NAT_AUTO_Test *nh = cls;
 
   nh->ttask = NULL;
-  nh->report (nh->report_cls,
-              nh->status);
+  nh->report (nh->report_cls, nh->status);
 }
 
 
@@ -455,30 +425,25 @@ do_fail (void *cls)
  */
 struct GNUNET_NAT_AUTO_Test *
 GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                           uint8_t proto,
-                           const char *section_name,
-                           GNUNET_NAT_TestCallback report,
-                           void *report_cls)
+                            uint8_t proto,
+                            const char *section_name,
+                            GNUNET_NAT_TestCallback report,
+                            void *report_cls)
 {
   struct GNUNET_NAT_AUTO_Test *nh;
   unsigned long long bnd_port;
   struct sockaddr_in sa;
-  const struct sockaddr *addrs[] = {
-    (const struct sockaddr *) &sa
-  };
-  const socklen_t addrlens[] = {
-    sizeof (sa)
-  };
-
-  if ( (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_number (cfg,
-                                               section_name,
-                                               "PORT",
-                                               &bnd_port)) ||
-       (bnd_port > 65535) )
+  const struct sockaddr *addrs[] = {(const struct sockaddr *) &sa};
+  const socklen_t addrlens[] = {sizeof (sa)};
+
+  if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                           section_name,
+                                                           "PORT",
+                                                           &bnd_port)) ||
+      (bnd_port > 65535))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to find valid PORT in section `%s'\n"),
+                _ ("Failed to find valid PORT in section `%s'\n"),
                 section_name);
     return NULL;
   }
@@ -499,67 +464,60 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   nh->status = GNUNET_NAT_ERROR_SUCCESS;
   if (0 == bnd_port)
   {
-    nh->nat
-      = GNUNET_NAT_register (cfg,
-                             section_name,
-                             proto,
-                             0, NULL, NULL,
-                            &addr_cb,
-                             &reversal_cb,
-                             nh);
+    nh->nat = GNUNET_NAT_register (cfg,
+                                   section_name,
+                                   proto,
+                                   0,
+                                   NULL,
+                                   NULL,
+                                   &addr_cb,
+                                   &reversal_cb,
+                                   nh);
   }
   else
   {
-    nh->lsock
-      = GNUNET_NETWORK_socket_create (AF_INET,
-                                      (IPPROTO_UDP == proto)
-                                      ? SOCK_DGRAM
-                                      : SOCK_STREAM,
-                                      proto);
-    if ( (NULL == nh->lsock) ||
-         (GNUNET_OK !=
-          GNUNET_NETWORK_socket_bind (nh->lsock,
-                                      (const struct sockaddr *) &sa,
-                                      sizeof (sa))))
+    nh->lsock =
+      GNUNET_NETWORK_socket_create (AF_INET,
+                                    (IPPROTO_UDP == proto) ? SOCK_DGRAM
+                                                           : SOCK_STREAM,
+                                    proto);
+    if ((NULL == nh->lsock) ||
+        (GNUNET_OK != GNUNET_NETWORK_socket_bind (nh->lsock,
+                                                  (const struct sockaddr *) &sa,
+                                                  sizeof (sa))))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to create socket bound to `%s' for NAT test: %s\n"),
-           GNUNET_a2s ((const struct sockaddr *) &sa,
-                       sizeof (sa)),
-           STRERROR (errno));
+           _ ("Failed to create socket bound to `%s' for NAT test: %s\n"),
+           GNUNET_a2s ((const struct sockaddr *) &sa, sizeof (sa)),
+           strerror (errno));
       if (NULL != nh->lsock)
       {
         GNUNET_NETWORK_socket_close (nh->lsock);
         nh->lsock = NULL;
       }
       nh->status = GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR;
-      nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail,
-                                            nh);
+      nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail, nh);
       return nh;
     }
     if (IPPROTO_TCP == proto)
     {
-      GNUNET_break (GNUNET_OK ==
-                    GNUNET_NETWORK_socket_listen (nh->lsock,
-                                                  5));
-      nh->ltask =
-          GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                         nh->lsock,
-                                        &do_accept,
-                                         nh);
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (nh->lsock, 5));
+      nh->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                                 nh->lsock,
+                                                 &do_accept,
+                                                 nh);
     }
     else
     {
-      nh->ltask =
-          GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                         nh->lsock,
-                                        &do_udp_read,
-                                         nh);
+      nh->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                                 nh->lsock,
+                                                 &do_udp_read,
+                                                 nh);
     }
     LOG (GNUNET_ERROR_TYPE_INFO,
-        "NAT test listens on port %llu (%s)\n",
-        bnd_port,
-        (IPPROTO_TCP == proto) ? "tcp" : "udp");
+         "NAT test listens on port %llu (%s)\n",
+         bnd_port,
+         (IPPROTO_TCP == proto) ? "tcp" : "udp");
     nh->nat = GNUNET_NAT_register (cfg,
                                    section_name,
                                    proto,
@@ -572,7 +530,7 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
     if (NULL == nh->nat)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
-          _("NAT test failed to start NAT library\n"));
+           _ ("NAT test failed to start NAT library\n"));
       if (NULL != nh->ltask)
       {
         GNUNET_SCHEDULER_cancel (nh->ltask);
@@ -584,8 +542,7 @@ GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
         nh->lsock = NULL;
       }
       nh->status = GNUNET_NAT_ERROR_NAT_REGISTER_FAILED;
-      nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail,
-                                            nh);
+      nh->ttask = GNUNET_SCHEDULER_add_now (&do_fail, nh);
       return nh;
     }
   }
@@ -604,21 +561,16 @@ GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst)
   struct NatActivity *pos;
   struct ClientActivity *cpos;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Stopping NAT test\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping NAT test\n");
   while (NULL != (cpos = tst->ca_head))
   {
-    GNUNET_CONTAINER_DLL_remove (tst->ca_head,
-                                tst->ca_tail,
-                                cpos);
+    GNUNET_CONTAINER_DLL_remove (tst->ca_head, tst->ca_tail, cpos);
     GNUNET_MQ_destroy (cpos->mq);
     GNUNET_free (cpos);
   }
   while (NULL != (pos = tst->na_head))
   {
-    GNUNET_CONTAINER_DLL_remove (tst->na_head,
-                                tst->na_tail,
-                                pos);
+    GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, pos);
     GNUNET_SCHEDULER_cancel (pos->rtask);
     GNUNET_NETWORK_socket_close (pos->sock);
     GNUNET_free (pos);
index 2755532035123cf33c88186dd838dfab4fd32005..6c533374e06cc5fb99b1d2505bf474b12dfab235 100644 (file)
@@ -120,20 +120,19 @@ test_finished ()
  */
 static void
 address_cb (void *cls,
-           void **app_ctx,
-           int add_remove,
-           enum GNUNET_NAT_AddressClass ac,
-           const struct sockaddr *addr,
-           socklen_t addrlen)
+            void **app_ctx,
+            int add_remove,
+            enum GNUNET_NAT_AddressClass ac,
+            const struct sockaddr *addr,
+            socklen_t addrlen)
 {
   (void) cls;
   (void) app_ctx;
-  
+
   fprintf (stdout,
            "%s %s (%d)\n",
            add_remove ? "+" : "-",
-           GNUNET_a2s (addr,
-                       addrlen),
+           GNUNET_a2s (addr, addrlen),
            (int) ac);
 }
 
@@ -149,13 +148,12 @@ address_cb (void *cls,
  */
 static void
 reversal_cb (void *cls,
-            const struct sockaddr *remote_addr,
-            socklen_t remote_addrlen)
+             const struct sockaddr *remote_addr,
+             socklen_t remote_addrlen)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-             "Connection reversal requested by %s\n",
-             GNUNET_a2s (remote_addr,
-                         remote_addrlen));
+              "Connection reversal requested by %s\n",
+              GNUNET_a2s (remote_addr, remote_addrlen));
 }
 
 
@@ -194,9 +192,9 @@ stun_read_task (void *cls)
   ssize_t size;
 
   rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                        ls,
-                                        &stun_read_task,
-                                        NULL);
+                                         ls,
+                                         &stun_read_task,
+                                         NULL);
   size = GNUNET_NETWORK_socket_recvfrom_amount (ls);
   if (size > 0)
   {
@@ -212,10 +210,10 @@ stun_read_task (void *cls)
     ssize_t ret;
 
     ret = GNUNET_NETWORK_socket_recvfrom (ls,
-                                         buf,
-                                         size + 1,
-                                         (struct sockaddr *) &sa,
-                                         &salen);
+                                          buf,
+                                          size + 1,
+                                          (struct sockaddr *) &sa,
+                                          &salen);
     if (ret != size)
     {
       GNUNET_break (0);
@@ -224,10 +222,10 @@ stun_read_task (void *cls)
       return;
     }
     (void) GNUNET_NAT_stun_handle_packet (nh,
-                                         (const struct sockaddr *) &sa,
-                                         salen,
-                                         buf,
-                                         ret);
+                                          (const struct sockaddr *) &sa,
+                                          salen,
+                                          buf,
+                                          ret);
   }
 }
 
@@ -254,8 +252,7 @@ run (void *cls,
 
   if (use_tcp && use_udp)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-               "Cannot use TCP and UDP\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Cannot use TCP and UDP\n");
     global_ret = 1;
     return;
   }
@@ -265,13 +262,11 @@ run (void *cls,
   if (use_udp)
     proto = IPPROTO_UDP;
 
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
 
   if (0 == proto)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-               "Must specify either TCP or UDP\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Must specify either TCP or UDP\n");
     global_ret = 1;
     return;
   }
@@ -281,28 +276,26 @@ run (void *cls,
   remote_sa = NULL;
   if (NULL != local_addr)
   {
-    local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr,
-                                                             &af,
-                                                             &local_sa);
+    local_len =
+      (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr, &af, &local_sa);
     if (0 == local_len)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Invalid socket address `%s'\n",
-                 local_addr);
+                  "Invalid socket address `%s'\n",
+                  local_addr);
       goto fail_and_shutdown;
     }
   }
 
   if (NULL != remote_addr)
   {
-    remote_len = GNUNET_STRINGS_parse_socket_addr (remote_addr,
-                                                  &af,
-                                                  &remote_sa);
+    remote_len =
+      GNUNET_STRINGS_parse_socket_addr (remote_addr, &af, &remote_sa);
     if (0 == remote_len)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Invalid socket address `%s'\n",
-                 remote_addr);
+                  "Invalid socket address `%s'\n",
+                  remote_addr);
       goto fail_and_shutdown;
     }
   }
@@ -312,19 +305,19 @@ run (void *cls,
     if (NULL == section_name)
       section_name = GNUNET_strdup ("undefined");
     nh = GNUNET_NAT_register (c,
-                             section_name,
-                             proto,
-                             1,
-                             (const struct sockaddr **) &local_sa,
-                             &local_len,
-                             &address_cb,
-                             (listen_reversal) ? &reversal_cb : NULL,
-                             NULL);
+                              section_name,
+                              proto,
+                              1,
+                              (const struct sockaddr **) &local_sa,
+                              &local_len,
+                              &address_cb,
+                              (listen_reversal) ? &reversal_cb : NULL,
+                              NULL);
   }
   else if (listen_reversal)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-               "Use of `-W` only effective in combination with `-i`\n");
+                "Use of `-W` only effective in combination with `-i`\n");
     goto fail_and_shutdown;
   }
 
@@ -332,33 +325,32 @@ run (void *cls,
   {
     int ret;
 
-    if ( (NULL == nh) ||
-        (sizeof (struct sockaddr_in) != local_len) )
+    if ((NULL == nh) || (sizeof (struct sockaddr_in) != local_len))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Require IPv4 local address to initiate connection reversal\n");
+                  "Require IPv4 local address to initiate connection reversal\n");
       goto fail_and_shutdown;
     }
     if (sizeof (struct sockaddr_in) != remote_len)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Require IPv4 reversal target address\n");
+                  "Require IPv4 reversal target address\n");
       goto fail_and_shutdown;
     }
     GNUNET_assert (AF_INET == local_sa->sa_family);
     GNUNET_assert (AF_INET == remote_sa->sa_family);
     ret = GNUNET_NAT_request_reversal (nh,
-                                      (const struct sockaddr_in *) local_sa,
-                                      (const struct sockaddr_in *) remote_sa);
+                                       (const struct sockaddr_in *) local_sa,
+                                       (const struct sockaddr_in *) remote_sa);
     switch (ret)
     {
     case GNUNET_SYSERR:
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Connection reversal internal error\n");
+                  "Connection reversal internal error\n");
       break;
     case GNUNET_NO:
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Connection reversal unavailable\n");
+                  "Connection reversal unavailable\n");
       break;
     case GNUNET_OK:
       /* operation in progress */
@@ -371,46 +363,38 @@ run (void *cls,
     if (NULL == local_addr)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "Require local address to support STUN requests\n");
+                  "Require local address to support STUN requests\n");
       goto fail_and_shutdown;
     }
     if (IPPROTO_UDP != proto)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                 "STUN only supported over UDP\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "STUN only supported over UDP\n");
       goto fail_and_shutdown;
     }
-    ls = GNUNET_NETWORK_socket_create (af,
-                                      SOCK_DGRAM,
-                                      IPPROTO_UDP);
+    ls = GNUNET_NETWORK_socket_create (af, SOCK_DGRAM, IPPROTO_UDP);
     if (NULL == ls)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-      "Failed to create socket\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Failed to create socket\n");
       goto fail_and_shutdown;
     }
-    if (GNUNET_OK !=
-        GNUNET_NETWORK_socket_bind (ls,
-                                    local_sa,
-                                    local_len))
+    if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ls, local_sa, local_len))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 "Failed to bind to %s: %s\n",
-                 GNUNET_a2s (local_sa,
-                             local_len),
-                 STRERROR (errno));
+                  "Failed to bind to %s: %s\n",
+                  GNUNET_a2s (local_sa, local_len),
+                  strerror (errno));
       goto fail_and_shutdown;
     }
     rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                          ls,
-                                          &stun_read_task,
-                                          NULL);
+                                           ls,
+                                           &stun_read_task,
+                                           NULL);
   }
   GNUNET_free_non_null (remote_sa);
   GNUNET_free_non_null (local_sa);
   test_finished ();
   return;
- fail_and_shutdown:
+fail_and_shutdown:
   global_ret = 1;
   GNUNET_SCHEDULER_shutdown ();
   GNUNET_free_non_null (remote_sa);
@@ -426,66 +410,63 @@ run (void *cls,
  * @return 0 on success, -1 on error
  */
 int
-main (int argc,
-      char *const argv[])
+main (int argc, char *const argv[])
 {
   struct GNUNET_GETOPT_CommandLineOption options[] = {
 
-    GNUNET_GETOPT_option_string ('i',
-                                 "in",
-                                 "ADDRESS",
-                                 gettext_noop ("which IP and port are we locally using to bind/listen to"),
-                                 &local_addr),
-
-    GNUNET_GETOPT_option_string ('r',
-                                 "remote",
-                                 "ADDRESS",
-                                 gettext_noop ("which remote IP and port should be asked for connection reversal"),
-                                 &remote_addr),
-
-    GNUNET_GETOPT_option_string ('S',
-                                 "section",
-                                 NULL,
-                                 gettext_noop ("name of configuration section to find additional options, such as manual host punching data"),
-                                 &section_name),
+    GNUNET_GETOPT_option_string (
+      'i',
+      "in",
+      "ADDRESS",
+      gettext_noop ("which IP and port are we locally using to bind/listen to"),
+      &local_addr),
+
+    GNUNET_GETOPT_option_string (
+      'r',
+      "remote",
+      "ADDRESS",
+      gettext_noop (
+        "which remote IP and port should be asked for connection reversal"),
+      &remote_addr),
+
+    GNUNET_GETOPT_option_string (
+      'S',
+      "section",
+      NULL,
+      gettext_noop (
+        "name of configuration section to find additional options, such as manual host punching data"),
+      &section_name),
 
     GNUNET_GETOPT_option_flag ('s',
-                                  "stun",
-                                  gettext_noop ("enable STUN processing"),
-                                  &do_stun),
+                               "stun",
+                               gettext_noop ("enable STUN processing"),
+                               &do_stun),
 
-    GNUNET_GETOPT_option_flag ('t',
-                                  "tcp",
-                                  gettext_noop ("use TCP"),
-                                  &use_tcp),
+    GNUNET_GETOPT_option_flag ('t', "tcp", gettext_noop ("use TCP"), &use_tcp),
 
-    GNUNET_GETOPT_option_flag ('u',
-                                  "udp",
-                                  gettext_noop ("use UDP"),
-                                  &use_udp),
+    GNUNET_GETOPT_option_flag ('u', "udp", gettext_noop ("use UDP"), &use_udp),
 
     GNUNET_GETOPT_option_flag ('W',
-                                  "watch",
-                                  gettext_noop ("watch for connection reversal requests"),
-                                  &listen_reversal),
-    GNUNET_GETOPT_OPTION_END
-  };
+                               "watch",
+                               gettext_noop (
+                                 "watch for connection reversal requests"),
+                               &listen_reversal),
+    GNUNET_GETOPT_OPTION_END};
 
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
   if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv,
-                         "gnunet-nat [options]",
-                          _("GNUnet NAT traversal autoconfigure daemon"),
-                         options,
+      GNUNET_PROGRAM_run (argc,
+                          argv,
+                          "gnunet-nat [options]",
+                          _ ("GNUnet NAT traversal autoconfigure daemon"),
+                          options,
                           &run,
-                         NULL))
+                          NULL))
   {
     global_ret = 1;
   }
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
   return global_ret;
 }
 
index 43ac54adf28b83640f3a6a3e1d4c3a0ad31d567f..cf5038dd7b9050fd5338d9d16501576c8b2f763b 100644 (file)
@@ -101,12 +101,10 @@ static void
 try_again (struct HelperContext *h)
 {
   GNUNET_assert (NULL == h->server_read_task);
-  h->server_retry_delay
-    = GNUNET_TIME_STD_BACKOFF (h->server_retry_delay);
-  h->server_read_task
-    = GNUNET_SCHEDULER_add_delayed (h->server_retry_delay,
-                                   &restart_nat_server,
-                                   h);
+  h->server_retry_delay = GNUNET_TIME_STD_BACKOFF (h->server_retry_delay);
+  h->server_read_task = GNUNET_SCHEDULER_add_delayed (h->server_retry_delay,
+                                                      &restart_nat_server,
+                                                      h);
 }
 
 
@@ -128,23 +126,16 @@ nat_server_read (void *cls)
   struct sockaddr_in sin_addr;
 
   h->server_read_task = NULL;
-  memset (mybuf,
-         0,
-         sizeof (mybuf));
-  bytes
-    = GNUNET_DISK_file_read (h->server_stdout_handle,
-                            mybuf,
-                            sizeof (mybuf));
+  memset (mybuf, 0, sizeof (mybuf));
+  bytes =
+    GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf));
   if (bytes < 1)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Finished reading from server stdout with code: %d\n",
-               (int) bytes);
-    if (0 != GNUNET_OS_process_kill (h->server_proc,
-                                    GNUNET_TERM_SIG))
-      GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING,
-                               "nat",
-                               "kill");
+                "Finished reading from server stdout with code: %d\n",
+                (int) bytes);
+    if (0 != GNUNET_OS_process_kill (h->server_proc, GNUNET_TERM_SIG))
+      GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "kill");
     GNUNET_OS_process_wait (h->server_proc);
     GNUNET_OS_process_destroy (h->server_proc);
     h->server_proc = NULL;
@@ -171,44 +162,37 @@ nat_server_read (void *cls)
   }
 
   /* construct socket address of sender */
-  memset (&sin_addr,
-         0,
-         sizeof (sin_addr));
+  memset (&sin_addr, 0, sizeof (sin_addr));
   sin_addr.sin_family = AF_INET;
 #if HAVE_SOCKADDR_IN_SIN_LEN
   sin_addr.sin_len = sizeof (sin_addr);
 #endif
-  if ( (NULL == port_start) ||
-       (1 != SSCANF (port_start,
-                    "%d",
-                    &port)) ||
-       (-1 == inet_pton (AF_INET,
-                        mybuf,
-                        &sin_addr.sin_addr)))
+  if ((NULL == port_start) || (1 != sscanf (port_start, "%d", &port)) ||
+      (-1 == inet_pton (AF_INET, mybuf, &sin_addr.sin_addr)))
   {
     /* should we restart gnunet-helper-nat-server? */
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("gnunet-helper-nat-server generated malformed address `%s'\n"),
-               mybuf);
-    h->server_read_task
-      = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                        h->server_stdout_handle,
-                                        &nat_server_read,
-                                       h);
+                _ (
+                  "gnunet-helper-nat-server generated malformed address `%s'\n"),
+                mybuf);
+    h->server_read_task =
+      GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                      h->server_stdout_handle,
+                                      &nat_server_read,
+                                      h);
     return;
   }
   sin_addr.sin_port = htons ((uint16_t) port);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "gnunet-helper-nat-server read: %s:%d\n",
-             mybuf,
-             port);
-  h->cb (h->cb_cls,
-        &sin_addr);
-  h->server_read_task
-    = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                      h->server_stdout_handle,
-                                     &nat_server_read,
-                                      h);
+              "gnunet-helper-nat-server read: %s:%d\n",
+              mybuf,
+              port);
+  h->cb (h->cb_cls, &sin_addr);
+  h->server_read_task =
+    GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                    h->server_stdout_handle,
+                                    &nat_server_read,
+                                    h);
 }
 
 
@@ -227,71 +211,59 @@ restart_nat_server (void *cls)
 
   h->server_read_task = NULL;
   GNUNET_assert (NULL !=
-                inet_ntop (AF_INET,
-                           &h->internal_address,
-                           ia,
-                           sizeof (ia)));
+                 inet_ntop (AF_INET, &h->internal_address, ia, sizeof (ia)));
   /* Start the server process */
   binary = GNUNET_OS_get_suid_binary_path (h->cfg, "gnunet-helper-nat-server");
-  if (GNUNET_YES !=
-      GNUNET_OS_check_helper_binary (binary,
-                                     GNUNET_YES,
-                                     ia))
+  if (GNUNET_YES != GNUNET_OS_check_helper_binary (binary, GNUNET_YES, ia))
   {
     /* move instantly to max delay, as this is unlikely to be fixed */
-    h->server_retry_delay
-      = GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD;
+    h->server_retry_delay = GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD;
     GNUNET_free (binary);
     try_again (h);
     return;
   }
-  h->server_stdout
-    = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES,
-                       GNUNET_NO, GNUNET_YES);
+  h->server_stdout =
+    GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
   if (NULL == h->server_stdout)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                        "pipe");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pipe");
     GNUNET_free (binary);
     try_again (h);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting `%s' at `%s'\n",
-             "gnunet-helper-nat-server",
-             ia);
-  h->server_proc
-    = GNUNET_OS_start_process (GNUNET_NO,
-                              0,
-                              NULL,
-                              h->server_stdout,
-                              NULL,
-                              binary,
-                              "gnunet-helper-nat-server",
-                              ia,
-                              NULL);
+              "Starting `%s' at `%s'\n",
+              "gnunet-helper-nat-server",
+              ia);
+  h->server_proc = GNUNET_OS_start_process (GNUNET_NO,
+                                            0,
+                                            NULL,
+                                            h->server_stdout,
+                                            NULL,
+                                            binary,
+                                            "gnunet-helper-nat-server",
+                                            ia,
+                                            NULL);
   GNUNET_free (binary);
   if (NULL == h->server_proc)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to start %s\n"),
-               "gnunet-helper-nat-server");
+                _ ("Failed to start %s\n"),
+                "gnunet-helper-nat-server");
     GNUNET_DISK_pipe_close (h->server_stdout);
     h->server_stdout = NULL;
     try_again (h);
     return;
   }
   /* Close the write end of the read pipe */
-  GNUNET_DISK_pipe_close_end (h->server_stdout,
-                             GNUNET_DISK_PIPE_END_WRITE);
-  h->server_stdout_handle
-    = GNUNET_DISK_pipe_handle (h->server_stdout,
-                              GNUNET_DISK_PIPE_END_READ);
-  h->server_read_task
-    = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     h->server_stdout_handle,
-                                     &nat_server_read,
-                                     h);
+  GNUNET_DISK_pipe_close_end (h->server_stdout, GNUNET_DISK_PIPE_END_WRITE);
+  h->server_stdout_handle =
+    GNUNET_DISK_pipe_handle (h->server_stdout, GNUNET_DISK_PIPE_END_READ);
+  h->server_read_task =
+    GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                    h->server_stdout_handle,
+                                    &nat_server_read,
+                                    h);
 }
 
 
@@ -307,9 +279,9 @@ restart_nat_server (void *cls)
  */
 struct HelperContext *
 GN_start_gnunet_nat_server_ (const struct in_addr *internal_address,
-                            GN_ReversalCallback cb,
-                            void *cb_cls,
-                            const struct GNUNET_CONFIGURATION_Handle *cfg)
+                             GN_ReversalCallback cb,
+                             void *cb_cls,
+                             const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct HelperContext *h;
 
@@ -344,10 +316,8 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h)
   }
   if (NULL != h->server_proc)
   {
-    if (0 != GNUNET_OS_process_kill (h->server_proc,
-                                     GNUNET_TERM_SIG))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                          "kill");
+    if (0 != GNUNET_OS_process_kill (h->server_proc, GNUNET_TERM_SIG))
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
     GNUNET_OS_process_wait (h->server_proc);
     GNUNET_OS_process_destroy (h->server_proc);
     h->server_proc = NULL;
@@ -379,9 +349,9 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h)
  */
 int
 GN_request_connection_reversal (const struct in_addr *internal_address,
-                               uint16_t internal_port,
-                               const struct in_addr *remote_v4,
-                               const struct GNUNET_CONFIGURATION_Handle *cfg)
+                                uint16_t internal_port,
+                                const struct in_addr *remote_v4,
+                                const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char intv4[INET_ADDRSTRLEN];
   char remv4[INET_ADDRSTRLEN];
@@ -389,22 +359,14 @@ GN_request_connection_reversal (const struct in_addr *internal_address,
   struct GNUNET_OS_Process *proc;
   char *binary;
 
-  if (NULL == inet_ntop (AF_INET,
-                        internal_address,
-                        intv4,
-                        INET_ADDRSTRLEN))
+  if (NULL == inet_ntop (AF_INET, internal_address, intv4, INET_ADDRSTRLEN))
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                        "inet_ntop");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
     return GNUNET_SYSERR;
   }
-  if (NULL == inet_ntop (AF_INET,
-                        remote_v4,
-                        remv4,
-                        INET_ADDRSTRLEN))
+  if (NULL == inet_ntop (AF_INET, remote_v4, remv4, INET_ADDRSTRLEN))
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                        "inet_ntop");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
     return GNUNET_SYSERR;
   }
   GNUNET_snprintf (port_as_string,
@@ -412,23 +374,22 @@ GN_request_connection_reversal (const struct in_addr *internal_address,
                    "%d",
                    internal_port);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Running gnunet-helper-nat-client %s %s %u\n",
-             intv4,
-             remv4,
-             internal_port);
+              "Running gnunet-helper-nat-client %s %s %u\n",
+              intv4,
+              remv4,
+              internal_port);
   binary = GNUNET_OS_get_suid_binary_path (cfg, "gnunet-helper-nat-client");
-  proc
-    = GNUNET_OS_start_process (GNUNET_NO,
-                              0,
-                              NULL,
-                              NULL,
-                              NULL,
-                               binary,
-                               "gnunet-helper-nat-client",
-                               intv4,
-                               remv4,
-                              port_as_string,
-                              NULL);
+  proc = GNUNET_OS_start_process (GNUNET_NO,
+                                  0,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  binary,
+                                  "gnunet-helper-nat-client",
+                                  intv4,
+                                  remv4,
+                                  port_as_string,
+                                  NULL);
   GNUNET_free (binary);
   if (NULL == proc)
     return GNUNET_SYSERR;
index c156d0eb017697badd576b8d99166c5c01dba7a8..375188ff2617ff147cf8ed85fb5f82d24df308d8 100644 (file)
@@ -29,7 +29,7 @@
 #include "gnunet-service-nat_mini.h"
 #include "nat.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
 
 /**
  * How long do we give upnpc to create a mapping?
 /**
  * How long do we give upnpc to remove a mapping?
  */
-#define UNMAP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+#define UNMAP_TIMEOUT \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 
 /**
  * How often do we check for changes in the mapping?
  */
-#define MAP_REFRESH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+#define MAP_REFRESH_FREQ \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 
 
 /* ************************* external-ip calling ************************ */
@@ -117,30 +119,27 @@ read_external_ipv4 (void *cls)
 
   eh->task = NULL;
   ret = GNUNET_DISK_file_read (eh->r,
-                              &eh->buf[eh->off],
+                               &eh->buf[eh->off],
                                sizeof (eh->buf) - eh->off);
   if (ret > 0)
   {
     /* try to read more */
     eh->off += ret;
-    eh->task
-      = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       eh->r,
-                                        &read_external_ipv4,
-                                       eh);
+    eh->task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                               eh->r,
+                                               &read_external_ipv4,
+                                               eh);
     return;
   }
   eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID;
-  if ( (eh->off > 7) &&
-       (eh->buf[eh->off - 1] == '\n') )
+  if ((eh->off > 7) && (eh->buf[eh->off - 1] == '\n'))
   {
     eh->buf[eh->off - 1] = '\0';
-    if (1 == inet_pton (AF_INET,
-                       eh->buf,
-                       &addr))
+    if (1 == inet_pton (AF_INET, eh->buf, &addr))
     {
       if (0 == addr.s_addr)
-        eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID;       /* got 0.0.0.0 */
+        eh->ret =
+          GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID; /* got 0.0.0.0 */
       else
         eh->ret = GNUNET_NAT_ERROR_SUCCESS;
     }
@@ -163,9 +162,7 @@ signal_external_ip_error (void *cls)
   struct GNUNET_NAT_ExternalHandle *eh = cls;
 
   eh->task = NULL;
-  eh->cb (eh->cb_cls,
-          NULL,
-          eh->ret);
+  eh->cb (eh->cb_cls, NULL, eh->ret);
   GNUNET_free (eh);
 }
 
@@ -178,8 +175,7 @@ signal_external_ip_error (void *cls)
  * @return handle for cancellation (can only be used until @a cb is called), never NULL
  */
 struct GNUNET_NAT_ExternalHandle *
-GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
-                                   void *cb_cls)
+GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb, void *cb_cls)
 {
   struct GNUNET_NAT_ExternalHandle *eh;
 
@@ -188,56 +184,43 @@ GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
   eh->cb_cls = cb_cls;
   eh->ret = GNUNET_NAT_ERROR_SUCCESS;
   if (GNUNET_SYSERR ==
-      GNUNET_OS_check_helper_binary ("external-ip",
-                                    GNUNET_NO,
-                                    NULL))
+      GNUNET_OS_check_helper_binary ("external-ip", GNUNET_NO, NULL))
   {
-    LOG (GNUNET_ERROR_TYPE_INFO,
-        _("`external-ip' command not found\n"));
+    LOG (GNUNET_ERROR_TYPE_INFO, _ ("`external-ip' command not found\n"));
     eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND;
-    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
-                                         eh);
+    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error, eh);
     return eh;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Running `external-ip' to determine our external IP\n");
-  eh->opipe = GNUNET_DISK_pipe (GNUNET_YES,
-                               GNUNET_YES,
-                               GNUNET_NO,
-                               GNUNET_YES);
+  eh->opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
   if (NULL == eh->opipe)
   {
     eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE;
-    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
-                                         eh);
+    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error, eh);
     return eh;
   }
-  eh->eip =
-      GNUNET_OS_start_process (GNUNET_NO,
-                              0,
-                              NULL,
-                              eh->opipe,
-                              NULL,
-                               "external-ip",
-                              "external-ip",
-                               NULL);
+  eh->eip = GNUNET_OS_start_process (GNUNET_NO,
+                                     0,
+                                     NULL,
+                                     eh->opipe,
+                                     NULL,
+                                     "external-ip",
+                                     "external-ip",
+                                     NULL);
   if (NULL == eh->eip)
   {
     GNUNET_DISK_pipe_close (eh->opipe);
     eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED;
-    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
-                                         eh);
+    eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error, eh);
     return eh;
   }
-  GNUNET_DISK_pipe_close_end (eh->opipe,
-                             GNUNET_DISK_PIPE_END_WRITE);
-  eh->r = GNUNET_DISK_pipe_handle (eh->opipe,
-                                  GNUNET_DISK_PIPE_END_READ);
-  eh->task
-    = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                      eh->r,
-                                      &read_external_ipv4,
-                                     eh);
+  GNUNET_DISK_pipe_close_end (eh->opipe, GNUNET_DISK_PIPE_END_WRITE);
+  eh->r = GNUNET_DISK_pipe_handle (eh->opipe, GNUNET_DISK_PIPE_END_READ);
+  eh->task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                             eh->r,
+                                             &read_external_ipv4,
+                                             eh);
   return eh;
 }
 
@@ -252,10 +235,8 @@ GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct GNUNET_NAT_ExternalHandle *eh)
 {
   if (NULL != eh->eip)
   {
-    (void) GNUNET_OS_process_kill (eh->eip,
-                                  SIGKILL);
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_OS_process_wait (eh->eip));
+    (void) GNUNET_OS_process_kill (eh->eip, SIGKILL);
+    GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (eh->eip));
     GNUNET_OS_process_destroy (eh->eip);
   }
   if (NULL != eh->opipe)
@@ -336,7 +317,6 @@ struct GNUNET_NAT_MiniHandle
    * Which port are we mapping?
    */
   uint16_t port;
-
 };
 
 
@@ -356,8 +336,7 @@ do_refresh (void *cls);
  * @param line line of output, NULL at the end
  */
 static void
-process_map_output (void *cls,
-                   const char *line);
+process_map_output (void *cls, const char *line);
 
 
 /**
@@ -370,26 +349,22 @@ run_upnpc_r (struct GNUNET_NAT_MiniHandle *mini)
 {
   char pstr[6];
 
-  GNUNET_snprintf (pstr,
-                   sizeof (pstr),
-                   "%u",
-                   (unsigned int) mini->port);
-  mini->map_cmd
-    = GNUNET_OS_command_run (&process_map_output,
-                            mini,
-                            MAP_TIMEOUT,
-                            "upnpc",
-                            "upnpc",
-                            "-r",
-                            pstr,
-                            mini->is_tcp ? "tcp" : "udp",
-                            NULL);
+  GNUNET_snprintf (pstr, sizeof (pstr), "%u", (unsigned int) mini->port);
+  mini->map_cmd = GNUNET_OS_command_run (&process_map_output,
+                                         mini,
+                                         MAP_TIMEOUT,
+                                         "upnpc",
+                                         "upnpc",
+                                         "-r",
+                                         pstr,
+                                         mini->is_tcp ? "tcp" : "udp",
+                                         NULL);
   if (NULL == mini->map_cmd)
   {
     mini->ac (mini->ac_cls,
               GNUNET_SYSERR,
               NULL,
-             0,
+              0,
               GNUNET_NAT_ERROR_UPNPC_FAILED);
     return;
   }
@@ -404,8 +379,7 @@ run_upnpc_r (struct GNUNET_NAT_MiniHandle *mini)
  * @param line line of output, NULL at the end
  */
 static void
-process_refresh_output (void *cls,
-                       const char *line)
+process_refresh_output (void *cls, const char *line)
 {
   struct GNUNET_NAT_MiniHandle *mini = cls;
   char pstr[9];
@@ -434,31 +408,28 @@ process_refresh_output (void *cls,
     return;
   }
   if (! mini->did_map)
-    return;                     /* never mapped, won't find our mapping anyway */
+    return; /* never mapped, won't find our mapping anyway */
 
   /* we're looking for output of the form:
    * "ExternalIPAddress = 12.134.41.124" */
 
-  s = strstr (line,
-             "ExternalIPAddress = ");
+  s = strstr (line, "ExternalIPAddress = ");
   if (NULL != s)
   {
     s += strlen ("ExternalIPAddress = ");
-    if (1 != inet_pton (AF_INET,
-                       s,
-                       &exip))
-      return;                   /* skip */
+    if (1 != inet_pton (AF_INET, s, &exip))
+      return; /* skip */
     if (exip.s_addr == mini->current_addr.sin_addr.s_addr)
-      return;                   /* no change */
+      return; /* no change */
     /* update mapping */
     mini->ac (mini->ac_cls,
-             GNUNET_NO,
+              GNUNET_NO,
               (const struct sockaddr *) &mini->current_addr,
               sizeof (mini->current_addr),
               GNUNET_NAT_ERROR_SUCCESS);
     mini->current_addr.sin_addr = exip;
     mini->ac (mini->ac_cls,
-             GNUNET_YES,
+              GNUNET_YES,
               (const struct sockaddr *) &mini->current_addr,
               sizeof (mini->current_addr),
               GNUNET_NAT_ERROR_SUCCESS);
@@ -475,32 +446,29 @@ process_refresh_output (void *cls,
    * "%s TCP  PORT->STRING:OURPORT *" or
    * "%s UDP  PORT->STRING:OURPORT *"
    */
-  GNUNET_snprintf (pstr,
-                  sizeof (pstr),
-                  ":%u ",
-                  mini->port);
+  GNUNET_snprintf (pstr, sizeof (pstr), ":%u ", mini->port);
   if (NULL == (s = strstr (line, "->")))
-    return;                     /* skip */
+    return; /* skip */
   if (NULL == strstr (s, pstr))
-    return;                     /* skip */
-  if (1 !=
-      SSCANF (line,
-              (mini->is_tcp) ? "%*u TCP  %u->%*s:%*u %*s" :
-              "%*u UDP  %u->%*s:%*u %*s", &nport))
-    return;                     /* skip */
+    return; /* skip */
+  if (1 != sscanf (line,
+                   (mini->is_tcp) ? "%*u TCP  %u->%*s:%*u %*s"
+                                  : "%*u UDP  %u->%*s:%*u %*s",
+                   &nport))
+    return; /* skip */
   mini->found = GNUNET_YES;
   if (nport == ntohs (mini->current_addr.sin_port))
-    return;                     /* no change */
+    return; /* no change */
 
   /* external port changed, update mapping */
   mini->ac (mini->ac_cls,
-           GNUNET_NO,
+            GNUNET_NO,
             (const struct sockaddr *) &mini->current_addr,
             sizeof (mini->current_addr),
             GNUNET_NAT_ERROR_SUCCESS);
   mini->current_addr.sin_port = htons ((uint16_t) nport);
   mini->ac (mini->ac_cls,
-           GNUNET_YES,
+            GNUNET_YES,
             (const struct sockaddr *) &mini->current_addr,
             sizeof (mini->current_addr),
             GNUNET_NAT_ERROR_SUCCESS);
@@ -518,10 +486,8 @@ do_refresh (void *cls)
   struct GNUNET_NAT_MiniHandle *mini = cls;
   int ac;
 
-  mini->refresh_task
-    = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
-                                   &do_refresh,
-                                   mini);
+  mini->refresh_task =
+    GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Running `upnpc' to check if our mapping still exists\n");
   mini->found = GNUNET_NO;
@@ -540,19 +506,18 @@ do_refresh (void *cls)
     mini->refresh_cmd = NULL;
     ac = GNUNET_YES;
   }
-  mini->refresh_cmd
-    = GNUNET_OS_command_run (&process_refresh_output,
-                            mini,
-                            MAP_TIMEOUT,
-                             "upnpc",
-                            "upnpc",
-                            "-l",
-                            NULL);
+  mini->refresh_cmd = GNUNET_OS_command_run (&process_refresh_output,
+                                             mini,
+                                             MAP_TIMEOUT,
+                                             "upnpc",
+                                             "upnpc",
+                                             "-l",
+                                             NULL);
   if (GNUNET_YES == ac)
     mini->ac (mini->ac_cls,
               GNUNET_SYSERR,
               NULL,
-             0,
+              0,
               GNUNET_NAT_ERROR_UPNPC_TIMEOUT);
 }
 
@@ -564,8 +529,7 @@ do_refresh (void *cls)
  * @param line line of output, NULL at the end
  */
 static void
-process_map_output (void *cls,
-                    const char *line)
+process_map_output (void *cls, const char *line)
 {
   struct GNUNET_NAT_MiniHandle *mini = cls;
   const char *ipaddr;
@@ -581,13 +545,11 @@ process_map_output (void *cls,
       mini->ac (mini->ac_cls,
                 GNUNET_SYSERR,
                 NULL,
-               0,
+                0,
                 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED);
     if (NULL == mini->refresh_task)
-      mini->refresh_task
-        = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
-                                       &do_refresh,
-                                       mini);
+      mini->refresh_task =
+        GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini);
     return;
   }
   /*
@@ -597,18 +559,16 @@ process_map_output (void *cls,
    */
   if ((NULL == (ipaddr = strstr (line, " "))) ||
       (NULL == (pstr = strstr (ipaddr, ":"))) ||
-      (1 != SSCANF (pstr + 1, "%u", &port)))
+      (1 != sscanf (pstr + 1, "%u", &port)))
   {
-    return;                     /* skip line */
+    return; /* skip line */
   }
   ipa = GNUNET_strdup (ipaddr + 1);
   strstr (ipa, ":")[0] = '\0';
-  if (1 != inet_pton (AF_INET,
-                     ipa,
-                     &mini->current_addr.sin_addr))
+  if (1 != inet_pton (AF_INET, ipa, &mini->current_addr.sin_addr))
   {
     GNUNET_free (ipa);
-    return;                     /* skip line */
+    return; /* skip line */
   }
   GNUNET_free (ipa);
 
@@ -619,7 +579,7 @@ process_map_output (void *cls,
 #endif
   mini->did_map = GNUNET_YES;
   mini->ac (mini->ac_cls,
-           GNUNET_YES,
+            GNUNET_YES,
             (const struct sockaddr *) &mini->current_addr,
             sizeof (mini->current_addr),
             GNUNET_NAT_ERROR_SUCCESS);
@@ -647,30 +607,20 @@ GNUNET_NAT_mini_map_start (uint16_t port,
 {
   struct GNUNET_NAT_MiniHandle *ret;
 
-  if (GNUNET_SYSERR ==
-      GNUNET_OS_check_helper_binary ("upnpc",
-                                    GNUNET_NO,
-                                    NULL))
+  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL))
   {
-    LOG (GNUNET_ERROR_TYPE_INFO,
-        _("`upnpc' command not found\n"));
-    ac (ac_cls,
-        GNUNET_SYSERR,
-        NULL, 0,
-        GNUNET_NAT_ERROR_UPNPC_NOT_FOUND);
+    LOG (GNUNET_ERROR_TYPE_INFO, _ ("`upnpc' command not found\n"));
+    ac (ac_cls, GNUNET_SYSERR, NULL, 0, GNUNET_NAT_ERROR_UPNPC_NOT_FOUND);
     return NULL;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Running `upnpc' to install mapping\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Running `upnpc' to install mapping\n");
   ret = GNUNET_new (struct GNUNET_NAT_MiniHandle);
   ret->ac = ac;
   ret->ac_cls = ac_cls;
   ret->is_tcp = is_tcp;
   ret->port = port;
   ret->refresh_task =
-    GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
-                                 &do_refresh,
-                                 ret);
+    GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, ret);
   run_upnpc_r (ret);
   return ret;
 }
@@ -683,15 +633,13 @@ GNUNET_NAT_mini_map_start (uint16_t port,
  * @param line line of output, NULL at the end
  */
 static void
-process_unmap_output (void *cls,
-                     const char *line)
+process_unmap_output (void *cls, const char *line)
 {
   struct GNUNET_NAT_MiniHandle *mini = cls;
 
   if (NULL == line)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "UPnP unmap done\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n");
     GNUNET_OS_command_stop (mini->unmap_cmd);
     mini->unmap_cmd = NULL;
     GNUNET_free (mini);
@@ -735,7 +683,7 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
     return;
   }
   mini->ac (mini->ac_cls,
-           GNUNET_NO,
+            GNUNET_NO,
             (const struct sockaddr *) &mini->current_addr,
             sizeof (mini->current_addr),
             GNUNET_NAT_ERROR_SUCCESS);
@@ -749,16 +697,15 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Unmapping port %u with UPnP\n",
        ntohs (mini->current_addr.sin_port));
-  mini->unmap_cmd
-    = GNUNET_OS_command_run (&process_unmap_output,
-                            mini,
-                            UNMAP_TIMEOUT,
-                             "upnpc",
-                            "upnpc",
-                            "-d",
-                            pstr,
-                             mini->is_tcp ? "tcp" : "udp",
-                            NULL);
+  mini->unmap_cmd = GNUNET_OS_command_run (&process_unmap_output,
+                                           mini,
+                                           UNMAP_TIMEOUT,
+                                           "upnpc",
+                                           "upnpc",
+                                           "-d",
+                                           pstr,
+                                           mini->is_tcp ? "tcp" : "udp",
+                                           NULL);
 }
 
 
index a6b847f3a1514102bd8f37315414ca665ae63b40..12f5f37fb16f299b6dc91f67246133b15b452d6d 100644 (file)
 /**
  * Generic loggins shorthand
  */
-#define LOG(kind,...)                                           \
-  GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
 
 /**
  * Debug logging shorthand
  */
-#define LOG_DEBUG(...)                          \
-  LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 
 
 /**
@@ -210,7 +208,7 @@ static char *data_filename;
  * How long to wait before triggering next round?
  * Default: 60 s.
  */
-static struct GNUNET_TIME_Relative wait_time = { 60 * 1000 };
+static struct GNUNET_TIME_Relative wait_time = {60 * 1000};
 
 /**
  * DLL head for operation list
@@ -300,30 +298,34 @@ shutdown_task (void *cls)
  */
 static void
 handle_estimate (void *cls,
-                struct GNUNET_TIME_Absolute timestamp,
-                 double estimate, double std_dev)
+                 struct GNUNET_TIME_Absolute timestamp,
+                 double estimate,
+                 double std_dev)
 {
   struct NSEPeer *peer = cls;
   char output_buffer[512];
   size_t size;
 
   if (NULL == output_file)
-    {
-      FPRINTF (stderr,
-              "Received network size estimate from peer %p. Size: %f std.dev. %f\n",
-              peer, estimate, std_dev);
-      return;
-    }
+  {
+    fprintf (stderr,
+             "Received network size estimate from peer %p. Size: %f std.dev. %f\n",
+             peer,
+             estimate,
+             std_dev);
+    return;
+  }
   size = GNUNET_snprintf (output_buffer,
-                         sizeof (output_buffer),
-                         "%p %llu %llu %f %f %f\n",
-                         peer, peers_running,
-                         (unsigned long long) timestamp.abs_value_us,
-                         GNUNET_NSE_log_estimate_to_n (estimate), estimate,
-                         std_dev);
+                          sizeof (output_buffer),
+                          "%p %llu %llu %f %f %f\n",
+                          peer,
+                          peers_running,
+                          (unsigned long long) timestamp.abs_value_us,
+                          GNUNET_NSE_log_estimate_to_n (estimate),
+                          estimate,
+                          std_dev);
   if (size != GNUNET_DISK_file_write (output_file, output_buffer, size))
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               "Unable to write to file!\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
 }
 
 
@@ -338,8 +340,7 @@ handle_estimate (void *cls,
  * @return service handle to return in 'op_result', NULL on error
  */
 static void *
-nse_connect_adapter (void *cls,
-                    const struct GNUNET_CONFIGURATION_Handle *cfg)
+nse_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct NSEPeer *current_peer = cls;
 
@@ -355,8 +356,7 @@ nse_connect_adapter (void *cls,
  * @param op_result service handle returned from the connect adapter
  */
 static void
-nse_disconnect_adapter (void *cls,
-                       void *op_result)
+nse_disconnect_adapter (void *cls, void *op_result)
 {
   GNUNET_NSE_disconnect (op_result);
 }
@@ -389,9 +389,11 @@ stat_iterator (void *cls,
   flag = strcasecmp (subsystem, "core");
   if (0 != flag)
     flag = 1;
-  size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n",
+  size = GNUNET_asprintf (&output_buffer,
+                          "%llu %llu %u\n",
                           now.abs_value_us / 1000LL / 1000LL,
-                          value, flag);
+                          value,
+                          flag);
   if (0 > size)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n");
@@ -419,8 +421,7 @@ stat_iterator (void *cls,
  * @return service handle to return in 'op_result', NULL on error
  */
 static void *
-stat_connect_adapter (void *cls,
-                      const struct GNUNET_CONFIGURATION_Handle *cfg)
+stat_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct NSEPeer *peer = cls;
 
@@ -440,12 +441,18 @@ stat_disconnect_adapter (void *cls, void *op_result)
 {
   struct NSEPeer *peer = cls;
 
-  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
-                (peer->sh, "core", "# peers connected",
-                 stat_iterator, peer));
-  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
-                (peer->sh, "nse", "# peers connected",
-                 stat_iterator, peer));
+  GNUNET_break (GNUNET_OK ==
+                GNUNET_STATISTICS_watch_cancel (peer->sh,
+                                                "core",
+                                                "# peers connected",
+                                                stat_iterator,
+                                                peer));
+  GNUNET_break (GNUNET_OK ==
+                GNUNET_STATISTICS_watch_cancel (peer->sh,
+                                                "nse",
+                                                "# peers connected",
+                                                stat_iterator,
+                                                peer));
   GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
   peer->sh = NULL;
 }
@@ -462,8 +469,10 @@ stat_disconnect_adapter (void *cls, void *op_result)
  *          operation has executed successfully.
  */
 static void
-stat_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
-              void *ca_result, const char *emsg )
+stat_comp_cb (void *cls,
+              struct GNUNET_TESTBED_Operation *op,
+              void *ca_result,
+              const char *emsg)
 {
   struct GNUNET_STATISTICS_Handle *sh = ca_result;
   struct NSEPeer *peer = cls;
@@ -473,12 +482,16 @@ stat_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
     GNUNET_break (0);
     return;
   }
-  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
-                (sh, "core", "# peers connected",
-                 stat_iterator, peer));
-  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
-                (sh, "nse", "# peers connected",
-                 stat_iterator, peer));
+  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
+                                                      "core",
+                                                      "# peers connected",
+                                                      stat_iterator,
+                                                      peer));
+  GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
+                                                      "nse",
+                                                      "# peers connected",
+                                                      stat_iterator,
+                                                      peer));
 }
 
 
@@ -500,29 +513,30 @@ connect_nse_service ()
   for (i = 0; i < num_peers_in_round[current_round]; i++)
   {
     if ((num_peers_in_round[current_round] > connection_limit) &&
-       (0 != (i % (num_peers_in_round[current_round] / connection_limit))))
+        (0 != (i % (num_peers_in_round[current_round] / connection_limit))))
       continue;
     LOG_DEBUG ("Connecting to nse service of peer %d\n", i);
     current_peer = GNUNET_new (struct NSEPeer);
     current_peer->daemon = daemons[i];
-    current_peer->nse_op
-        = GNUNET_TESTBED_service_connect (NULL,
-                                          current_peer->daemon,
-                                          "nse",
-                                          NULL, NULL,
-                                          &nse_connect_adapter,
-                                          &nse_disconnect_adapter,
-                                          current_peer);
+    current_peer->nse_op =
+      GNUNET_TESTBED_service_connect (NULL,
+                                      current_peer->daemon,
+                                      "nse",
+                                      NULL,
+                                      NULL,
+                                      &nse_connect_adapter,
+                                      &nse_disconnect_adapter,
+                                      current_peer);
     if (NULL != data_file)
-      current_peer->stat_op
-          = GNUNET_TESTBED_service_connect (NULL,
-                                            current_peer->daemon,
-                                            "statistics",
-                                            stat_comp_cb,
-                                            current_peer,
-                                            &stat_connect_adapter,
-                                            &stat_disconnect_adapter,
-                                            current_peer);
+      current_peer->stat_op =
+        GNUNET_TESTBED_service_connect (NULL,
+                                        current_peer->daemon,
+                                        "statistics",
+                                        stat_comp_cb,
+                                        current_peer,
+                                        &stat_connect_adapter,
+                                        &stat_disconnect_adapter,
+                                        current_peer);
     GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);
     if (++connections == connection_limit)
       break;
@@ -549,9 +563,7 @@ next_round (void *cls);
 static void
 finish_round (void *cls)
 {
-  LOG (GNUNET_ERROR_TYPE_INFO,
-       "Have %u connections\n",
-       total_connections);
+  LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections);
   close_monitor_connections ();
   round_task = GNUNET_SCHEDULER_add_now (&next_round, NULL);
 }
@@ -565,12 +577,9 @@ finish_round (void *cls)
 static void
 run_round ()
 {
-  LOG_DEBUG ("Running round %u\n",
-            current_round);
+  LOG_DEBUG ("Running round %u\n", current_round);
   connect_nse_service ();
-  GNUNET_SCHEDULER_add_delayed (wait_time,
-                               &finish_round,
-                               NULL);
+  GNUNET_SCHEDULER_add_delayed (wait_time, &finish_round, NULL);
 }
 
 
@@ -583,9 +592,7 @@ make_oplist_entry ()
   struct OpListEntry *entry;
 
   entry = GNUNET_new (struct OpListEntry);
-  GNUNET_CONTAINER_DLL_insert_tail (oplist_head,
-                                   oplist_tail,
-                                   entry);
+  GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
   return entry;
 }
 
@@ -599,7 +606,7 @@ make_oplist_entry ()
  */
 static void
 manage_service_cb (void *cls,
-                  struct GNUNET_TESTBED_Operation *op,
+                   struct GNUNET_TESTBED_Operation *op,
                    const char *emsg)
 {
   struct OpListEntry *entry = cls;
@@ -613,9 +620,7 @@ manage_service_cb (void *cls,
   }
   GNUNET_assert (0 != entry->delta);
   peers_running += entry->delta;
-  GNUNET_CONTAINER_DLL_remove (oplist_head,
-                              oplist_tail,
-                              entry);
+  GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
   GNUNET_free (entry);
   if (num_peers_in_round[current_round] == peers_running)
     run_round ();
@@ -633,7 +638,7 @@ adjust_running_peers ()
   unsigned int i;
 
   /* start peers if we have too few */
-  for (i=peers_running;i<num_peers_in_round[current_round];i++)
+  for (i = peers_running; i < num_peers_in_round[current_round]; i++)
   {
     entry = make_oplist_entry ();
     entry->delta = 1;
@@ -645,16 +650,16 @@ adjust_running_peers ()
                                                     1);
   }
   /* stop peers if we have too many */
-  for (i=num_peers_in_round[current_round];i<peers_running;i++)
+  for (i = num_peers_in_round[current_round]; i < peers_running; i++)
   {
     entry = make_oplist_entry ();
     entry->delta = -1;
-    entry->op =  GNUNET_TESTBED_peer_manage_service (NULL,
-                                                     daemons[i],
-                                                     "nse",
-                                                     &manage_service_cb,
-                                                     entry,
-                                                     0);
+    entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
+                                                    daemons[i],
+                                                    "nse",
+                                                    &manage_service_cb,
+                                                    entry,
+                                                    0);
   }
 }
 
@@ -697,19 +702,19 @@ next_round (void *cls)
  */
 static void
 master_controller_cb (void *cls,
-                     const struct GNUNET_TESTBED_EventInformation *event)
+                      const struct GNUNET_TESTBED_EventInformation *event)
 {
   switch (event->type)
-    {
-    case GNUNET_TESTBED_ET_CONNECT:
-      total_connections++;
-      break;
-    case GNUNET_TESTBED_ET_DISCONNECT:
-      total_connections--;
-      break;
-    default:
-      break;
-    }
+  {
+  case GNUNET_TESTBED_ET_CONNECT:
+    total_connections++;
+    break;
+  case GNUNET_TESTBED_ET_DISCONNECT:
+    total_connections--;
+    break;
+  default:
+    break;
+  }
 }
 
 
@@ -761,7 +766,9 @@ test_master (void *cls,
  * @param cfg configuration handle
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *tok;
@@ -777,46 +784,43 @@ run (void *cls, char *const *args, const char *cfgfile,
     return;
   }
   for (tok = strtok (num_peer_spec, ","); NULL != tok; tok = strtok (NULL, ","))
+  {
+    if (1 != sscanf (tok, "%u", &num))
     {
-      if (1 != sscanf (tok, "%u", &num))
-       {
-         fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
-         return;
-       }
-      if (0 == num)
-       {
-         fprintf (stderr, "Refusing to run a round with 0 peers\n");
-         return;
-       }
-      GNUNET_array_append (num_peers_in_round, num_rounds, num);
-      num_peers = GNUNET_MAX (num_peers, num);
+      fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
+      return;
     }
-  if (0 == num_peers)
+    if (0 == num)
     {
-      fprintf (stderr, "Refusing to run a testbed with no rounds\n");
+      fprintf (stderr, "Refusing to run a round with 0 peers\n");
       return;
     }
-  if ( (NULL != data_filename) &&
-       (NULL == (data_file =
-                GNUNET_DISK_file_open (data_filename,
-                                       GNUNET_DISK_OPEN_READWRITE |
-                                       GNUNET_DISK_OPEN_TRUNCATE |
-                                       GNUNET_DISK_OPEN_CREATE,
-                                       GNUNET_DISK_PERM_USER_READ |
-                                       GNUNET_DISK_PERM_USER_WRITE))) )
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                             "open",
-                             data_filename);
-
-  if ( (NULL != output_filename) &&
-       (NULL == (output_file =
-                GNUNET_DISK_file_open (output_filename,
-                                       GNUNET_DISK_OPEN_READWRITE |
-                                       GNUNET_DISK_OPEN_CREATE,
-                                       GNUNET_DISK_PERM_USER_READ |
-                                       GNUNET_DISK_PERM_USER_WRITE))) )
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
-                             output_filename);
+    GNUNET_array_append (num_peers_in_round, num_rounds, num);
+    num_peers = GNUNET_MAX (num_peers, num);
+  }
+  if (0 == num_peers)
+  {
+    fprintf (stderr, "Refusing to run a testbed with no rounds\n");
+    return;
+  }
+  if ((NULL != data_filename) &&
+      (NULL ==
+       (data_file = GNUNET_DISK_file_open (data_filename,
+                                           GNUNET_DISK_OPEN_READWRITE |
+                                             GNUNET_DISK_OPEN_TRUNCATE |
+                                             GNUNET_DISK_OPEN_CREATE,
+                                           GNUNET_DISK_PERM_USER_READ |
+                                             GNUNET_DISK_PERM_USER_WRITE))))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", data_filename);
+
+  if ((NULL != output_filename) &&
+      (NULL ==
+       (output_file = GNUNET_DISK_file_open (output_filename,
+                                             GNUNET_DISK_OPEN_READWRITE |
+                                               GNUNET_DISK_OPEN_CREATE,
+                                             GNUNET_DISK_PERM_USER_READ |
+                                               GNUNET_DISK_PERM_USER_WRITE))))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", output_filename);
   event_mask = 0LL;
   event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
   event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
@@ -827,9 +831,9 @@ run (void *cls, char *const *args, const char *cfgfile,
                       num_peers,
                       event_mask,
                       master_controller_cb,
-                      NULL,     /* master_controller_cb cls */
+                      NULL, /* master_controller_cb cls */
                       &test_master,
-                      NULL);    /* test_master cls */
+                      NULL); /* test_master cls */
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
@@ -842,56 +846,70 @@ run (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_uint ('C',
-                                   "connections",
-                                   "COUNT",
-                                   gettext_noop ("limit to the number of connections to NSE services, 0 for none"),
-                                   &connection_limit),
-    GNUNET_GETOPT_option_string ('d',
-                                 "details",
-                                 "FILENAME",
-                                 gettext_noop ("name of the file for writing connection information and statistics"),
-                                 &data_filename),
-
-    GNUNET_GETOPT_option_string ('H',
-                                 "hosts",
-                                 "FILENAME",
-                                 gettext_noop ("name of the file with the login information for the testbed"),
-                                 &hosts_file),
-
-    GNUNET_GETOPT_option_string ('o',
-                                 "output",
-                                 "FILENAME",
-                                 gettext_noop ("name of the file for writing the main results"),
-                                 &output_filename),
-
-
-    GNUNET_GETOPT_option_string ('p',
-                                 "peers",
-                                 "NETWORKSIZESPEC",
-                                 gettext_noop ("Number of peers to run in each round, separated by commas"),
-                                 &num_peer_spec),
-
-    GNUNET_GETOPT_option_increment_uint ('V',
-                                          "verbose",
-                                          gettext_noop ("be verbose (print progress information)"),
-                                          &verbose),
-
-    GNUNET_GETOPT_option_relative_time ('w',
-                                            "wait",
-                                            "DELAY",
-                                            gettext_noop ("delay between rounds"),
-                                            &wait_time),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_uint (
+       'C',
+       "connections",
+       "COUNT",
+       gettext_noop (
+         "limit to the number of connections to NSE services, 0 for none"),
+       &connection_limit),
+     GNUNET_GETOPT_option_string (
+       'd',
+       "details",
+       "FILENAME",
+       gettext_noop (
+         "name of the file for writing connection information and statistics"),
+       &data_filename),
+
+     GNUNET_GETOPT_option_string (
+       'H',
+       "hosts",
+       "FILENAME",
+       gettext_noop (
+         "name of the file with the login information for the testbed"),
+       &hosts_file),
+
+     GNUNET_GETOPT_option_string (
+       'o',
+       "output",
+       "FILENAME",
+       gettext_noop ("name of the file for writing the main results"),
+       &output_filename),
+
+
+     GNUNET_GETOPT_option_string (
+       'p',
+       "peers",
+       "NETWORKSIZESPEC",
+       gettext_noop (
+         "Number of peers to run in each round, separated by commas"),
+       &num_peer_spec),
+
+     GNUNET_GETOPT_option_increment_uint (
+       'V',
+       "verbose",
+       gettext_noop ("be verbose (print progress information)"),
+       &verbose),
+
+     GNUNET_GETOPT_option_relative_time ('w',
+                                         "wait",
+                                         "DELAY",
+                                         gettext_noop ("delay between rounds"),
+                                         &wait_time),
+     GNUNET_GETOPT_OPTION_END};
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-  if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv, "nse-profiler",
-                         gettext_noop
-                         ("Measure quality and performance of the NSE service."),
-                         options, &run, NULL))
+  if (
+    GNUNET_OK !=
+    GNUNET_PROGRAM_run (argc,
+                        argv,
+                        "nse-profiler",
+                        gettext_noop (
+                          "Measure quality and performance of the NSE service."),
+                        options,
+                        &run,
+                        NULL))
     ok = 1;
   return ok;
 }
index c8ffa152e0d7ed7761641f9808b69f262ebbfd8d..73b80e28bb80ca68a278ae5630c1cedf75cb413b 100644 (file)
@@ -72,7 +72,7 @@ handle_estimate (void *cls,
 {
   (void) cls;
   status = 0;
-  FPRINTF (stdout,
+  fprintf (stdout,
            "%llu %f %f %f\n",
            (unsigned long long) timestamp.abs_value_us,
            GNUNET_NSE_log_estimate_to_n (estimate),
index e427e393b16554c74509414c42459617c10d1094..67ca1712761e3a5062d591e639ea54a381ceb39a 100644 (file)
@@ -63,7 +63,7 @@ check_nse_message (void *cls, struct GNUNET_TIME_Absolute timestamp,
 {
   int *ok = cls;
 
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Received NSE message, estimate %f, standard deviation %f.\n",
            estimate, std_dev);
   /* Fantastic check below. Expect NaN, the only thing not equal to itself. */
index 6a60461736e4e9549ea52bf52fdf59d5b665ad25..ec5a94f765bb5640eef507d7755926f62b038ee3 100644 (file)
@@ -98,7 +98,7 @@ handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
 {
   struct NSEPeer *peer = cls;
 
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Received network size estimate from peer %u. logSize: %f std.dev. %f (%f/%u)\n",
            (unsigned int) (peer - nse_peers),
           estimate, std_dev,
index 1094166005188bf311777e461aac8152bf75a7b5..fdcaaba586d8a6eed48e748f22d51c0302669810 100644 (file)
@@ -114,7 +114,6 @@ struct PrintContext
    * Hello was friend only, #GNUNET_YES or #GNUNET_NO
    */
   int friend_only;
-
 };
 
 
@@ -236,29 +235,26 @@ dump_pc (struct PrintContext *pc)
 {
   unsigned int i;
 
-  printf (_("%sPeer `%s'\n"),
-         (GNUNET_YES == pc->friend_only) ? "F2F: " : "",
-         GNUNET_i2s_full (&pc->peer));
+  printf (_ ("%sPeer `%s'\n"),
+          (GNUNET_YES == pc->friend_only) ? "F2F: " : "",
+          GNUNET_i2s_full (&pc->peer));
   for (i = 0; i < pc->num_addresses; i++)
   {
     if (NULL != pc->address_list[i].result)
     {
-      printf (_("\tExpires: %s \t %s\n"),
-              GNUNET_STRINGS_absolute_time_to_string (pc->address_list[i].expiration),
+      printf (_ ("\tExpires: %s \t %s\n"),
+              GNUNET_STRINGS_absolute_time_to_string (
+                pc->address_list[i].expiration),
               pc->address_list[i].result);
       GNUNET_free (pc->address_list[i].result);
     }
   }
   printf ("\n");
   GNUNET_free_non_null (pc->address_list);
-  GNUNET_CONTAINER_DLL_remove (pc_head,
-                              pc_tail,
-                              pc);
+  GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
   GNUNET_free (pc);
-  if ( (NULL == pc_head) &&
-       (NULL == pic) )
-    tt = GNUNET_SCHEDULER_add_now (&state_machine,
-                                   NULL);
+  if ((NULL == pc_head) && (NULL == pic))
+    tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
 }
 
 
@@ -276,9 +272,7 @@ dump_pc (struct PrintContext *pc)
  *        if #GNUNET_SYSERR: address is invalid
  */
 static void
-process_resolved_address (void *cls,
-                          const char *address,
-                          int res)
+process_resolved_address (void *cls, const char *address, int res)
 {
   struct AddressRecord *ar = cls;
   struct PrintContext *pc = ar->pc;
@@ -296,7 +290,7 @@ process_resolved_address (void *cls,
   ar->atsc = NULL;
   if (GNUNET_SYSERR == res)
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Failure: Cannot convert address to string for peer `%s'\n"),
+                _ ("Failure: Cannot convert address to string for peer `%s'\n"),
                 GNUNET_i2s (&ar->pc->peer));
   pc->num_addresses++;
   if (pc->num_addresses == pc->address_list_size)
@@ -352,8 +346,9 @@ print_address (void *cls,
   ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg,
                                                  address,
                                                  no_resolve,
-                                                TIMEOUT,
-                                                &process_resolved_address, ar);
+                                                 TIMEOUT,
+                                                 &process_resolved_address,
+                                                 ar);
   return GNUNET_OK;
 }
 
@@ -381,9 +376,9 @@ print_peer_info (void *cls,
     pic = NULL; /* end of iteration */
     if (NULL != err_msg)
     {
-      FPRINTF (stderr,
-              _("Error in communication with PEERINFO service: %s\n"),
-              err_msg);
+      fprintf (stderr,
+               _ ("Error in communication with PEERINFO service: %s\n"),
+               err_msg);
     }
     if (NULL == pc_head)
       tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
@@ -391,25 +386,19 @@ print_peer_info (void *cls,
   }
   friend_only = GNUNET_NO;
   if (NULL != hello)
-       friend_only = GNUNET_HELLO_is_friend_only (hello);
-  if ( (GNUNET_YES == be_quiet) ||
-       (NULL == hello) )
+    friend_only = GNUNET_HELLO_is_friend_only (hello);
+  if ((GNUNET_YES == be_quiet) || (NULL == hello))
   {
     printf ("%s%s\n",
-           (GNUNET_YES == friend_only) ? "F2F: " : "",
-           GNUNET_i2s_full (peer));
+            (GNUNET_YES == friend_only) ? "F2F: " : "",
+            GNUNET_i2s_full (peer));
     return;
   }
   pc = GNUNET_new (struct PrintContext);
-  GNUNET_CONTAINER_DLL_insert (pc_head,
-                              pc_tail,
-                              pc);
+  GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
   pc->peer = *peer;
   pc->friend_only = friend_only;
-  GNUNET_HELLO_iterate_addresses (hello,
-                                 GNUNET_NO,
-                                 &count_address,
-                                 pc);
+  GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_address, pc);
   if (0 == pc->off)
   {
     dump_pc (pc);
@@ -417,10 +406,7 @@ print_peer_info (void *cls,
   }
   pc->address_list_size = pc->off;
   pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off);
-  GNUNET_HELLO_iterate_addresses (hello,
-                                  GNUNET_NO,
-                                 &print_address,
-                                  pc);
+  GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &print_address, pc);
 }
 
 /* ************************* DUMP Hello  ************************** */
@@ -462,45 +448,40 @@ dump_my_hello ()
   size = GNUNET_HELLO_size (my_hello);
   if (0 == size)
   {
-    FPRINTF (stderr,
-             _("Failure: Received invalid %s\n"),
-             "HELLO");
+    fprintf (stderr, _ ("Failure: Received invalid %s\n"), "HELLO");
     return;
   }
-  if (GNUNET_SYSERR ==
-      GNUNET_DISK_fn_write (dump_hello,
-                            my_hello,
-                            size,
-                            GNUNET_DISK_PERM_USER_READ |
-                            GNUNET_DISK_PERM_USER_WRITE |
-                            GNUNET_DISK_PERM_GROUP_READ |
-                            GNUNET_DISK_PERM_OTHER_READ))
+  if (GNUNET_SYSERR == GNUNET_DISK_fn_write (dump_hello,
+                                             my_hello,
+                                             size,
+                                             GNUNET_DISK_PERM_USER_READ |
+                                               GNUNET_DISK_PERM_USER_WRITE |
+                                               GNUNET_DISK_PERM_GROUP_READ |
+                                               GNUNET_DISK_PERM_OTHER_READ))
   {
-    FPRINTF (stderr,
-             _("Failed to write HELLO with %u bytes to file `%s'\n"),
+    fprintf (stderr,
+             _ ("Failed to write HELLO with %u bytes to file `%s'\n"),
              size,
              dump_hello);
-    if (0 != UNLINK (dump_hello))
+    if (0 != unlink (dump_hello))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
-                                GNUNET_ERROR_TYPE_BULK,
+                                  GNUNET_ERROR_TYPE_BULK,
                                 "unlink",
                                 dump_hello);
-
   }
   c_addr = 0;
-  GNUNET_HELLO_iterate_addresses (my_hello,
-                                  GNUNET_NO,
-                                  count_addr,
-                                  &c_addr);
+  GNUNET_HELLO_iterate_addresses (my_hello, GNUNET_NO, count_addr, &c_addr);
 
   if (! be_quiet)
   {
-    FPRINTF (stderr,
-             _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"),
-             (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only": "public",
-             c_addr,
-             size,
-             dump_hello);
+    fprintf (
+      stderr,
+      _ ("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"),
+      (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only"
+                                                             : "public",
+      c_addr,
+      size,
+      dump_hello);
   }
   GNUNET_free (dump_hello);
   dump_hello = NULL;
@@ -522,7 +503,7 @@ static void
 print_my_uri (void *cls,
               const struct GNUNET_PeerIdentity *peer,
               const struct GNUNET_HELLO_Message *hello,
-             const char *err_msg)
+              const char *err_msg)
 {
   char *uri;
 
@@ -530,21 +511,19 @@ print_my_uri (void *cls,
   {
     pic = NULL;
     if (NULL != err_msg)
-      FPRINTF (stderr,
-              _("Error in communication with PEERINFO service: %s\n"),
-              err_msg);
+      fprintf (stderr,
+               _ ("Error in communication with PEERINFO service: %s\n"),
+               err_msg);
     tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
     return;
   }
 
   if (NULL == hello)
     return;
-  uri = GNUNET_HELLO_compose_uri (hello,
-                                  &GPI_plugins_find);
+  uri = GNUNET_HELLO_compose_uri (hello, &GPI_plugins_find);
   if (NULL != uri)
   {
-    printf ("%s\n",
-            (const char *) uri);
+    printf ("%s\n", (const char *) uri);
     GNUNET_free (uri);
   }
 }
@@ -589,10 +568,7 @@ parse_hello_uri (const char *put_uri)
   {
     /* WARNING: this adds the address from URI WITHOUT verification! */
     if (GNUNET_OK == ret)
-      ac = GNUNET_PEERINFO_add_peer (peerinfo,
-                                     hello,
-                                     &add_continuation,
-                                     NULL);
+      ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL);
     else
       tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
     GNUNET_free (hello);
@@ -639,17 +615,15 @@ shutdown_task (void *cls)
   }
   while (NULL != (pc = pc_head))
   {
-    GNUNET_CONTAINER_DLL_remove (pc_head,
-                                pc_tail,
-                                pc);
-    for (i=0;i<pc->address_list_size;i++)
+    GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
+    for (i = 0; i < pc->address_list_size; i++)
     {
       ar = &pc->address_list[i];
       GNUNET_free_non_null (ar->result);
       if (NULL != ar->atsc)
       {
-       GNUNET_TRANSPORT_address_to_string_cancel (ar->atsc);
-       ar->atsc = NULL;
+        GNUNET_TRANSPORT_address_to_string_cancel (ar->atsc);
+        ar->atsc = NULL;
       }
     }
     GNUNET_free_non_null (pc->address_list);
@@ -677,20 +651,17 @@ shutdown_task (void *cls)
  * @param hello the HELLO message
  */
 static void
-hello_callback (void *cls,
-                const struct GNUNET_MessageHeader *hello)
+hello_callback (void *cls, const struct GNUNET_MessageHeader *hello)
 {
   if (NULL == hello)
   {
-    fprintf (stderr,
-             "Failed to get my own HELLO from this peer!\n");
+    fprintf (stderr, "Failed to get my own HELLO from this peer!\n");
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello);
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_HELLO_get_id (my_hello,
-                                      &my_peer_identity));
+                 GNUNET_HELLO_get_id (my_hello, &my_peer_identity));
   GNUNET_TRANSPORT_hello_get_cancel (gh);
   gh = NULL;
   if (NULL != dump_hello)
@@ -714,44 +685,35 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   cfg = c;
-  if ( (NULL != args[0]) &&
-       (NULL == put_uri) &&
-       (args[0] == strcasestr (args[0],
-                              "gnunet://hello/")) )
+  if ((NULL != args[0]) && (NULL == put_uri) &&
+      (args[0] == strcasestr (args[0], "gnunet://hello/")))
   {
     put_uri = GNUNET_strdup (args[0]);
     args++;
   }
   if (NULL != args[0])
   {
-    FPRINTF (stderr,
-            _("Invalid command line argument `%s'\n"),
-            args[0]);
+    fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
     return;
   }
   if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg)))
   {
-    FPRINTF (stderr,
-             "%s",
-             "Could not access PEERINFO service.  Exiting.\n");
+    fprintf (stderr, "%s", "Could not access PEERINFO service.  Exiting.\n");
     return;
   }
-  if ( (GNUNET_YES == get_self) ||
-       (GNUNET_YES == get_uri) ||
-       (NULL != dump_hello) )
+  if ((GNUNET_YES == get_self) || (GNUNET_YES == get_uri) ||
+      (NULL != dump_hello))
   {
     gh = GNUNET_TRANSPORT_hello_get (cfg,
-                                    GNUNET_TRANSPORT_AC_ANY,
+                                     GNUNET_TRANSPORT_AC_ANY,
                                      &hello_callback,
                                      NULL);
   }
   else
   {
-    tt = GNUNET_SCHEDULER_add_now (&state_machine,
-                                  NULL);
+    tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
   }
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
@@ -771,9 +733,7 @@ state_machine (void *cls)
     GPI_plugins_load (cfg);
     if (GNUNET_SYSERR == parse_hello_uri (put_uri))
     {
-      fprintf (stderr,
-              _("Invalid URI `%s'\n"),
-              put_uri);
+      fprintf (stderr, _ ("Invalid URI `%s'\n"), put_uri);
       GNUNET_SCHEDULER_shutdown ();
     }
     GNUNET_free (put_uri);
@@ -786,20 +746,17 @@ state_machine (void *cls)
     pic = GNUNET_PEERINFO_iterate (peerinfo,
                                    include_friend_only,
                                    NULL,
-                                  &print_peer_info,
-                                  NULL);
+                                   &print_peer_info,
+                                   NULL);
   }
   else if (GNUNET_YES == get_self)
   {
     get_self = GNUNET_NO;
     if (be_quiet)
-      printf ("%s\n",
-             GNUNET_i2s_full (&my_peer_identity));
+      printf ("%s\n", GNUNET_i2s_full (&my_peer_identity));
     else
-      printf (_("I am peer `%s'.\n"),
-             GNUNET_i2s_full (&my_peer_identity));
-    tt = GNUNET_SCHEDULER_add_now (&state_machine,
-                                  NULL);
+      printf (_ ("I am peer `%s'.\n"), GNUNET_i2s_full (&my_peer_identity));
+    tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
   }
   else if (GNUNET_YES == get_uri)
   {
@@ -808,7 +765,7 @@ state_machine (void *cls)
                                    include_friend_only,
                                    &my_peer_identity,
                                    &print_my_uri,
-                                  NULL);
+                                   NULL);
     get_uri = GNUNET_NO;
   }
   else if (GNUNET_YES == default_operation)
@@ -816,8 +773,7 @@ state_machine (void *cls)
     /* default operation list all */
     default_operation = GNUNET_NO;
     get_info = GNUNET_YES;
-    tt = GNUNET_SCHEDULER_add_now (&state_machine,
-                                  NULL);
+    tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
   }
   else
   {
@@ -837,68 +793,69 @@ state_machine (void *cls)
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('n',
-                                  "numeric",
-                                  gettext_noop ("don't resolve host names"),
-                                  &no_resolve),
-
-    GNUNET_GETOPT_option_flag ('q',
-                                  "quiet",
-                                  gettext_noop ("output only the identity strings"),
-                                  &be_quiet),
-    GNUNET_GETOPT_option_flag ('f',
-                                  "friends",
-                                  gettext_noop ("include friend-only information"),
-                                  &include_friend_only),
-
-    GNUNET_GETOPT_option_flag ('s',
-                                  "self",
-                                  gettext_noop ("output our own identity only"),
-                                  &get_self),
-    
-    GNUNET_GETOPT_option_flag ('i',
-                                  "info",
-                                  gettext_noop ("list all known peers"),
-                                  &get_info),
-
-    GNUNET_GETOPT_option_string ('d',
-                                 "dump-hello",
-                                 NULL,
-                                 gettext_noop ("dump hello to file"),
-                                 &dump_hello),
-
-    GNUNET_GETOPT_option_flag ('g',
-                                  "get-hello",
-                                  gettext_noop ("also output HELLO uri(s)"),
-                                  &get_uri),
-
-    GNUNET_GETOPT_option_string ('p',
-                                 "put-hello",
-                                 "HELLO",
-                                 gettext_noop ("add given HELLO uri to the database"),
-                                 &put_uri),
-
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('n',
+                                "numeric",
+                                gettext_noop ("don't resolve host names"),
+                                &no_resolve),
+
+     GNUNET_GETOPT_option_flag ('q',
+                                "quiet",
+                                gettext_noop (
+                                  "output only the identity strings"),
+                                &be_quiet),
+     GNUNET_GETOPT_option_flag ('f',
+                                "friends",
+                                gettext_noop (
+                                  "include friend-only information"),
+                                &include_friend_only),
+
+     GNUNET_GETOPT_option_flag ('s',
+                                "self",
+                                gettext_noop ("output our own identity only"),
+                                &get_self),
+
+     GNUNET_GETOPT_option_flag ('i',
+                                "info",
+                                gettext_noop ("list all known peers"),
+                                &get_info),
+
+     GNUNET_GETOPT_option_string ('d',
+                                  "dump-hello",
+                                  NULL,
+                                  gettext_noop ("dump hello to file"),
+                                  &dump_hello),
+
+     GNUNET_GETOPT_option_flag ('g',
+                                "get-hello",
+                                gettext_noop ("also output HELLO uri(s)"),
+                                &get_uri),
+
+     GNUNET_GETOPT_option_string ('p',
+                                  "put-hello",
+                                  "HELLO",
+                                  gettext_noop (
+                                    "add given HELLO uri to the database"),
+                                  &put_uri),
+
+     GNUNET_GETOPT_OPTION_END};
   int ret;
 
   default_operation = GNUNET_YES;
-  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc,
-                                                 argv,
-                                                 &argc,
-                                                &argv))
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc,
-                            argv,
-                            "gnunet-peerinfo",
-                            gettext_noop ("Print information about peers."),
-                            options,
-                            &run,
-                            NULL)) ? 0 : 1;
-  GNUNET_free ((void*) argv);
+         GNUNET_PROGRAM_run (argc,
+                             argv,
+                             "gnunet-peerinfo",
+                             gettext_noop ("Print information about peers."),
+                             options,
+                             &run,
+                             NULL))
+          ? 0
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 61fdd0f2403e0bdb5c23757260e7b56a14dfa0f0..a884c5b760a9a42bd26feaafd6c0e3a1b7b07338 100644 (file)
 /**
  * How often do we scan the HOST_DIR for new entries?
  */
-#define DATA_HOST_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
+#define DATA_HOST_FREQ \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 
 /**
  * How often do we discard old entries in data/hosts/?
  */
-#define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60)
+#define DATA_HOST_CLEAN_FREQ \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60)
 
 
 /**
@@ -66,7 +68,6 @@ struct HostEntry
    * Friend only hello for the peer (can be NULL)
    */
   struct GNUNET_HELLO_Message *friend_only_hello;
-
 };
 
 
@@ -134,8 +135,7 @@ static struct GNUNET_SCHEDULER_Task *cron_scan;
  * @return generated notification message
  */
 static struct InfoMessage *
-make_info_message (const struct HostEntry *he,
-                   int include_friend_only)
+make_info_message (const struct HostEntry *he, int include_friend_only)
 {
   struct InfoMessage *im;
   struct GNUNET_HELLO_Message *src;
@@ -150,9 +150,7 @@ make_info_message (const struct HostEntry *he,
   im->header.size = htons (hs + sizeof (struct InfoMessage));
   im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
   im->peer = he->identity;
-  GNUNET_memcpy (&im[1],
-                 src,
-                 hs);
+  GNUNET_memcpy (&im[1], src, hs);
   return im;
 }
 
@@ -175,7 +173,7 @@ discard_expired (void *cls,
   if (now->abs_value_us > expiration.abs_value_us)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Removing expired address of transport `%s'\n"),
+                _ ("Removing expired address of transport `%s'\n"),
                 address->transport_name);
     return GNUNET_NO;
   }
@@ -241,16 +239,14 @@ notify_all (struct HostEntry *entry)
   struct InfoMessage *msg_friend;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Notifying all clients about peer `%s'\n",
-             GNUNET_i2s(&entry->identity));
-  msg_pub = make_info_message (entry,
-                               GNUNET_NO);
+              "Notifying all clients about peer `%s'\n",
+              GNUNET_i2s (&entry->identity));
+  msg_pub = make_info_message (entry, GNUNET_NO);
   GNUNET_notification_context_broadcast (notify_list,
                                          &msg_pub->header,
                                          GNUNET_NO);
   GNUNET_free (msg_pub);
-  msg_friend = make_info_message (entry,
-                                  GNUNET_YES);
+  msg_friend = make_info_message (entry, GNUNET_YES);
   GNUNET_notification_context_broadcast (notify_friend_only_list,
                                          &msg_friend->header,
                                          GNUNET_NO);
@@ -299,26 +295,21 @@ read_host_file (const char *fn,
 
   if (GNUNET_YES != GNUNET_DISK_file_test (fn))
     return;
-  size_total = GNUNET_DISK_fn_read (fn,
-                                    buffer,
-                                    sizeof (buffer));
+  size_total = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Read %d bytes from `%s'\n",
               (int) size_total,
               fn);
-  if ( (size_total < 0) ||
-       (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader)) )
+  if ((size_total < 0) ||
+      (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Failed to parse HELLO in file `%s': %s\n"),
-               fn,
+                _ ("Failed to parse HELLO in file `%s': %s\n"),
+                fn,
                 "File has invalid size");
-    if ( (GNUNET_YES == unlink_garbage) &&
-        (0 != UNLINK (fn)) &&
-        (ENOENT != errno) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                "unlink",
-                                fn);
+    if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) &&
+        (ENOENT != errno))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
     return;
   }
 
@@ -327,29 +318,22 @@ read_host_file (const char *fn,
   {
     hello = (const struct GNUNET_HELLO_Message *) &buffer[read_pos];
     size_hello = GNUNET_HELLO_size (hello);
-    if ( (0 == size_hello) ||
-         (((size_t) size_total) - read_pos < size_hello) )
+    if ((0 == size_hello) || (((size_t) size_total) - read_pos < size_hello))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Failed to parse HELLO in file `%s'\n"),
+                  _ ("Failed to parse HELLO in file `%s'\n"),
                   fn);
       if (0 == read_pos)
       {
-        if ((GNUNET_YES == unlink_garbage) &&
-            (0 != UNLINK (fn)) &&
-            (ENOENT != errno) )
-          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                    "unlink",
-                                    fn);
+        if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) &&
+            (ENOENT != errno))
+          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
       }
       else
       {
-        if ( (GNUNET_YES == unlink_garbage) &&
-             (0 != TRUNCATE (fn, read_pos)) &&
-             (ENOENT != errno) )
-          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                    "truncate",
-                                    fn);
+        if ((GNUNET_YES == unlink_garbage) && (0 != truncate (fn, read_pos)) &&
+            (ENOENT != errno))
+          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate", fn);
       }
       return;
     }
@@ -357,25 +341,22 @@ read_host_file (const char *fn,
     now = GNUNET_TIME_absolute_get ();
     hello_clean = GNUNET_HELLO_iterate_addresses (hello,
                                                   GNUNET_YES,
-                                                 &discard_expired,
+                                                  &discard_expired,
                                                   &now);
     if (NULL == hello_clean)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Failed to parse HELLO in file `%s'\n"),
+                  _ ("Failed to parse HELLO in file `%s'\n"),
                   fn);
-      if ((GNUNET_YES == unlink_garbage) &&
-          (0 != UNLINK (fn)) &&
-          (ENOENT != errno) )
-        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                  "unlink",
-                                  fn);
+      if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) &&
+          (ENOENT != errno))
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
       return;
     }
     left = 0;
     (void) GNUNET_HELLO_iterate_addresses (hello_clean,
                                            GNUNET_NO,
-                                          &count_addresses,
+                                           &count_addresses,
                                            &left);
 
     if (0 == left)
@@ -387,23 +368,23 @@ read_host_file (const char *fn,
     if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello_clean))
     {
       if (NULL == r->hello)
-       r->hello = hello_clean;
+        r->hello = hello_clean;
       else
       {
-       GNUNET_break (0);
-       GNUNET_free (r->hello);
-       r->hello = hello_clean;
+        GNUNET_break (0);
+        GNUNET_free (r->hello);
+        r->hello = hello_clean;
       }
     }
     else
     {
       if (NULL == r->friend_only_hello)
-       r->friend_only_hello = hello_clean;
+        r->friend_only_hello = hello_clean;
       else
       {
-       GNUNET_break (0);
-       GNUNET_free (r->friend_only_hello);
-       r->friend_only_hello = hello_clean;
+        GNUNET_break (0);
+        GNUNET_free (r->friend_only_hello);
+        r->friend_only_hello = hello_clean;
       }
     }
     read_pos += size_hello;
@@ -412,16 +393,14 @@ read_host_file (const char *fn,
   if (0 == left)
   {
     /* no addresses left, remove from disk */
-    if ( (GNUNET_YES == unlink_garbage) &&
-         (0 != UNLINK (fn)) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                "unlink",
-                                fn);
+    if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Found `%s' and `%s' HELLO message in file\n",
-             (NULL != r->hello) ? "public" : "NON-public",
-             (NULL != r->friend_only_hello) ? "friend only" : "NO friend only");
+              "Found `%s' and `%s' HELLO message in file\n",
+              (NULL != r->hello) ? "public" : "NON-public",
+              (NULL != r->friend_only_hello) ? "friend only"
+                                             : "NO friend only");
 }
 
 
@@ -438,8 +417,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
   struct ReadHostFileContext r;
   char *fn;
 
-  entry = GNUNET_CONTAINER_multipeermap_get (hostmap,
-                                             identity);
+  entry = GNUNET_CONTAINER_multipeermap_get (hostmap, identity);
   if (NULL == entry)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -448,27 +426,24 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
     GNUNET_STATISTICS_update (stats,
                               gettext_noop ("# peers known"),
                               1,
-                             GNUNET_NO);
+                              GNUNET_NO);
     entry = GNUNET_new (struct HostEntry);
     entry->identity = *identity;
     GNUNET_assert (GNUNET_OK ==
-                   GNUNET_CONTAINER_multipeermap_put (hostmap,
-                                                      &entry->identity,
-                                                      entry,
-                                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                   GNUNET_CONTAINER_multipeermap_put (
+                     hostmap,
+                     &entry->identity,
+                     entry,
+                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
     notify_all (entry);
     fn = get_host_filename (identity);
     if (NULL != fn)
     {
-      read_host_file (fn,
-                      GNUNET_YES,
-                      &r);
+      read_host_file (fn, GNUNET_YES, &r);
       if (NULL != r.hello)
-       update_hello (identity,
-                      r.hello);
+        update_hello (identity, r.hello);
       if (NULL != r.friend_only_hello)
-       update_hello (identity,
-                      r.friend_only_hello);
+        update_hello (identity, r.friend_only_hello);
       GNUNET_free_non_null (r.hello);
       GNUNET_free_non_null (r.friend_only_hello);
       GNUNET_free (fn);
@@ -487,11 +462,13 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
 static void
 remove_garbage (const char *fullname)
 {
-  if (0 == UNLINK (fullname))
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-                _("File `%s' in directory `%s' does not match naming convention. Removed.\n"),
-                fullname,
-                networkIdDirectory);
+  if (0 == unlink (fullname))
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
+      _ (
+        "File `%s' in directory `%s' does not match naming convention. Removed.\n"),
+      fullname,
+      networkIdDirectory);
   else
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                               "unlink",
@@ -529,8 +506,7 @@ struct DirScanContext
  * @return #GNUNET_OK (continue iteration)
  */
 static int
-hosts_directory_scan_callback (void *cls,
-                               const char *fullname)
+hosts_directory_scan_callback (void *cls, const char *fullname)
 {
   struct DirScanContext *dsc = cls;
   struct GNUNET_PeerIdentity identity;
@@ -541,51 +517,40 @@ hosts_directory_scan_callback (void *cls,
   struct GNUNET_PeerIdentity id;
 
   if (GNUNET_YES != GNUNET_DISK_file_test (fullname))
-    return GNUNET_OK;           /* ignore non-files */
+    return GNUNET_OK; /* ignore non-files */
 
-  filename = strrchr (fullname,
-                      DIR_SEPARATOR);
-  if ( (NULL == filename) ||
-       (1 > strlen (filename)) )
+  filename = strrchr (fullname, DIR_SEPARATOR);
+  if ((NULL == filename) || (1 > strlen (filename)))
     filename = fullname;
   else
-    filename ++;
+    filename++;
 
-  read_host_file (fullname,
-                  dsc->remove_files,
-                  &r);
-  if ( (NULL == r.hello) &&
-       (NULL == r.friend_only_hello))
+  read_host_file (fullname, dsc->remove_files, &r);
+  if ((NULL == r.hello) && (NULL == r.friend_only_hello))
     return GNUNET_OK;
   if (NULL != r.friend_only_hello)
   {
-    if (GNUNET_OK !=
-        GNUNET_HELLO_get_id (r.friend_only_hello,
-                             &id_friend))
+    if (GNUNET_OK != GNUNET_HELLO_get_id (r.friend_only_hello, &id_friend))
     {
       if (GNUNET_YES == dsc->remove_files)
-       remove_garbage (fullname);
+        remove_garbage (fullname);
       return GNUNET_OK;
     }
     id = id_friend;
   }
   if (NULL != r.hello)
   {
-    if (GNUNET_OK !=
-        GNUNET_HELLO_get_id (r.hello,
-                             &id_public))
+    if (GNUNET_OK != GNUNET_HELLO_get_id (r.hello, &id_public))
     {
       if (GNUNET_YES == dsc->remove_files)
-       remove_garbage (fullname);
+        remove_garbage (fullname);
       return GNUNET_OK;
     }
     id = id_public;
   }
 
-  if (  (NULL != r.hello) &&
-        (NULL != r.friend_only_hello) &&
-        (0 != GNUNET_memcmp (&id_friend,
-                      &id_public)) )
+  if ((NULL != r.hello) && (NULL != r.friend_only_hello) &&
+      (0 != GNUNET_memcmp (&id_friend, &id_public)))
   {
     /* HELLOs are not for the same peer */
     GNUNET_break (0);
@@ -603,7 +568,7 @@ hosts_directory_scan_callback (void *cls,
       /* HELLOs are not for the same peer */
       GNUNET_break (0);
       if (GNUNET_YES == dsc->remove_files)
-       remove_garbage (fullname);
+        remove_garbage (fullname);
       return GNUNET_OK;
     }
   }
@@ -614,7 +579,7 @@ hosts_directory_scan_callback (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Updating peer `%s' public HELLO \n",
-               GNUNET_i2s (&id));
+                GNUNET_i2s (&id));
     update_hello (&id, r.hello);
     GNUNET_free (r.hello);
   }
@@ -622,7 +587,7 @@ hosts_directory_scan_callback (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Updating peer `%s' friend only HELLO \n",
-               GNUNET_i2s (&id));
+                GNUNET_i2s (&id));
     update_hello (&id, r.friend_only_hello);
     GNUNET_free (r.friend_only_hello);
   }
@@ -644,31 +609,32 @@ cron_scan_directory_data_hosts (void *cls)
 
   (void) cls;
   cron_scan = NULL;
-  if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_create (networkIdDirectory))
+  if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory))
   {
-    cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
-                                                           GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                           &cron_scan_directory_data_hosts, NULL);
+    cron_scan =
+      GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
+                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                  &cron_scan_directory_data_hosts,
+                                                  NULL);
     return;
   }
   dsc.matched = 0;
   dsc.remove_files = GNUNET_YES;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
-              _("Scanning directory `%s'\n"),
+              _ ("Scanning directory `%s'\n"),
               networkIdDirectory);
   GNUNET_DISK_directory_scan (networkIdDirectory,
                               &hosts_directory_scan_callback,
                               &dsc);
-  if ( (0 == dsc.matched) &&
-       (0 == (++retries & 31)) )
+  if ((0 == dsc.matched) && (0 == (++retries & 31)))
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-                _("Still no peers found in `%s'!\n"),
+                _ ("Still no peers found in `%s'!\n"),
                 networkIdDirectory);
-  cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
-                                                         GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                         &cron_scan_directory_data_hosts,
-                                                         NULL);
+  cron_scan =
+    GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
+                                                GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                &cron_scan_directory_data_hosts,
+                                                NULL);
 }
 
 
@@ -681,31 +647,25 @@ cron_scan_directory_data_hosts (void *cls)
  */
 static struct GNUNET_HELLO_Message *
 update_friend_hello (const struct GNUNET_HELLO_Message *hello,
-                    const struct GNUNET_HELLO_Message *friend_hello)
+                     const struct GNUNET_HELLO_Message *friend_hello)
 {
-  struct GNUNET_HELLO_Message * res;
-  struct GNUNET_HELLO_Message * tmp;
+  struct GNUNET_HELLO_Message *res;
+  struct GNUNET_HELLO_Message *tmp;
   struct GNUNET_PeerIdentity pid;
 
   if (NULL != friend_hello)
   {
-    res = GNUNET_HELLO_merge (hello,
-                              friend_hello);
-    GNUNET_assert (GNUNET_YES ==
-                   GNUNET_HELLO_is_friend_only (res));
+    res = GNUNET_HELLO_merge (hello, friend_hello);
+    GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res));
     return res;
   }
 
-  if (GNUNET_OK !=
-      GNUNET_HELLO_get_id (hello, &pid))
+  if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
   {
     GNUNET_break (0);
     return NULL;
   }
-  tmp = GNUNET_HELLO_create (&pid.public_key,
-                             NULL,
-                             NULL,
-                             GNUNET_YES);
+  tmp = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, GNUNET_YES);
   res = GNUNET_HELLO_merge (hello, tmp);
   GNUNET_free (tmp);
   GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res));
@@ -762,11 +722,8 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
   }
   else
   {
-    mrg = GNUNET_HELLO_merge ((*dest),
-                              hello);
-    delta = GNUNET_HELLO_equals (mrg,
-                                 (*dest),
-                                 GNUNET_TIME_absolute_get ());
+    mrg = GNUNET_HELLO_merge ((*dest), hello);
+    delta = GNUNET_HELLO_equals (mrg, (*dest), GNUNET_TIME_absolute_get ());
     if (delta.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
     {
       /* no differences, just ignore the update */
@@ -781,35 +738,30 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
     (*dest) = mrg;
   }
 
-  if ( (NULL != (host->hello)) &&
-       (GNUNET_NO == friend_hello_type) )
+  if ((NULL != (host->hello)) && (GNUNET_NO == friend_hello_type))
   {
     /* Update friend only hello */
-    mrg = update_friend_hello (host->hello,
-                               host->friend_only_hello);
+    mrg = update_friend_hello (host->hello, host->friend_only_hello);
     if (NULL != host->friend_only_hello)
       GNUNET_free (host->friend_only_hello);
     host->friend_only_hello = mrg;
   }
 
   if (NULL != host->hello)
-    GNUNET_assert ((GNUNET_NO ==
-                    GNUNET_HELLO_is_friend_only (host->hello)));
+    GNUNET_assert ((GNUNET_NO == GNUNET_HELLO_is_friend_only (host->hello)));
   if (NULL != host->friend_only_hello)
-    GNUNET_assert ((GNUNET_YES ==
-                    GNUNET_HELLO_is_friend_only (host->friend_only_hello)));
+    GNUNET_assert (
+      (GNUNET_YES == GNUNET_HELLO_is_friend_only (host->friend_only_hello)));
 
   fn = get_host_filename (peer);
-  if ( (NULL != fn) &&
-       (GNUNET_OK ==
-        GNUNET_DISK_directory_create_for_file (fn)) )
+  if ((NULL != fn) && (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)))
   {
     store_hello = GNUNET_NO;
     size = 0;
     cnt = 0;
     if (NULL != host->hello)
       (void) GNUNET_HELLO_iterate_addresses (host->hello,
-                                            GNUNET_NO,
+                                             GNUNET_NO,
                                              &count_addresses,
                                              &cnt);
     if (cnt > 0)
@@ -821,7 +773,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
     if (NULL != host->friend_only_hello)
       (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello,
                                              GNUNET_NO,
-                                            &count_addresses,
+                                             &count_addresses,
                                              &cnt);
     store_friend_hello = GNUNET_NO;
     if (0 < cnt)
@@ -830,12 +782,11 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
       size += GNUNET_HELLO_size (host->friend_only_hello);
     }
 
-    if ( (GNUNET_NO == store_hello) &&
-         (GNUNET_NO == store_friend_hello) )
+    if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello))
     {
       /* no valid addresses, don't put HELLO on disk; in fact,
         if one exists on disk, remove it */
-      (void) UNLINK (fn);
+      (void) unlink (fn);
     }
     else
     {
@@ -844,32 +795,32 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
 
       if (GNUNET_YES == store_hello)
       {
-       GNUNET_memcpy (buffer,
-                       host->hello,
-                       GNUNET_HELLO_size (host->hello));
-       pos += GNUNET_HELLO_size (host->hello);
+        GNUNET_memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello));
+        pos += GNUNET_HELLO_size (host->hello);
       }
       if (GNUNET_YES == store_friend_hello)
       {
-       GNUNET_memcpy (&buffer[pos],
-                      host->friend_only_hello,
-                      GNUNET_HELLO_size (host->friend_only_hello));
-       pos += GNUNET_HELLO_size (host->friend_only_hello);
+        GNUNET_memcpy (&buffer[pos],
+                       host->friend_only_hello,
+                       GNUNET_HELLO_size (host->friend_only_hello));
+        pos += GNUNET_HELLO_size (host->friend_only_hello);
       }
       GNUNET_assert (pos == size);
 
-      if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size,
-                                                GNUNET_DISK_PERM_USER_READ |
-                                                GNUNET_DISK_PERM_USER_WRITE |
-                                                GNUNET_DISK_PERM_GROUP_READ |
-                                                GNUNET_DISK_PERM_OTHER_READ))
-       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
+      if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn,
+                                                 buffer,
+                                                 size,
+                                                 GNUNET_DISK_PERM_USER_READ |
+                                                   GNUNET_DISK_PERM_USER_WRITE |
+                                                   GNUNET_DISK_PERM_GROUP_READ |
+                                                   GNUNET_DISK_PERM_OTHER_READ))
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
       else
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Stored %s %s HELLO in %s  with total size %u\n",
-                   (GNUNET_YES == store_friend_hello) ? "friend-only": "",
-                   (GNUNET_YES == store_hello) ? "public": "",
-                   fn,
+                    (GNUNET_YES == store_friend_hello) ? "friend-only" : "",
+                    (GNUNET_YES == store_hello) ? "public" : "",
+                    fn,
                     size);
       GNUNET_free (buffer);
     }
@@ -905,9 +856,7 @@ struct TransmitContext
  * @return #GNUNET_YES (continue to iterate)
  */
 static int
-add_to_tc (void *cls,
-           const struct GNUNET_PeerIdentity *key,
-           void *value)
+add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 {
   struct TransmitContext *tc = cls;
   struct HostEntry *pos = value;
@@ -917,53 +866,39 @@ add_to_tc (void *cls,
 
   hs = 0;
 
-  if ( (NULL != pos->hello) &&
-       (GNUNET_NO == tc->friend_only) )
+  if ((NULL != pos->hello) && (GNUNET_NO == tc->friend_only))
   {
-       /* Copy public HELLO */
+    /* Copy public HELLO */
     hs = GNUNET_HELLO_size (pos->hello);
-    GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE -
-                   sizeof (struct InfoMessage));
-    env = GNUNET_MQ_msg_extra (im,
-                               hs,
-                               GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
-    GNUNET_memcpy (&im[1],
-                   pos->hello,
-                   hs);
+    GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - sizeof (struct InfoMessage));
+    env = GNUNET_MQ_msg_extra (im, hs, GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
+    GNUNET_memcpy (&im[1], pos->hello, hs);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Sending public HELLO with size %u for peer `%s'\n",
-               hs,
+                hs,
                 GNUNET_i2s (key));
   }
-  else if ( (NULL != pos->friend_only_hello) &&
-            (GNUNET_YES == tc->friend_only) )
+  else if ((NULL != pos->friend_only_hello) && (GNUNET_YES == tc->friend_only))
   {
-       /* Copy friend only HELLO */
+    /* Copy friend only HELLO */
     hs = GNUNET_HELLO_size (pos->friend_only_hello);
-    GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE -
-                   sizeof (struct InfoMessage));
-    env = GNUNET_MQ_msg_extra (im,
-                               hs,
-                               GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
-    GNUNET_memcpy (&im[1],
-                   pos->friend_only_hello,
-                   hs);
+    GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - sizeof (struct InfoMessage));
+    env = GNUNET_MQ_msg_extra (im, hs, GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
+    GNUNET_memcpy (&im[1], pos->friend_only_hello, hs);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Sending friend-only HELLO with size %u for peer `%s'\n",
-               hs,
+                hs,
                 GNUNET_i2s (key));
   }
   else
   {
-    env = GNUNET_MQ_msg (im,
-                         GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
+    env = GNUNET_MQ_msg (im, GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Adding no HELLO for peer `%s'\n",
                 GNUNET_i2s (key));
   }
   im->peer = pos->identity;
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (tc->client),
-                  env);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (tc->client), env);
   return GNUNET_YES;
 }
 
@@ -976,8 +911,7 @@ add_to_tc (void *cls,
  * @return #GNUNET_OK (continue iteration)
  */
 static int
-discard_hosts_helper (void *cls,
-                      const char *fn)
+discard_hosts_helper (void *cls, const char *fn)
 {
   struct GNUNET_TIME_Absolute *now = cls;
   char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
@@ -991,31 +925,25 @@ discard_hosts_helper (void *cls,
   unsigned int cnt;
   char *writebuffer;
   uint64_t fsize;
-  
-  if (GNUNET_OK !=
-      GNUNET_DISK_file_size (fn,
-                            &fsize,
-                            GNUNET_YES,
-                            GNUNET_YES))
+
+  if (GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_YES, GNUNET_YES))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
-                             GNUNET_ERROR_TYPE_BULK,
-                             "fstat",
-                             fn);
+                                GNUNET_ERROR_TYPE_BULK,
+                              "fstat",
+                              fn);
     return GNUNET_OK;
   }
-  read_size = GNUNET_DISK_fn_read (fn,
-                                  buffer,
-                                  sizeof (buffer));
+  read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
 
-  if ( (read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
-       (fsize > GNUNET_MAX_MESSAGE_SIZE) )
+  if ((read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
+      (fsize > GNUNET_MAX_MESSAGE_SIZE))
   {
-    if (0 != UNLINK (fn))
+    if (0 != unlink (fn))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
-                                GNUNET_ERROR_TYPE_BULK,
-                               "unlink",
-                               fn);
+                                  GNUNET_ERROR_TYPE_BULK,
+                                "unlink",
+                                fn);
     return GNUNET_OK;
   }
 
@@ -1030,31 +958,27 @@ discard_hosts_helper (void *cls,
     if (0 == cur_hello_size)
     {
       /* Invalid data, discard */
-      if (0 != UNLINK (fn))
-       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
-                                 GNUNET_ERROR_TYPE_BULK,
+      if (0 != unlink (fn))
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
+                                    GNUNET_ERROR_TYPE_BULK,
                                   "unlink",
                                   fn);
       GNUNET_free (writebuffer);
       return GNUNET_OK;
     }
-    new_hello = GNUNET_HELLO_iterate_addresses (hello,
-                                                GNUNET_YES,
-                                                &discard_expired,
-                                                now);
+    new_hello =
+      GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, now);
     cnt = 0;
     if (NULL != new_hello)
       (void) GNUNET_HELLO_iterate_addresses (hello,
                                              GNUNET_NO,
                                              &count_addresses,
                                              &cnt);
-    if ( (NULL != new_hello) && (0 < cnt) )
+    if ((NULL != new_hello) && (0 < cnt))
     {
       /* Store new HELLO to write it when done */
       new_hello_size = GNUNET_HELLO_size (new_hello);
-      GNUNET_memcpy (&writebuffer[write_pos],
-                     new_hello,
-                     new_hello_size);
+      GNUNET_memcpy (&writebuffer[write_pos], new_hello, new_hello_size);
       write_pos += new_hello_size;
     }
     read_pos += cur_hello_size;
@@ -1067,14 +991,15 @@ discard_hosts_helper (void *cls,
                           writebuffer,
                           write_pos,
                           GNUNET_DISK_PERM_USER_READ |
-                          GNUNET_DISK_PERM_USER_WRITE |
-                          GNUNET_DISK_PERM_GROUP_READ |
-                          GNUNET_DISK_PERM_OTHER_READ);
+                            GNUNET_DISK_PERM_USER_WRITE |
+                            GNUNET_DISK_PERM_GROUP_READ |
+                            GNUNET_DISK_PERM_OTHER_READ);
   }
-  else if (0 != UNLINK (fn))
+  else if (0 != unlink (fn))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
-                              GNUNET_ERROR_TYPE_BULK,
-                              "unlink", fn);
+                                GNUNET_ERROR_TYPE_BULK,
+                              "unlink",
+                              fn);
 
   GNUNET_free (writebuffer);
   return GNUNET_OK;
@@ -1096,14 +1021,12 @@ cron_clean_data_hosts (void *cls)
   cron_clean = NULL;
   now = GNUNET_TIME_absolute_get ();
   GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
-              _("Cleaning up directory `%s'\n"),
+              _ ("Cleaning up directory `%s'\n"),
               networkIdDirectory);
-  GNUNET_DISK_directory_scan (networkIdDirectory,
-                              &discard_hosts_helper,
-                              &now);
+  GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now);
   cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
-                                            &cron_clean_data_hosts,
-                                            NULL);
+                                             &cron_clean_data_hosts,
+                                             NULL);
 }
 
 
@@ -1115,15 +1038,12 @@ cron_clean_data_hosts (void *cls)
  * @return #GNUNET_OK if @a hello is well-formed
  */
 static int
-check_hello (void *cls,
-             const struct GNUNET_HELLO_Message *hello)
+check_hello (void *cls, const struct GNUNET_HELLO_Message *hello)
 {
   struct GNUNET_PeerIdentity pid;
 
   (void) cls;
-  if (GNUNET_OK !=
-      GNUNET_HELLO_get_id (hello,
-                           &pid))
+  if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1139,21 +1059,17 @@ check_hello (void *cls,
  * @param hello the actual message
  */
 static void
-handle_hello (void *cls,
-              const struct GNUNET_HELLO_Message *hello)
+handle_hello (void *cls, const struct GNUNET_HELLO_Message *hello)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_PeerIdentity pid;
 
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_HELLO_get_id (hello,
-                                      &pid));
+  GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &pid));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "HELLO message received for peer `%s'\n",
               GNUNET_i2s (&pid));
   add_host_to_known_hosts (&pid);
-  update_hello (&pid,
-                hello);
+  update_hello (&pid, hello);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1165,8 +1081,7 @@ handle_hello (void *cls,
  * @param lpm the actual message
  */
 static void
-handle_get (void *cls,
-            const struct ListPeerMessage *lpm)
+handle_get (void *cls, const struct ListPeerMessage *lpm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct TransmitContext tcx;
@@ -1182,10 +1097,8 @@ handle_get (void *cls,
                                               &lpm->peer,
                                               &add_to_tc,
                                               &tcx);
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1197,25 +1110,19 @@ handle_get (void *cls,
  * @param lapm the actual message
  */
 static void
-handle_get_all (void *cls,
-                const struct ListAllPeersMessage *lapm)
+handle_get_all (void *cls, const struct ListAllPeersMessage *lapm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct TransmitContext tcx;
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_MessageHeader *msg;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "GET_ALL message received\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GET_ALL message received\n");
   tcx.friend_only = ntohl (lapm->include_friend_only);
   tcx.client = client;
-  GNUNET_CONTAINER_multipeermap_iterate (hostmap,
-                                         &add_to_tc,
-                                         &tcx);
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_CONTAINER_multipeermap_iterate (hostmap, &add_to_tc, &tcx);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1227,8 +1134,7 @@ handle_get_all (void *cls,
  * @param nm the actual message
  */
 static void
-handle_notify (void *cls,
-               const struct NotifyMessage *nm)
+handle_notify (void *cls, const struct NotifyMessage *nm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_MQ_Handle *mq;
@@ -1236,25 +1142,18 @@ handle_notify (void *cls,
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_MessageHeader *msg;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "NOTIFY message received\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "NOTIFY message received\n");
   mq = GNUNET_SERVICE_client_get_mq (client);
   GNUNET_SERVICE_client_mark_monitor (client);
   if (ntohl (nm->include_friend_only))
-    GNUNET_notification_context_add (notify_friend_only_list,
-                                     mq);
+    GNUNET_notification_context_add (notify_friend_only_list, mq);
   else
-    GNUNET_notification_context_add (notify_list,
-                                     mq);
+    GNUNET_notification_context_add (notify_list, mq);
   tcx.friend_only = ntohl (nm->include_friend_only);
   tcx.client = client;
-  GNUNET_CONTAINER_multipeermap_iterate (hostmap,
-                                         &add_to_tc,
-                                         &tcx);
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
-  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
-                  env);
+  GNUNET_CONTAINER_multipeermap_iterate (hostmap, &add_to_tc, &tcx);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
+  GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -1304,9 +1203,7 @@ client_disconnect_cb (void *cls,
  * @return #GNUNET_YES (continue to iterate)
  */
 static int
-free_host_entry (void *cls,
-                 const struct GNUNET_PeerIdentity *key,
-                 void *value)
+free_host_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 {
   struct HostEntry *he = value;
 
@@ -1333,14 +1230,11 @@ shutdown_task (void *cls)
   GNUNET_notification_context_destroy (notify_friend_only_list);
   notify_friend_only_list = NULL;
 
-  GNUNET_CONTAINER_multipeermap_iterate (hostmap,
-                                         &free_host_entry,
-                                         NULL);
+  GNUNET_CONTAINER_multipeermap_iterate (hostmap, &free_host_entry, NULL);
   GNUNET_CONTAINER_multipeermap_destroy (hostmap);
   if (NULL != stats)
   {
-    GNUNET_STATISTICS_destroy (stats,
-                               GNUNET_NO);
+    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
     stats = NULL;
   }
   if (NULL != cron_clean)
@@ -1381,60 +1275,48 @@ run (void *cls,
 
   (void) cls;
   (void) service;
-  hostmap
-    = GNUNET_CONTAINER_multipeermap_create (1024,
-                                            GNUNET_YES);
-  stats
-    = GNUNET_STATISTICS_create ("peerinfo",
-                                cfg);
-  notify_list
-    = GNUNET_notification_context_create (0);
-  notify_friend_only_list
-    = GNUNET_notification_context_create (0);
-  noio = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                               "peerinfo",
-                                               "NO_IO");
-  use_included
-    = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                            "peerinfo",
-                                            "USE_INCLUDED_HELLOS");
+  hostmap = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
+  stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
+  notify_list = GNUNET_notification_context_create (0);
+  notify_friend_only_list = GNUNET_notification_context_create (0);
+  noio = GNUNET_CONFIGURATION_get_value_yesno (cfg, "peerinfo", "NO_IO");
+  use_included = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                       "peerinfo",
+                                                       "USE_INCLUDED_HELLOS");
   if (GNUNET_SYSERR == use_included)
     use_included = GNUNET_NO;
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
   if (GNUNET_YES != noio)
   {
-    GNUNET_assert (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                            "peerinfo",
-                                                           "HOSTS",
-                                                           &networkIdDirectory));
-    if (GNUNET_OK !=
-       GNUNET_DISK_directory_create (networkIdDirectory))
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                               "peerinfo",
+                                               "HOSTS",
+                                               &networkIdDirectory));
+    if (GNUNET_OK != GNUNET_DISK_directory_create (networkIdDirectory))
     {
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
 
-    cron_scan
-      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                            &cron_scan_directory_data_hosts,
-                                            NULL);
+    cron_scan =
+      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                          &cron_scan_directory_data_hosts,
+                                          NULL);
 
-    cron_clean
-      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                            &cron_clean_data_hosts,
-                                            NULL);
+    cron_clean =
+      GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                          &cron_clean_data_hosts,
+                                          NULL);
     if (GNUNET_YES == use_included)
     {
       ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
-      GNUNET_asprintf (&peerdir,
-                       "%shellos",
-                       ip);
+      GNUNET_asprintf (&peerdir, "%shellos", ip);
       GNUNET_free (ip);
 
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Importing HELLOs from `%s'\n"),
+                  _ ("Importing HELLOs from `%s'\n"),
                   peerdir);
       dsc.matched = 0;
       dsc.remove_files = GNUNET_NO;
@@ -1447,7 +1329,7 @@ run (void *cls,
     else
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Skipping import of included HELLOs\n"));
+                  _ ("Skipping import of included HELLOs\n"));
     }
   }
 }
@@ -1456,30 +1338,30 @@ run (void *cls,
 /**
  * Define "main" method using service macro.
  */
-GNUNET_SERVICE_MAIN
-("peerinfo",
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_var_size (hello,
-                        GNUNET_MESSAGE_TYPE_HELLO,
-                        struct GNUNET_HELLO_Message,
-                        NULL),
- GNUNET_MQ_hd_fixed_size (get,
-                         GNUNET_MESSAGE_TYPE_PEERINFO_GET,
-                         struct ListPeerMessage,
-                         NULL),
- GNUNET_MQ_hd_fixed_size (get_all,
-                         GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL,
-                         struct ListAllPeersMessage,
-                         NULL),
- GNUNET_MQ_hd_fixed_size (notify,
-                         GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY,
-                         struct NotifyMessage,
-                         NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN (
+  "peerinfo",
 GNUNET_SERVICE_OPTION_NONE,
 &run,
 &client_connect_cb,
 &client_disconnect_cb,
 NULL,
 GNUNET_MQ_hd_var_size (hello,
+                         GNUNET_MESSAGE_TYPE_HELLO,
+                         struct GNUNET_HELLO_Message,
+                         NULL),
 GNUNET_MQ_hd_fixed_size (get,
+                           GNUNET_MESSAGE_TYPE_PEERINFO_GET,
+                           struct ListPeerMessage,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (get_all,
+                           GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL,
+                           struct ListAllPeersMessage,
+                           NULL),
 GNUNET_MQ_hd_fixed_size (notify,
+                           GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY,
+                           struct NotifyMessage,
+                           NULL),
 GNUNET_MQ_handler_end ());
 
 
 /* end of gnunet-service-peerinfo.c */
index 29c27c48cf03382ce5a4877564d47d7e846b8385..d56e0c558ca50cd7dda7e4b26d2fcf32b68c9330 100644 (file)
@@ -177,7 +177,7 @@ main (int argc,
                                       "test_peerinfo_api_data.conf",
                                       &run, NULL))
     return 1;
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Received %u/%u calls before timeout\n",
            numpeers,
           NUM_REQUESTS * NUM_REQUESTS / 2);
index d6be5f06d577f8fd4d5d50588cfdefd820a9fbaf..24b5723ffc92693d6b20a1d0563825dff09de6af 100644 (file)
@@ -83,7 +83,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
   if (NULL == (ret = GNUNET_PLUGIN_load (libname,
                                          (void*) cfg)))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Failed to load plugin `%s'!\n",
              plugin_name);
     GNUNET_free (libname);
@@ -174,7 +174,7 @@ run (void *cls,
   psp = load_plugin (cfg);
   if (NULL == psp)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
             "Failed to initialize peerstore.  Database likely not setup, skipping test.\n");
     return;
@@ -215,7 +215,7 @@ main (int argc, char *argv[])
                       &run,
                       NULL);
   if (ok != 0)
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Missed some testcases: %d\n",
              ok);
   return ok;
index 4769ed2d1522b1a2f6af0966d0c8adf05ee9beac..d47460edf9c05aada6a9a38ce36be197e63c9ba1 100644 (file)
@@ -476,7 +476,7 @@ OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
   payload_len = sizeof (struct OIDC_Parameters);
   if (NULL != nonce_str && strcmp ("", nonce_str) != 0)
   {
-    if ((1 != SSCANF (nonce_str, "%u", &nonce)) || (nonce > UINT32_MAX))
+    if ((1 != sscanf (nonce_str, "%u", &nonce)) || (nonce > UINT32_MAX))
     {
       GNUNET_break (0);
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid nonce %s\n", nonce_str);
@@ -754,4 +754,3 @@ OIDC_access_token_new ()
                                 &access_token);
   return access_token;
 }
-
index e8f6d867ba4490fb243c318ee20fb8b64f082ca3..d82b7800abf84d60233f71f868c60467388c7d23 100644 (file)
@@ -205,17 +205,17 @@ update_meter (struct ProgressMeter *meter)
     {
       if (meter->completed == 0)
       {
-        FPRINTF (stdout, "%sProgress: [0%%", meter->startup_string);
+        fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
       }
       else
-        FPRINTF (stdout, "%d%%",
+        fprintf (stdout, "%d%%",
                  (int) (((float) meter->completed / meter->total) * 100));
     }
     else if (meter->completed % meter->dotnum == 0)
-      FPRINTF (stdout, "%s", ".");
+      fprintf (stdout, "%s", ".");
 
     if (meter->completed + 1 == meter->total)
-      FPRINTF (stdout, "%d%%]\n", 100);
+      fprintf (stdout, "%d%%]\n", 100);
     fflush (stdout);
   }
   meter->completed++;
index 099f9f68cd6e00e2a4bc879d10440caac798ca80..7016bf9c4e8da36d421f737c08db32d8e11ddebd 100644 (file)
@@ -64,7 +64,7 @@ static void
 end_badly ()
 {
   die_task = NULL;
-  FPRINTF (stderr, "%s",  "Testcase failed (timeout).\n");
+  fprintf (stderr, "%s",  "Testcase failed (timeout).\n");
   GNUNET_REGEX_announce_cancel (a);
   a = NULL;
   GNUNET_REGEX_search_cancel (s);
index d7a58b9942937aa98d47749cd88e6959cac85719..f264c4faee0538e017b578774ef1c5e38bda6399 100644 (file)
@@ -75,7 +75,7 @@ end (void *cls)
 static void
 end_badly ()
 {
-  FPRINTF (stderr, "%s",  "Testcase failed (timeout).\n");
+  fprintf (stderr, "%s",  "Testcase failed (timeout).\n");
   end (NULL);
   ok = 1;
 }
index 4b8fa15bb73c3d1186dd3eff8e4bafc3eaadeffd..b5be65a5f18404f3b8ca5f417959b636b15b7db6 100644 (file)
@@ -118,26 +118,19 @@ do_shutdown (void *cls)
  * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error
  */
 static void
-print_query_result (void *cls,
-                    int is_valid)
+print_query_result (void *cls, int is_valid)
 {
   q = NULL;
   switch (is_valid)
   {
   case GNUNET_YES:
-    FPRINTF (stdout,
-             _("Key `%s' is valid\n"),
-             test_ego);
+    fprintf (stdout, _ ("Key `%s' is valid\n"), test_ego);
     break;
   case GNUNET_NO:
-    FPRINTF (stdout,
-             _("Key `%s' has been revoked\n"),
-             test_ego);
+    fprintf (stdout, _ ("Key `%s' has been revoked\n"), test_ego);
     break;
   case GNUNET_SYSERR:
-    FPRINTF (stdout,
-             "%s",
-             _("Internal error\n"));
+    fprintf (stdout, "%s", _ ("Internal error\n"));
     break;
   default:
     GNUNET_break (0);
@@ -154,36 +147,31 @@ print_query_result (void *cls,
  * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error
  */
 static void
-print_revocation_result (void *cls,
-                         int is_valid)
+print_revocation_result (void *cls, int is_valid)
 {
   h = NULL;
   switch (is_valid)
   {
   case GNUNET_YES:
     if (NULL != revoke_ego)
-      FPRINTF (stdout,
-               _("Key for ego `%s' is still valid, revocation failed (!)\n"),
+      fprintf (stdout,
+               _ ("Key for ego `%s' is still valid, revocation failed (!)\n"),
                revoke_ego);
     else
-      FPRINTF (stdout,
-               "%s",
-               _("Revocation failed (!)\n"));
+      fprintf (stdout, "%s", _ ("Revocation failed (!)\n"));
     break;
   case GNUNET_NO:
     if (NULL != revoke_ego)
-      FPRINTF (stdout,
-               _("Key for ego `%s' has been successfully revoked\n"),
+      fprintf (stdout,
+               _ ("Key for ego `%s' has been successfully revoked\n"),
                revoke_ego);
     else
-      FPRINTF (stdout,
-               "%s",
-               _("Revocation successful.\n"));
+      fprintf (stdout, "%s", _ ("Revocation successful.\n"));
     break;
   case GNUNET_SYSERR:
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%s",
-             _("Internal error, key revocation might have failed\n"));
+             _ ("Internal error, key revocation might have failed\n"));
     break;
   default:
     GNUNET_break (0);
@@ -239,16 +227,14 @@ perform_revocation (const struct RevocationData *rd)
 static void
 sync_rd (const struct RevocationData *rd)
 {
-  if ( (NULL != filename) &&
-       (sizeof (struct RevocationData) ==
-       GNUNET_DISK_fn_write (filename,
-                             &rd,
-                             sizeof (rd),
-                             GNUNET_DISK_PERM_USER_READ |
-                             GNUNET_DISK_PERM_USER_WRITE)) )
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                             "write",
-                             filename);
+  if ((NULL != filename) &&
+      (sizeof (struct RevocationData) ==
+       GNUNET_DISK_fn_write (filename,
+                             &rd,
+                             sizeof (rd),
+                             GNUNET_DISK_PERM_USER_READ |
+                               GNUNET_DISK_PERM_USER_WRITE)))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename);
 }
 
 
@@ -287,48 +273,44 @@ calculate_pow (void *cls)
   if (0 == (rd->pow % 128))
     sync_rd (rd);
   /* display progress estimate */
-  if ( (0 == ((1 << matching_bits) / 100 / 50)) ||
-       (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))) )
-    FPRINTF (stderr, "%s", ".");
-  if ( (0 != rd->pow) &&
-       ( (0 == ((1 << matching_bits) / 100)) ||
-         (0 == (rd->pow % ((1 << matching_bits) / 100))) ) )
-    FPRINTF (stderr, " - @ %3u%% (estimate)\n",
+  if ((0 == ((1 << matching_bits) / 100 / 50)) ||
+      (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))))
+    fprintf (stderr, "%s", ".");
+  if ((0 != rd->pow) && ((0 == ((1 << matching_bits) / 100)) ||
+                         (0 == (rd->pow % ((1 << matching_bits) / 100)))))
+    fprintf (stderr,
+             " - @ %3u%% (estimate)\n",
              (unsigned int) (rd->pow * 100) / (1 << matching_bits));
   /* actually do POW calculation */
   rd->pow++;
-  if (GNUNET_OK ==
-      GNUNET_REVOCATION_check_pow (&rd->key,
-                                   rd->pow,
-                                   (unsigned int) matching_bits))
+  if (GNUNET_OK == GNUNET_REVOCATION_check_pow (&rd->key,
+                                                rd->pow,
+                                                (unsigned int) matching_bits))
   {
-    if ( (NULL != filename) &&
-         (sizeof (struct RevocationData) !=
-          GNUNET_DISK_fn_write (filename,
-                                rd,
-                                sizeof (struct RevocationData),
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE)) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                                "write",
-                                filename);
+    if ((NULL != filename) &&
+        (sizeof (struct RevocationData) !=
+         GNUNET_DISK_fn_write (filename,
+                               rd,
+                               sizeof (struct RevocationData),
+                               GNUNET_DISK_PERM_USER_READ |
+                                 GNUNET_DISK_PERM_USER_WRITE)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename);
     if (perform)
     {
       perform_revocation (rd);
     }
     else
     {
-      FPRINTF (stderr, "%s", "\n");
-      FPRINTF (stderr,
-               _("Revocation certificate for `%s' stored in `%s'\n"),
+      fprintf (stderr, "%s", "\n");
+      fprintf (stderr,
+               _ ("Revocation certificate for `%s' stored in `%s'\n"),
                revoke_ego,
                filename);
       GNUNET_SCHEDULER_shutdown ();
     }
     return;
   }
-  pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow,
-                                      rd);
+  pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, rd);
 }
 
 
@@ -339,8 +321,7 @@ calculate_pow (void *cls)
  * @param ego the ego, NULL if not found
  */
 static void
-ego_callback (void *cls,
-              const struct GNUNET_IDENTITY_Ego *ego)
+ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
 {
   struct RevocationData *rd;
   struct GNUNET_CRYPTO_EcdsaPublicKey key;
@@ -348,28 +329,20 @@ ego_callback (void *cls,
   el = NULL;
   if (NULL == ego)
   {
-    FPRINTF (stdout,
-             _("Ego `%s' not found.\n"),
-             revoke_ego);
+    fprintf (stdout, _ ("Ego `%s' not found.\n"), revoke_ego);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_IDENTITY_ego_get_public_key (ego,
-                                      &key);
+  GNUNET_IDENTITY_ego_get_public_key (ego, &key);
   rd = GNUNET_new (struct RevocationData);
-  if ( (NULL != filename) &&
-       (GNUNET_YES ==
-        GNUNET_DISK_file_test (filename)) &&
-       (sizeof (struct RevocationData) ==
-        GNUNET_DISK_fn_read (filename,
-                             rd,
-                             sizeof (struct RevocationData))) )
+  if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) &&
+      (sizeof (struct RevocationData) ==
+       GNUNET_DISK_fn_read (filename, rd, sizeof (struct RevocationData))))
   {
-    if (0 != GNUNET_memcmp (&rd->key,
-                     &key))
+    if (0 != GNUNET_memcmp (&rd->key, &key))
     {
       fprintf (stderr,
-               _("Error: revocation certificate in `%s' is not for `%s'\n"),
+               _ ("Error: revocation certificate in `%s' is not for `%s'\n"),
                filename,
                revoke_ego);
       GNUNET_free (rd);
@@ -378,18 +351,15 @@ ego_callback (void *cls,
   }
   else
   {
-    GNUNET_REVOCATION_sign_revocation (GNUNET_IDENTITY_ego_get_private_key (ego),
+    GNUNET_REVOCATION_sign_revocation (GNUNET_IDENTITY_ego_get_private_key (
+                                         ego),
                                        &rd->sig);
     rd->key = key;
   }
   if (GNUNET_YES ==
-      GNUNET_REVOCATION_check_pow (&key,
-                                   rd->pow,
-                                   (unsigned int) matching_bits))
+      GNUNET_REVOCATION_check_pow (&key, rd->pow, (unsigned int) matching_bits))
   {
-    FPRINTF (stderr,
-             "%s",
-             _("Revocation certificate ready\n"));
+    fprintf (stderr, "%s", _ ("Revocation certificate ready\n"));
     if (perform)
       perform_revocation (rd);
     else
@@ -397,13 +367,11 @@ ego_callback (void *cls,
     GNUNET_free (rd);
     return;
   }
-  FPRINTF (stderr,
+  fprintf (stderr,
            "%s",
-           _("Revocation certificate not ready, calculating proof of work\n"));
-  pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow,
-                                      rd);
-  GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown,
-                                rd);
+           _ ("Revocation certificate not ready, calculating proof of work\n"));
+  pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, rd);
+  GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, rd);
 }
 
 
@@ -429,31 +397,26 @@ run (void *cls,
   {
     if (GNUNET_OK !=
         GNUNET_CRYPTO_ecdsa_public_key_from_string (test_ego,
-                                                       strlen (test_ego),
-                                                       &pk))
+                                                    strlen (test_ego),
+                                                    &pk))
     {
-      FPRINTF (stderr,
-               _("Public key `%s' malformed\n"),
-               test_ego);
+      fprintf (stderr, _ ("Public key `%s' malformed\n"), test_ego);
       return;
     }
-    GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                  NULL);
-    q = GNUNET_REVOCATION_query (cfg,
-                                 &pk,
-                                 &print_query_result,
-                                 NULL);
+    GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+    q = GNUNET_REVOCATION_query (cfg, &pk, &print_query_result, NULL);
     if (NULL != revoke_ego)
-      FPRINTF (stderr,
-               "%s",
-               _("Testing and revoking at the same time is not allowed, only executing test.\n"));
+      fprintf (
+        stderr,
+        "%s",
+        _ (
+          "Testing and revoking at the same time is not allowed, only executing test.\n"));
     return;
   }
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg,
-                                             "REVOCATION",
-                                             "WORKBITS",
-                                             &matching_bits))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                          "REVOCATION",
+                                                          "WORKBITS",
+                                                          &matching_bits))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "REVOCATION",
@@ -462,37 +425,28 @@ run (void *cls,
   }
   if (NULL != revoke_ego)
   {
-    if ( !perform && (NULL == filename) )
+    if (! perform && (NULL == filename))
     {
-        FPRINTF (stderr,
-                 "%s",
-                 _("No filename to store revocation certificate given.\n"));
-        return;
+      fprintf (stderr,
+               "%s",
+               ("No filename to store revocation certificate given.\n"));
+      return;
     }
     /* main code here */
-    el = GNUNET_IDENTITY_ego_lookup (cfg,
-                                     revoke_ego,
-                                     &ego_callback,
-                                     NULL);
-    GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                  NULL);
+    el = GNUNET_IDENTITY_ego_lookup (cfg, revoke_ego, &ego_callback, NULL);
+    GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
     return;
   }
-  if ( (NULL != filename) &&
-       (perform) )
+  if ((NULL != filename) && (perform))
   {
-    if (sizeof (rd) !=
-        GNUNET_DISK_fn_read (filename,
-                             &rd,
-                             sizeof (rd)))
+    if (sizeof (rd) != GNUNET_DISK_fn_read (filename, &rd, sizeof (rd)))
     {
       fprintf (stderr,
-               _("Failed to read revocation certificate from `%s'\n"),
+               _ ("Failed to read revocation certificate from `%s'\n"),
                filename);
       return;
     }
-    GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                  NULL);
+    GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
     if (GNUNET_YES !=
         GNUNET_REVOCATION_check_pow (&rd.key,
                                      rd.pow,
@@ -501,18 +455,14 @@ run (void *cls,
       struct RevocationData *cp = GNUNET_new (struct RevocationData);
 
       *cp = rd;
-      pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow,
-                                          cp);
-      GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown,
-                                    cp);
+      pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, cp);
+      GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, cp);
       return;
     }
     perform_revocation (&rd);
     return;
   }
-  FPRINTF (stderr,
-           "%s",
-           _("No action specified. Nothing to do.\n"));
+  fprintf (stderr, "%s", _ ("No action specified. Nothing to do.\n"));
 }
 
 
@@ -531,36 +481,46 @@ main (int argc, char *const *argv)
     GNUNET_GETOPT_option_string ('f',
                                  "filename",
                                  "NAME",
-                                 gettext_noop ("use NAME for the name of the revocation file"),
+                                 gettext_noop (
+                                   "use NAME for the name of the revocation file"),
                                  &filename),
 
-    GNUNET_GETOPT_option_string ('R',
-                                 "revoke",
-                                 "NAME",
-                                 gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "),
-                                 &revoke_ego), 
-
-    GNUNET_GETOPT_option_flag ('p',
-                                  "perform",
-                                  gettext_noop ("actually perform revocation, otherwise we just do the precomputation"),
-                                  &perform),
+    GNUNET_GETOPT_option_string (
+      'R',
+      "revoke",
+      "NAME",
+      gettext_noop (
+        "revoke the private key associated for the the private key associated with the ego NAME "),
+      &revoke_ego),
+
+    GNUNET_GETOPT_option_flag (
+      'p',
+      "perform",
+      gettext_noop (
+        "actually perform revocation, otherwise we just do the precomputation"),
+      &perform),
 
     GNUNET_GETOPT_option_string ('t',
                                  "test",
                                  "KEY",
-                                 gettext_noop ("test if the public key KEY has been revoked"),
-                                 &test_ego), 
+                                 gettext_noop (
+                                   "test if the public key KEY has been revoked"),
+                                 &test_ego),
 
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-revocation",
-                            gettext_noop ("help text"), options, &run,
-                            NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+  ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc,
+                                          argv,
+                                          "gnunet-revocation",
+                                          gettext_noop ("help text"),
+                                          options,
+                                          &run,
+                                          NULL))
+          ? ret
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 50b5b67397e7bbd1140510a83faa25b952576322..d731ffa557e5a33b9828dc65dd4c86c1ac0bfef5 100644 (file)
@@ -97,7 +97,7 @@ reply_handle (void *cls,
   req_handle = NULL;
   for (i = 0; i < n; i++)
   {
-    FPRINTF (stdout, "%s\n",
+    fprintf (stdout, "%s\n",
         GNUNET_i2s_full (&recv_peers[i]));
   }
   ret = 0;
@@ -122,12 +122,12 @@ view_update_handle (void *cls,
 
   if (0 == n)
   {
-    FPRINTF (stdout, "Empty view\n");
+    fprintf (stdout, "Empty view\n");
   }
   req_handle = NULL;
   for (i = 0; i < n; i++)
   {
-    FPRINTF (stdout, "%s\n",
+    fprintf (stdout, "%s\n",
         GNUNET_i2s_full (&recv_peers[i]));
   }
 
@@ -159,12 +159,12 @@ stream_input_handle (void *cls,
 
   if (0 == num_peers)
   {
-    FPRINTF (stdout, "No peer was returned\n");
+    fprintf (stdout, "No peer was returned\n");
   }
   req_handle = NULL;
   for (i = 0; i < num_peers; i++)
   {
-    FPRINTF (stdout, "%s\n",
+    fprintf (stdout, "%s\n",
              GNUNET_i2s_full (&recv_peers[i]));
   }
 }
@@ -192,7 +192,7 @@ run (void *cls,
   rps_handle = GNUNET_RPS_connect (cfg);
   if (NULL == rps_handle)
   {
-    FPRINTF (stderr, "Failed to connect to the rps service\n");
+    fprintf (stderr, "Failed to connect to the rps service\n");
     return;
   }
 
@@ -235,7 +235,7 @@ run (void *cls,
   else
   { /* Seed PeerID */
     GNUNET_RPS_seed_ids (rps_handle, 1, &peer_id);
-    FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (&peer_id));
+    fprintf (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (&peer_id));
     ret = 0;
     GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
   }
index 5ce54d768f87c986b6d75351b9f7476bceb3bed4..18905f458a93017e1e634f487a09860432efde30 100644 (file)
@@ -71,7 +71,6 @@ struct WatchEntry
    * #GNUNET_NO : last_value is n/a, #GNUNET_YES: last_value is valid
    */
   int last_value_set;
-
 };
 
 
@@ -138,7 +137,6 @@ struct StatsEntry
    * #GNUNET_NO: value is n/a, #GNUNET_YES: value is valid
    */
   int set;
-
 };
 
 
@@ -173,7 +171,6 @@ struct SubsystemEntry
    * the end of this struct, do not free().
    */
   const char *service;
-
 };
 
 
@@ -201,7 +198,6 @@ struct ClientEntry
    * Maximum watch ID used by this client so far.
    */
   uint32_t max_wid;
-
 };
 
 
@@ -257,11 +253,10 @@ save ()
   size_t slen;
   struct GNUNET_STATISTICS_SetMessage *msg;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               "STATISTICS",
-                                               "DATABASE",
-                                               &fn))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                            "STATISTICS",
+                                                            "DATABASE",
+                                                            &fn))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "STATISTICS",
@@ -273,17 +268,12 @@ save ()
   total = 0;
   while (NULL != (se = sub_head))
   {
-    GNUNET_CONTAINER_DLL_remove (sub_head,
-                                 sub_tail,
-                                 se);
+    GNUNET_CONTAINER_DLL_remove (sub_head, sub_tail, se);
     slen = strlen (se->service) + 1;
     while (NULL != (pos = se->stat_head))
     {
-      GNUNET_CONTAINER_DLL_remove (se->stat_head,
-                                   se->stat_tail,
-                                   pos);
-      if ( (pos->persistent) &&
-          (NULL != wh) )
+      GNUNET_CONTAINER_DLL_remove (se->stat_head, se->stat_tail, pos);
+      if ((pos->persistent) && (NULL != wh))
       {
         nlen = strlen (pos->name) + 1;
         size = sizeof (struct GNUNET_STATISTICS_SetMessage) + nlen + slen;
@@ -298,19 +288,14 @@ save ()
                                                    2,
                                                    se->service,
                                                    pos->name));
-        msg->flags = htonl (pos->persistent ? GNUNET_STATISTICS_SETFLAG_PERSISTENT : 0);
+        msg->flags =
+          htonl (pos->persistent ? GNUNET_STATISTICS_SETFLAG_PERSISTENT : 0);
         msg->value = GNUNET_htonll (pos->value);
-        if (GNUNET_OK != GNUNET_BIO_write (wh,
-                                           msg,
-                                           size))
+        if (GNUNET_OK != GNUNET_BIO_write (wh, msg, size))
         {
-          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                    "write",
-                                    fn);
+          GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
           if (GNUNET_OK != GNUNET_BIO_write_close (wh))
-            GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                      "close",
-                                      fn);
+            GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "close", fn);
           wh = NULL;
         }
         else
@@ -325,17 +310,13 @@ save ()
   }
   if (NULL != wh)
   {
-    if (GNUNET_OK !=
-        GNUNET_BIO_write_close (wh))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                                "close",
-                                fn);
+    if (GNUNET_OK != GNUNET_BIO_write_close (wh))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "close", fn);
     if (0 == total)
-      GNUNET_break (0 ==
-                    UNLINK (fn));
+      GNUNET_break (0 == unlink (fn));
     else
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Wrote %llu bytes of statistics to `%s'\n"),
+                  _ ("Wrote %llu bytes of statistics to `%s'\n"),
                   total,
                   fn);
   }
@@ -350,37 +331,31 @@ save ()
  * @param e value to transmit
  */
 static void
-transmit (struct ClientEntry *ce,
-          const struct StatsEntry *e)
+transmit (struct ClientEntry *ce, const struct StatsEntry *e)
 {
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_STATISTICS_ReplyMessage *m;
   size_t size;
 
-  size = strlen (e->subsystem->service) + 1 +
-    strlen (e->name) + 1;
+  size = strlen (e->subsystem->service) + 1 + strlen (e->name) + 1;
   GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
-  env = GNUNET_MQ_msg_extra (m,
-                            size,
-                            GNUNET_MESSAGE_TYPE_STATISTICS_VALUE);
+  env = GNUNET_MQ_msg_extra (m, size, GNUNET_MESSAGE_TYPE_STATISTICS_VALUE);
   m->uid = htonl (e->uid);
   if (e->persistent)
     m->uid |= htonl (GNUNET_STATISTICS_PERSIST_BIT);
   m->value = GNUNET_htonll (e->value);
-  GNUNET_assert (size ==
-                 GNUNET_STRINGS_buffer_fill ((char *) &m[1],
-                                             size,
-                                             2,
-                                             e->subsystem->service,
-                                             e->name));
+  GNUNET_assert (size == GNUNET_STRINGS_buffer_fill ((char *) &m[1],
+                                                     size,
+                                                     2,
+                                                     e->subsystem->service,
+                                                     e->name));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Transmitting value for `%s:%s' (%d): %llu\n",
               e->subsystem->service,
               e->name,
               e->persistent,
               (unsigned long long) e->value);
-  GNUNET_MQ_send (ce->mq,
-                 env);
+  GNUNET_MQ_send (ce->mq, env);
 }
 
 
@@ -394,8 +369,8 @@ transmit (struct ClientEntry *ce,
  */
 static void *
 client_connect_cb (void *cls,
-                  struct GNUNET_SERVICE_Client *c,
-                  struct GNUNET_MQ_Handle *mq)
+                   struct GNUNET_SERVICE_Client *c,
+                   struct GNUNET_MQ_Handle *mq)
 {
   struct ClientEntry *ce;
 
@@ -403,8 +378,7 @@ client_connect_cb (void *cls,
   ce->client = c;
   ce->mq = mq;
   client_count++;
-  GNUNET_notification_context_add (nc,
-                                  mq);
+  GNUNET_notification_context_add (nc, mq);
   return ce;
 }
 
@@ -417,20 +391,18 @@ client_connect_cb (void *cls,
  * @return #GNUNET_OK if @a message is well-formed
  */
 static int
-check_get (void *cls,
-          const struct GNUNET_MessageHeader *message)
+check_get (void *cls, const struct GNUNET_MessageHeader *message)
 {
   const char *service;
   const char *name;
   size_t size;
 
   size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader);
-  if (size !=
-      GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
-                                      size,
-                                      2,
-                                      &service,
-                                      &name))
+  if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
+                                              size,
+                                              2,
+                                              &service,
+                                              &name))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -446,8 +418,7 @@ check_get (void *cls,
  * @param message the actual message
  */
 static void
-handle_get (void *cls,
-            const struct GNUNET_MessageHeader *message)
+handle_get (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct ClientEntry *ce = cls;
   struct GNUNET_MQ_Envelope *env;
@@ -462,11 +433,11 @@ handle_get (void *cls,
 
   size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader);
   GNUNET_assert (size ==
-                GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
-                                                size,
-                                                2,
-                                                &service,
-                                                &name));
+                 GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
+                                                 size,
+                                                 2,
+                                                 &service,
+                                                 &name));
   slen = strlen (service);
   nlen = strlen (name);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -475,23 +446,17 @@ handle_get (void *cls,
               nlen ? name : "*");
   for (se = sub_head; NULL != se; se = se->next)
   {
-    if (! ( (0 == slen) ||
-            (0 == strcmp (service, se->service))) )
+    if (! ((0 == slen) || (0 == strcmp (service, se->service))))
       continue;
     for (pos = se->stat_head; NULL != pos; pos = pos->next)
     {
-      if  (! ( (0 == nlen) ||
-               (0 == strcmp (name,
-                            pos->name))) )
+      if (! ((0 == nlen) || (0 == strcmp (name, pos->name))))
         continue;
-      transmit (ce,
-               pos);
+      transmit (ce, pos);
     }
   }
-  env = GNUNET_MQ_msg (end,
-                      GNUNET_MESSAGE_TYPE_STATISTICS_END);
-  GNUNET_MQ_send (ce->mq,
-                 env);
+  env = GNUNET_MQ_msg (end, GNUNET_MESSAGE_TYPE_STATISTICS_END);
+  GNUNET_MQ_send (ce->mq, env);
   GNUNET_SERVICE_client_continue (ce->client);
 }
 
@@ -519,14 +484,13 @@ notify_change (struct StatsEntry *se)
     {
       pos->last_value_set = GNUNET_YES;
     }
-    env = GNUNET_MQ_msg (wvm,
-                        GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE);
-    wvm->flags = htonl (se->persistent ? GNUNET_STATISTICS_SETFLAG_PERSISTENT : 0);
+    env = GNUNET_MQ_msg (wvm, GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE);
+    wvm->flags =
+      htonl (se->persistent ? GNUNET_STATISTICS_SETFLAG_PERSISTENT : 0);
     wvm->wid = htonl (pos->wid);
     wvm->reserved = htonl (0);
     wvm->value = GNUNET_htonll (se->value);
-    GNUNET_MQ_send (pos->ce->mq,
-                   env);
+    GNUNET_MQ_send (pos->ce->mq, env);
     pos->last_value = se->value;
   }
 }
@@ -541,8 +505,7 @@ notify_change (struct StatsEntry *se)
  * @return subsystem entry, never NULL (subsystem entry is created if necessary)
  */
 static struct SubsystemEntry *
-find_subsystem_entry (struct ClientEntry *ce,
-                      const char *service)
+find_subsystem_entry (struct ClientEntry *ce, const char *service)
 {
   size_t slen;
   struct SubsystemEntry *se;
@@ -551,13 +514,10 @@ find_subsystem_entry (struct ClientEntry *ce,
     se = ce->subsystem;
   else
     se = NULL;
-  if ( (NULL == se) ||
-       (0 != strcmp (service,
-                     se->service)) )
+  if ((NULL == se) || (0 != strcmp (service, se->service)))
   {
     for (se = sub_head; NULL != se; se = se->next)
-      if (0 == strcmp (service,
-                       se->service))
+      if (0 == strcmp (service, se->service))
         break;
     if (NULL != ce)
       ce->subsystem = se;
@@ -568,15 +528,10 @@ find_subsystem_entry (struct ClientEntry *ce,
               "Allocating new subsystem entry `%s'\n",
               service);
   slen = strlen (service) + 1;
-  se = GNUNET_malloc (sizeof (struct SubsystemEntry) +
-                      slen);
-  GNUNET_memcpy (&se[1],
-          service,
-          slen);
+  se = GNUNET_malloc (sizeof (struct SubsystemEntry) + slen);
+  GNUNET_memcpy (&se[1], service, slen);
   se->service = (const char *) &se[1];
-  GNUNET_CONTAINER_DLL_insert (sub_head,
-                               sub_tail,
-                               se);
+  GNUNET_CONTAINER_DLL_insert (sub_head, sub_tail, se);
   if (NULL != ce)
     ce->subsystem = se;
   return se;
@@ -591,13 +546,12 @@ find_subsystem_entry (struct ClientEntry *ce,
  * @return statistis entry, or NULL if not found
  */
 static struct StatsEntry *
-find_stat_entry (struct SubsystemEntry *se,
-                 const char *name)
+find_stat_entry (struct SubsystemEntry *se, const char *name)
 {
   struct StatsEntry *pos;
 
   for (pos = se->stat_head; NULL != pos; pos = pos->next)
-    if  (0 == strcmp (name, pos->name))
+    if (0 == strcmp (name, pos->name))
       return pos;
   return NULL;
 }
@@ -611,20 +565,18 @@ find_stat_entry (struct SubsystemEntry *se,
  * @return #GNUNET_OK if message is well-formed
  */
 static int
-check_set (void *cls,
-          const struct GNUNET_STATISTICS_SetMessage *msg)
+check_set (void *cls, const struct GNUNET_STATISTICS_SetMessage *msg)
 {
   const char *service;
   const char *name;
   size_t msize;
 
   msize = ntohs (msg->header.size) - sizeof (*msg);
-  if (msize !=
-      GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1],
-                                      msize,
-                                      2,
-                                      &service,
-                                      &name))
+  if (msize != GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1],
+                                               msize,
+                                               2,
+                                               &service,
+                                               &name))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -640,8 +592,7 @@ check_set (void *cls,
  * @param message the actual message
  */
 static void
-handle_set (void *cls,
-            const struct GNUNET_STATISTICS_SetMessage *msg)
+handle_set (void *cls, const struct GNUNET_STATISTICS_SetMessage *msg)
 {
   struct ClientEntry *ce = cls;
   const char *service;
@@ -659,14 +610,12 @@ handle_set (void *cls,
 
   msize = ntohs (msg->header.size);
   size = msize - sizeof (struct GNUNET_STATISTICS_SetMessage);
-  GNUNET_assert (size ==
-                GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1],
-                                                size,
-                                                2,
-                                                &service,
-                                                &name));
-  se = find_subsystem_entry (ce,
-                            service);
+  GNUNET_assert (size == GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1],
+                                                         size,
+                                                         2,
+                                                         &service,
+                                                         &name));
+  se = find_subsystem_entry (ce, service);
   flags = ntohl (msg->flags);
   value = GNUNET_ntohll (msg->value);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -675,8 +624,7 @@ handle_set (void *cls,
               name,
               (unsigned int) flags,
               (unsigned long long) value);
-  pos = find_stat_entry (se,
-                        name);
+  pos = find_stat_entry (se, name);
   if (NULL != pos)
   {
     initial_set = 0;
@@ -696,8 +644,7 @@ handle_set (void *cls,
       else
       {
         changed = (0 != delta);
-        GNUNET_break ( (delta <= 0) ||
-                       (pos->value + delta > pos->value) );
+        GNUNET_break ((delta <= 0) || (pos->value + delta > pos->value));
         pos->value += delta;
       }
     }
@@ -710,12 +657,8 @@ handle_set (void *cls,
     if (pos != se->stat_head)
     {
       /* move to front for faster setting next time! */
-      GNUNET_CONTAINER_DLL_remove (se->stat_head,
-                                   se->stat_tail,
-                                   pos);
-      GNUNET_CONTAINER_DLL_insert (se->stat_head,
-                                   se->stat_tail,
-                                   pos);
+      GNUNET_CONTAINER_DLL_remove (se->stat_head, se->stat_tail, pos);
+      GNUNET_CONTAINER_DLL_insert (se->stat_head, se->stat_tail, pos);
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Statistic `%s:%s' updated to value %llu (%d).\n",
@@ -723,8 +666,7 @@ handle_set (void *cls,
                 name,
                 (unsigned long long) pos->value,
                 pos->persistent);
-    if ( (changed) ||
-         (1 == initial_set) )
+    if ((changed) || (1 == initial_set))
       notify_change (pos);
     GNUNET_SERVICE_client_continue (ce->client);
     return;
@@ -732,13 +674,11 @@ handle_set (void *cls,
   /* not found, create a new entry */
   nlen = strlen (name) + 1;
   pos = GNUNET_malloc (sizeof (struct StatsEntry) + nlen);
-  GNUNET_memcpy (&pos[1],
-                name,
-                nlen);
+  GNUNET_memcpy (&pos[1], name, nlen);
   pos->name = (const char *) &pos[1];
   pos->subsystem = se;
-  if ( (0 == (flags & GNUNET_STATISTICS_SETFLAG_RELATIVE)) ||
-       (0 < (int64_t) GNUNET_ntohll (msg->value)) )
+  if ((0 == (flags & GNUNET_STATISTICS_SETFLAG_RELATIVE)) ||
+      (0 < (int64_t) GNUNET_ntohll (msg->value)))
   {
     pos->value = GNUNET_ntohll (msg->value);
     pos->set = GNUNET_YES;
@@ -749,9 +689,7 @@ handle_set (void *cls,
   }
   pos->uid = uidgen++;
   pos->persistent = (0 != (flags & GNUNET_STATISTICS_SETFLAG_PERSISTENT));
-  GNUNET_CONTAINER_DLL_insert (se->stat_head,
-                               se->stat_tail,
-                               pos);
+  GNUNET_CONTAINER_DLL_insert (se->stat_head, se->stat_tail, pos);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "New statistic on `%s:%s' with value %llu created.\n",
               service,
@@ -770,20 +708,18 @@ handle_set (void *cls,
  * @return #GNUNET_OK if message is well-formed
  */
 static int
-check_watch (void *cls,
-            const struct GNUNET_MessageHeader *message)
+check_watch (void *cls, const struct GNUNET_MessageHeader *message)
 {
   size_t size;
   const char *service;
   const char *name;
 
   size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader);
-  if (size !=
-      GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
-                                      size,
-                                      2,
-                                      &service,
-                                      &name))
+  if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
+                                              size,
+                                              2,
+                                              &service,
+                                              &name))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -799,8 +735,7 @@ check_watch (void *cls,
  * @param message the actual message
  */
 static void
-handle_watch (void *cls,
-              const struct GNUNET_MessageHeader *message)
+handle_watch (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct ClientEntry *ce = cls;
   const char *service;
@@ -821,32 +756,25 @@ handle_watch (void *cls,
   msize = ntohs (message->size);
   size = msize - sizeof (struct GNUNET_MessageHeader);
   GNUNET_assert (size ==
-                GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
-                                                size,
-                                                2,
-                                                &service,
-                                                &name));
+                 GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1],
+                                                 size,
+                                                 2,
+                                                 &service,
+                                                 &name));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received request to watch statistic on `%s:%s'\n",
               service,
               name);
-  se = find_subsystem_entry (ce,
-                            service);
-  pos = find_stat_entry (se,
-                        name);
+  se = find_subsystem_entry (ce, service);
+  pos = find_stat_entry (se, name);
   if (NULL == pos)
   {
     nlen = strlen (name) + 1;
-    pos = GNUNET_malloc (sizeof (struct StatsEntry) +
-                         nlen);
-    GNUNET_memcpy (&pos[1],
-                  name,
-                  nlen);
+    pos = GNUNET_malloc (sizeof (struct StatsEntry) + nlen);
+    GNUNET_memcpy (&pos[1], name, nlen);
     pos->name = (const char *) &pos[1];
     pos->subsystem = se;
-    GNUNET_CONTAINER_DLL_insert (se->stat_head,
-                                 se->stat_tail,
-                                 pos);
+    GNUNET_CONTAINER_DLL_insert (se->stat_head, se->stat_tail, pos);
     pos->uid = uidgen++;
     pos->set = GNUNET_NO;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -859,9 +787,7 @@ handle_watch (void *cls,
   we->ce = ce;
   we->last_value_set = GNUNET_NO;
   we->wid = ce->max_wid++;
-  GNUNET_CONTAINER_DLL_insert (pos->we_head,
-                               pos->we_tail,
-                               we);
+  GNUNET_CONTAINER_DLL_insert (pos->we_head, pos->we_tail, we);
   if (0 != pos->value)
     notify_change (pos);
   GNUNET_SERVICE_client_continue (ce->client);
@@ -877,17 +803,14 @@ handle_watch (void *cls,
  * @param message the actual message
  */
 static void
-handle_disconnect (void *cls,
-                  const struct GNUNET_MessageHeader *message)
+handle_disconnect (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct ClientEntry *ce = cls;
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_MessageHeader *msg;
 
-  env = GNUNET_MQ_msg (msg,
-                      GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT_CONFIRM);
-  GNUNET_MQ_send (ce->mq,
-                 env);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT_CONFIRM);
+  GNUNET_MQ_send (ce->mq, env);
   GNUNET_SERVICE_client_continue (ce->client);
 }
 
@@ -910,20 +833,14 @@ do_shutdown ()
   GNUNET_assert (0 == client_count);
   while (NULL != (se = sub_head))
   {
-    GNUNET_CONTAINER_DLL_remove (sub_head,
-                                 sub_tail,
-                                 se);
+    GNUNET_CONTAINER_DLL_remove (sub_head, sub_tail, se);
     while (NULL != (pos = se->stat_head))
     {
-      GNUNET_CONTAINER_DLL_remove (se->stat_head,
-                                   se->stat_tail,
-                                   pos);
+      GNUNET_CONTAINER_DLL_remove (se->stat_head, se->stat_tail, pos);
       while (NULL != (we = pos->we_head))
       {
         GNUNET_break (0);
-        GNUNET_CONTAINER_DLL_remove (pos->we_head,
-                                     pos->we_tail,
-                                     we);
+        GNUNET_CONTAINER_DLL_remove (pos->we_head, pos->we_tail, we);
         GNUNET_free (we);
       }
       GNUNET_free (pos);
@@ -957,8 +874,8 @@ shutdown_task (void *cls)
  */
 static void
 client_disconnect_cb (void *cls,
-                     struct GNUNET_SERVICE_Client *client,
-                     void *app_cls)
+                      struct GNUNET_SERVICE_Client *client,
+                      void *app_cls)
 {
   struct ClientEntry *ce = app_cls;
   struct WatchEntry *we;
@@ -977,16 +894,13 @@ client_disconnect_cb (void *cls,
         wen = we->next;
         if (we->ce != ce)
           continue;
-        GNUNET_CONTAINER_DLL_remove (pos->we_head,
-                                     pos->we_tail,
-                                     we);
+        GNUNET_CONTAINER_DLL_remove (pos->we_head, pos->we_tail, we);
         GNUNET_free (we);
       }
     }
   }
   GNUNET_free (ce);
-  if ( (0 == client_count) &&
-       (GNUNET_YES == in_shutdown) )
+  if ((0 == client_count) && (GNUNET_YES == in_shutdown))
     do_shutdown ();
 }
 
@@ -1003,23 +917,19 @@ client_disconnect_cb (void *cls,
  *    #GNUNET_SYSERR to stop further processing with error
  */
 static int
-inject_message (void *cls,
-               const struct GNUNET_MessageHeader *message)
+inject_message (void *cls, const struct GNUNET_MessageHeader *message)
 {
   uint16_t msize = ntohs (message->size);
   const struct GNUNET_STATISTICS_SetMessage *sm;
 
   sm = (const struct GNUNET_STATISTICS_SetMessage *) message;
-  if ( (sizeof (struct GNUNET_STATISTICS_SetMessage) > msize) ||
-       (GNUNET_OK !=
-       check_set (NULL,
-                  sm)) )
+  if ((sizeof (struct GNUNET_STATISTICS_SetMessage) > msize) ||
+      (GNUNET_OK != check_set (NULL, sm)))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  handle_set (NULL,
-             sm);
+  handle_set (NULL, sm);
   return GNUNET_OK;
 }
 
@@ -1037,23 +947,19 @@ load ()
   char *buf;
   struct GNUNET_MessageStreamTokenizer *mst;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               "STATISTICS",
-                                               "DATABASE",
-                                               &fn))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                            "STATISTICS",
+                                                            "DATABASE",
+                                                            &fn))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "STATISTICS",
                                "DATABASE");
     return;
   }
-  if ( (GNUNET_OK !=
-        GNUNET_DISK_file_size (fn,
-                               &fsize,
-                               GNUNET_NO,
-                               GNUNET_YES)) ||
-       (0 == fsize) )
+  if ((GNUNET_OK !=
+       GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) ||
+      (0 == fsize))
   {
     GNUNET_free (fn);
     return;
@@ -1066,39 +972,25 @@ load ()
     GNUNET_free (fn);
     return;
   }
-  if (GNUNET_OK !=
-      GNUNET_BIO_read (rh,
-                       fn,
-                       buf,
-                       fsize))
+  if (GNUNET_OK != GNUNET_BIO_read (rh, fn, buf, fsize))
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                              "read",
-                              fn);
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_BIO_read_close (rh,
-                                        NULL));
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fn);
+    GNUNET_break (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
     GNUNET_free (buf);
     GNUNET_free (fn);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Loading %llu bytes of statistics from `%s'\n"),
+              _ ("Loading %llu bytes of statistics from `%s'\n"),
               (unsigned long long) fsize,
-             fn);
-  mst = GNUNET_MST_create (&inject_message,
-                          NULL);
-  GNUNET_break (GNUNET_OK ==
-                GNUNET_MST_from_buffer (mst,
-                                       buf,
-                                       (size_t) fsize,
-                                       GNUNET_YES,
-                                       GNUNET_NO));
+              fn);
+  mst = GNUNET_MST_create (&inject_message, NULL);
+  GNUNET_break (
+    GNUNET_OK ==
+    GNUNET_MST_from_buffer (mst, buf, (size_t) fsize, GNUNET_YES, GNUNET_NO));
   GNUNET_MST_destroy (mst);
   GNUNET_free (buf);
-  GNUNET_break (GNUNET_OK ==
-                GNUNET_BIO_read_close (rh,
-                                       NULL));
+  GNUNET_break (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
   GNUNET_free (fn);
 }
 
@@ -1118,38 +1010,37 @@ run (void *cls,
   cfg = c;
   nc = GNUNET_notification_context_create (16);
   load ();
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
 
 /**
  * Define "main" method using service macro.
  */
-GNUNET_SERVICE_MAIN
-("statistics",
- GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_var_size (set,
-                       GNUNET_MESSAGE_TYPE_STATISTICS_SET,
-                       struct GNUNET_STATISTICS_SetMessage,
-                       NULL),
- GNUNET_MQ_hd_var_size (get,
-                       GNUNET_MESSAGE_TYPE_STATISTICS_GET,
-                       struct GNUNET_MessageHeader,
-                       NULL),
- GNUNET_MQ_hd_var_size (watch,
-                       GNUNET_MESSAGE_TYPE_STATISTICS_WATCH,
-                       struct GNUNET_MessageHeader,
-                       NULL),
- GNUNET_MQ_hd_fixed_size (disconnect,
-                         GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT,
-                         struct GNUNET_MessageHeader,
-                         NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN (
+  "statistics",
 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN,
 &run,
 &client_connect_cb,
 &client_disconnect_cb,
 NULL,
 GNUNET_MQ_hd_var_size (set,
+                         GNUNET_MESSAGE_TYPE_STATISTICS_SET,
+                         struct GNUNET_STATISTICS_SetMessage,
+                         NULL),
 GNUNET_MQ_hd_var_size (get,
+                         GNUNET_MESSAGE_TYPE_STATISTICS_GET,
+                         struct GNUNET_MessageHeader,
+                         NULL),
 GNUNET_MQ_hd_var_size (watch,
+                         GNUNET_MESSAGE_TYPE_STATISTICS_WATCH,
+                         struct GNUNET_MessageHeader,
+                         NULL),
 GNUNET_MQ_hd_fixed_size (disconnect,
+                           GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT,
+                           struct GNUNET_MessageHeader,
+                           NULL),
 GNUNET_MQ_handler_end ());
 
 
 #if defined(LINUX) && defined(__GLIBC__)
@@ -1158,8 +1049,7 @@ GNUNET_SERVICE_MAIN
 /**
  * MINIMIZE heap size (way below 128k) since this process doesn't need much.
  */
-void __attribute__ ((constructor))
-GNUNET_STATISTICS_memory_init ()
+void __attribute__ ((constructor)) GNUNET_STATISTICS_memory_init ()
 {
   mallopt (M_TRIM_THRESHOLD, 4 * 1024);
   mallopt (M_TOP_PAD, 1 * 1024);
index bc30670e998e43858a946623050fa2ad524bd6c3..f1ea8cb194cb38fb4ee5e87ef006403aabf0f402 100644 (file)
@@ -216,7 +216,7 @@ printer (void *cls, const struct GNUNET_HashCode *key, void *value)
     if (GNUNET_YES == watch)
     {
       now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-      FPRINTF (stdout,
+      fprintf (stdout,
                "%24s%s %s%s%12s%s %s%50s%s%s ",
                now_str,
                csv_separator,
@@ -231,7 +231,7 @@ printer (void *cls, const struct GNUNET_HashCode *key, void *value)
     }
     else
     {
-      FPRINTF (stdout,
+      fprintf (stdout,
                "%s%s%12s%s %s%50s%s%s ",
                value_set->is_persistent ? "!" : " ",
                csv_separator,
@@ -245,12 +245,12 @@ printer (void *cls, const struct GNUNET_HashCode *key, void *value)
   }
   for (unsigned i = 0; i < num_nodes; i++)
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%16llu%s",
              (unsigned long long) value_set->values[i],
              csv_separator);
   }
-  FPRINTF (stdout, "\n");
+  fprintf (stdout, "\n");
   GNUNET_free (value_set->subsystem);
   GNUNET_free (value_set->name);
   GNUNET_free (value_set->values);
@@ -283,7 +283,7 @@ printer_watch (void *cls,
     if (GNUNET_YES == watch)
     {
       now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-      FPRINTF (stdout,
+      fprintf (stdout,
                "%24s%s %s%s%12s%s %s%50s%s%s %16llu\n",
                now_str,
                csv_separator,
@@ -299,7 +299,7 @@ printer_watch (void *cls,
     }
     else
     {
-      FPRINTF (stdout,
+      fprintf (stdout,
                "%s%s%12s%s %s%50s%s%s %16llu\n",
                is_persistent ? "!" : " ",
                csv_separator,
@@ -313,7 +313,7 @@ printer_watch (void *cls,
     }
   }
   else
-    FPRINTF (stdout, "%llu\n", (unsigned long long) value);
+    fprintf (stdout, "%llu\n", (unsigned long long) value);
 
   return GNUNET_OK;
 }
@@ -401,9 +401,9 @@ continuation_print (void *cls, int success)
   if (GNUNET_OK != success)
   {
     if (NULL == remote_host)
-      FPRINTF (stderr, "%s", _ ("Failed to obtain statistics.\n"));
+      fprintf (stderr, "%s", _ ("Failed to obtain statistics.\n"));
     else
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ ("Failed to obtain statistics from host `%s:%llu'\n"),
                remote_host,
                remote_port);
@@ -439,9 +439,9 @@ cleanup (void *cls, int success)
   if (GNUNET_OK != success)
   {
     if (NULL == remote_host)
-      FPRINTF (stderr, "%s", _ ("Failed to obtain statistics.\n"));
+      fprintf (stderr, "%s", _ ("Failed to obtain statistics.\n"));
     else
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ ("Failed to obtain statistics from host `%s:%llu'\n"),
                remote_host,
                remote_port);
@@ -478,7 +478,7 @@ collector (void *cls,
 
   len_subsys_name = strlen (subsystem) + 3 + strlen (name) + 1;
   subsys_name = GNUNET_malloc (len_subsys_name);
-  SPRINTF (subsys_name, "%s---%s", subsystem, name);
+  sprintf (subsys_name, "%s---%s", subsystem, name);
   key = &hc;
   GNUNET_CRYPTO_hash (subsys_name, len_subsys_name, key);
   GNUNET_free (subsys_name);
@@ -515,13 +515,13 @@ main_task (void *cls)
   {
     if (NULL == subsystem)
     {
-      FPRINTF (stderr, "%s", _ ("Missing argument: subsystem \n"));
+      fprintf (stderr, "%s", _ ("Missing argument: subsystem \n"));
       ret = 1;
       return;
     }
     if (NULL == name)
     {
-      FPRINTF (stderr, "%s", _ ("Missing argument: name\n"));
+      fprintf (stderr, "%s", _ ("Missing argument: name\n"));
       ret = 1;
       return;
     }
@@ -605,7 +605,7 @@ iter_check_config (void *cls, const char *filename)
     if (GNUNET_OK !=
         GNUNET_CONFIGURATION_load (nodes[num_nodes - 1].conf, filename))
     {
-      FPRINTF (stderr, "Failed loading config `%s'\n", filename);
+      fprintf (stderr, "Failed loading config `%s'\n", filename);
       return GNUNET_SYSERR;
     }
     return GNUNET_NO;
@@ -636,7 +636,7 @@ iter_testbed_path (void *cls, const char *filename)
   unsigned index_node;
 
   GNUNET_assert (NULL != filename);
-  if (1 == SSCANF (GNUNET_STRINGS_get_short_name (filename), "%u", &index_node))
+  if (1 == sscanf (GNUNET_STRINGS_get_short_name (filename), "%u", &index_node))
   {
     if (-1 == GNUNET_DISK_directory_scan (filename, iter_check_config, NULL))
     {
@@ -665,7 +665,7 @@ discover_testbed_nodes (const char *path_testbed)
     GNUNET_DISK_directory_scan (path_testbed, iter_testbed_path, NULL);
   if (-1 == num_dir_entries)
   {
-    FPRINTF (stderr, "Failure during scanning directory `%s'\n", path_testbed);
+    fprintf (stderr, "Failure during scanning directory `%s'\n", path_testbed);
     return -1;
   }
   return 0;
@@ -693,9 +693,9 @@ run (void *cls,
     csv_separator = "";
   if (NULL != args[0])
   {
-    if (1 != SSCANF (args[0], "%llu", &set_val))
+    if (1 != sscanf (args[0], "%llu", &set_val))
     {
-      FPRINTF (stderr, _ ("Invalid argument `%s'\n"), args[0]);
+      fprintf (stderr, _ ("Invalid argument `%s'\n"), args[0]);
       ret = 1;
       return;
     }
@@ -710,7 +710,7 @@ run (void *cls,
                                                                   "PORT",
                                                                   &remote_port))
       {
-        FPRINTF (stderr,
+        fprintf (stderr,
                  _ ("A port is required to connect to host `%s'\n"),
                  remote_host);
         return;
@@ -718,7 +718,7 @@ run (void *cls,
     }
     else if (65535 <= remote_port)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ (
                  "A port has to be between 1 and 65535 to connect to host `%s'\n"),
                remote_host);
index 1bfbfda508f8a11162ef3ec28b01a609ce694f8b..7857652e03bb8a5e899ecd1b8e249a993e110ba6 100644 (file)
 #include "testbed_api_topology.h"
 #include "sqlite3.h"
 
-#define LOG(type, ...)                          \
-  GNUNET_log (type, __VA_ARGS__)
+#define LOG(type, ...) GNUNET_log (type, __VA_ARGS__)
 
 
-#define LOG_ERROR(...)                          \
-  LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
+#define LOG_ERROR(...) LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
 
 /**
  * Log an error message at log-level 'level' that indicates
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).
  */
-#define LOG_SQLITE(db, msg, level, cmd)                                 \
-  do {                                                                  \
-    GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \
-                     cmd, __FILE__,__LINE__, sqlite3_errmsg(db));  \
-    if (msg != NULL)                                                    \
-      GNUNET_asprintf(msg, _("`%s' failed at %s:%u with error: %s"), cmd, \
-                      __FILE__, __LINE__, sqlite3_errmsg(db));     \
-  } while(0)
+#define LOG_SQLITE(db, msg, level, cmd)                           \
+  do                                                              \
+  {                                                               \
+    GNUNET_log_from (level,                                       \
+                     "sqlite",                                    \
+                     _ ("`%s' failed at %s:%d with error: %s\n"), \
+                     cmd,                                         \
+                     __FILE__,                                    \
+                     __LINE__,                                    \
+                     sqlite3_errmsg (db));                        \
+    if (msg != NULL)                                              \
+      GNUNET_asprintf (msg,                                       \
+                       _ ("`%s' failed at %s:%u with error: %s"), \
+                       cmd,                                       \
+                       __FILE__,                                  \
+                       __LINE__,                                  \
+                       sqlite3_errmsg (db));                      \
+  } while (0)
 
 
 /**
@@ -97,11 +105,11 @@ link_processor (void *cls,
                 unsigned int latency,
                 unsigned int loss)
 {
-  if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) ||
-       (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) ||
-       (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) ||
-       (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) ||
-       (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss)) )
+  if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) ||
+      (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) ||
+      (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) ||
+      (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) ||
+      (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss)))
   {
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int");
     return GNUNET_SYSERR;
@@ -111,11 +119,11 @@ link_processor (void *cls,
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step");
     return GNUNET_SYSERR;
   }
-  FPRINTF (stdout, "%u -> %u\n", A, B);
+  fprintf (stdout, "%u -> %u\n", A, B);
   GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert));
   //GNUNET_break (SQLITE_OK == sqlite3_clear_bindings (stmt_insert));
-  if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) ||
-       (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A)) )
+  if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) ||
+      (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A)))
   {
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int");
     return GNUNET_SYSERR;
@@ -125,7 +133,7 @@ link_processor (void *cls,
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step");
     return GNUNET_SYSERR;
   }
-  FPRINTF (stdout, "%u -> %u\n", B, A);
+  fprintf (stdout, "%u -> %u\n", B, A);
   GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert));
   return GNUNET_OK;
 }
@@ -142,31 +150,29 @@ link_processor (void *cls,
 static int
 setup_db (const char *dbfile)
 {
-  const char *query_create =
-      "CREATE TABLE whitelist ("
-      "id INTEGER,"
-      "oid INTEGER,"
-      "bandwidth INTEGER DEFAULT NULL,"
-      "latency INTEGER DEFAULT NULL,"
-      "loss INTEGER DEFAULT NULL,"
-      " UNIQUE ("
-      "  id,"
-      "  oid"
-      " ) ON CONFLICT IGNORE"
-      ");";
-  const char *query_insert =
-      "INSERT INTO whitelist("
-      " id,"
-      " oid,"
-      " bandwidth,"
-      " latency,"
-      " loss"
-      ") VALUES ("
-      " ?1,"
-      " ?2,"
-      " ?3,"
-      " ?4,"
-      " ?5);";
+  const char *query_create = "CREATE TABLE whitelist ("
+                             "id INTEGER,"
+                             "oid INTEGER,"
+                             "bandwidth INTEGER DEFAULT NULL,"
+                             "latency INTEGER DEFAULT NULL,"
+                             "loss INTEGER DEFAULT NULL,"
+                             " UNIQUE ("
+                             "  id,"
+                             "  oid"
+                             " ) ON CONFLICT IGNORE"
+                             ");";
+  const char *query_insert = "INSERT INTO whitelist("
+                             " id,"
+                             " oid,"
+                             " bandwidth,"
+                             " latency,"
+                             " loss"
+                             ") VALUES ("
+                             " ?1,"
+                             " ?2,"
+                             " ?3,"
+                             " ?4,"
+                             " ?5);";
   int ret;
 
   ret = GNUNET_SYSERR;
@@ -178,21 +184,23 @@ setup_db (const char *dbfile)
   if (0 != sqlite3_exec (db, query_create, NULL, NULL, NULL))
   {
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
-    FPRINTF (stderr, "Error: %d.  Perhaps the database `%s' already exits.\n",
+    fprintf (stderr,
+             "Error: %d.  Perhaps the database `%s' already exits.\n",
              sqlite3_errcode (db),
              dbfile);
     goto err_ret;
   }
-  GNUNET_break (0 == sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL));
-  if (SQLITE_OK != sqlite3_prepare_v2 (db, query_insert, -1,
-                                       &stmt_insert, NULL))
+  GNUNET_break (0 ==
+                sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL));
+  if (SQLITE_OK !=
+      sqlite3_prepare_v2 (db, query_insert, -1, &stmt_insert, NULL))
   {
     LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2");
     goto err_ret;
   }
   ret = GNUNET_OK;
 
- err_ret:
+err_ret:
   return ret;
 }
 
@@ -206,7 +214,9 @@ setup_db (const char *dbfile)
  * @param cfg the configuration file handle
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *config)
 {
   const char *dbfile;
@@ -222,24 +232,24 @@ run (void *cls, char *const *args, const char *cfgfile,
   arg_uint2 = 0; /* make compilers happy */
   if (NULL == args)
   {
-    LOG_ERROR (_("Need at least 2 arguments\n"));
+    LOG_ERROR (_ ("Need at least 2 arguments\n"));
     return;
   }
   if (NULL == (dbfile = args[argc++]))
   {
-    LOG_ERROR (_("Database filename missing\n"));
+    LOG_ERROR (_ ("Database filename missing\n"));
     return;
   }
   if (GNUNET_OK != setup_db (dbfile))
     return;
   if (NULL == (topology_string = args[argc++]))
   {
-    LOG_ERROR (_("Topology string missing\n"));
+    LOG_ERROR (_ ("Topology string missing\n"));
     return;
   }
   if (GNUNET_YES != GNUNET_TESTBED_topology_get_ (&topology, topology_string))
   {
-    LOG_ERROR (_("Invalid topology: %s\n"), topology_string);
+    LOG_ERROR (_ ("Invalid topology: %s\n"), topology_string);
     return;
   }
   arg_str1 = NULL;
@@ -252,13 +262,13 @@ run (void *cls, char *const *args, const char *cfgfile,
   case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
     if (NULL == (value = args[argc++]))
     {
-      LOG_ERROR (_("An argument is missing for given topology `%s'\n"),
+      LOG_ERROR (_ ("An argument is missing for given topology `%s'\n"),
                  topology_string);
       return;
     }
-    if (-1 == SSCANF (value, "%u", &arg_uint1))
+    if (-1 == sscanf (value, "%u", &arg_uint1))
     {
-      LOG_ERROR (_("Invalid argument `%s' given as topology argument\n"),
+      LOG_ERROR (_ ("Invalid argument `%s' given as topology argument\n"),
                  value);
       return;
     }
@@ -266,7 +276,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
     if (NULL == (arg_str1 = args[argc++]))
     {
-      LOG_ERROR (_("Filename argument missing for topology `%s'\n"),
+      LOG_ERROR (_ ("Filename argument missing for topology `%s'\n"),
                  topology_string);
       return;
     }
@@ -280,13 +290,13 @@ run (void *cls, char *const *args, const char *cfgfile,
   case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
     if (NULL == (value = args[argc++]))
     {
-      LOG_ERROR (_("Second argument for topology `%s' is missing\n"),
+      LOG_ERROR (_ ("Second argument for topology `%s' is missing\n"),
                  topology_string);
       return;
     }
-    if (-1 == SSCANF (value, "%u", &arg_uint2))
+    if (-1 == sscanf (value, "%u", &arg_uint2))
     {
-      LOG_ERROR (_("Invalid argument `%s'; expecting unsigned int\n"), value);
+      LOG_ERROR (_ ("Invalid argument `%s'; expecting unsigned int\n"), value);
       return;
     }
     break;
@@ -301,23 +311,31 @@ run (void *cls, char *const *args, const char *cfgfile,
   case GNUNET_TESTBED_TOPOLOGY_STAR:
   case GNUNET_TESTBED_TOPOLOGY_CLIQUE:
   case GNUNET_TESTBED_TOPOLOGY_2D_TORUS:
-    GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+    GNUNET_TESTBED_underlay_construct_ (num_peers,
+                                        link_processor,
+                                        NULL,
                                         topology);
     break;
   case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
   case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING:
   case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD:
-    GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+    GNUNET_TESTBED_underlay_construct_ (num_peers,
+                                        link_processor,
+                                        NULL,
                                         topology,
                                         arg_uint1);
     break;
   case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
-    GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+    GNUNET_TESTBED_underlay_construct_ (num_peers,
+                                        link_processor,
+                                        NULL,
                                         topology,
                                         arg_str1);
     break;
   case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
-    GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+    GNUNET_TESTBED_underlay_construct_ (num_peers,
+                                        link_processor,
+                                        NULL,
                                         topology,
                                         arg_uint1,
                                         arg_uint2);
@@ -337,37 +355,41 @@ main (int argc, char *const argv[])
   struct GNUNET_GETOPT_CommandLineOption option[] = {
 
     GNUNET_GETOPT_option_uint ('p',
-                                   "num-peers",
-                                   "COUNT",
-                                   gettext_noop ("create COUNT number of peers"),
-                                   &num_peers),
-    GNUNET_GETOPT_OPTION_END
-  };
+                               "num-peers",
+                               "COUNT",
+                               gettext_noop ("create COUNT number of peers"),
+                               &num_peers),
+    GNUNET_GETOPT_OPTION_END};
 
   int ret;
 
   exit_result = GNUNET_SYSERR;
-  ret =
-      GNUNET_PROGRAM_run (argc, argv, "gnunet-underlay-topology",
-                          _("Generates SQLite3 database representing a given underlay topology.\n"
-                            "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n"
-                            "The following options are available for TOPO followed by TOPOOPTS if applicable:\n"
-                            "\t LINE\n"
-                            "\t RING\n"
-                            "\t RANDOM <num_rnd_links>\n"
-                            "\t SMALL_WORLD <num_rnd_links>\n"
-                            "\t SMALL_WORLD_RING <num_rnd_links>\n"
-                            "\t CLIQUE\n"
-                            "\t 2D_TORUS\n"
-                            "\t SCALE_FREE <cap> <m>\n"
-                            "\t FROM_FILE <filename>\n"
-                            "TOPOOPTS:\n"
-                            "\t num_rnd_links: The number of random links\n"
-                            "\t cap: the maximum number of links a node can have\n"
-                            "\t m: the number of links a node should have while joining the network\n"
-                            "\t filename: the path of the file which contains topology information\n"
-                            "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"),
-                          option, &run, NULL);
+  ret = GNUNET_PROGRAM_run (
+    argc,
+    argv,
+    "gnunet-underlay-topology",
+    _ (
+      "Generates SQLite3 database representing a given underlay topology.\n"
+      "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n"
+      "The following options are available for TOPO followed by TOPOOPTS if applicable:\n"
+      "\t LINE\n"
+      "\t RING\n"
+      "\t RANDOM <num_rnd_links>\n"
+      "\t SMALL_WORLD <num_rnd_links>\n"
+      "\t SMALL_WORLD_RING <num_rnd_links>\n"
+      "\t CLIQUE\n"
+      "\t 2D_TORUS\n"
+      "\t SCALE_FREE <cap> <m>\n"
+      "\t FROM_FILE <filename>\n"
+      "TOPOOPTS:\n"
+      "\t num_rnd_links: The number of random links\n"
+      "\t cap: the maximum number of links a node can have\n"
+      "\t m: the number of links a node should have while joining the network\n"
+      "\t filename: the path of the file which contains topology information\n"
+      "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"),
+    option,
+    &run,
+    NULL);
   if (NULL != stmt_insert)
     sqlite3_finalize (stmt_insert);
   if (NULL != db)
index 72d7fe16f997ee1ddc8dcc75d58bba12aebaa07e..a45f8de03ccda59029ed60264b4581ad93161d1d 100644 (file)
@@ -267,7 +267,7 @@ child_death_task (void *cls)
     GNUNET_OS_process_destroy (testbed);
     testbed = NULL;
     /* Send SIGTERM to our process group */
-    if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG))
+    if (0 != kill (0, GNUNET_TERM_SIG))
     {
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal");
       GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */
index 8c976e13ba4a015ae109652c26961f1fb7f48ecc..1d1d1ce445c288dfbba9f795b5868d962a55cf76 100644 (file)
@@ -853,7 +853,7 @@ host_habitable_cb (void *cls,
   hc_handle = NULL;
   if (GNUNET_NO == status)
   {
-    (void) PRINTF ("%s",
+    (void) printf ("%s",
                    "Unable to run the test as this system is not configured "
                    "to use password less SSH logins to localhost.\n"
                    "Skipping test\n");
@@ -895,7 +895,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   {
     GNUNET_TESTBED_host_destroy (host);
     host = NULL;
-    (void) PRINTF ("%s",
+    (void) printf ("%s",
                    "Unable to run the test as this system is not configured "
                    "to use password less SSH logins to localhost.\n"
                    "Skipping test\n");
index 181d7d86d25acb8c7dc6cde2c878aedd862227e2..6c1a24f9c53a2d35118138e9ed412c0418a79da0 100644 (file)
 /**
  * Generic logging shortcut
  */
-#define LOG(kind,...)                          \
-  GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
 
 /**
  * Debug logging shorthand
  */
-#define LOG_DEBUG(...)                         \
-  LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 
 /**
  * Different stages in testing
@@ -294,15 +292,18 @@ static enum Stage result;
 /**
  * shortcut to exit during failure
  */
-#define FAIL_TEST(cond) do {                                    \
-    if (!(cond)) {                                              \
-      GNUNET_break(0);                                          \
-      if (NULL != abort_task)               \
-        GNUNET_SCHEDULER_cancel (abort_task);                   \
-      abort_task = NULL;                    \
-      GNUNET_SCHEDULER_shutdown ();              \
-      return;                                                   \
-    }                                                          \
+#define FAIL_TEST(cond)                       \
+  do                                          \
+  {                                           \
+    if (! (cond))                             \
+    {                                         \
+      GNUNET_break (0);                       \
+      if (NULL != abort_task)                 \
+        GNUNET_SCHEDULER_cancel (abort_task); \
+      abort_task = NULL;                      \
+      GNUNET_SCHEDULER_shutdown ();           \
+      return;                                 \
+    }                                         \
   } while (0)
 
 
@@ -357,9 +358,7 @@ do_shutdown (void *cls)
 static void
 do_abort (void *cls)
 {
-  LOG (GNUNET_ERROR_TYPE_WARNING,
-       "Aborting in stage %d\n",
-       result);
+  LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting in stage %d\n", result);
   abort_task = NULL;
   GNUNET_SCHEDULER_shutdown ();
 }
@@ -430,9 +429,7 @@ delay_task (void *cls)
  * @param emsg NULL if peer is not NULL; else MAY contain the error description
  */
 static void
-peer_create_cb (void *cls,
-                struct GNUNET_TESTBED_Peer *peer,
-                const char *emsg)
+peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
 {
   FAIL_TEST (NULL != peer);
   FAIL_TEST (NULL == emsg);
@@ -455,11 +452,10 @@ peer_create_cb (void *cls,
     slave2_peer = peer;
     GNUNET_TESTBED_operation_done (op);
     op = NULL;
-    delay_task_id =
-        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                      (GNUNET_TIME_UNIT_SECONDS, 1),
-                                      &delay_task,
-                                      NULL);
+    delay_task_id = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+      &delay_task,
+      NULL);
     return;
   case SLAVE3_STARTED:
     result = SLAVE3_PEER_CREATE_SUCCESS;
@@ -500,8 +496,7 @@ check_operation_success (const struct GNUNET_TESTBED_EventInformation *event)
  * @param event information about the event
  */
 static void
-controller_cb (void *cls,
-               const struct GNUNET_TESTBED_EventInformation *event)
+controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 {
   switch (result)
   {
@@ -558,8 +553,8 @@ controller_cb (void *cls,
     result = SLAVE3_PEER_START_SUCCESS;
     sleep (1);
     LOG_DEBUG ("**************************************\n");
-    op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer,
-                                         slave3_peer);
+    op =
+      GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer, slave3_peer);
     FAIL_TEST (NULL != op);
     break;
   case SLAVE3_PEER_START_SUCCESS:
@@ -570,10 +565,10 @@ controller_cb (void *cls,
     result = SLAVE2_SLAVE3_PEERS_CONNECTED;
     GNUNET_TESTBED_operation_done (op);
     op = NULL;
-    delay_task_id =
-        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                      (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task,
-                                      NULL);
+    delay_task_id = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+      &delay_task,
+      NULL);
     break;
   case SLAVE1_PEER_STOP_SUCCESS:
     FAIL_TEST (GNUNET_TESTBED_ET_PEER_START == event->type);
@@ -581,8 +576,8 @@ controller_cb (void *cls,
     FAIL_TEST (event->details.peer_start.peer == slave2_peer);
     GNUNET_TESTBED_operation_done (op);
     result = SLAVE2_PEER_START_SUCCESS;
-    op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer,
-                                         slave2_peer);
+    op =
+      GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer, slave2_peer);
     break;
   case SLAVE2_PEER_START_SUCCESS:
     FAIL_TEST (NULL != event);
@@ -592,10 +587,10 @@ controller_cb (void *cls,
     result = MASTER_SLAVE2_PEERS_CONNECTED;
     GNUNET_TESTBED_operation_done (op);
     op = NULL;
-    delay_task_id =
-        GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                      (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task,
-                                      NULL);
+    delay_task_id = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+      &delay_task,
+      NULL);
     break;
   case SLAVE2_SLAVE3_PEERS_CONNECTED:
     FAIL_TEST (GNUNET_TESTBED_ET_PEER_STOP == event->type);
@@ -714,7 +709,8 @@ registration_cont (void *cls, const char *emsg)
  *          GNUNET_TESTBED_controller_stop() shouldn't be called in this case
  */
 static void
-status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
+status_cb (void *cls,
+           const struct GNUNET_CONFIGURATION_Handle *config,
            int status)
 {
   switch (result)
@@ -726,8 +722,10 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
     event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
     event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
     event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
-    mc = GNUNET_TESTBED_controller_connect (host, event_mask,
-                                            &controller_cb, NULL);
+    mc = GNUNET_TESTBED_controller_connect (host,
+                                            event_mask,
+                                            &controller_cb,
+                                            NULL);
     FAIL_TEST (NULL != mc);
     result = MASTER_STARTED;
     op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL);
@@ -759,7 +757,7 @@ host_habitable_cb (void *cls,
   hc_handle = NULL;
   if (GNUNET_NO == status)
   {
-    (void) PRINTF ("%s",
+    (void) printf ("%s",
                    "Unable to run the test as this system is not configured "
                    "to use password less SSH logins to localhost.\n"
                    "Skipping test\n");
@@ -769,8 +767,7 @@ host_habitable_cb (void *cls,
     result = SKIP;
     return;
   }
-  cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb,
-                                        NULL);
+  cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, NULL);
 }
 
 
@@ -783,34 +780,35 @@ host_habitable_cb (void *cls,
  * @param cfg the configuration file handle
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *config)
 {
   cfg = GNUNET_CONFIGURATION_dup (config);
   host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0);
   FAIL_TEST (NULL != host);
-  if (NULL ==
-      (hc_handle =
-       GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,
-                                         NULL)))
+  if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host,
+                                                             config,
+                                                             &host_habitable_cb,
+                                                             NULL)))
   {
     GNUNET_TESTBED_host_destroy (host);
     GNUNET_CONFIGURATION_destroy (cfg);
     cfg = NULL;
     host = NULL;
-    (void) PRINTF ("%s",
+    (void) printf ("%s",
                    "Unable to run the test as this system is not configured "
                    "to use password less SSH logins to localhost.\n"
                    "Marking test as successful\n");
     result = SKIP;
     return;
   }
-  abort_task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                    (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,
-                                    NULL);
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
-                                 NULL);
+  abort_task = GNUNET_SCHEDULER_add_delayed (
+    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5),
+    &do_abort,
+    NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
 }
 
 
@@ -820,20 +818,21 @@ run (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char **argv)
 {
-  char *const argv2[] = { "test_testbed_api_controllerlink",
-    "-c", "test_testbed_api.conf",
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
+  char *const argv2[] = {"test_testbed_api_controllerlink",
+                         "-c",
+                         "test_testbed_api.conf",
+                         NULL};
+  struct GNUNET_GETOPT_CommandLineOption options[] = {GNUNET_GETOPT_OPTION_END};
   int ret;
 
   result = INIT;
-  ret =
-      GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
-                          "test_testbed_api_controllerlink", "nohelp", options,
-                          &run, NULL);
+  ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1,
+                            argv2,
+                            "test_testbed_api_controllerlink",
+                            "nohelp",
+                            options,
+                            &run,
+                            NULL);
   if (GNUNET_OK != ret)
     return 1;
   switch (result)
@@ -841,7 +840,7 @@ main (int argc, char **argv)
   case SUCCESS:
     return 0;
   case SKIP:
-    return 77;                  /* Mark test as skipped */
+    return 77; /* Mark test as skipped */
   default:
     return 1;
   }
index 6dbd99bc9d7c32ec330e01dcc1050d648cd456ad..e824a5f23ae7c95ce1c1bc4055136912be4bc201 100644 (file)
 /**
  * Generic logging shorthand
  */
-#define LOG(kind, ...)                          \
-  GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
+#define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
 
 /**
  * Debug logging shorthand
  */
-#define LOG_DEBUG(...)                          \
-  LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
+#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
 
 /**
  * Prints API violation message
  */
-#define API_VIOLATION(cond,errstr)              \
-  do {                                          \
-    if (cond)                                   \
-      break;                                    \
+#define API_VIOLATION(cond, errstr)                                        \
+  do                                                                       \
+  {                                                                        \
+    if (cond)                                                              \
+      break;                                                               \
     LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \
-    GNUNET_assert (0);                                                  \
+    GNUNET_assert (0);                                                     \
   } while (0)
 
 /**
  * Log an error message at log-level 'level' that indicates a failure of the
  * command 'cmd' with the message given by gai_strerror(rc).
  */
-#define LOG_GAI(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)
+#define LOG_GAI(level, cmd, rc)                       \
+  do                                                  \
+  {                                                   \
+    LOG (level,                                       \
+         _ ("`%s' failed at %s:%d with error: %s\n"), \
+         cmd,                                         \
+         __FILE__,                                    \
+         __LINE__,                                    \
+         gai_strerror (rc));                          \
+  } while (0)
 
 /**
  * Number of extra elements we create space for when we grow host list
@@ -157,7 +165,6 @@ struct GNUNET_TESTBED_Host
    * The port which is to be used for SSH
    */
   uint16_t port;
-
 };
 
 
@@ -201,8 +208,9 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id)
  * @return handle to the host, NULL on error
  */
 struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
-                                   const struct GNUNET_CONFIGURATION_Handle *cfg)
+GNUNET_TESTBED_host_create_by_id_ (
+  uint32_t id,
+  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
 }
@@ -216,7 +224,7 @@ GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
  *         'localhost', but then obviously not globally unique)
  */
 uint32_t
-GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host * host)
+GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host)
 {
   return host->id;
 }
@@ -255,7 +263,7 @@ GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host)
  * @return username to login to the host
  */
 uint16_t
-GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host * host)
+GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host)
 {
   return host->port;
 }
@@ -294,8 +302,9 @@ GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host)
  * @param new_cfg the new configuration to replace the old one
  */
 void
-GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
-                                  const struct GNUNET_CONFIGURATION_Handle *new_cfg)
+GNUNET_TESTBED_host_replace_cfg_ (
+  struct GNUNET_TESTBED_Host *host,
+  const struct GNUNET_CONFIGURATION_Handle *new_cfg)
 {
   GNUNET_CONFIGURATION_destroy (host->cfg);
   host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
@@ -316,11 +325,12 @@ GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
  * @return handle to the host, NULL on error
  */
 struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname,
-                                    const char *username,
-                                    const struct GNUNET_CONFIGURATION_Handle
-                                    *cfg,
-                                    uint16_t port)
+GNUNET_TESTBED_host_create_with_id (
+  uint32_t id,
+  const char *hostname,
+  const char *username,
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  uint16_t port)
 {
   struct GNUNET_TESTBED_Host *host;
   unsigned int new_size;
@@ -337,8 +347,8 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname,
   host->port = (0 == port) ? 22 : port;
   host->cfg = GNUNET_CONFIGURATION_dup (cfg);
   host->opq_parallel_overlay_connect_operations =
-      GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE,
-                                              UINT_MAX);
+    GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE,
+                                            UINT_MAX);
   new_size = host_list_size;
   while (id >= new_size)
     new_size += HOST_LIST_GROW_STEP;
@@ -363,17 +373,24 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname,
  * @return handle to the host, NULL on error
  */
 struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create (const char *hostname, const char *username,
+GNUNET_TESTBED_host_create (const char *hostname,
+                            const char *username,
                             const struct GNUNET_CONFIGURATION_Handle *cfg,
                             uint16_t port)
 {
   static uint32_t uid_generator;
 
   if (NULL == hostname)
-    return GNUNET_TESTBED_host_create_with_id (0, hostname, username,
-                                               cfg, port);
-  return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname,
-                                             username, cfg, port);
+    return GNUNET_TESTBED_host_create_with_id (0,
+                                               hostname,
+                                               username,
+                                               cfg,
+                                               port);
+  return GNUNET_TESTBED_host_create_with_id (++uid_generator,
+                                             hostname,
+                                             username,
+                                             cfg,
+                                             port);
 }
 
 
@@ -389,10 +406,10 @@ GNUNET_TESTBED_host_create (const char *hostname, const char *username,
  * @return number of hosts returned in 'hosts', 0 on error
  */
 unsigned int
-GNUNET_TESTBED_hosts_load_from_file (const char *filename,
-                                     const struct GNUNET_CONFIGURATION_Handle
-                                     *cfg,
-                                     struct GNUNET_TESTBED_Host ***hosts)
+GNUNET_TESTBED_hosts_load_from_file (
+  const char *filename,
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  struct GNUNET_TESTBED_Host ***hosts)
 {
   struct GNUNET_TESTBED_Host *starting_host;
   char *data;
@@ -410,7 +427,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
   GNUNET_assert (NULL != filename);
   if (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
+    LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Hosts file %s not found\n"), filename);
     return 0;
   }
   if (GNUNET_OK !=
@@ -418,14 +435,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
     fs = 0;
   if (0 == fs)
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         _ ("Hosts file %s has no data\n"),
+         filename);
     return 0;
   }
   data = GNUNET_malloc (fs);
   if (fs != GNUNET_DISK_fn_read (filename, data, fs))
   {
     GNUNET_free (data);
-    LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s cannot be read\n"),
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         _ ("Hosts file %s cannot be read\n"),
          filename);
     return 0;
   }
@@ -450,11 +470,12 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       username = NULL;
       hostname = NULL;
       port = 0;
-      if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0))
-          || (-1 == pmatch[3].rm_so))
+      if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) ||
+          (-1 == pmatch[3].rm_so))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                    "Error reading line `%s' in hostfile\n", buf);
+                    "Error reading line `%s' in hostfile\n",
+                    buf);
         buf = &data[offset + 1];
         continue;
       }
@@ -462,19 +483,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       {
         size = pmatch[2].rm_eo - pmatch[2].rm_so;
         username = GNUNET_malloc (size + 1);
-        GNUNET_assert(0 != GNUNET_strlcpy (username,
-                                           buf + pmatch[2].rm_so,
-                                           size + 1));
+        GNUNET_assert (
+          0 != GNUNET_strlcpy (username, buf + pmatch[2].rm_so, size + 1));
       }
       if (-1 != pmatch[5].rm_so)
       {
-        (void) SSCANF (buf + pmatch[5].rm_so, "%5hd", &port);
+        (void) sscanf (buf + pmatch[5].rm_so, "%5hd", &port);
       }
       size = pmatch[3].rm_eo - pmatch[3].rm_so;
       hostname = GNUNET_malloc (size + 1);
-      GNUNET_assert(0 != GNUNET_strlcpy (hostname,
-                                         buf + pmatch[3].rm_so,
-                                         size + 1));
+      GNUNET_assert (
+        0 != GNUNET_strlcpy (hostname, buf + pmatch[3].rm_so, size + 1));
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Successfully read host %s, port %d and user %s from file\n",
            (NULL == hostname) ? "NULL" : hostname,
@@ -483,8 +502,8 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       /* We store hosts in a static list; hence we only require the starting
        * host pointer in that list to access the newly created list of hosts */
       if (NULL == starting_host)
-        starting_host = GNUNET_TESTBED_host_create (hostname, username, cfg,
-                                                    port);
+        starting_host =
+          GNUNET_TESTBED_host_create (hostname, username, cfg, port);
       else
         (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port);
       count++;
@@ -522,7 +541,7 @@ simple_resolve (const char *host)
   struct addrinfo hint;
   unsigned int rc;
 
-  hint.ai_family = AF_INET;    /* IPv4 */
+  hint.ai_family = AF_INET; /* IPv4 */
   hint.ai_socktype = 0;
   hint.ai_protocol = 0;
   hint.ai_addrlen = 0;
@@ -562,13 +581,13 @@ simple_resolve (const char *host)
  * @return number of hosts returned in 'hosts', 0 on error
  */
 unsigned int
-GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
-                                            GNUNET_CONFIGURATION_Handle *cfg,
-                                            struct GNUNET_TESTBED_Host ***hosts)
+GNUNET_TESTBED_hosts_load_from_loadleveler (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  struct GNUNET_TESTBED_Host ***hosts)
 {
-#if !ENABLE_SUPERMUC
+#if ! ENABLE_SUPERMUC
   LOG (GNUNET_ERROR_TYPE_ERROR,
-       _("The function %s is only available when compiled with (--with-ll)\n"),
+       _ ("The function %s is only available when compiled with (--with-ll)\n"),
        __func__);
   GNUNET_assert (0);
 #else
@@ -607,8 +626,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
   }
   GNUNET_free_non_null ((char *) host->username);
   GNUNET_free_non_null ((char *) host->hostname);
-  GNUNET_TESTBED_operation_queue_destroy_
-      (host->opq_parallel_overlay_connect_operations);
+  GNUNET_TESTBED_operation_queue_destroy_ (
+    host->opq_parallel_overlay_connect_operations);
   GNUNET_CONFIGURATION_destroy (host->cfg);
   GNUNET_free (host);
   while (host_list_size >= HOST_LIST_GROW_STEP)
@@ -624,8 +643,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
     host_list_size -= HOST_LIST_GROW_STEP;
   }
   host_list =
-      GNUNET_realloc (host_list,
-                      sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
+    GNUNET_realloc (host_list,
+                    sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
 }
 
 
@@ -636,15 +655,15 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
  * @param controller the controller at which this host is registered
  */
 void
-GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
-                                         const struct GNUNET_TESTBED_Controller
-                                         *const controller)
+GNUNET_TESTBED_mark_host_registered_at_ (
+  struct GNUNET_TESTBED_Host *host,
+  const struct GNUNET_TESTBED_Controller *const controller)
 {
   struct RegisteredController *rc;
 
   for (rc = host->rc_head; NULL != rc; rc = rc->next)
   {
-    if (controller == rc->controller)   /* already registered at controller */
+    if (controller == rc->controller) /* already registered at controller */
     {
       GNUNET_break (0);
       return;
@@ -663,13 +682,13 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
  * @param controller the controller at which this host has to be unmarked
  */
 void
-GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
-                                    const struct GNUNET_TESTBED_Controller
-                                    *const controller)
+GNUNET_TESTBED_deregister_host_at_ (
+  struct GNUNET_TESTBED_Host *host,
+  const struct GNUNET_TESTBED_Controller *const controller)
 {
   struct RegisteredController *rc;
 
-  for (rc = host->rc_head; NULL != rc; rc=rc->next)
+  for (rc = host->rc_head; NULL != rc; rc = rc->next)
     if (controller == rc->controller)
       break;
   if (NULL == rc)
@@ -690,15 +709,15 @@ GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
  * @return GNUNET_YES if registered; GNUNET_NO if not
  */
 int
-GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
-                                    const struct GNUNET_TESTBED_Controller
-                                    *const controller)
+GNUNET_TESTBED_is_host_registered_ (
+  const struct GNUNET_TESTBED_Host *host,
+  const struct GNUNET_TESTBED_Controller *const controller)
 {
   struct RegisteredController *rc;
 
   for (rc = host->rc_head; NULL != rc; rc = rc->next)
   {
-    if (controller == rc->controller)   /* already registered at controller */
+    if (controller == rc->controller) /* already registered at controller */
     {
       return GNUNET_YES;
     }
@@ -746,7 +765,6 @@ struct GNUNET_TESTBED_ControllerProc
    * The message corresponding to send handle
    */
   struct GNUNET_MessageHeader *msg;
-
 };
 
 
@@ -763,7 +781,8 @@ copy_argv (const char *const *argv)
   unsigned int argp;
 
   GNUNET_assert (NULL != argv);
-  for (argp = 0; NULL != argv[argp]; argp++) ;
+  for (argp = 0; NULL != argv[argp]; argp++)
+    ;
   argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1));
   for (argp = 0; NULL != argv[argp]; argp++)
     argv_dup[argp] = GNUNET_strdup (argv[argp]);
@@ -836,19 +855,18 @@ free_argv (char **argv)
 static char **
 gen_rsh_args (const char *port, const char *hostname, const char *username)
 {
-  static const char *default_ssh_args[] = {
-    "ssh",
-    "-o",
-    "BatchMode=yes",
-    "-o",
-    "NoHostAuthenticationForLocalhost=yes",
-    "-o",
-    "StrictHostKeyChecking=no",
-    "-o",
-    "PasswordAuthentication=no",
-    "%h",
-    NULL
-  };
+  static const char *default_ssh_args[] =
+    {"ssh",
+     "-o",
+     "BatchMode=yes",
+     "-o",
+     "NoHostAuthenticationForLocalhost=yes",
+     "-o",
+     "StrictHostKeyChecking=no",
+     "-o",
+     "PasswordAuthentication=no",
+     "%h",
+     NULL};
   char **ssh_args;
   char *ssh_cmd;
   char *ssh_cmd_cp;
@@ -915,7 +933,7 @@ gen_rsh_args (const char *port, const char *hostname, const char *username)
  * @return NULL-terminated args
  */
 static char **
-gen_rsh_suffix_args (const char * const *append_args)
+gen_rsh_suffix_args (const char *const *append_args)
 {
   char **rshell_args;
   char *rshell_cmd;
@@ -937,7 +955,9 @@ gen_rsh_suffix_args (const char * const *append_args)
   if (NULL != append_args)
   {
     for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
-      GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (append_args[append_cnt]));
+      GNUNET_array_append (rshell_args,
+                           cnt,
+                           GNUNET_strdup (append_args[append_cnt]));
   }
   GNUNET_array_append (rshell_args, cnt, NULL);
   return rshell_args;
@@ -957,8 +977,7 @@ gen_rsh_suffix_args (const char * const *append_args)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
  */
 static int
-helper_mst (void *cls,
-            const struct GNUNET_MessageHeader *message)
+helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_TESTBED_ControllerProc *cp = cls;
   const struct GNUNET_TESTBED_HelperReply *msg;
@@ -973,27 +992,28 @@ helper_mst (void *cls,
   GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY ==
                  ntohs (msg->header.type));
   config_size = (uLongf) ntohs (msg->config_size);
-  xconfig_size =
-      (uLongf) (ntohs (msg->header.size) -
-                sizeof (struct GNUNET_TESTBED_HelperReply));
+  xconfig_size = (uLongf) (ntohs (msg->header.size) -
+                           sizeof (struct GNUNET_TESTBED_HelperReply));
   config = GNUNET_malloc (config_size);
-  GNUNET_assert (Z_OK ==
-                 uncompress ((Bytef *) config, &config_size,
-                             (const Bytef *) &msg[1], xconfig_size));
+  GNUNET_assert (Z_OK == uncompress ((Bytef *) config,
+                                     &config_size,
+                                     (const Bytef *) &msg[1],
+                                     xconfig_size));
   /* Replace the configuration template present in the host with the
      controller's running configuration */
   GNUNET_CONFIGURATION_destroy (cp->host->cfg);
   cp->host->cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_assert (GNUNET_CONFIGURATION_deserialize
-                 (cp->host->cfg,
-                 config,
-                 config_size,
-                 NULL));
+  GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->host->cfg,
+                                                   config,
+                                                   config_size,
+                                                   NULL));
   GNUNET_free (config);
   if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
     hostname = "localhost";
   /* Change the hostname so that we can connect to it */
-  GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname",
+  GNUNET_CONFIGURATION_set_value_string (cp->host->cfg,
+                                         "testbed",
+                                         "hostname",
                                          hostname);
   cp->host->locked = GNUNET_NO;
   cp->host->controller_started = GNUNET_YES;
@@ -1077,24 +1097,27 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
   struct GNUNET_TESTBED_HelperInit *msg;
   const struct GNUNET_CONFIGURATION_Handle *cfg;
   const char *hostname;
-  static char *const binary_argv[] = {
-    HELPER_TESTBED_BINARY, NULL
-  };
+  static char *const binary_argv[] = {HELPER_TESTBED_BINARY, NULL};
 
   GNUNET_assert (NULL != host);
   GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
   hostname = NULL;
-  API_VIOLATION (GNUNET_NO == host->locked,
-                 "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
+  API_VIOLATION (
+    GNUNET_NO == host->locked,
+    "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
   host->locked = GNUNET_YES;
-  API_VIOLATION (GNUNET_NO == host->controller_started,
-                 "Attempting to start a controller on a host which is already started a controller");
+  API_VIOLATION (
+    GNUNET_NO == host->controller_started,
+    "Attempting to start a controller on a host which is already started a controller");
   cp = GNUNET_new (struct GNUNET_TESTBED_ControllerProc);
   if (0 == GNUNET_TESTBED_host_get_id_ (host))
   {
-    cp->helper =
-        GNUNET_HELPER_start (GNUNET_YES, HELPER_TESTBED_BINARY, binary_argv,
-                             &helper_mst, &helper_exp_cb, cp);
+    cp->helper = GNUNET_HELPER_start (GNUNET_YES,
+                                      HELPER_TESTBED_BINARY,
+                                      binary_argv,
+                                      &helper_mst,
+                                      &helper_exp_cb,
+                                      cp);
   }
   else
   {
@@ -1112,16 +1135,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
     GNUNET_asprintf (&port, "%u", host->port);
     LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
     if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_filename (cfg, "testbed",
-                                               "HELPER_BINARY_PATH",
-                                               &helper_binary_path_args[0]))
+        GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                 "testbed",
+                                                 "HELPER_BINARY_PATH",
+                                                 &helper_binary_path_args[0]))
       helper_binary_path_args[0] =
-          GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
+        GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
     helper_binary_path_args[1] = NULL;
     rsh_args = gen_rsh_args (port, hostname, username);
-    rsh_suffix_args = gen_rsh_suffix_args ((const char **) helper_binary_path_args);
+    rsh_suffix_args =
+      gen_rsh_suffix_args ((const char **) helper_binary_path_args);
     cp->helper_argv =
-        join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
+      join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
     free_argv (rsh_args);
     free_argv (rsh_suffix_args);
     GNUNET_free (port);
@@ -1129,14 +1154,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
     for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
     {
       aux = argstr;
-      GNUNET_assert (0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
+      GNUNET_assert (
+        0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
       GNUNET_free (aux);
     }
     LOG_DEBUG ("Helper cmd str: %s\n", argstr);
     GNUNET_free (argstr);
-    cp->helper =
-        GNUNET_HELPER_start (GNUNET_NO, cp->helper_argv[0], cp->helper_argv, &helper_mst,
-                             &helper_exp_cb, cp);
+    cp->helper = GNUNET_HELPER_start (GNUNET_NO,
+                                      cp->helper_argv[0],
+                                      cp->helper_argv,
+                                      &helper_mst,
+                                      &helper_exp_cb,
+                                      cp);
     GNUNET_free (helper_binary_path_args[0]);
   }
   if (NULL == cp->helper)
@@ -1152,7 +1181,7 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
   msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg);
   cp->msg = &msg->header;
   cp->shandle =
-      GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
+    GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
   if (NULL == cp->shandle)
   {
     GNUNET_free (msg);
@@ -1249,14 +1278,13 @@ struct GNUNET_TESTBED_HostHabitableCheckHandle
   /**
    * Task id for the habitability check task
    */
-  struct GNUNET_SCHEDULER_Task * habitability_check_task;
+  struct GNUNET_SCHEDULER_Task *habitability_check_task;
 
   /**
    * How long we wait before checking the process status. Should grow
    * exponentially
    */
   struct GNUNET_TIME_Relative wait_time;
-
 };
 
 
@@ -1288,7 +1316,7 @@ habitability_check (void *cls)
   {
     h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
     h->habitability_check_task =
-        GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
+      GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
     return;
   }
   GNUNET_OS_process_destroy (h->auxp);
@@ -1320,11 +1348,11 @@ call_cb:
  *           GNUNET_TESTBED_is_host_habitable_cancel()
  */
 struct GNUNET_TESTBED_HostHabitableCheckHandle *
-GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
-                                  const struct GNUNET_CONFIGURATION_Handle
-                                  *config,
-                                  GNUNET_TESTBED_HostHabitableCallback cb,
-                                  void *cb_cls)
+GNUNET_TESTBED_is_host_habitable (
+  const struct GNUNET_TESTBED_Host *host,
+  const struct GNUNET_CONFIGURATION_Handle *config,
+  GNUNET_TESTBED_HostHabitableCallback cb,
+  void *cb_cls)
 {
   struct GNUNET_TESTBED_HostHabitableCheckHandle *h;
   char **rsh_args;
@@ -1339,11 +1367,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
   h->host = host;
   hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (config, "testbed",
-                                             "HELPER_BINARY_PATH",
-                                             &stat_args[1]))
-    stat_args[1] =
-        GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
+      GNUNET_CONFIGURATION_get_value_filename (config,
+                                               "testbed",
+                                               "HELPER_BINARY_PATH",
+                                               &stat_args[1]))
+    stat_args[1] = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
   GNUNET_asprintf (&port, "%u", host->port);
   rsh_args = gen_rsh_args (port, hostname, host->username);
   GNUNET_free (port);
@@ -1352,22 +1380,26 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
   stat_args[2] = NULL;
   rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
   GNUNET_free (stat_args[1]);
-  h->helper_argv = join_argv ((const char **) rsh_args,
-                              (const char **) rsh_suffix_args);
+  h->helper_argv =
+    join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
   free_argv (rsh_suffix_args);
   free_argv (rsh_args);
-  h->auxp =
-      GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL,
-                                   NULL, NULL, h->helper_argv[0], h->helper_argv);
+  h->auxp = GNUNET_OS_start_process_vap (GNUNET_NO,
+                                         GNUNET_OS_INHERIT_STD_ERR,
+                                         NULL,
+                                         NULL,
+                                         NULL,
+                                         h->helper_argv[0],
+                                         h->helper_argv);
   if (NULL == h->auxp)
   {
-    GNUNET_break (0);           /* Cannot exec SSH? */
+    GNUNET_break (0); /* Cannot exec SSH? */
     GNUNET_free (h);
     return NULL;
   }
   h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
   h->habitability_check_task =
-      GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
+    GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
   return h;
 }
 
@@ -1378,9 +1410,8 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
  * @param handle the habitability check handle
  */
 void
-GNUNET_TESTBED_is_host_habitable_cancel (struct
-                                         GNUNET_TESTBED_HostHabitableCheckHandle
-                                         *handle)
+GNUNET_TESTBED_is_host_habitable_cancel (
+  struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
 {
   GNUNET_SCHEDULER_cancel (handle->habitability_check_task);
   (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG);
@@ -1427,7 +1458,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
   hostname = GNUNET_TESTBED_host_get_hostname (host);
   if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n",
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Host hostname: %s already registered\n",
          (NULL == hostname) ? "localhost" : hostname);
     return NULL;
   }
@@ -1486,8 +1518,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
  * @param handle the registration handle to cancel
  */
 void
-GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
-                                    *handle)
+GNUNET_TESTBED_cancel_registration (
+  struct GNUNET_TESTBED_HostRegistrationHandle *handle)
 {
   if (handle != handle->c->rh)
   {
@@ -1511,8 +1543,8 @@ void
 GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h,
                                struct GNUNET_TESTBED_Operation *op)
 {
-  GNUNET_TESTBED_operation_queue_insert_
-      (h->opq_parallel_overlay_connect_operations, op);
+  GNUNET_TESTBED_operation_queue_insert_ (h->opq_parallel_overlay_connect_operations,
+                                          op);
 }
 
 
index ec611ba4c919697839dfe4cdcddd703346ed638b..bc402227c2d122a74f227e876b92dea87eac63f8 100644 (file)
@@ -28,8 +28,7 @@
 #include "gnunet_testing_lib.h"
 
 
-#define LOG(kind,...)                                           \
-  GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__)
 
 
 /**
@@ -84,9 +83,8 @@ static struct GNUNET_SCHEDULER_Task *tid;
 static struct GNUNET_TESTING_Peer *my_peer;
 
 
-
 static int
-create_unique_cfgs (const char * template, const unsigned int no)
+create_unique_cfgs (const char *template, const unsigned int no)
 {
   struct GNUNET_TESTING_System *system;
   int fail;
@@ -95,54 +93,67 @@ create_unique_cfgs (const char * template, const unsigned int no)
   struct GNUNET_CONFIGURATION_Handle *cfg_new;
   struct GNUNET_CONFIGURATION_Handle *cfg_tmpl;
 
-  if (GNUNET_NO == GNUNET_DISK_file_test(template))
+  if (GNUNET_NO == GNUNET_DISK_file_test (template))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Configuration template `%s': file not found\n",
+                create_cfg_template);
     return 1;
   }
-  cfg_tmpl = GNUNET_CONFIGURATION_create();
+  cfg_tmpl = GNUNET_CONFIGURATION_create ();
 
   /* load template */
-  if ((create_cfg_template != NULL) && (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template)))
+  if ((create_cfg_template != NULL) &&
+      (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, create_cfg_template)))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Could not load template `%s'\n",
+                create_cfg_template);
     GNUNET_CONFIGURATION_destroy (cfg_tmpl);
 
     return 1;
   }
   /* load defaults */
-  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl,  NULL))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, NULL))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Could not load template `%s'\n",
+                create_cfg_template);
     GNUNET_CONFIGURATION_destroy (cfg_tmpl);
     return 1;
   }
 
   fail = GNUNET_NO;
-  system = GNUNET_TESTING_system_create ("testing", NULL /* controller */,
-                                         NULL, NULL);
+  system =
+    GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL, NULL);
   for (cur = 0; cur < no; cur++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Creating configuration no. %u \n",
+                cur);
     if (create_cfg_template != NULL)
-      GNUNET_asprintf (&cur_file,"%04u-%s",cur, create_cfg_template);
+      GNUNET_asprintf (&cur_file, "%04u-%s", cur, create_cfg_template);
     else
-      GNUNET_asprintf (&cur_file,"%04u%s",cur, ".conf");
+      GNUNET_asprintf (&cur_file, "%04u%s", cur, ".conf");
 
     cfg_new = GNUNET_CONFIGURATION_dup (cfg_tmpl);
-    if (GNUNET_OK !=
-       GNUNET_TESTING_configuration_create (system, cfg_new))
+    if (GNUNET_OK != GNUNET_TESTING_configuration_create (system, cfg_new))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not create another configuration\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Could not create another configuration\n");
       GNUNET_CONFIGURATION_destroy (cfg_new);
       fail = GNUNET_YES;
       break;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Writing configuration no. %u to file `%s' \n", cur, cur_file);
-    if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file))
+                "Writing configuration no. %u to file `%s' \n",
+                cur,
+                cur_file);
+    if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg_new, cur_file))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Failed to write configuration no. %u \n",
+                  cur);
       fail = GNUNET_YES;
     }
     GNUNET_CONFIGURATION_destroy (cfg_new);
@@ -150,7 +161,7 @@ create_unique_cfgs (const char * template, const unsigned int no)
     if (GNUNET_YES == fail)
       break;
   }
-  GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+  GNUNET_CONFIGURATION_destroy (cfg_tmpl);
   GNUNET_TESTING_system_destroy (system, GNUNET_NO);
   if (GNUNET_YES == fail)
     return 1;
@@ -170,22 +181,27 @@ create_hostkeys (const unsigned int no)
   pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
   if (NULL == pk)
   {
-    fprintf (stderr, _("Could not extract hostkey %u (offset too large?)\n"), create_no);
+    fprintf (stderr,
+             _ ("Could not extract hostkey %u (offset too large?)\n"),
+             create_no);
     GNUNET_TESTING_system_destroy (system, GNUNET_YES);
     return 1;
   }
   (void) GNUNET_DISK_directory_create_for_file (create_hostkey);
-  fd = GNUNET_DISK_file_open (create_hostkey,
-                             GNUNET_DISK_OPEN_READWRITE |
-                             GNUNET_DISK_OPEN_CREATE,
-                             GNUNET_DISK_PERM_USER_READ |
-                             GNUNET_DISK_PERM_USER_WRITE);
+  fd =
+    GNUNET_DISK_file_open (create_hostkey,
+                           GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE,
+                           GNUNET_DISK_PERM_USER_READ |
+                             GNUNET_DISK_PERM_USER_WRITE);
   GNUNET_assert (fd != NULL);
-  ret = GNUNET_DISK_file_write (fd, pk,
-                               sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
+  ret = GNUNET_DISK_file_write (fd,
+                                pk,
+                                sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
-                  "Wrote hostkey to file: `%s'\n", create_hostkey);
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                   "transport-testing",
+                   "Wrote hostkey to file: `%s'\n",
+                   create_hostkey);
   GNUNET_free (pk);
   GNUNET_TESTING_system_destroy (system, GNUNET_YES);
   return 0;
@@ -203,8 +219,10 @@ cleanup (void *cls)
 {
   if (NULL != tmpfilename)
   {
-    if (0 != UNLINK (tmpfilename))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", tmpfilename);
+    if (0 != unlink (tmpfilename))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                "unlink",
+                                tmpfilename);
   }
   if (NULL != tid)
   {
@@ -250,12 +268,14 @@ stdin_cb (void *cls)
     /* ignore whitespace */
     break;
   default:
-    fprintf (stderr, _("Unknown command, use 'q' to quit or 'r' to restart peer\n"));
+    fprintf (stderr,
+             _ ("Unknown command, use 'q' to quit or 'r' to restart peer\n"));
     break;
   }
   tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       fh,
-                                        &stdin_cb, NULL);
+                                        fh,
+                                        &stdin_cb,
+                                        NULL);
 }
 
 
@@ -268,7 +288,8 @@ stdin_cb (void *cls)
  * @param peer handle to the peer
  */
 static void
-testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
+testing_main (void *cls,
+              const struct GNUNET_CONFIGURATION_Handle *cfg,
               struct GNUNET_TESTING_Peer *peer)
 {
   my_peer = peer;
@@ -285,17 +306,17 @@ testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
     GNUNET_break (0);
     return;
   }
-  printf("ok\n%s\n", tmpfilename);
-  fflush(stdout);
+  printf ("ok\n%s\n", tmpfilename);
+  fflush (stdout);
   GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
   fh = GNUNET_DISK_get_handle_from_native (stdin);
   tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       fh,
-                                        &stdin_cb, NULL);
+                                        fh,
+                                        &stdin_cb,
+                                        NULL);
 }
 
 
-
 /**
  * Main function that will be running without scheduler.
  *
@@ -305,13 +326,18 @@ testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
  * @param cfg configuration
  */
 static void
-run_no_scheduler (void *cls, char *const *args, const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
+run_no_scheduler (void *cls,
+                  char *const *args,
+                  const char *cfgfile,
+                  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   if (NULL != run_service_name)
   {
-    ret = GNUNET_TESTING_service_run ("gnunet_service_test", run_service_name,
-                                      cfgfile, &testing_main, NULL);
+    ret = GNUNET_TESTING_service_run ("gnunet_service_test",
+                                      run_service_name,
+                                      cfgfile,
+                                      &testing_main,
+                                      NULL);
     return;
   }
 
@@ -320,7 +346,9 @@ run_no_scheduler (void *cls, char *const *args, const char *cfgfile,
     if (create_no > 0)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Creating %u configuration files based on template `%s'\n", create_no, create_cfg_template);
+                  "Creating %u configuration files based on template `%s'\n",
+                  create_no,
+                  create_cfg_template);
       ret = create_unique_cfgs (create_cfg_template, create_no);
     }
     else
@@ -348,37 +376,42 @@ run_no_scheduler (void *cls, char *const *args, const char *cfgfile,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('C',
-                                  "cfg",
-                                  gettext_noop ("create unique configuration files"),
-                                  &create_cfg),
-    GNUNET_GETOPT_option_string ('k',
-                                 "key",
-                                 "FILENAME",
-                                 gettext_noop ("extract hostkey file from pre-computed hostkey list"),
-                                 &create_hostkey),
-
-    GNUNET_GETOPT_option_uint ('n',
-                                   "number",
-                                   "NUMBER",
-                                   gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"),
-                                   &create_no),
-
-
-    GNUNET_GETOPT_option_string ('t',
-                                 "template",
-                                 "FILENAME",
-                                 gettext_noop ("configuration template"),
-                                 &create_cfg_template),
-
-    GNUNET_GETOPT_option_string ('r',
-                                 "run",
-                                 "SERVICE",
-                                 gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
-                                 &run_service_name),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('C',
+                                "cfg",
+                                gettext_noop (
+                                  "create unique configuration files"),
+                                &create_cfg),
+     GNUNET_GETOPT_option_string (
+       'k',
+       "key",
+       "FILENAME",
+       gettext_noop ("extract hostkey file from pre-computed hostkey list"),
+       &create_hostkey),
+
+     GNUNET_GETOPT_option_uint (
+       'n',
+       "number",
+       "NUMBER",
+       gettext_noop (
+         "number of unique configuration files to create, or number of the hostkey to extract"),
+       &create_no),
+
+
+     GNUNET_GETOPT_option_string ('t',
+                                  "template",
+                                  "FILENAME",
+                                  gettext_noop ("configuration template"),
+                                  &create_cfg_template),
+
+     GNUNET_GETOPT_option_string (
+       'r',
+       "run",
+       "SERVICE",
+       gettext_noop (
+         "run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
+       &run_service_name),
+     GNUNET_GETOPT_OPTION_END};
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
@@ -386,11 +419,20 @@ main (int argc, char *const *argv)
    * GNUNET_TESTING_service_run, which starts the scheduler on its own.
    * Furthermore, the other functionality currently does not require the scheduler, too,
    * but beware when extending gnunet-testing. */
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run2 (argc, argv, "gnunet-testing",
-                            gettext_noop ("Command line tool to access the testing library"), options, &run_no_scheduler,
-                            NULL, GNUNET_YES)) ? ret : 1;
-  GNUNET_free ((void*) argv);
+  ret =
+    (GNUNET_OK ==
+     GNUNET_PROGRAM_run2 (argc,
+                          argv,
+                          "gnunet-testing",
+                          gettext_noop (
+                            "Command line tool to access the testing library"),
+                          options,
+                          &run_no_scheduler,
+                          NULL,
+                          GNUNET_YES))
+      ? ret
+      : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index 9210486d375dfafac7a33abd46bf9e2bfa031852..39a48d071a9a0cb3c8a8d9d4df1e30894d270dfc 100644 (file)
@@ -15,7 +15,9 @@ static int result;
  * @param cfg the configuration file handle
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *config)
 {
   char *idfile;
@@ -30,7 +32,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   if ((NULL == args) || (NULL == args[0]))
   {
-    FPRINTF (stderr, "Need the hostkey file\n");
+    fprintf (stderr, "Need the hostkey file\n");
     return;
   }
   idfile = args[0];
@@ -42,11 +44,11 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
   if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE))
   {
-    FPRINTF (stderr,
-             _("Incorrect hostkey file format: %s\n"), idfile);
+    fprintf (stderr, _ ("Incorrect hostkey file format: %s\n"), idfile);
     return;
   }
-  f = GNUNET_DISK_file_open (idfile, GNUNET_DISK_OPEN_READ,
+  f = GNUNET_DISK_file_open (idfile,
+                             GNUNET_DISK_OPEN_READ,
                              GNUNET_DISK_PERM_NONE);
   if (NULL == f)
   {
@@ -65,14 +67,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   {
     if (nskip + cnt >= nmax)
     {
-      PRINTF ("Max keys %u reached\n", nmax);
+      printf ("Max keys %u reached\n", nmax);
       break;
     }
     GNUNET_memcpy (&pkey,
                    data + (cnt * GNUNET_TESTING_HOSTKEYFILESIZE),
                    GNUNET_TESTING_HOSTKEYFILESIZE);
     GNUNET_CRYPTO_eddsa_key_get_public (&pkey, &id.public_key);
-    PRINTF ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id));
+    printf ("Key %u: %s\n", cnt, GNUNET_i2s_full (&id));
   }
   result = GNUNET_OK;
   GNUNET_DISK_file_unmap (map);
@@ -80,23 +82,28 @@ run (void *cls, char *const *args, const char *cfgfile,
 }
 
 
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
-  struct GNUNET_GETOPT_CommandLineOption option[] = {
-    GNUNET_GETOPT_option_uint ('n',
-                                   "num-keys",
-                                   "COUNT",
-                                   gettext_noop ("list COUNT number of keys"),
-                                   &nkeys),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption option[] =
+    {GNUNET_GETOPT_option_uint ('n',
+                                "num-keys",
+                                "COUNT",
+                                gettext_noop ("list COUNT number of keys"),
+                                &nkeys),
+     GNUNET_GETOPT_OPTION_END};
   int ret;
 
   result = GNUNET_SYSERR;
   nkeys = 10;
   ret =
-      GNUNET_PROGRAM_run (argc, argv, "list-keys", "Lists the peer IDs corresponding to the given keys file\n",
-                          option, &run, NULL);
+    GNUNET_PROGRAM_run (argc,
+                        argv,
+                        "list-keys",
+                        "Lists the peer IDs corresponding to the given keys file\n",
+                        option,
+                        &run,
+                        NULL);
   if (GNUNET_OK != ret)
     return 1;
   if (GNUNET_SYSERR == result)
index 7dbd97294c5d05e8c2a58a153359c8aceb85ae8a..c5c240b371fe68c8f394cb3340f1924f2995b362 100644 (file)
@@ -34,8 +34,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_testing_lib.h"
 
-#define LOG(kind,...)                                           \
-  GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
 
 
 /**
@@ -269,7 +268,8 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
   if (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Hostkeys file not found: %s\n"), filename);
+         _ ("Hostkeys file not found: %s\n"),
+         filename);
     GNUNET_free (filename);
     return GNUNET_SYSERR;
   }
@@ -280,17 +280,19 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
   if (0 == fs)
   {
     GNUNET_free (filename);
-    return GNUNET_SYSERR;       /* File is empty */
+    return GNUNET_SYSERR; /* File is empty */
   }
   if (0 != (fs % GNUNET_TESTING_HOSTKEYFILESIZE))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Incorrect hostkey file format: %s\n"), filename);
+         _ ("Incorrect hostkey file format: %s\n"),
+         filename);
     GNUNET_free (filename);
     return GNUNET_SYSERR;
   }
-  fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
-                                        GNUNET_DISK_PERM_NONE);
+  fd = GNUNET_DISK_file_open (filename,
+                              GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
@@ -298,10 +300,8 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
     return GNUNET_SYSERR;
   }
   GNUNET_free (filename);
-  system->hostkeys_data = GNUNET_DISK_file_map (fd,
-                                               &system->map,
-                                               GNUNET_DISK_MAP_TYPE_READ,
-                                               fs);
+  system->hostkeys_data =
+    GNUNET_DISK_file_map (fd, &system->map, GNUNET_DISK_MAP_TYPE_READ, fs);
   GNUNET_DISK_file_close (fd);
   if (NULL == system->hostkeys_data)
     return GNUNET_SYSERR;
@@ -336,8 +336,10 @@ hostkeys_unload (struct GNUNET_TESTING_System *system)
  * @param value value of the option
  */
 static void
-cfg_copy_iterator (void *cls, const char *section,
-                   const char *option, const char *value)
+cfg_copy_iterator (void *cls,
+                   const char *section,
+                   const char *option,
+                   const char *value)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg2 = cls;
 
@@ -367,14 +369,13 @@ cfg_copy_iterator (void *cls, const char *section,
  * @return handle to this system, NULL on error
  */
 struct GNUNET_TESTING_System *
-GNUNET_TESTING_system_create_with_portrange (const char *testdir,
-                                            const char *trusted_ip,
-                                            const char *hostname,
-                                             const struct
-                                             GNUNET_TESTING_SharedService *
-                                             shared_services,
-                                            uint16_t lowport,
-                                            uint16_t highport)
+GNUNET_TESTING_system_create_with_portrange (
+  const char *testdir,
+  const char *trusted_ip,
+  const char *hostname,
+  const struct GNUNET_TESTING_SharedService *shared_services,
+  uint16_t lowport,
+  uint16_t highport)
 {
   struct GNUNET_TESTING_System *system;
   struct GNUNET_TESTING_SharedService tss;
@@ -411,14 +412,21 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir,
     ss = GNUNET_new (struct SharedService);
     ss->sname = GNUNET_strdup (tss.service);
     ss->cfg = GNUNET_CONFIGURATION_create ();
-    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname,
-                                                 &cfg_copy_iterator, ss->cfg);
-    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "TESTING",
-                                                 &cfg_copy_iterator, ss->cfg);
-    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "PATHS",
-                                                 &cfg_copy_iterator, ss->cfg);
+    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
+                                                 ss->sname,
+                                                 &cfg_copy_iterator,
+                                                 ss->cfg);
+    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
+                                                 "TESTING",
+                                                 &cfg_copy_iterator,
+                                                 ss->cfg);
+    GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
+                                                 "PATHS",
+                                                 &cfg_copy_iterator,
+                                                 ss->cfg);
     ss->share = tss.share;
-    GNUNET_array_append (system->shared_services, system->n_shared_services,
+    GNUNET_array_append (system->shared_services,
+                         system->n_shared_services,
                          ss);
   }
   return system;
@@ -446,18 +454,18 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir,
  * @return handle to this system, NULL on error
  */
 struct GNUNET_TESTING_System *
-GNUNET_TESTING_system_create (const char *testdir,
-                             const char *trusted_ip,
-                             const char *hostname,
-                              const struct GNUNET_TESTING_SharedService *
-                              shared_services)
+GNUNET_TESTING_system_create (
+  const char *testdir,
+  const char *trusted_ip,
+  const char *hostname,
+  const struct GNUNET_TESTING_SharedService *shared_services)
 {
   return GNUNET_TESTING_system_create_with_portrange (testdir,
-                                                     trusted_ip,
-                                                     hostname,
+                                                      trusted_ip,
+                                                      hostname,
                                                       shared_services,
-                                                     LOW_PORT,
-                                                     HIGH_PORT);
+                                                      LOW_PORT,
+                                                      HIGH_PORT);
 }
 
 
@@ -490,7 +498,9 @@ start_shared_service_instance (struct SharedServiceInstance *i)
   GNUNET_free (binary);
   i->proc = GNUNET_OS_start_process (PIPE_CONTROL,
                                      GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                     NULL, NULL, NULL,
+                                     NULL,
+                                     NULL,
+                                     NULL,
                                      libexec_binary,
                                      libexec_binary,
                                      "-c",
@@ -509,7 +519,8 @@ stop_shared_service_instance (struct SharedServiceInstance *i)
   GNUNET_break (0 == i->n_refs);
   if (0 != GNUNET_OS_process_kill (i->proc, GNUNET_TERM_SIG))
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Killing shared service instance (%s) failed\n", i->ss->sname);
+         "Killing shared service instance (%s) failed\n",
+         i->ss->sname);
   (void) GNUNET_OS_process_wait (i->proc);
   GNUNET_OS_process_destroy (i->proc);
   i->proc = NULL;
@@ -525,7 +536,7 @@ stop_shared_service_instance (struct SharedServiceInstance *i)
  */
 void
 GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
-                              int remove_paths)
+                               int remove_paths)
 {
   struct SharedService *ss;
   struct SharedServiceInstance *i;
@@ -589,19 +600,20 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
         On system with either IPv4 or IPv6. A port is considered open if it's
         open in the respective address family
   */
-  hint.ai_family = AF_UNSPEC;  /* IPv4 and IPv6 */
+  hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */
   hint.ai_socktype = 0;
   hint.ai_protocol = 0;
   hint.ai_addrlen = 0;
   hint.ai_addr = NULL;
   hint.ai_canonname = NULL;
   hint.ai_next = NULL;
-  hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */
+  hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */
   port_buckets = system->reserved_ports;
-  for (index = (system->lowport / 32) + 1; index < (system->highport / 32); index++)
+  for (index = (system->lowport / 32) + 1; index < (system->highport / 32);
+       index++)
   {
     xor_image = (UINT32_MAX ^ port_buckets[index]);
-    if (0 == xor_image)        /* Ports in the bucket are full */
+    if (0 == xor_image) /* Ports in the bucket are full */
       continue;
     pos = system->lowport % 32;
     while (pos < 32)
@@ -613,7 +625,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
       }
       open_port = (index * 32) + pos;
       if (open_port >= system->highport)
-       return 0;
+        return 0;
       GNUNET_asprintf (&open_port_str, "%u", (unsigned int) open_port);
       ret = NULL;
       GNUNET_assert (0 == getaddrinfo (NULL, open_port_str, &hint, &ret));
@@ -624,18 +636,16 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
         socket = GNUNET_NETWORK_socket_create (ai->ai_family, SOCK_STREAM, 0);
         if (NULL == socket)
           continue;
-        bind_status = GNUNET_NETWORK_socket_bind (socket,
-                                                  ai->ai_addr,
-                                                  ai->ai_addrlen);
+        bind_status =
+          GNUNET_NETWORK_socket_bind (socket, ai->ai_addr, ai->ai_addrlen);
         GNUNET_NETWORK_socket_close (socket);
         if (GNUNET_OK != bind_status)
           break;
         socket = GNUNET_NETWORK_socket_create (ai->ai_family, SOCK_DGRAM, 0);
         if (NULL == socket)
           continue;
-        bind_status = GNUNET_NETWORK_socket_bind (socket,
-                                                  ai->ai_addr,
-                                                  ai->ai_addrlen);
+        bind_status =
+          GNUNET_NETWORK_socket_bind (socket, ai->ai_addr, ai->ai_addrlen);
         GNUNET_NETWORK_socket_close (socket);
         if (GNUNET_OK != bind_status)
           break;
@@ -645,8 +655,9 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
       if (GNUNET_OK == bind_status)
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "Found a free port %u\n", (unsigned int) open_port);
-       return open_port;
+             "Found a free port %u\n",
+             (unsigned int) open_port);
+        return open_port;
       }
       pos++;
     }
@@ -664,7 +675,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
  */
 void
 GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
-                            uint16_t port)
+                             uint16_t port)
 {
   uint32_t *port_buckets;
   uint16_t bucket;
@@ -676,7 +687,7 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Releasing port %u\n", port);
   if (0 == (port_buckets[bucket] & (1U << pos)))
   {
-    GNUNET_break(0); /* Port was not reserved by us using reserve_port() */
+    GNUNET_break (0); /* Port was not reserved by us using reserve_port() */
     return;
   }
   port_buckets[bucket] &= ~(1U << pos);
@@ -702,8 +713,8 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
  */
 struct GNUNET_CRYPTO_EddsaPrivateKey *
 GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
-                           uint32_t key_number,
-                           struct GNUNET_PeerIdentity *id)
+                            uint32_t key_number,
+                            struct GNUNET_PeerIdentity *id)
 {
   struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
 
@@ -712,17 +723,16 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
   if (key_number >= system->total_hostkeys)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Key number %u does not exist\n"),
+         _ ("Key number %u does not exist\n"),
          key_number);
     return NULL;
   }
   private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey);
   GNUNET_memcpy (private_key,
-         system->hostkeys_data +
-         (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
-         GNUNET_TESTING_HOSTKEYFILESIZE);
-  GNUNET_CRYPTO_eddsa_key_get_public (private_key,
-                                      &id->public_key);
+                 system->hostkeys_data +
+                   (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
+                 GNUNET_TESTING_HOSTKEYFILESIZE);
+  GNUNET_CRYPTO_eddsa_key_get_public (private_key, &id->public_key);
   return private_key;
 }
 
@@ -794,18 +804,17 @@ update_config (void *cls,
 
   if (GNUNET_OK != uc->status)
     return;
-  if (! ((0 == strcmp (option, "PORT"))
-         || (0 == strcmp (option, "UNIXPATH"))
-         || (0 == strcmp (option, "HOSTNAME"))))
+  if (! ((0 == strcmp (option, "PORT")) || (0 == strcmp (option, "UNIXPATH")) ||
+         (0 == strcmp (option, "HOSTNAME"))))
     return;
   GNUNET_asprintf (&single_variable, "single_%s_per_host", section);
   GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section);
-  if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival)))
+  if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
   {
     if ((ival != 0) &&
-        (GNUNET_YES !=
-         GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing",
-                                               single_variable)))
+        (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (uc->cfg,
+                                                             "testing",
+                                                             single_variable)))
     {
       new_port = GNUNET_TESTING_reserve_port (uc->system);
       if (0 == new_port)
@@ -821,37 +830,41 @@ update_config (void *cls,
     }
     else if ((ival != 0) &&
              (GNUNET_YES ==
-              GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing",
+              GNUNET_CONFIGURATION_get_value_yesno (uc->cfg,
+                                                    "testing",
                                                     single_variable)) &&
-             GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing",
+             GNUNET_CONFIGURATION_get_value_number (uc->cfg,
+                                                    "testing",
                                                     per_host_variable,
                                                     &num_per_host))
     {
       /* GNUNET_snprintf (cval, sizeof (cval), "%u", */
       /*                  ival + ctx->fdnum % num_per_host); */
       /* value = cval; */
-      GNUNET_break (0);         /* FIXME */
+      GNUNET_break (0); /* FIXME */
     }
   }
   if (0 == strcmp (option, "UNIXPATH"))
   {
-    if (GNUNET_YES !=
-        GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing",
-                                              single_variable))
+    if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (uc->cfg,
+                                                            "testing",
+                                                            single_variable))
     {
       GNUNET_snprintf (uval,
                        sizeof (uval),
                        "%s/%s.sock",
-                       uc->gnunet_home, section);
+                       uc->gnunet_home,
+                       section);
       value = uval;
     }
     else if ((GNUNET_YES ==
-              GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing",
+              GNUNET_CONFIGURATION_get_value_number (uc->cfg,
+                                                     "testing",
                                                      per_host_variable,
                                                      &num_per_host)) &&
              (num_per_host > 0))
     {
-      GNUNET_break(0);          /* FIXME */
+      GNUNET_break (0); /* FIXME */
     }
   }
   if (0 == strcmp (option, "HOSTNAME"))
@@ -872,8 +885,7 @@ update_config (void *cls,
  * @param section name of the section
  */
 static void
-update_config_sections (void *cls,
-                        const char *section)
+update_config_sections (void *cls, const char *section)
 {
   struct UpdateContext *uc = cls;
   char **ikeys;
@@ -889,13 +901,14 @@ update_config_sections (void *cls,
   val = NULL;
   /* Ignore certain options from sections.  See
      https://gnunet.org/bugs/view.php?id=2476 */
-  if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
-                                                     "TESTING_IGNORE_KEYS"))
+  if (GNUNET_YES ==
+      GNUNET_CONFIGURATION_have_value (uc->cfg, section, "TESTING_IGNORE_KEYS"))
   {
-    GNUNET_assert
-      (GNUNET_YES ==
-       GNUNET_CONFIGURATION_get_value_string (uc->cfg, section,
-                                              "TESTING_IGNORE_KEYS", &val));
+    GNUNET_assert (GNUNET_YES ==
+                   GNUNET_CONFIGURATION_get_value_string (uc->cfg,
+                                                          section,
+                                                          "TESTING_IGNORE_KEYS",
+                                                          &val));
     ptr = val;
     for (ikeys_cnt = 0; NULL != (ptr = strstr (ptr, ";")); ikeys_cnt++)
       ptr++;
@@ -920,18 +933,22 @@ update_config_sections (void *cls,
     for (key = 0; key < ikeys_cnt; key++)
     {
       if (NULL != strstr (ikeys[key], "ADVERTISED_PORT"))
-       break;
+        break;
     }
     if ((key == ikeys_cnt) &&
-       (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
-                                                       "ADVERTISED_PORT")))
+        (GNUNET_YES ==
+         GNUNET_CONFIGURATION_have_value (uc->cfg, section, "ADVERTISED_PORT")))
     {
-      if (GNUNET_OK ==
-         GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr))
+      if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (uc->cfg,
+                                                              section,
+                                                              "PORT",
+                                                              &ptr))
       {
-       GNUNET_CONFIGURATION_set_value_string (uc->cfg, section,
-                                              "ADVERTISED_PORT", ptr);
-       GNUNET_free (ptr);
+        GNUNET_CONFIGURATION_set_value_string (uc->cfg,
+                                               section,
+                                               "ADVERTISED_PORT",
+                                               ptr);
+        GNUNET_free (ptr);
       }
     }
     for (key = 0; key < ikeys_cnt; key++)
@@ -950,19 +967,24 @@ update_config_sections (void *cls,
   if ((NULL != uc->system->trusted_ip) &&
       (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
     ACCEPT_FROM_key = "ACCEPT_FROM6";
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key,
-                                             &orig_allowed_hosts))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (uc->cfg,
+                                                          section,
+                                                          ACCEPT_FROM_key,
+                                                          &orig_allowed_hosts))
   {
     orig_allowed_hosts = GNUNET_strdup ("127.0.0.1;");
   }
   if (NULL == uc->system->trusted_ip)
     allowed_hosts = GNUNET_strdup (orig_allowed_hosts);
   else
-    GNUNET_asprintf (&allowed_hosts, "%s%s;", orig_allowed_hosts,
+    GNUNET_asprintf (&allowed_hosts,
+                     "%s%s;",
+                     orig_allowed_hosts,
                      uc->system->trusted_ip);
   GNUNET_free (orig_allowed_hosts);
-  GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key,
+  GNUNET_CONFIGURATION_set_value_string (uc->cfg,
+                                         section,
+                                         ACCEPT_FROM_key,
                                          allowed_hosts);
   GNUNET_free (allowed_hosts);
 }
@@ -979,15 +1001,17 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
   uint32_t port;
 
   ss->n_peers++;
-  if ( ((0 == ss->share) && (NULL == ss->instances))
-       ||
-       ( (0 != ss->share)
-         && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) )
+  if (((0 == ss->share) && (NULL == ss->instances)) ||
+      ((0 != ss->share) &&
+       (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share))))
   {
     i = GNUNET_new (struct SharedServiceInstance);
     i->ss = ss;
-    (void) GNUNET_asprintf (&gnunet_home, "%s/shared/%s/%u",
-                            system->tmppath, ss->sname, ss->n_instances);
+    (void) GNUNET_asprintf (&gnunet_home,
+                            "%s/shared/%s/%u",
+                            system->tmppath,
+                            ss->sname,
+                            ss->n_instances);
     (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", gnunet_home);
     port = GNUNET_TESTING_reserve_port (system);
     if (0 == port)
@@ -1000,12 +1024,18 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
     temp = GNUNET_CONFIGURATION_dup (ss->cfg);
     (void) GNUNET_asprintf (&i->port_str, "%u", port);
     (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", gnunet_home);
-    GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "GNUNET_HOME",
+    GNUNET_CONFIGURATION_set_value_string (temp,
+                                           "PATHS",
+                                           "GNUNET_HOME",
                                            gnunet_home);
     GNUNET_free (gnunet_home);
-    GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH",
+    GNUNET_CONFIGURATION_set_value_string (temp,
+                                           ss->sname,
+                                           "UNIXPATH",
                                            i->unix_sock);
-    GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT",
+    GNUNET_CONFIGURATION_set_value_string (temp,
+                                           ss->sname,
+                                           "PORT",
                                            i->port_str);
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_write (temp, i->cfg_fn))
     {
@@ -1021,9 +1051,13 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
     GNUNET_assert (0 < ss->n_instances);
     i = ss->instances[ss->n_instances - 1];
   }
-  GNUNET_CONFIGURATION_iterate_section_values(ss->cfg, ss->sname,
-                                              &cfg_copy_iterator, cfg);
-  GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH",
+  GNUNET_CONFIGURATION_iterate_section_values (ss->cfg,
+                                               ss->sname,
+                                               &cfg_copy_iterator,
+                                               cfg);
+  GNUNET_CONFIGURATION_set_value_string (cfg,
+                                         ss->sname,
+                                         "UNIXPATH",
                                          i->unix_sock);
   GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "PORT", i->port_str);
   return i;
@@ -1063,24 +1097,27 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
   uc.status = GNUNET_OK;
   uc.ports = NULL;
   uc.nports = 0;
-  GNUNET_asprintf (&uc.gnunet_home, "%s/%u", system->tmppath,
+  GNUNET_asprintf (&uc.gnunet_home,
+                   "%s/%u",
+                   system->tmppath,
                    system->path_counter++);
   GNUNET_asprintf (&default_config, "%s/config", uc.gnunet_home);
-  GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
-                                         default_config);
-  GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG",
+  GNUNET_CONFIGURATION_set_value_string (cfg,
+                                         "PATHS",
+                                         "DEFAULTCONFIG",
                                          default_config);
+  GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", default_config);
   GNUNET_free (default_config);
-  GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "GNUNET_HOME",
+  GNUNET_CONFIGURATION_set_value_string (cfg,
+                                         "PATHS",
+                                         "GNUNET_HOME",
                                          uc.gnunet_home);
   /* make PORTs and UNIXPATHs unique */
   GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc);
   /* allow connections to services from system trusted_ip host */
   GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc);
   /* enable loopback-based connections between peers */
-  GNUNET_CONFIGURATION_set_value_string (cfg,
-                                        "nat",
-                                        "USE_LOCALADDR", "YES");
+  GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "USE_LOCALADDR", "YES");
   GNUNET_free (uc.gnunet_home);
   if ((NULL != ports) && (NULL != nports))
   {
@@ -1111,7 +1148,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
  */
 int
 GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system,
-                                    struct GNUNET_CONFIGURATION_Handle *cfg)
+                                     struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   return GNUNET_TESTING_configuration_create_ (system, cfg, NULL, NULL);
 }
@@ -1132,10 +1169,10 @@ GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system,
  */
 struct GNUNET_TESTING_Peer *
 GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
-                              struct GNUNET_CONFIGURATION_Handle *cfg,
-                              uint32_t key_number,
-                              struct GNUNET_PeerIdentity *id,
-                              char **emsg)
+                               struct GNUNET_CONFIGURATION_Handle *cfg,
+                               uint32_t key_number,
+                               struct GNUNET_PeerIdentity *id,
+                               char **emsg)
 {
   struct GNUNET_TESTING_Peer *peer;
   struct GNUNET_DISK_FileHandle *fd;
@@ -1157,9 +1194,11 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
     *emsg = NULL;
   if (key_number >= system->total_hostkeys)
   {
-    GNUNET_asprintf (&emsg_,
-                    _("You attempted to create a testbed with more than %u hosts.  Please precompute more hostkeys first.\n"),
-                    (unsigned int) system->total_hostkeys);
+    GNUNET_asprintf (
+      &emsg_,
+      _ (
+        "You attempted to create a testbed with more than %u hosts.  Please precompute more hostkeys first.\n"),
+      (unsigned int) system->total_hostkeys);
     goto err_ret;
   }
   pk = NULL;
@@ -1167,17 +1206,17 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
       (NULL == (pk = GNUNET_TESTING_hostkey_get (system, key_number, id))))
   {
     GNUNET_asprintf (&emsg_,
-                    _("Failed to initialize hostkey for peer %u\n"),
-                    (unsigned int) key_number);
+                     _ ("Failed to initialize hostkey for peer %u\n"),
+                     (unsigned int) key_number);
     goto err_ret;
   }
   if (NULL != pk)
     GNUNET_free (pk);
-  if (GNUNET_NO ==
-      GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY"))
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY"))
   {
-    GNUNET_asprintf (&emsg_,
-                     _("PRIVATE_KEY option in PEER section missing in configuration\n"));
+    GNUNET_asprintf (
+      &emsg_,
+      _ ("PRIVATE_KEY option in PEER section missing in configuration\n"));
     goto err_ret;
   }
   /* Remove sections for shared services */
@@ -1186,46 +1225,50 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
     ss = system->shared_services[cnt];
     GNUNET_CONFIGURATION_remove_section (cfg, ss->sname);
   }
-  if (GNUNET_OK != GNUNET_TESTING_configuration_create_ (system, cfg,
-                                                         &ports, &nports))
+  if (GNUNET_OK !=
+      GNUNET_TESTING_configuration_create_ (system, cfg, &ports, &nports))
   {
     GNUNET_asprintf (&emsg_,
-                     _("Failed to create configuration for peer "
-                       "(not enough free ports?)\n"));
+                     _ ("Failed to create configuration for peer "
+                        "(not enough free ports?)\n"));
     goto err_ret;
   }
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
-                                                         "PRIVATE_KEY",
-                                                         &hostkey_filename));
+                 GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                          "PEER",
+                                                          "PRIVATE_KEY",
+                                                          &hostkey_filename));
   fd = GNUNET_DISK_file_open (hostkey_filename,
                               GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
-                              GNUNET_DISK_PERM_USER_READ
-                              | GNUNET_DISK_PERM_USER_WRITE);
+                              GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE);
   if (NULL == fd)
   {
-    GNUNET_asprintf (&emsg_, _("Cannot open hostkey file `%s': %s\n"),
-                     hostkey_filename, STRERROR (errno));
+    GNUNET_asprintf (&emsg_,
+                     _ ("Cannot open hostkey file `%s': %s\n"),
+                     hostkey_filename,
+                     strerror (errno));
     GNUNET_free (hostkey_filename);
     goto err_ret;
   }
   GNUNET_free (hostkey_filename);
   if (GNUNET_TESTING_HOSTKEYFILESIZE !=
-      GNUNET_DISK_file_write (fd, system->hostkeys_data
-                             + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
-                             GNUNET_TESTING_HOSTKEYFILESIZE))
+      GNUNET_DISK_file_write (fd,
+                              system->hostkeys_data +
+                                (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
+                              GNUNET_TESTING_HOSTKEYFILESIZE))
   {
     GNUNET_asprintf (&emsg_,
-                    _("Failed to write hostkey file for peer %u: %s\n"),
-                    (unsigned int) key_number,
-                    STRERROR (errno));
+                     _ ("Failed to write hostkey file for peer %u: %s\n"),
+                     (unsigned int) key_number,
+                     strerror (errno));
     GNUNET_DISK_file_close (fd);
     goto err_ret;
   }
   GNUNET_DISK_file_close (fd);
-  ss_instances = GNUNET_malloc (sizeof (struct SharedServiceInstance *)
-                                system->n_shared_services);
-  for (cnt=0; cnt < system->n_shared_services; cnt++)
+  ss_instances = GNUNET_malloc (sizeof (struct SharedServiceInstance *) *
+                                system->n_shared_services);
+  for (cnt = 0; cnt < system->n_shared_services; cnt++)
   {
     ss = system->shared_services[cnt];
     ss_instances[cnt] = associate_shared_service (system, ss, cfg);
@@ -1236,15 +1279,18 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
     }
   }
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_get_value_filename
-                 (cfg, "PATHS", "DEFAULTCONFIG", &config_filename));
+                 GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                          "PATHS",
+                                                          "DEFAULTCONFIG",
+                                                          &config_filename));
   if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
   {
     GNUNET_asprintf (&emsg_,
-                    _("Failed to write configuration file `%s' for peer %u: %s\n"),
-                    config_filename,
-                    (unsigned int) key_number,
-                    STRERROR (errno));
+                     _ (
+                       "Failed to write configuration file `%s' for peer %u: %s\n"),
+                     config_filename,
+                     (unsigned int) key_number,
+                     strerror (errno));
     GNUNET_free (config_filename);
     goto err_ret;
   }
@@ -1253,10 +1299,14 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
   peer->cfgfile = config_filename; /* Free in peer_destroy */
   peer->cfg = GNUNET_CONFIGURATION_dup (cfg);
   libexec_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "arm", "PREFIX", &peer->main_binary))
+  if (GNUNET_SYSERR ==
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "arm",
+                                             "PREFIX",
+                                             &peer->main_binary))
   {
     /* No prefix */
-    GNUNET_asprintf(&peer->main_binary, "%s", libexec_binary);
+    GNUNET_asprintf (&peer->main_binary, "%s", libexec_binary);
     peer->args = GNUNET_strdup ("");
   }
   else
@@ -1266,11 +1316,11 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
   peer->system = system;
   peer->key_number = key_number;
   GNUNET_free (libexec_binary);
-  peer->ports = ports;          /* Free in peer_destroy */
+  peer->ports = ports; /* Free in peer_destroy */
   peer->nports = nports;
   return peer;
 
- err_ret:
+err_ret:
   GNUNET_free_non_null (ss_instances);
   GNUNET_free_non_null (ports);
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_);
@@ -1290,7 +1340,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
  */
 void
 GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
-                                 struct GNUNET_PeerIdentity *id)
+                                  struct GNUNET_PeerIdentity *id)
 {
   if (NULL != peer->id)
   {
@@ -1298,9 +1348,8 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
     return;
   }
   peer->id = GNUNET_new (struct GNUNET_PeerIdentity);
-  GNUNET_free (GNUNET_TESTING_hostkey_get (peer->system,
-                                                         peer->key_number,
-                                                         peer->id));
+  GNUNET_free (
+    GNUNET_TESTING_hostkey_get (peer->system, peer->key_number, peer->id));
   GNUNET_memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity));
 }
 
@@ -1326,26 +1375,28 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
   for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
   {
     i = peer->ss_instances[cnt];
-    if ((0 == i->n_refs)
-        && (GNUNET_SYSERR == start_shared_service_instance (i)) )
+    if ((0 == i->n_refs) &&
+        (GNUNET_SYSERR == start_shared_service_instance (i)))
       return GNUNET_SYSERR;
     i->n_refs++;
   }
-  peer->main_binary = GNUNET_CONFIGURATION_expand_dollar (peer->cfg, peer->main_binary);
-  peer->main_process = GNUNET_OS_start_process_s (PIPE_CONTROL,
-                                                  GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                                  NULL,
-                                                  peer->main_binary,
-                                                  peer->args,
-                                                  "-c",
-                                                  peer->cfgfile,
-                                                  NULL);
+  peer->main_binary =
+    GNUNET_CONFIGURATION_expand_dollar (peer->cfg, peer->main_binary);
+  peer->main_process =
+    GNUNET_OS_start_process_s (PIPE_CONTROL,
+                               GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                               NULL,
+                               peer->main_binary,
+                               peer->args,
+                               "-c",
+                               peer->cfgfile,
+                               NULL);
   if (NULL == peer->main_process)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Failed to start `%s': %s\n"),
-               peer->main_binary,
-               STRERROR (errno));
+                _ ("Failed to start `%s': %s\n"),
+                peer->main_binary,
+                strerror (errno));
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -1433,8 +1484,7 @@ GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer)
  *                  #GNUNET_SYSERR on error.
  */
 static void
-disconn_status (void *cls,
-                int connected)
+disconn_status (void *cls, int connected)
 {
   struct GNUNET_TESTING_Peer *peer = cls;
 
@@ -1551,12 +1601,11 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
  */
 int
 GNUNET_TESTING_peer_run (const char *testdir,
-                        const char *cfgfilename,
-                        GNUNET_TESTING_TestMain tm,
-                        void *tm_cls)
+                         const char *cfgfilename,
+                         GNUNET_TESTING_TestMain tm,
+                         void *tm_cls)
 {
-  return GNUNET_TESTING_service_run (testdir, "arm",
-                                    cfgfilename, tm, tm_cls);
+  return GNUNET_TESTING_service_run (testdir, "arm", cfgfilename, tm, tm_cls);
 }
 
 
@@ -1624,10 +1673,10 @@ service_run_main (void *cls)
  */
 int
 GNUNET_TESTING_service_run (const char *testdir,
-                           const char *service_name,
-                           const char *cfgfilename,
-                           GNUNET_TESTING_TestMain tm,
-                           void *tm_cls)
+                            const char *service_name,
+                            const char *cfgfilename,
+                            GNUNET_TESTING_TestMain tm,
+                            void *tm_cls)
 {
   struct ServiceContext sc;
   struct GNUNET_TESTING_System *system;
@@ -1636,9 +1685,7 @@ GNUNET_TESTING_service_run (const char *testdir,
   char *binary;
   char *libexec_binary;
 
-  GNUNET_log_setup (testdir,
-                    "WARNING",
-                    NULL);
+  GNUNET_log_setup (testdir, "WARNING", NULL);
   system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL, NULL);
   if (NULL == system)
     return 1;
@@ -1646,7 +1693,8 @@ GNUNET_TESTING_service_run (const char *testdir,
   if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgfilename))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-        _("Failed to load configuration from %s\n"), cfgfilename);
+         _ ("Failed to load configuration from %s\n"),
+         cfgfilename);
     GNUNET_CONFIGURATION_destroy (cfg);
     GNUNET_TESTING_system_destroy (system, GNUNET_YES);
     return 1;
@@ -1663,10 +1711,14 @@ GNUNET_TESTING_service_run (const char *testdir,
   GNUNET_free (peer->args);
   GNUNET_asprintf (&binary, "gnunet-service-%s", service_name);
   libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, service_name, "PREFIX", &peer->main_binary))
+  if (GNUNET_SYSERR ==
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             service_name,
+                                             "PREFIX",
+                                             &peer->main_binary))
   {
     /* No prefix */
-    GNUNET_asprintf(&peer->main_binary, "%s", libexec_binary);
+    GNUNET_asprintf (&peer->main_binary, "%s", libexec_binary);
     peer->args = GNUNET_strdup ("");
   }
   else
index 477d218ce774ac073f61bc2ac0c2c58133aa09c2..6b2c5820856bd09338dda9c4f941f5b6cf4d85f9 100644 (file)
@@ -208,7 +208,7 @@ notify_connect_complete (void *cls,
   GNUNET_TESTBED_operation_done (op);
   if (NULL != emsg)
   {
-    FPRINTF (stderr, "Failed to connect two peers: %s\n", emsg);
+    fprintf (stderr, "Failed to connect two peers: %s\n", emsg);
     result = GNUNET_SYSERR;
     GNUNET_SCHEDULER_shutdown ();
     return;
index 576c202784312cc6393944d65e81313193f995af..c883166c66ec1513e2e2ca7f0f89a756ab5c6b7d 100644 (file)
@@ -1103,7 +1103,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
   char *colon;
   char *cp;
 
-  if (1 == SSCANF (bindto, "%u%1s", &port, dummy))
+  if (1 == sscanf (bindto, "%u%1s", &port, dummy))
   {
     /* interpreting value as just a PORT number */
     if (port > UINT16_MAX)
@@ -1146,7 +1146,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
     /* interpet value after colon as port */
     *colon = '\0';
     colon++;
-    if (1 == SSCANF (colon, "%u%1s", &port, dummy))
+    if (1 == sscanf (colon, "%u%1s", &port, dummy))
     {
       /* interpreting value as just a PORT number */
       if (port > UINT16_MAX)
@@ -1877,7 +1877,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "socket(%d) failed: %s",
                 in->sa_family,
-                STRERROR (errno));
+                strerror (errno));
     GNUNET_free (in);
     return GNUNET_SYSERR;
   }
@@ -1886,7 +1886,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "connect to `%s' failed: %s",
                 address,
-                STRERROR (errno));
+                strerror (errno));
     GNUNET_NETWORK_socket_close (sock);
     GNUNET_free (in);
     return GNUNET_SYSERR;
index 68635b5bf32b5f47827c3e877270ea3b37ca1b3e..2c8893d75a8a57d48975e38bdfb2330866fe7409 100644 (file)
@@ -1725,7 +1725,7 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
   char *colon;
   char *cp;
 
-  if (1 == SSCANF (bindto, "%u%1s", &port, dummy))
+  if (1 == sscanf (bindto, "%u%1s", &port, dummy))
   {
     /* interpreting value as just a PORT number */
     if (port > UINT16_MAX)
@@ -1768,7 +1768,7 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
     /* interpet value after colon as port */
     *colon = '\0';
     colon++;
-    if (1 == SSCANF (colon, "%u%1s", &port, dummy))
+    if (1 == sscanf (colon, "%u%1s", &port, dummy))
     {
       /* interpreting value as just a PORT number */
       if (port > UINT16_MAX)
index 1d5029f209514a8fac8f9a837b2c130c5ecf3658..cb1fbc2304140320f599aa00979b24a94e8b062b 100644 (file)
@@ -430,7 +430,7 @@ resend:
               GNUNET_i2s (&queue->target),
               (int) sent,
               (unsigned int) msg_size,
-              (sent < 0) ? STRERROR (errno) : "ok");
+              (sent < 0) ? strerror (errno) : "ok");
   if (-1 != sent)
   {
     GNUNET_STATISTICS_update (stats,
index dbd9014cb7cd2f84d0d60fda4d27f34c295964be..c7ed1b903d8e374799b12d8eefa3d1173578a368 100644 (file)
@@ -140,13 +140,13 @@ stdin_send (void *cls,
   if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
        (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
   {
-    FPRINTF (stderr, "%s", "Received malformed message\n");
+    fprintf (stderr, "%s", "Received malformed message\n");
     exit (1);
   }
   payload_size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
   if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2)
   {
-    FPRINTF (stderr, "%s",  "Packet too big for buffer\n");
+    fprintf (stderr, "%s",  "Packet too big for buffer\n");
     exit (1);
   }
   memset (&newheader, 0, sizeof (newheader));
@@ -184,7 +184,7 @@ file_in_send (void *cls,
   sendsize = ntohs (hdr->size);
   if ((sendsize + write_std->size) > MAXLINE * 2)
   {
-    FPRINTF (stderr, "%s", "Packet too big for buffer\n");
+    fprintf (stderr, "%s", "Packet too big for buffer\n");
     exit (1);
   }
   GNUNET_memcpy (write_std->buf + write_std->size, hdr, sendsize);
@@ -227,7 +227,7 @@ main (int argc, char *argv[])
   if ( (2 != argc) ||
        ((0 != strcmp (argv[1], "1")) && (0 != strcmp (argv[1], "2"))) )
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
             "This program must be started with the operating mode (1 or 2) as the only argument.\n");
     return 1;
@@ -238,7 +238,7 @@ main (int argc, char *argv[])
   if ( (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE1)) ||
        (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE2)) )
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Failed to create directory for file `%s'\n",
              FIFO_FILE1);
     return 1;
@@ -249,7 +249,7 @@ main (int argc, char *argv[])
     {
       erg = mkfifo (FIFO_FILE1, 0666);
       if ( (0 != erg) && (EEXIST != errno) )
-       FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
+       fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
                 strerror (errno));
     }
   }
@@ -259,7 +259,7 @@ main (int argc, char *argv[])
     {
        GNUNET_break (0 == (erg = mkfifo (FIFO_FILE2, 0666)));
       if ( (0 != erg) && (EEXIST != errno) )
-       FPRINTF (stderr,
+       fprintf (stderr,
                  "Error in mkfifo(%s): %s\n",
                  FIFO_FILE2,
                 strerror (errno));
@@ -272,7 +272,7 @@ main (int argc, char *argv[])
     fpin = fopen (FIFO_FILE1, "r");
     if (NULL == fpin)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "fopen of read FIFO_FILE1 failed: %s\n",
                STRERROR (errno));
       goto end;
@@ -284,7 +284,7 @@ main (int argc, char *argv[])
     }
     if (NULL == fpout)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "fopen of write FIFO_FILE2 failed: %s\n",
                STRERROR (errno));
       goto end;
@@ -300,7 +300,7 @@ main (int argc, char *argv[])
     }
     if (NULL == fpout)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "fopen of write FIFO_FILE1 failed: %s\n",
                STRERROR (errno));
       goto end;
@@ -308,7 +308,7 @@ main (int argc, char *argv[])
     fpin = fopen (FIFO_FILE2, "r");
     if (NULL == fpin)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "fopen of read FIFO_FILE2 failed: %s\n",
                STRERROR (errno));
       goto end;
@@ -319,7 +319,7 @@ main (int argc, char *argv[])
   GNUNET_assert (fpin >= 0);
   if (fdpin >= FD_SETSIZE)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "File fdpin number too large (%d > %u)\n",
              fdpin,
              (unsigned int) FD_SETSIZE);
@@ -331,7 +331,7 @@ main (int argc, char *argv[])
 
   if (fdpout >= FD_SETSIZE)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "File fdpout number too large (%d > %u)\n",
              fdpout,
              (unsigned int) FD_SETSIZE);
@@ -395,7 +395,7 @@ main (int argc, char *argv[])
       continue;
     if (0 > retval)
     {
-      FPRINTF (stderr, "select failed: %s\n", STRERROR (errno));
+      fprintf (stderr, "select failed: %s\n", STRERROR (errno));
       closeprog = 1;
       break;
     }
@@ -408,7 +408,7 @@ main (int argc, char *argv[])
       if (0 > ret)
       {
         closeprog = 1;
-        FPRINTF (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
+        fprintf (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
                  STRERROR (errno));
         break;
       }
@@ -433,7 +433,7 @@ main (int argc, char *argv[])
       if (0 > ret)
       {
         closeprog = 1;
-        FPRINTF (stderr, "Write ERROR to fdpout failed: %s\n", STRERROR (errno));
+        fprintf (stderr, "Write ERROR to fdpout failed: %s\n", STRERROR (errno));
       }
       else
       {
@@ -454,7 +454,7 @@ main (int argc, char *argv[])
       if (0 > readsize)
       {
         closeprog = 1;
-        FPRINTF (stderr, "Error reading from STDIN_FILENO: %s\n",
+        fprintf (stderr, "Error reading from STDIN_FILENO: %s\n",
                  STRERROR (errno));
       }
       else if (0 < readsize)
@@ -477,7 +477,7 @@ main (int argc, char *argv[])
       if (0 > readsize)
       {
         closeprog = 1;
-        FPRINTF (stderr, "Error reading from fdpin: %s\n", STRERROR (errno));
+        fprintf (stderr, "Error reading from fdpin: %s\n", STRERROR (errno));
         break;
       }
       else if (0 < readsize)
index 89f5b410863bc1eeec8cbca357f99004886ad9cc..d4f8589d10bf75d3faf4536790ae8f63ad4e1371 100644 (file)
@@ -195,7 +195,7 @@ shutdown_task (void *cls)
   }
 
   if (verbosity > 0)
-    FPRINTF (stdout, "\n");
+    fprintf (stdout, "\n");
 
   /* Output format:
    * All time values in ms
@@ -216,7 +216,7 @@ shutdown_task (void *cls)
       icur->rate = ((benchmark_count * benchmark_size) / 1024) /
                    ((float) icur->dur.rel_value_us / (1000 * 1000));
       if (verbosity > 0)
-        FPRINTF (stdout,
+        fprintf (stdout,
                  _ ("%llu B in %llu ms == %.2f KB/s!\n"),
                  ((long long unsigned int) benchmark_count * benchmark_size),
                  ((long long unsigned int) icur->dur.rel_value_us / 1000),
@@ -252,7 +252,7 @@ shutdown_task (void *cls)
     stddev_duration = sqrtf (stddev_duration);
 
     /* Output */
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%u;%u;%llu;%llu;%.2f;%.2f",
              benchmark_count,
              benchmark_size,
@@ -267,7 +267,7 @@ shutdown_task (void *cls)
       inext = icur->next;
       GNUNET_CONTAINER_DLL_remove (ihead, itail, icur);
 
-      FPRINTF (stdout,
+      fprintf (stdout,
                ";%llu;%.2f",
                (long long unsigned int) (icur->dur.rel_value_us / 1000),
                icur->rate);
@@ -279,14 +279,14 @@ shutdown_task (void *cls)
   if (benchmark_receive)
   {
     duration = GNUNET_TIME_absolute_get_duration (start_time);
-    FPRINTF (stdout,
+    fprintf (stdout,
              "Received %llu bytes/s (%llu bytes in %s)\n",
              1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
              traffic_received,
              GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
   }
 #endif
-  FPRINTF (stdout, "\n");
+  fprintf (stdout, "\n");
 }
 
 
@@ -326,7 +326,7 @@ send_msg (void *cls)
   }
   GNUNET_MQ_send (mq, env);
   if ((verbosity > 0) && (0 == itail->msgs_sent % 10))
-    FPRINTF (stdout, ".");
+    fprintf (stdout, ".");
 }
 
 
@@ -343,7 +343,7 @@ iteration_start ()
   GNUNET_CONTAINER_DLL_insert_tail (ihead, itail, icur);
   icur->start = GNUNET_TIME_absolute_get ();
   if (verbosity > 0)
-    FPRINTF (
+    fprintf (
       stdout,
       "\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
       benchmark_count,
@@ -385,12 +385,12 @@ notify_connect (void *cls,
 {
   if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
   {
-    FPRINTF (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid));
+    fprintf (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid));
     return NULL;
   }
 
   if (verbosity > 0)
-    FPRINTF (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid));
+    fprintf (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid));
   mq = m;
   iteration_start ();
   return NULL;
@@ -415,7 +415,7 @@ notify_disconnect (void *cls,
   mq = NULL;
   if (GNUNET_YES == benchmark_running)
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              "Disconnected from peer `%s' while benchmarking\n",
              GNUNET_i2s (&pid));
     return;
@@ -449,7 +449,7 @@ handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
   if (! benchmark_receive)
     return;
   if (verbosity > 0)
-    FPRINTF (stdout,
+    fprintf (stdout,
              "Received %u bytes\n",
              (unsigned int) ntohs (message->size));
 }
@@ -461,7 +461,7 @@ blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
   if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
   {
     if (verbosity > 0)
-      FPRINTF (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer));
+      fprintf (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer));
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -494,26 +494,26 @@ run (void *cls,
   ret = 1;
   if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size)
   {
-    FPRINTF (stderr, "Message size too big!\n");
+    fprintf (stderr, "Message size too big!\n");
     return;
   }
 
   if (NULL == cpid)
   {
-    FPRINTF (stderr, "No peer identity given\n");
+    fprintf (stderr, "No peer identity given\n");
     return;
   }
   if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid,
                                                                strlen (cpid),
                                                                &pid.public_key))
   {
-    FPRINTF (stderr, "Failed to parse peer identity `%s'\n", cpid);
+    fprintf (stderr, "Failed to parse peer identity `%s'\n", cpid);
     return;
   }
   if (1 == benchmark_send)
   {
     if (verbosity > 0)
-      FPRINTF (stderr,
+      fprintf (stderr,
                "Trying to send %u messages with size %u to peer `%s'\n",
                benchmark_count,
                benchmark_size,
@@ -521,20 +521,20 @@ run (void *cls,
   }
   else if (1 == benchmark_receive)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Trying to receive messages from peer `%s'\n",
              GNUNET_i2s (&pid));
   }
   else
   {
-    FPRINTF (stderr, "No operation given\n");
+    fprintf (stderr, "No operation given\n");
     return;
   }
 
   ats = GNUNET_ATS_connectivity_init (cfg);
   if (NULL == ats)
   {
-    FPRINTF (stderr, "Failed to connect to ATS service\n");
+    fprintf (stderr, "Failed to connect to ATS service\n");
     ret = 1;
     return;
   }
@@ -548,7 +548,7 @@ run (void *cls,
                                           NULL);
   if (NULL == handle)
   {
-    FPRINTF (stderr, "Failed to connect to transport service\n");
+    fprintf (stderr, "Failed to connect to transport service\n");
     GNUNET_ATS_connectivity_done (ats);
     ats = NULL;
     ret = 1;
index 36c8fc451cf25044d1f347eda72cc690363c83ac..ebc3f402d7996953df1e1f06a9431cb997d72c9d 100644 (file)
@@ -402,7 +402,7 @@ shutdown_task (void *cls)
   if (benchmark_send)
   {
     duration = GNUNET_TIME_absolute_get_duration (start_time);
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
              1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
              traffic_sent,
@@ -411,7 +411,7 @@ shutdown_task (void *cls)
   if (benchmark_receive)
   {
     duration = GNUNET_TIME_absolute_get_duration (start_time);
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Received %llu bytes/s (%llu bytes in %s)\n"),
              1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
              traffic_received,
@@ -451,7 +451,7 @@ operation_timeout (void *cls)
   op_timeout = NULL;
   if ((benchmark_send) || (benchmark_receive))
   {
-    FPRINTF (stdout, _ ("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid));
+    fprintf (stdout, _ ("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid));
     GNUNET_SCHEDULER_shutdown ();
     ret = 1;
     return;
@@ -462,7 +462,7 @@ operation_timeout (void *cls)
     while (NULL != (cur = next))
     {
       next = cur->next;
-      FPRINTF (stdout,
+      fprintf (stdout,
                _ ("Failed to resolve address for peer `%s'\n"),
                GNUNET_i2s (&cur->addrcp->peer));
 
@@ -472,7 +472,7 @@ operation_timeout (void *cls)
       GNUNET_free (cur->addrcp);
       GNUNET_free (cur);
     }
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%s",
              _ ("Failed to list connections, timeout occurred\n"));
     GNUNET_SCHEDULER_shutdown ();
@@ -500,7 +500,7 @@ do_send (void *cls)
   traffic_sent += BLOCKSIZE * 1024;
   GNUNET_MQ_notify_sent (env, &do_send, mq);
   if (verbosity > 0)
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Transmitting %u bytes\n"),
              (unsigned int) BLOCKSIZE * 1024);
   GNUNET_MQ_send (mq, env);
@@ -531,7 +531,7 @@ notify_connect (void *cls,
     op_timeout = NULL;
   }
   if (verbosity > 0)
-    FPRINTF (
+    fprintf (
       stdout,
       _ (
         "Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
@@ -562,7 +562,7 @@ notify_disconnect (void *cls,
     return; /* not about target peer */
   if (! benchmark_send)
     return; /* not transmitting */
-  FPRINTF (stdout,
+  fprintf (stdout,
            _ ("Disconnected from peer `%s' while benchmarking\n"),
            GNUNET_i2s (&pid));
 }
@@ -586,7 +586,7 @@ monitor_notify_connect (void *cls,
   const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
 
   monitor_connect_counter++;
-  FPRINTF (stdout,
+  fprintf (stdout,
            _ ("%24s: %-17s %4s   (%u connections in total)\n"),
            now_str,
            _ ("Connected to"),
@@ -615,7 +615,7 @@ monitor_notify_disconnect (void *cls,
   GNUNET_assert (monitor_connect_counter > 0);
   monitor_connect_counter--;
 
-  FPRINTF (stdout,
+  fprintf (stdout,
            _ ("%24s: %-17s %4s   (%u connections in total)\n"),
            now_str,
            _ ("Disconnected from"),
@@ -650,7 +650,7 @@ handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
   if (! benchmark_receive)
     return;
   if (verbosity > 0)
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Received %u bytes\n"),
              (unsigned int) ntohs (message->size));
   if (0 == traffic_received)
@@ -686,7 +686,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
   if (((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
       (GNUNET_YES == monitor_connections))
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Peer `%s': %s %s in state `%s' until %s\n"),
              GNUNET_i2s (id),
              (NULL == transport) ? "<none>" : transport,
@@ -698,7 +698,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
            (GNUNET_TRANSPORT_is_connected (state)))
   {
     /* Only connected peers, skip state */
-    FPRINTF (stdout,
+    fprintf (stdout,
              _ ("Peer `%s': %s %s\n"),
              GNUNET_i2s (id),
              transport,
@@ -732,7 +732,7 @@ process_peer_string (void *cls, const char *address, int res)
   {
     if (GNUNET_SYSERR == res)
     {
-      FPRINTF (
+      fprintf (
         stderr,
         "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
         GNUNET_i2s (&rc->addrcp->peer),
@@ -1094,7 +1094,7 @@ process_peer_monitoring_cb (void *cls,
 
   if (NULL == peer)
   {
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%s",
              _ (
                "Monitor disconnected from transport service. Reconnecting.\n"));
@@ -1189,7 +1189,7 @@ run (void *cls,
 
   if (1 < counter)
   {
-    FPRINTF (
+    fprintf (
       stderr,
       _ (
         "Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
@@ -1204,7 +1204,7 @@ run (void *cls,
   }
   if (0 == counter)
   {
-    FPRINTF (
+    fprintf (
       stderr,
       _ (
         "No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
@@ -1222,7 +1222,7 @@ run (void *cls,
   {
     if (0 == memcmp (&zero_pid, &pid, sizeof (pid)))
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ ("Option `%s' makes no sense without option `%s'.\n"),
                "-D",
                "-p");
@@ -1232,14 +1232,14 @@ run (void *cls,
     blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, NULL);
     if (NULL == blacklist)
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
                _ (
                  "Failed to connect to transport service for disconnection\n"));
       ret = 1;
       return;
     }
-    FPRINTF (stdout,
+    fprintf (stdout,
              "%s",
              _ ("Blacklisting request in place, stop with CTRL-C\n"));
   }
@@ -1247,7 +1247,7 @@ run (void *cls,
   {
     if (0 == memcmp (&zero_pid, &pid, sizeof (pid)))
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                _ ("Option `%s' makes no sense without option `%s'.\n"),
                "-s",
                "-p");
@@ -1263,7 +1263,7 @@ run (void *cls,
                                             NULL);
     if (NULL == handle)
     {
-      FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+      fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
       ret = 1;
       return;
     }
@@ -1289,12 +1289,12 @@ run (void *cls,
                                             NULL);
     if (NULL == handle)
     {
-      FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+      fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
       ret = 1;
       return;
     }
     if (verbosity > 0)
-      FPRINTF (stdout, "%s", _ ("Starting to receive benchmark data\n"));
+      fprintf (stdout, "%s", _ ("Starting to receive benchmark data\n"));
     start_time = GNUNET_TIME_absolute_get ();
   }
   else if (iterate_connections) /* -i: List information about peers once */
@@ -1335,7 +1335,7 @@ run (void *cls,
                                             NULL);
     if (NULL == handle)
     {
-      FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+      fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
       ret = 1;
       return;
     }
index 705c91b85de18408a692a0d780f8c4c0c62ead80..1c61f07d74847990e907c72f8f658a105b83eb04 100644 (file)
@@ -667,7 +667,7 @@ inittransport_smtp (struct GNUNET_CoreAPIForTransport * core)
         stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)"));
   }
   GNUNET_GC_get_configuration_value_filename (core_api->cfg, "SMTP", "PIPE", &pipename);
-  UNLINK (pipename);
+  unlink (pipename);
   if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
   {
     GNUNET_GE_LOG_STRERROR (ectx,
@@ -722,7 +722,7 @@ donetransport_smtp ()
   }
   GNUNET_mutex_destroy (lock);
   lock = NULL;
-  UNLINK (pipename);
+  unlink (pipename);
   GNUNET_free (pipename);
   pipename = NULL;
   GNUNET_free (email);
index a0dd8061701545cfebcf854af1dc8b5e02dee01d..0ea0bf460b55577074a1f52549432eab0f536cb7 100644 (file)
@@ -35,7 +35,7 @@
 #include "gnunet_transport_plugin.h"
 #include "transport.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-tcp",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-tcp", __VA_ARGS__)
 
 #define PLUGIN_NAME "tcp"
 
@@ -86,7 +86,6 @@ void
 LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv);
 
 
-
 /**
  * Function called to notify a client about the connection begin ready
  * to queue more data.  @a buf will be NULL and @a size zero if the
@@ -97,10 +96,9 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv);
  * @param buf where the callee should write the message
  * @return number of bytes written to @a buf
  */
-typedef size_t
-(*GNUNET_CONNECTION_TransmitReadyNotify) (void *cls,
-                                          size_t size,
-                                          void *buf);
+typedef size_t (*GNUNET_CONNECTION_TransmitReadyNotify) (void *cls,
+                                                         size_t size,
+                                                         void *buf);
 
 /**
  * Credentials for UNIX domain sockets.
@@ -127,9 +125,9 @@ struct GNUNET_CONNECTION_Credentials
  * @param client identification of the client; NULL
  *        for the last call when the server is destroyed
  */
-typedef void
-(*GNUNET_SERVER_DisconnectCallback) (void *cls,
-                                     struct GNUNET_SERVER_Client *client);
+typedef void (*GNUNET_SERVER_DisconnectCallback) (
+  void *cls,
+  struct GNUNET_SERVER_Client *client);
 
 
 /**
@@ -139,11 +137,9 @@ typedef void
  * @param cls closure
  * @param client identification of the client
  */
-typedef void
-(*GNUNET_SERVER_ConnectCallback) (void *cls,
-                                  struct GNUNET_SERVER_Client *client);
-
-
+typedef void (*GNUNET_SERVER_ConnectCallback) (
+  void *cls,
+  struct GNUNET_SERVER_Client *client);
 
 
 /**
@@ -156,13 +152,11 @@ typedef void
  * @return GNUNET_YES to allow, GNUNET_NO to deny, GNUNET_SYSERR
  *   for unknown address family (will be denied).
  */
-typedef int
-(*GNUNET_CONNECTION_AccessCheck) (void *cls,
-                                  const struct
-                                  GNUNET_CONNECTION_Credentials *
-                                  ucred,
-                                  const struct sockaddr * addr,
-                                  socklen_t addrlen);
+typedef int (*GNUNET_CONNECTION_AccessCheck) (
+  void *cls,
+  const struct GNUNET_CONNECTION_Credentials *ucred,
+  const struct sockaddr *addr,
+  socklen_t addrlen);
 
 /**
  * Callback function for data received from the network.  Note that
@@ -176,12 +170,12 @@ typedef int
  * @param addrlen size of addr
  * @param errCode value of errno (on errors receiving)
  */
-typedef void
-(*GNUNET_CONNECTION_Receiver) (void *cls, const void *buf,
-                               size_t available,
-                               const struct sockaddr * addr,
-                               socklen_t addrlen, int errCode);
-
+typedef void (*GNUNET_CONNECTION_Receiver) (void *cls,
+                                            const void *buf,
+                                            size_t available,
+                                            const struct sockaddr *addr,
+                                            socklen_t addrlen,
+                                            int errCode);
 
 
 /**
@@ -202,9 +196,9 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection);
  * @param client handle to client the tokenzier will be used for
  * @return handle to custom tokenizer ('mst')
  */
-typedef void*
-(*GNUNET_SERVER_MstCreateCallback) (void *cls,
-                                    struct GNUNET_SERVER_Client *client);
+typedef void *(*GNUNET_SERVER_MstCreateCallback) (
+  void *cls,
+  struct GNUNET_SERVER_Client *client);
 
 
 /**
@@ -213,9 +207,7 @@ typedef void*
  * @param cls closure from #GNUNET_SERVER_set_callbacks
  * @param mst custom tokenizer handle
  */
-typedef void
-(*GNUNET_SERVER_MstDestroyCallback) (void *cls,
-                                     void *mst);
+typedef void (*GNUNET_SERVER_MstDestroyCallback) (void *cls, void *mst);
 
 /**
  * Signature of a function to receive data for a custom tokenizer.
@@ -233,13 +225,14 @@ typedef void
  *         #GNUNET_NO if one_shot was set and we have another message ready
  *         #GNUNET_SYSERR if the data stream is corrupt
  */
-typedef int
-(*GNUNET_SERVER_MstReceiveCallback) (void *cls, void *mst,
-                                     struct GNUNET_SERVER_Client *client,
-                                     const char *buf,
-                                     size_t size,
-                                     int purge,
-                                     int one_shot);
+typedef int (*GNUNET_SERVER_MstReceiveCallback) (
+  void *cls,
+  void *mst,
+  struct GNUNET_SERVER_Client *client,
+  const char *buf,
+  size_t size,
+  int purge,
+  int one_shot);
 /**
  * Functions with this signature are called whenever a message is
  * received.
@@ -248,10 +241,10 @@ typedef int
  * @param client identification of the client
  * @param message the actual message
  */
-typedef void
-(*GNUNET_SERVER_MessageCallback) (void *cls,
-                                  struct GNUNET_SERVER_Client *client,
-                                  const struct GNUNET_MessageHeader *message);
+typedef void (*GNUNET_SERVER_MessageCallback) (
+  void *cls,
+  struct GNUNET_SERVER_Client *client,
+  const struct GNUNET_MessageHeader *message);
 
 /**
  * Message handler.  Each struct specifies how to handle on particular
@@ -281,7 +274,6 @@ struct GNUNET_SERVER_MessageHandler
    * if they do not have the right size.
    */
   uint16_t expected_size;
-
 };
 
 
@@ -311,7 +303,6 @@ enum LEGACY_SERVICE_Options
 };
 
 
-
 /**
  * Ask the server to disconnect from the given client.  This is the
  * same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done,
@@ -348,10 +339,10 @@ GNUNET_SERVER_client_get_user_context_ (struct GNUNET_SERVER_Client *client,
  * @param message the actual message
  * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
  */
-typedef int
-(*GNUNET_SERVER_MessageTokenizerCallback) (void *cls,
-                                           void *client,
-                                           const struct GNUNET_MessageHeader *message);
+typedef int (*GNUNET_SERVER_MessageTokenizerCallback) (
+  void *cls,
+  void *client,
+  const struct GNUNET_MessageHeader *message);
 
 
 /**
@@ -384,9 +375,10 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
 int
 GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
                            void *client_identity,
-                           const char *buf, size_t size,
-                           int purge, int one_shot);
-
+                           const char *buf,
+                           size_t size,
+                           int purge,
+                           int one_shot);
 
 
 /**
@@ -417,7 +409,7 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
  * @param type expected return type (i.e. 'struct Foo')
  * @return pointer to user context of type 'type *'.
  */
-#define GNUNET_SERVER_client_get_user_context(client,type)              \
+#define GNUNET_SERVER_client_get_user_context(client, type) \
   (type *) GNUNET_SERVER_client_get_user_context_ (client, sizeof (type))
 
 /**
@@ -426,11 +418,10 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
  * @param client client to query
  * @param value pointer to user context
  */
-#define GNUNET_SERVER_client_set_user_context(client,value)             \
+#define GNUNET_SERVER_client_set_user_context(client, value) \
   GNUNET_SERVER_client_set_user_context_ (client, value, sizeof (*value))
 
 
-
 /**
  * Notify us when the server has enough space to transmit
  * a message of the given size to the given client.
@@ -447,11 +438,12 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
  *         NULL if we are already going to notify someone else (busy)
  */
 struct GNUNET_SERVER_TransmitHandle *
-GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
-                                     size_t size,
-                                     struct GNUNET_TIME_Relative timeout,
-                                     GNUNET_CONNECTION_TransmitReadyNotify callback,
-                                     void *callback_cls);
+GNUNET_SERVER_notify_transmit_ready (
+  struct GNUNET_SERVER_Client *client,
+  size_t size,
+  struct GNUNET_TIME_Relative timeout,
+  GNUNET_CONNECTION_TransmitReadyNotify callback,
+  void *callback_cls);
 
 /**
  * Abort transmission request.
@@ -459,9 +451,8 @@ GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
  * @param th request to abort
  */
 void
-GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHandle *th);
-
-
+GNUNET_SERVER_notify_transmit_ready_cancel (
+  struct GNUNET_SERVER_TransmitHandle *th);
 
 
 /**
@@ -495,11 +486,10 @@ GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client);
  * @param server the initialized server
  * @param cfg configuration to use
  */
-typedef void
-(*LEGACY_SERVICE_Main) (void *cls,
-                        struct GNUNET_SERVER_Handle *server,
-                        const struct GNUNET_CONFIGURATION_Handle *cfg);
-
+typedef void (*LEGACY_SERVICE_Main) (
+  void *cls,
+  struct GNUNET_SERVER_Handle *server,
+  const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
 /**
@@ -527,11 +517,12 @@ GNUNET_SERVER_suspend (struct GNUNET_SERVER_Handle *server);
  *         NULL if we are already going to notify someone else (busy)
  */
 struct GNUNET_SERVER_TransmitHandle *
-GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
-                                     size_t size,
-                                     struct GNUNET_TIME_Relative timeout,
-                                     GNUNET_CONNECTION_TransmitReadyNotify callback,
-                                     void *callback_cls);
+GNUNET_SERVER_notify_transmit_ready (
+  struct GNUNET_SERVER_Client *client,
+  size_t size,
+  struct GNUNET_TIME_Relative timeout,
+  GNUNET_CONNECTION_TransmitReadyNotify callback,
+  void *callback_cls);
 
 
 /**
@@ -567,8 +558,6 @@ void
 GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *server);
 
 
-
-
 #include "tcp_connection_legacy.c"
 #include "tcp_server_mst_legacy.c"
 #include "tcp_server_legacy.c"
@@ -590,7 +579,6 @@ struct WelcomeMessage
    * Identity of the node connecting (TCP client)
    */
   struct GNUNET_PeerIdentity clientIdentity;
-
 };
 
 /**
@@ -608,7 +596,6 @@ struct TCP_NAT_ProbeMessage
    * Identity of the sender of the message.
    */
   struct GNUNET_PeerIdentity clientIdentity;
-
 };
 GNUNET_NETWORK_STRUCT_END
 
@@ -693,7 +680,6 @@ struct IPv4TcpAddress
    * Port number, in network byte order.
    */
   uint16_t t4_port GNUNET_PACKED;
-
 };
 
 /**
@@ -716,7 +702,6 @@ struct IPv6TcpAddress
    * Port number, in network byte order.
    */
   uint16_t t6_port GNUNET_PACKED;
-
 };
 GNUNET_NETWORK_STRUCT_END
 
@@ -770,7 +755,6 @@ struct PendingMessage
    * instead of just a `struct GNUNET_MessageHeader`.
    */
   size_t message_size;
-
 };
 
 /**
@@ -872,7 +856,6 @@ struct GNUNET_ATS_Session
    * Was this session created using NAT traversal?
    */
   int is_nat;
-
 };
 
 
@@ -1045,7 +1028,6 @@ struct Plugin
    * rest of the world.
    */
   uint16_t adv_port;
-
 };
 
 
@@ -1071,9 +1053,9 @@ struct Plugin
  */
 static int
 get_server_addresses (const char *service_name,
-                     const struct GNUNET_CONFIGURATION_Handle *cfg,
-                     struct sockaddr ***addrs,
-                     socklen_t ** addr_lens)
+                      const struct GNUNET_CONFIGURATION_Handle *cfg,
+                      struct sockaddr ***addrs,
+                      socklen_t **addr_lens)
 {
   int disablev6;
   struct GNUNET_NETWORK_Handle *desc;
@@ -1097,8 +1079,9 @@ get_server_addresses (const char *service_name,
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
   {
     if (GNUNET_SYSERR ==
-        (disablev6 =
-         GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
+        (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                           service_name,
+                                                           "DISABLEV6")))
       return GNUNET_SYSERR;
   }
   else
@@ -1117,8 +1100,10 @@ get_server_addresses (const char *service_name,
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
-           service_name, STRERROR (errno));
+           _ (
+             "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+           service_name,
+           strerror (errno));
       disablev6 = GNUNET_YES;
     }
     else
@@ -1131,18 +1116,19 @@ get_server_addresses (const char *service_name,
   port = 0;
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
   {
-    if (GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
-                                              "PORT", &port))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                            service_name,
+                                                            "PORT",
+                                                            &port))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
     }
     if (port > 65535)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
       return GNUNET_SYSERR;
     }
@@ -1151,8 +1137,10 @@ get_server_addresses (const char *service_name,
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
-                                                         "BINDTO", &hostname));
+                  GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                         service_name,
+                                                         "BINDTO",
+                                                         &hostname));
   }
   else
     hostname = NULL;
@@ -1162,9 +1150,10 @@ get_server_addresses (const char *service_name,
 #ifdef AF_UNIX
   if ((GNUNET_YES ==
        GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
-                                              &unixpath)) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                             service_name,
+                                                             "UNIXPATH",
+                                                             &unixpath)) &&
       (0 < strlen (unixpath)))
   {
     /* probe UNIX support */
@@ -1173,12 +1162,11 @@ get_server_addresses (const char *service_name,
     if (strlen (unixpath) >= sizeof (s_un.sun_path))
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
+           _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
+           unixpath,
            (unsigned long long) sizeof (s_un.sun_path));
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
-      LOG (GNUNET_ERROR_TYPE_INFO,
-          _("Using `%s' instead\n"),
-           unixpath);
+      LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
     }
 #ifdef LINUX
     abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -1187,12 +1175,9 @@ get_server_addresses (const char *service_name,
     if (GNUNET_SYSERR == abstract)
       abstract = GNUNET_NO;
 #endif
-    if ((GNUNET_YES != abstract)
-        && (GNUNET_OK !=
-            GNUNET_DISK_directory_create_for_file (unixpath)))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                               "mkdir",
-                               unixpath);
+    if ((GNUNET_YES != abstract) &&
+        (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
   }
   if (NULL != unixpath)
   {
@@ -1208,9 +1193,10 @@ get_server_addresses (const char *service_name,
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+           _ (
+             "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
            service_name,
-           STRERROR (errno));
+           strerror (errno));
       GNUNET_free (unixpath);
       unixpath = NULL;
     }
@@ -1225,7 +1211,8 @@ get_server_addresses (const char *service_name,
   if ((0 == port) && (NULL == unixpath))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+         _ (
+           "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
          service_name);
     GNUNET_free_non_null (hostname);
     return GNUNET_SYSERR;
@@ -1256,7 +1243,7 @@ get_server_addresses (const char *service_name,
         (NULL == res))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to resolve `%s': %s\n"),
+           _ ("Failed to resolve `%s': %s\n"),
            hostname,
            gai_strerror (ret));
       GNUNET_free (hostname);
@@ -1275,7 +1262,7 @@ get_server_addresses (const char *service_name,
     if (0 == i)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to find %saddress for `%s'.\n"),
+           _ ("Failed to find %saddress for `%s'.\n"),
            disablev6 ? "IPv4 " : "",
            hostname);
       freeaddrinfo (res);
@@ -1301,11 +1288,13 @@ get_server_addresses (const char *service_name,
       if ((disablev6) && (AF_INET6 == pos->ai_family))
         continue;
       if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
-        continue;               /* not TCP */
+        continue; /* not TCP */
       if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
-        continue;               /* huh? */
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
-           service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+        continue; /* huh? */
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Service `%s' will bind to `%s'\n",
+           service_name,
+           GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
       if (AF_INET == pos->ai_family)
       {
         GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
@@ -1412,17 +1401,16 @@ notify_session_monitor (struct Plugin *plugin,
     return;
   memset (&info, 0, sizeof (info));
   info.state = state;
-  info.is_inbound = GNUNET_HELLO_address_check_option (session->address,
-                                         GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+  info.is_inbound =
+    GNUNET_HELLO_address_check_option (session->address,
+                                       GNUNET_HELLO_ADDRESS_INFO_INBOUND);
   info.num_msg_pending = session->msgs_in_queue;
   info.num_bytes_pending = session->bytes_in_queue;
   if (NULL != session->receive_delay_task)
     info.receive_delay = session->receive_delay;
   info.session_timeout = session->timeout;
   info.address = session->address;
-  plugin->sic (plugin->sic_cls,
-               session,
-               &info);
+  plugin->sic (plugin->sic_cls, session, &info);
 }
 
 
@@ -1440,10 +1428,10 @@ notify_session_monitor (struct Plugin *plugin,
  */
 static void
 tcp_nat_port_map_callback (void *cls,
-                          void **app_ctx,
+                           void **app_ctx,
                            int add_remove,
-                          enum GNUNET_NAT_AddressClass ac,
-                          const struct sockaddr *addr,
+                           enum GNUNET_NAT_AddressClass ac,
+                           const struct sockaddr *addr,
                            socklen_t addrlen)
 {
   struct Plugin *plugin = cls;
@@ -1462,8 +1450,8 @@ tcp_nat_port_map_callback (void *cls,
   switch (addr->sa_family)
   {
   case AF_INET:
-    GNUNET_assert(addrlen == sizeof(struct sockaddr_in));
-    memset (&t4, 0, sizeof(t4));
+    GNUNET_assert (addrlen == sizeof (struct sockaddr_in));
+    memset (&t4, 0, sizeof (t4));
     t4.options = htonl (plugin->myoptions);
     t4.ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
     t4.t4_port = ((struct sockaddr_in *) addr)->sin_port;
@@ -1477,32 +1465,30 @@ tcp_nat_port_map_callback (void *cls,
          #tcp_plugin_check_address() */
       return;
     }
-    GNUNET_assert(addrlen == sizeof(struct sockaddr_in6));
-    memset (&t6, 0, sizeof(t6));
+    GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
+    memset (&t6, 0, sizeof (t6));
     GNUNET_memcpy (&t6.ipv6_addr,
-                  &((struct sockaddr_in6 *) addr)->sin6_addr,
-                  sizeof(struct in6_addr));
+                   &((struct sockaddr_in6 *) addr)->sin6_addr,
+                   sizeof (struct in6_addr));
     t6.options = htonl (plugin->myoptions);
     t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port;
     arg = &t6;
     args = sizeof (t6);
     break;
   default:
-    GNUNET_break(0);
+    GNUNET_break (0);
     return;
   }
   /* modify our published address list */
   GNUNET_assert ((args == sizeof (struct IPv4TcpAddress)) ||
-                (args == sizeof (struct IPv6TcpAddress)));
+                 (args == sizeof (struct IPv6TcpAddress)));
   /* TODO: use 'ac' here in the future... */
   address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
-                                          PLUGIN_NAME,
-                                          arg,
-                                          args,
-                                          GNUNET_HELLO_ADDRESS_INFO_NONE);
-  plugin->env->notify_address (plugin->env->cls,
-                              add_remove,
-                              address);
+                                           PLUGIN_NAME,
+                                           arg,
+                                           args,
+                                           GNUNET_HELLO_ADDRESS_INFO_NONE);
+  plugin->env->notify_address (plugin->env->cls, add_remove, address);
   GNUNET_HELLO_address_free (address);
 }
 
@@ -1519,9 +1505,7 @@ tcp_nat_port_map_callback (void *cls,
  * @return string representing the same address
  */
 static const char *
-tcp_plugin_address_to_string (void *cls,
-                              const void *addr,
-                              size_t addrlen)
+tcp_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
   static char rbuf[INET6_ADDRSTRLEN + 12];
   char buf[INET6_ADDRSTRLEN];
@@ -1536,35 +1520,35 @@ tcp_plugin_address_to_string (void *cls,
 
   switch (addrlen)
   {
-  case sizeof(struct IPv6TcpAddress):
+  case sizeof (struct IPv6TcpAddress):
     t6 = addr;
     af = AF_INET6;
     port = ntohs (t6->t6_port);
     options = ntohl (t6->options);
-    GNUNET_memcpy (&a6, &t6->ipv6_addr, sizeof(a6));
+    GNUNET_memcpy (&a6, &t6->ipv6_addr, sizeof (a6));
     sb = &a6;
     break;
-  case sizeof(struct IPv4TcpAddress):
+  case sizeof (struct IPv4TcpAddress):
     t4 = addr;
     af = AF_INET;
     port = ntohs (t4->t4_port);
     options = ntohl (t4->options);
-    GNUNET_memcpy (&a4, &t4->ipv4_addr, sizeof(a4));
+    GNUNET_memcpy (&a4, &t4->ipv4_addr, sizeof (a4));
     sb = &a4;
     break;
   default:
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Unexpected address length: %u bytes\n"),
+         _ ("Unexpected address length: %u bytes\n"),
          (unsigned int) addrlen);
-    return NULL ;
+    return NULL;
   }
   if (NULL == inet_ntop (af, sb, buf, INET6_ADDRSTRLEN))
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                         "inet_ntop");
-    return NULL ;
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
+    return NULL;
   }
-  GNUNET_snprintf (rbuf, sizeof(rbuf),
+  GNUNET_snprintf (rbuf,
+                   sizeof (rbuf),
                    (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u",
                    PLUGIN_NAME,
                    options,
@@ -1605,25 +1589,25 @@ tcp_plugin_string_to_address (void *cls,
   optionstr = NULL;
   if ((NULL == addr) || (0 == addrlen))
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
   }
   if ('\0' != addr[addrlen - 1])
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
   }
   if (strlen (addr) != addrlen - 1)
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
   }
   plugin = GNUNET_strdup (addr);
   optionstr = strchr (plugin, '.');
   if (NULL == optionstr)
   {
-    GNUNET_break(0);
-    GNUNET_free(plugin);
+    GNUNET_break (0);
+    GNUNET_free (plugin);
     return GNUNET_SYSERR;
   }
   optionstr[0] = '\0';
@@ -1632,28 +1616,25 @@ tcp_plugin_string_to_address (void *cls,
   address = strchr (optionstr, '.');
   if (NULL == address)
   {
-    GNUNET_break(0);
-    GNUNET_free(plugin);
+    GNUNET_break (0);
+    GNUNET_free (plugin);
     return GNUNET_SYSERR;
   }
   address[0] = '\0';
   address++;
 
   if (GNUNET_OK !=
-      GNUNET_STRINGS_to_address_ip (address,
-                                   strlen (address),
-                                   &socket_address))
+      GNUNET_STRINGS_to_address_ip (address, strlen (address), &socket_address))
   {
-    GNUNET_break(0);
-    GNUNET_free(plugin);
+    GNUNET_break (0);
+    GNUNET_free (plugin);
     return GNUNET_SYSERR;
   }
 
-  GNUNET_free(plugin);
+  GNUNET_free (plugin);
   switch (socket_address.ss_family)
   {
-  case AF_INET:
-  {
+  case AF_INET: {
     struct IPv4TcpAddress *t4;
     struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address;
     t4 = GNUNET_new (struct IPv4TcpAddress);
@@ -1661,11 +1642,10 @@ tcp_plugin_string_to_address (void *cls,
     t4->ipv4_addr = in4->sin_addr.s_addr;
     t4->t4_port = in4->sin_port;
     *buf = t4;
-    *added = sizeof(struct IPv4TcpAddress);
+    *added = sizeof (struct IPv4TcpAddress);
     return GNUNET_OK;
   }
-  case AF_INET6:
-  {
+  case AF_INET6: {
     struct IPv6TcpAddress *t6;
     struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
     t6 = GNUNET_new (struct IPv6TcpAddress);
@@ -1673,7 +1653,7 @@ tcp_plugin_string_to_address (void *cls,
     t6->ipv6_addr = in6->sin6_addr;
     t6->t6_port = in6->sin6_port;
     *buf = t6;
-    *added = sizeof(struct IPv6TcpAddress);
+    *added = sizeof (struct IPv6TcpAddress);
     return GNUNET_OK;
   }
   default:
@@ -1711,8 +1691,7 @@ lookup_session_by_client (struct Plugin *plugin,
  * @return #GNUNET_OK on success
  */
 static int
-tcp_plugin_disconnect_session (void *cls,
-                               struct GNUNET_ATS_Session *session)
+tcp_plugin_disconnect_session (void *cls, struct GNUNET_ATS_Session *session)
 {
   struct Plugin *plugin = cls;
   struct PendingMessage *pm;
@@ -1731,26 +1710,24 @@ tcp_plugin_disconnect_session (void *cls,
     session->timeout = GNUNET_TIME_UNIT_ZERO_ABS;
   }
 
-  if (GNUNET_YES ==
-      GNUNET_CONTAINER_multipeermap_remove (plugin->sessionmap,
-                                            &session->target,
-                                            session))
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (plugin->sessionmap,
+                                                          &session->target,
+                                                          session))
   {
     GNUNET_STATISTICS_update (session->plugin->env->stats,
-                             gettext_noop ("# TCP sessions active"),
-                             -1,
-                             GNUNET_NO);
+                              gettext_noop ("# TCP sessions active"),
+                              -1,
+                              GNUNET_NO);
   }
   else
   {
     GNUNET_assert (GNUNET_YES ==
-                  GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
-                                                        &session->target,
-                                                        session));
+                   GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
+                                                         &session->target,
+                                                         session));
   }
   if (NULL != session->client)
-    GNUNET_SERVER_client_set_user_context (session->client,
-                                           NULL);
+    GNUNET_SERVER_client_set_user_context (session->client, NULL);
 
   /* clean up state */
   if (NULL != session->transmit_handle)
@@ -1772,17 +1749,19 @@ tcp_plugin_disconnect_session (void *cls,
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          (NULL != pm->transmit_cont)
-         ? "Could not deliver message to `%s' at %s.\n"
-         : "Could not deliver message to `%s' at %s, notifying.\n",
+           ? "Could not deliver message to `%s' at %s.\n"
+           : "Could not deliver message to `%s' at %s, notifying.\n",
          GNUNET_i2s (&session->target),
          tcp_plugin_address_to_string (session->plugin,
                                        session->address->address,
                                        session->address->address_length));
     GNUNET_STATISTICS_update (session->plugin->env->stats,
                               gettext_noop ("# bytes currently in TCP buffers"),
-                              -(int64_t) pm->message_size, GNUNET_NO);
+                              -(int64_t) pm->message_size,
+                              GNUNET_NO);
     GNUNET_STATISTICS_update (session->plugin->env->stats,
-                              gettext_noop ("# bytes discarded by TCP (disconnect)"),
+                              gettext_noop (
+                                "# bytes discarded by TCP (disconnect)"),
                               pm->message_size,
                               GNUNET_NO);
     GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
@@ -1802,9 +1781,7 @@ tcp_plugin_disconnect_session (void *cls,
   }
   GNUNET_assert (0 == session->msgs_in_queue);
   GNUNET_assert (0 == session->bytes_in_queue);
-  notify_session_monitor (session->plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_DONE);
+  notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_DONE);
 
   if (NULL != session->receive_delay_task)
   {
@@ -1855,22 +1832,18 @@ session_timeout (void *cls)
   {
     /* not actually our turn yet, but let's at least update
        the monitor, it may think we're about to die ... */
-    notify_session_monitor (s->plugin,
-                            s,
-                            GNUNET_TRANSPORT_SS_UPDATE);
-    s->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
-                                                    &session_timeout,
-                                                    s);
+    notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
+    s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, &session_timeout, s);
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Session %p was idle for %s, disconnecting\n",
        s,
-       GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
-                                               GNUNET_YES));
+       GNUNET_STRINGS_relative_time_to_string (
+         GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+         GNUNET_YES));
   /* call session destroy function */
-  tcp_plugin_disconnect_session (s->plugin,
-                                s);
+  tcp_plugin_disconnect_session (s->plugin, s);
 }
 
 
@@ -1883,7 +1856,8 @@ static void
 reschedule_session_timeout (struct GNUNET_ATS_Session *s)
 {
   GNUNET_assert (NULL != s->timeout_task);
-  s->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+  s->timeout =
+    GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
 }
 
 
@@ -1927,46 +1901,41 @@ create_session (struct Plugin *plugin,
   if (NULL != client)
   {
     session->client = client;
-    GNUNET_SERVER_client_set_user_context (client,
-                                           session);
+    GNUNET_SERVER_client_set_user_context (client, session);
   }
   session->address = GNUNET_HELLO_address_copy (address);
   session->target = address->peer;
   session->expecting_welcome = GNUNET_YES;
   session->scope = scope;
   pm = GNUNET_malloc (sizeof (struct PendingMessage) +
-                     sizeof (struct WelcomeMessage));
+                      sizeof (struct WelcomeMessage));
   pm->msg = (const char *) &pm[1];
-  pm->message_size = sizeof(struct WelcomeMessage);
-  GNUNET_memcpy (&pm[1],
-          &plugin->my_welcome,
-          sizeof(struct WelcomeMessage));
+  pm->message_size = sizeof (struct WelcomeMessage);
+  GNUNET_memcpy (&pm[1], &plugin->my_welcome, sizeof (struct WelcomeMessage));
   pm->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# bytes currently in TCP buffers"),
-                           pm->message_size,
+                            pm->message_size,
                             GNUNET_NO);
   GNUNET_CONTAINER_DLL_insert (session->pending_messages_head,
                                session->pending_messages_tail,
                                pm);
   session->msgs_in_queue++;
   session->bytes_in_queue += pm->message_size;
-  session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
-  session->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
-                                                        &session_timeout,
-                                                        session);
-  notify_session_monitor (session->plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_INIT);
+  session->timeout =
+    GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+  session->timeout_task =
+    GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+                                  &session_timeout,
+                                  session);
+  notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_INIT);
   if (GNUNET_YES != is_nat)
   {
     GNUNET_STATISTICS_update (plugin->env->stats,
                               gettext_noop ("# TCP sessions active"),
                               1,
                               GNUNET_NO);
-    notify_session_monitor (session->plugin,
-                            session,
-                            GNUNET_TRANSPORT_SS_UP);
+    notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_UP);
   }
   else
   {
@@ -2000,9 +1969,7 @@ process_pending_messages (struct GNUNET_ATS_Session *session);
  * @return number of bytes written to @a buf
  */
 static size_t
-do_transmit (void *cls,
-            size_t size,
-            void *buf)
+do_transmit (void *cls, size_t size, void *buf)
 {
   struct GNUNET_ATS_Session *session = cls;
   struct GNUNET_PeerIdentity pid;
@@ -2026,8 +1993,8 @@ do_transmit (void *cls,
     tl = NULL;
     ret = 0;
     now = GNUNET_TIME_absolute_get ();
-    while ( (NULL != (pos = session->pending_messages_head)) &&
-            (pos->timeout.abs_value_us <= now.abs_value_us) )
+    while ((NULL != (pos = session->pending_messages_head)) &&
+           (pos->timeout.abs_value_us <= now.abs_value_us))
     {
       GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
                                    session->pending_messages_tail,
@@ -2041,10 +2008,7 @@ do_transmit (void *cls,
            pos->message_size,
            GNUNET_i2s (&session->target));
       ret += pos->message_size;
-      GNUNET_CONTAINER_DLL_insert_after (hd,
-                                         tl,
-                                         tl,
-                                         pos);
+      GNUNET_CONTAINER_DLL_insert_after (hd, tl, tl, pos);
     }
     /* do this call before callbacks (so that if callbacks destroy
      * session, they have a chance to cancel actions done by this
@@ -2055,9 +2019,7 @@ do_transmit (void *cls,
      * the callbacks may abort the session */
     while (NULL != (pos = hd))
     {
-      GNUNET_CONTAINER_DLL_remove (hd,
-                                   tl,
-                                   pos);
+      GNUNET_CONTAINER_DLL_remove (hd, tl, pos);
       if (NULL != pos->transmit_cont)
         pos->transmit_cont (pos->transmit_cont_cls,
                             &pid,
@@ -2067,10 +2029,12 @@ do_transmit (void *cls,
       GNUNET_free (pos);
     }
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              gettext_noop ("# bytes currently in TCP buffers"), -(int64_t) ret,
+                              gettext_noop ("# bytes currently in TCP buffers"),
+                              -(int64_t) ret,
                               GNUNET_NO);
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              gettext_noop ("# bytes discarded by TCP (timeout)"),
+                              gettext_noop (
+                                "# bytes discarded by TCP (timeout)"),
                               ret,
                               GNUNET_NO);
     if (0 < ret)
@@ -2095,7 +2059,7 @@ do_transmit (void *cls,
     session->msgs_in_queue--;
     GNUNET_assert (pos->message_size <= session->bytes_in_queue);
     session->bytes_in_queue -= pos->message_size;
-    GNUNET_assert(size >= pos->message_size);
+    GNUNET_assert (size >= pos->message_size);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Transmitting message of type %u size %u to peer %s at %s\n",
          ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type),
@@ -2105,19 +2069,13 @@ do_transmit (void *cls,
                                        session->address->address,
                                        session->address->address_length));
     /* FIXME: this GNUNET_memcpy can be up to 7% of our total runtime */
-    GNUNET_memcpy (cbuf,
-            pos->msg,
-            pos->message_size);
+    GNUNET_memcpy (cbuf, pos->msg, pos->message_size);
     cbuf += pos->message_size;
     ret += pos->message_size;
     size -= pos->message_size;
-    GNUNET_CONTAINER_DLL_insert_tail (hd,
-                                      tl,
-                                      pos);
+    GNUNET_CONTAINER_DLL_insert_tail (hd, tl, pos);
   }
-  notify_session_monitor (session->plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+  notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
   /* schedule 'continuation' before callbacks so that callbacks that
    * cancel everything don't cause us to use a session that no longer
    * exists... */
@@ -2141,7 +2099,7 @@ do_transmit (void *cls,
   GNUNET_assert (NULL == tl);
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# bytes currently in TCP buffers"),
-                            - (int64_t) ret,
+                            -(int64_t) ret,
                             GNUNET_NO);
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# bytes transmitted via TCP"),
@@ -2168,12 +2126,13 @@ process_pending_messages (struct GNUNET_ATS_Session *session)
   if (NULL == (pm = session->pending_messages_head))
     return;
 
-  session->transmit_handle
-    = GNUNET_SERVER_notify_transmit_ready (session->client,
-                                           pm->message_size,
-                                           GNUNET_TIME_absolute_get_remaining (pm->timeout),
-                                           &do_transmit,
-                                           session);
+  session->transmit_handle =
+    GNUNET_SERVER_notify_transmit_ready (session->client,
+                                         pm->message_size,
+                                         GNUNET_TIME_absolute_get_remaining (
+                                           pm->timeout),
+                                         &do_transmit,
+                                         session);
 }
 
 
@@ -2214,7 +2173,7 @@ tcp_plugin_send (void *cls,
                  GNUNET_TRANSPORT_TransmitContinuation cont,
                  void *cont_cls)
 {
-  struct Plugin * plugin = cls;
+  struct Plugin *plugin = cls;
   struct PendingMessage *pm;
 
   /* create new message entry */
@@ -2265,7 +2224,8 @@ tcp_plugin_send (void *cls,
          "This NAT WAIT session for peer `%s' is not yet ready!\n",
          GNUNET_i2s (&session->target));
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              gettext_noop ("# bytes currently in TCP buffers"), msgbuf_size,
+                              gettext_noop ("# bytes currently in TCP buffers"),
+                              msgbuf_size,
                               GNUNET_NO);
     /* append pm to pending_messages list */
     GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
@@ -2278,15 +2238,9 @@ tcp_plugin_send (void *cls,
                             GNUNET_TRANSPORT_SS_HANDSHAKE);
     return msgbuf_size;
   }
-  LOG (GNUNET_ERROR_TYPE_ERROR,
-       "Invalid session %p\n",
-       session);
+  LOG (GNUNET_ERROR_TYPE_ERROR, "Invalid session %p\n", session);
   if (NULL != cont)
-    cont (cont_cls,
-          &session->target,
-          GNUNET_SYSERR,
-          pm->message_size,
-          0);
+    cont (cont_cls, &session->target, GNUNET_SYSERR, pm->message_size, 0);
   GNUNET_break (0);
   GNUNET_free (pm);
   return GNUNET_SYSERR; /* session does not exist here */
@@ -2307,7 +2261,6 @@ struct GNUNET_ATS_SessionItCtx
    * Where to store the session (if we found it).
    */
   struct GNUNET_ATS_Session *result;
-
 };
 
 
@@ -2327,9 +2280,7 @@ session_lookup_it (void *cls,
   struct GNUNET_ATS_SessionItCtx *si_ctx = cls;
   struct GNUNET_ATS_Session *session = value;
 
-  if (0 !=
-      GNUNET_HELLO_address_cmp (si_ctx->address,
-                                session->address))
+  if (0 != GNUNET_HELLO_address_cmp (si_ctx->address, session->address))
     return GNUNET_YES;
   si_ctx->result = session;
   return GNUNET_NO;
@@ -2353,8 +2304,7 @@ nat_connect_timeout (void *cls)
        tcp_plugin_address_to_string (session->plugin,
                                      session->address->address,
                                      session->address->address_length));
-  tcp_plugin_disconnect_session (session->plugin,
-                                 session);
+  tcp_plugin_disconnect_session (session->plugin, session);
 }
 
 
@@ -2389,8 +2339,7 @@ delayed_done (void *cls)
 
   session->receive_delay_task = NULL;
   reschedule_session_timeout (session);
-  GNUNET_SERVER_receive_done (session->client,
-                             GNUNET_OK);
+  GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
 }
 
 
@@ -2414,13 +2363,11 @@ tcp_plugin_update_inbound_delay (void *cls,
     return;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "New inbound delay %s\n",
-       GNUNET_STRINGS_relative_time_to_string (delay,
-                                               GNUNET_NO));
+       GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_NO));
   session->receive_delay = GNUNET_TIME_relative_to_absolute (delay);
   GNUNET_SCHEDULER_cancel (session->receive_delay_task);
-  session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay,
-                                                              &delayed_done,
-                                                              session);
+  session->receive_delay_task =
+    GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
 }
 
 
@@ -2434,8 +2381,7 @@ tcp_plugin_update_inbound_delay (void *cls,
  * @return the session if the address is valid, NULL otherwise
  */
 static struct GNUNET_ATS_Session *
-tcp_plugin_get_session (void *cls,
-                        const struct GNUNET_HELLO_Address *address)
+tcp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session = NULL;
@@ -2471,9 +2417,8 @@ tcp_plugin_get_session (void *cls,
   }
 
   /* look for existing session */
-  if (GNUNET_YES ==
-      GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
-                                              &address->peer))
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
+                                                            &address->peer))
   {
     struct GNUNET_ATS_SessionItCtx si_ctx;
 
@@ -2482,7 +2427,7 @@ tcp_plugin_get_session (void *cls,
     GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
                                                 &address->peer,
                                                 &session_lookup_it,
-                                               &si_ctx);
+                                                &si_ctx);
     if (NULL != si_ctx.result)
     {
       session = si_ctx.result;
@@ -2503,13 +2448,13 @@ tcp_plugin_get_session (void *cls,
                     peer pair at the same time. */
   }
 
-  if (addrlen == sizeof(struct IPv6TcpAddress))
+  if (addrlen == sizeof (struct IPv6TcpAddress))
   {
     GNUNET_assert (NULL != address->address); /* make static analysis happy */
     t6 = address->address;
     options = t6->options;
     af = AF_INET6;
-    memset (&a6, 0, sizeof(a6));
+    memset (&a6, 0, sizeof (a6));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a6.sin6_len = sizeof (a6);
 #endif
@@ -2517,17 +2462,17 @@ tcp_plugin_get_session (void *cls,
     a6.sin6_port = t6->t6_port;
     if (t6->t6_port == 0)
       is_natd = GNUNET_YES;
-    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
     sb = &a6;
-    sbs = sizeof(a6);
+    sbs = sizeof (a6);
   }
-  else if (addrlen == sizeof(struct IPv4TcpAddress))
+  else if (addrlen == sizeof (struct IPv4TcpAddress))
   {
-    GNUNET_assert(NULL != address->address); /* make static analysis happy */
+    GNUNET_assert (NULL != address->address); /* make static analysis happy */
     t4 = address->address;
     options = t4->options;
     af = AF_INET;
-    memset (&a4, 0, sizeof(a4));
+    memset (&a4, 0, sizeof (a4));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a4.sin_len = sizeof (a4);
 #endif
@@ -2537,24 +2482,22 @@ tcp_plugin_get_session (void *cls,
       is_natd = GNUNET_YES;
     a4.sin_addr.s_addr = t4->ipv4_addr;
     sb = &a4;
-    sbs = sizeof(a4);
+    sbs = sizeof (a4);
   }
   else
   {
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              gettext_noop ("# requests to create session with invalid address"),
-                              1,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      gettext_noop ("# requests to create session with invalid address"),
+      1,
+      GNUNET_NO);
     return NULL;
   }
 
-  net_type = plugin->env->get_address_type (plugin->env->cls,
-                                            sb,
-                                            sbs);
+  net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs);
   GNUNET_break (net_type != GNUNET_NT_UNSPECIFIED);
 
-  if ( (is_natd == GNUNET_YES) &&
-       (addrlen == sizeof(struct IPv6TcpAddress)) )
+  if ((is_natd == GNUNET_YES) && (addrlen == sizeof (struct IPv6TcpAddress)))
   {
     /* NAT client only works with IPv4 addresses */
     return NULL;
@@ -2566,62 +2509,51 @@ tcp_plugin_get_session (void *cls,
     return NULL;
   }
 
-  if ( (is_natd == GNUNET_YES) &&
-       (GNUNET_YES ==
-       GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
-                                               &address->peer)))
+  if ((is_natd == GNUNET_YES) &&
+      (GNUNET_YES ==
+       GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
+                                               &address->peer)))
   {
     /* Only do one NAT punch attempt per peer identity */
     return NULL;
   }
 
-  if ( (is_natd == GNUNET_YES) &&
-       (NULL != plugin->nat) &&
-       (GNUNET_NO ==
-        GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
-                                                &address->peer)))
+  if ((is_natd == GNUNET_YES) && (NULL != plugin->nat) &&
+      (GNUNET_NO ==
+       GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
+                                               &address->peer)))
   {
     struct sockaddr_in local_sa;
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Found valid IPv4 NAT address (creating session)!\n");
-    session = create_session (plugin,
-                              address,
-                              net_type,
-                              NULL,
-                              GNUNET_YES);
-    session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT,
-                                                                    &nat_connect_timeout,
-                                                                    session);
+    session = create_session (plugin, address, net_type, NULL, GNUNET_YES);
+    session->nat_connection_timeout =
+      GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT, &nat_connect_timeout, session);
     GNUNET_assert (GNUNET_OK ==
-                   GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns,
-                                                      &session->target,
-                                                      session,
-                                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                   GNUNET_CONTAINER_multipeermap_put (
+                     plugin->nat_wait_conns,
+                     &session->target,
+                     session,
+                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Created NAT WAIT connection to `%s' at `%s'\n",
          GNUNET_i2s (&session->target),
          GNUNET_a2s (sb, sbs));
-    memset (&local_sa,
-           0,
-           sizeof (local_sa));
+    memset (&local_sa, 0, sizeof (local_sa));
     local_sa.sin_family = AF_INET;
     local_sa.sin_port = htons (plugin->open_port);
     /* We leave sin_address at 0, let the kernel figure it out,
        even if our bind() is more specific.  (May want to reconsider
        later.) */
-    if (GNUNET_OK ==
-       GNUNET_NAT_request_reversal (plugin->nat,
-                                    &local_sa,
-                                    &a4))
+    if (GNUNET_OK == GNUNET_NAT_request_reversal (plugin->nat, &local_sa, &a4))
       return session;
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Running NAT client for `%s' at `%s' failed\n",
-        GNUNET_i2s (&session->target),
-        GNUNET_a2s (sb, sbs));
-    tcp_plugin_disconnect_session (plugin,
-                                  session);
+         "Running NAT client for `%s' at `%s' failed\n",
+         GNUNET_i2s (&session->target),
+         GNUNET_a2s (sb, sbs));
+    tcp_plugin_disconnect_session (plugin, session);
     return NULL;
   }
 
@@ -2638,22 +2570,22 @@ tcp_plugin_get_session (void *cls,
     }
     else
     {
-      if ( (GNUNET_OK !=
-            GNUNET_NETWORK_socket_setsockopt (s,
-                                              IPPROTO_TCP,
-                                              TCP_STEALTH,
-                                              &session->target,
-                                              sizeof (struct GNUNET_PeerIdentity))) ||
-           (GNUNET_OK !=
-            GNUNET_NETWORK_socket_setsockopt (s,
-                                              IPPROTO_TCP,
-                                              TCP_STEALTH_INTEGRITY,
-                                              &plugin->my_welcome,
-                                              sizeof (struct WelcomeMessage))) )
+      if ((GNUNET_OK !=
+           GNUNET_NETWORK_socket_setsockopt (s,
+                                             IPPROTO_TCP,
+                                             TCP_STEALTH,
+                                             &session->target,
+                                             sizeof (
+                                               struct GNUNET_PeerIdentity))) ||
+          (GNUNET_OK !=
+           GNUNET_NETWORK_socket_setsockopt (s,
+                                             IPPROTO_TCP,
+                                             TCP_STEALTH_INTEGRITY,
+                                             &plugin->my_welcome,
+                                             sizeof (struct WelcomeMessage))))
       {
         /* TCP STEALTH not supported by kernel */
-        GNUNET_break (GNUNET_OK ==
-                      GNUNET_NETWORK_socket_close (s));
+        GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
         sa = NULL;
       }
       else
@@ -2685,13 +2617,13 @@ tcp_plugin_get_session (void *cls,
   session = create_session (plugin,
                             address,
                             net_type,
-                            GNUNET_SERVER_connect_socket (plugin->server,
-                                                          sa),
+                            GNUNET_SERVER_connect_socket (plugin->server, sa),
                             GNUNET_NO);
-  (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
-                                            &session->target,
-                                            session,
-                                            GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+  (void) GNUNET_CONTAINER_multipeermap_put (
+    plugin->sessionmap,
+    &session->target,
+    session,
+    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   /* Send TCP Welcome */
   process_pending_messages (session);
 
@@ -2718,11 +2650,11 @@ session_disconnect_it (void *cls,
   struct GNUNET_ATS_Session *session = value;
 
   GNUNET_STATISTICS_update (session->plugin->env->stats,
-                            gettext_noop ("# transport-service disconnect requests for TCP"),
+                            gettext_noop (
+                              "# transport-service disconnect requests for TCP"),
                             1,
                             GNUNET_NO);
-  tcp_plugin_disconnect_session (plugin,
-                                 session);
+  tcp_plugin_disconnect_session (plugin, session);
   return GNUNET_YES;
 }
 
@@ -2744,8 +2676,7 @@ session_disconnect_it (void *cls,
  *        to be cancelled
  */
 static void
-tcp_plugin_disconnect (void *cls,
-                       const struct GNUNET_PeerIdentity *target)
+tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
 {
   struct Plugin *plugin = cls;
 
@@ -2774,8 +2705,7 @@ tcp_plugin_disconnect (void *cls,
  * @param hostname hostname part of the address
  */
 static void
-append_port (void *cls,
-             const char *hostname)
+append_port (void *cls, const char *hostname)
 {
   struct PrettyPrinterContext *ppc = cls;
   struct Plugin *plugin = ppc->plugin;
@@ -2791,9 +2721,7 @@ append_port (void *cls,
     GNUNET_CONTAINER_DLL_remove (plugin->ppc_dll_head,
                                  plugin->ppc_dll_tail,
                                  ppc);
-    ppc->asc (ppc->asc_cls,
-              NULL,
-              GNUNET_OK);
+    ppc->asc (ppc->asc_cls, NULL, GNUNET_OK);
     GNUNET_free (ppc);
     return;
   }
@@ -2811,9 +2739,7 @@ append_port (void *cls,
                      ppc->options,
                      hostname,
                      ppc->port);
-  ppc->asc (ppc->asc_cls,
-            ret,
-            GNUNET_OK);
+  ppc->asc (ppc->asc_cls, ret, GNUNET_OK);
   GNUNET_free (ret);
 }
 
@@ -2852,35 +2778,35 @@ tcp_plugin_address_pretty_printer (void *cls,
   uint16_t port;
   uint32_t options;
 
-  if (sizeof(struct IPv6TcpAddress) == addrlen)
+  if (sizeof (struct IPv6TcpAddress) == addrlen)
   {
     t6 = addr;
-    memset (&a6, 0, sizeof(a6));
+    memset (&a6, 0, sizeof (a6));
     a6.sin6_family = AF_INET6;
     a6.sin6_port = t6->t6_port;
-    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
     port = ntohs (t6->t6_port);
     options = ntohl (t6->options);
     sb = &a6;
-    sbs = sizeof(a6);
+    sbs = sizeof (a6);
   }
-  else if (sizeof(struct IPv4TcpAddress) == addrlen)
+  else if (sizeof (struct IPv4TcpAddress) == addrlen)
   {
     t4 = addr;
-    memset (&a4, 0, sizeof(a4));
+    memset (&a4, 0, sizeof (a4));
     a4.sin_family = AF_INET;
     a4.sin_port = t4->t4_port;
     a4.sin_addr.s_addr = t4->ipv4_addr;
     port = ntohs (t4->t4_port);
     options = ntohl (t4->options);
     sb = &a4;
-    sbs = sizeof(a4);
+    sbs = sizeof (a4);
   }
   else
   {
     /* invalid address */
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Unexpected address length: %u bytes\n"),
+         _ ("Unexpected address length: %u bytes\n"),
          (unsigned int) addrlen);
     asc (asc_cls, NULL, GNUNET_SYSERR);
     asc (asc_cls, NULL, GNUNET_OK);
@@ -2888,7 +2814,7 @@ tcp_plugin_address_pretty_printer (void *cls,
   }
   ppc = GNUNET_new (struct PrettyPrinterContext);
   ppc->plugin = plugin;
-  if (addrlen == sizeof(struct IPv6TcpAddress))
+  if (addrlen == sizeof (struct IPv6TcpAddress))
     ppc->ipv6 = GNUNET_YES;
   else
     ppc->ipv6 = GNUNET_NO;
@@ -2896,23 +2822,20 @@ tcp_plugin_address_pretty_printer (void *cls,
   ppc->asc_cls = asc_cls;
   ppc->port = port;
   ppc->options = options;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Starting DNS reverse lookup\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting DNS reverse lookup\n");
   ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb,
                                                        sbs,
                                                        ! numeric,
                                                        timeout,
                                                        &append_port,
-                                                      ppc);
+                                                       ppc);
   if (NULL == ppc->resolver_handle)
   {
     GNUNET_break (0);
     GNUNET_free (ppc);
     return;
   }
-  GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head,
-                               plugin->ppc_dll_tail,
-                               ppc);
+  GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, plugin->ppc_dll_tail, ppc);
 }
 
 
@@ -2932,29 +2855,25 @@ tcp_plugin_address_pretty_printer (void *cls,
  *         and transport, #GNUNET_SYSERR if not
  */
 static int
-tcp_plugin_check_address (void *cls,
-                         const void *addr,
-                         size_t addrlen)
+tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
 {
   struct Plugin *plugin = cls;
   const struct IPv4TcpAddress *v4;
   const struct IPv6TcpAddress *v6;
 
-  if ( (addrlen != sizeof(struct IPv4TcpAddress)) &&
-       (addrlen != sizeof(struct IPv6TcpAddress)) )
+  if ((addrlen != sizeof (struct IPv4TcpAddress)) &&
+      (addrlen != sizeof (struct IPv6TcpAddress)))
   {
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
 
-  if (addrlen == sizeof(struct IPv4TcpAddress))
+  if (addrlen == sizeof (struct IPv4TcpAddress))
   {
     struct sockaddr_in s4;
 
     v4 = (const struct IPv4TcpAddress *) addr;
-    if (0 != memcmp (&v4->options,
-                     &plugin->myoptions,
-                     sizeof(uint32_t)))
+    if (0 != memcmp (&v4->options, &plugin->myoptions, sizeof (uint32_t)))
     {
       GNUNET_break (0);
       return GNUNET_SYSERR;
@@ -2968,9 +2887,7 @@ tcp_plugin_check_address (void *cls,
     s4.sin_addr.s_addr = v4->ipv4_addr;
 
     if (GNUNET_OK !=
-       GNUNET_NAT_test_address (plugin->nat,
-                                &s4,
-                                sizeof (struct sockaddr_in)))
+        GNUNET_NAT_test_address (plugin->nat, &s4, sizeof (struct sockaddr_in)))
       return GNUNET_SYSERR;
   }
   else
@@ -2983,9 +2900,7 @@ tcp_plugin_check_address (void *cls,
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
     }
-    if (0 != memcmp (&v6->options,
-                     &plugin->myoptions,
-                     sizeof (uint32_t)))
+    if (0 != memcmp (&v6->options, &plugin->myoptions, sizeof (uint32_t)))
     {
       GNUNET_break (0);
       return GNUNET_SYSERR;
@@ -2998,10 +2913,9 @@ tcp_plugin_check_address (void *cls,
     s6.sin6_port = v6->t6_port;
     s6.sin6_addr = v6->ipv6_addr;
 
-    if (GNUNET_OK !=
-       GNUNET_NAT_test_address (plugin->nat,
-                                &s6,
-                                sizeof(struct sockaddr_in6)))
+    if (GNUNET_OK != GNUNET_NAT_test_address (plugin->nat,
+                                              &s6,
+                                              sizeof (struct sockaddr_in6)))
       return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -3032,29 +2946,27 @@ handle_tcp_nat_probe (void *cls,
   const struct sockaddr_in *s4;
   const struct sockaddr_in6 *s6;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received NAT probe\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received NAT probe\n");
   /* We have received a TCP NAT probe, meaning we (hopefully) initiated
    * a connection to this peer by running gnunet-nat-client.  This peer
    * received the punch message and now wants us to use the new connection
    * as the default for that peer.  Do so and then send a WELCOME message
    * so we can really be connected!
    */
-  if (ntohs (message->size) != sizeof(struct TCP_NAT_ProbeMessage))
+  if (ntohs (message->size) != sizeof (struct TCP_NAT_ProbeMessage))
   {
-    GNUNET_break_op(0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
 
   tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *) message;
-  if (0 == memcmp (&tcp_nat_probe->clientIdentity, plugin->env->my_identity,
-          sizeof(struct GNUNET_PeerIdentity)))
+  if (0 == memcmp (&tcp_nat_probe->clientIdentity,
+                   plugin->env->my_identity,
+                   sizeof (struct GNUNET_PeerIdentity)))
   {
     /* refuse connections from ourselves */
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
 
@@ -3062,14 +2974,11 @@ handle_tcp_nat_probe (void *cls,
                                                &tcp_nat_probe->clientIdentity);
   if (NULL == session)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Did NOT find session for NAT probe!\n");
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_OK);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Did NOT find session for NAT probe!\n");
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
     return;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Found session for NAT probe!\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Found session for NAT probe!\n");
 
   if (NULL != session->nat_connection_timeout)
   {
@@ -3077,28 +2986,24 @@ handle_tcp_nat_probe (void *cls,
     session->nat_connection_timeout = NULL;
   }
 
-  if (GNUNET_OK !=
-      GNUNET_SERVER_client_get_address (client,
-                                       &vaddr,
-                                       &alen))
+  if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
   {
-    GNUNET_break(0);
-    GNUNET_SERVER_receive_done (client,
-                               GNUNET_SYSERR);
-    tcp_plugin_disconnect_session (plugin,
-                                   session);
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    tcp_plugin_disconnect_session (plugin, session);
     return;
   }
-  GNUNET_assert (GNUNET_YES ==
-                GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
-                                                      &tcp_nat_probe->clientIdentity,
-                                                      session));
-  GNUNET_SERVER_client_set_user_context (client,
-                                        session);
-  (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
-                                           &session->target,
-                                           session,
-                                           GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+  GNUNET_assert (
+    GNUNET_YES ==
+    GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
+                                          &tcp_nat_probe->clientIdentity,
+                                          session));
+  GNUNET_SERVER_client_set_user_context (client, session);
+  (void) GNUNET_CONTAINER_multipeermap_put (
+    plugin->sessionmap,
+    &session->target,
+    session,
+    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   session->last_activity = GNUNET_TIME_absolute_get ();
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Found address `%s' for incoming connection\n",
@@ -3111,45 +3016,43 @@ handle_tcp_nat_probe (void *cls,
     t4->options = htonl (TCP_OPTIONS_NONE);
     t4->t4_port = s4->sin_port;
     t4->ipv4_addr = s4->sin_addr.s_addr;
-    session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
-                                                      PLUGIN_NAME,
-                                                      &t4,
-                                                      sizeof(struct IPv4TcpAddress),
-                                                      GNUNET_HELLO_ADDRESS_INFO_NONE);
+    session->address =
+      GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+                                     PLUGIN_NAME,
+                                     &t4,
+                                     sizeof (struct IPv4TcpAddress),
+                                     GNUNET_HELLO_ADDRESS_INFO_NONE);
     break;
   case AF_INET6:
     s6 = vaddr;
     t6 = GNUNET_new (struct IPv6TcpAddress);
     t6->options = htonl (TCP_OPTIONS_NONE);
     t6->t6_port = s6->sin6_port;
-    GNUNET_memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
-    session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
-                                                      PLUGIN_NAME,
-                                                      &t6,
-                                                      sizeof(struct IPv6TcpAddress),
-                                                      GNUNET_HELLO_ADDRESS_INFO_NONE);
+    GNUNET_memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
+    session->address =
+      GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+                                     PLUGIN_NAME,
+                                     &t6,
+                                     sizeof (struct IPv6TcpAddress),
+                                     GNUNET_HELLO_ADDRESS_INFO_NONE);
     break;
   default:
-    GNUNET_break_op(0);
-    LOG(GNUNET_ERROR_TYPE_DEBUG,
-        "Bad address for incoming connection!\n");
-    GNUNET_free(vaddr);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
-    tcp_plugin_disconnect_session (plugin,
-                                   session);
+    GNUNET_break_op (0);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Bad address for incoming connection!\n");
+    GNUNET_free (vaddr);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    tcp_plugin_disconnect_session (plugin, session);
     return;
   }
   GNUNET_free (vaddr);
   GNUNET_break (NULL == session->client);
   session->client = client;
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           gettext_noop ("# TCP sessions active"),
-                           1,
-                           GNUNET_NO);
+                            gettext_noop ("# TCP sessions active"),
+                            1,
+                            GNUNET_NO);
   process_pending_messages (session);
-  GNUNET_SERVER_receive_done (client,
-                             GNUNET_OK);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 
@@ -3179,13 +3082,10 @@ handle_tcp_welcome (void *cls,
 
   if (0 == memcmp (&wm->clientIdentity,
                    plugin->env->my_identity,
-                   sizeof(struct GNUNET_PeerIdentity)))
+                   sizeof (struct GNUNET_PeerIdentity)))
   {
     /* refuse connections from ourselves */
-    if (GNUNET_OK ==
-        GNUNET_SERVER_client_get_address (client,
-                                          &vaddr,
-                                          &alen))
+    if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
            "Received WELCOME message from my own identity `%s' on address `%s'\n",
@@ -3193,34 +3093,26 @@ handle_tcp_welcome (void *cls,
            GNUNET_a2s (vaddr, alen));
       GNUNET_free (vaddr);
     }
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
 
-  if (GNUNET_OK ==
-      GNUNET_SERVER_client_get_address (client,
-                                        &vaddr,
-                                        &alen))
+  if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
   {
-    LOG(GNUNET_ERROR_TYPE_DEBUG,
-        "Received WELCOME message from `%s' on address `%s'\n",
-        GNUNET_i2s (&wm->clientIdentity),
-        GNUNET_a2s (vaddr, alen));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Received WELCOME message from `%s' on address `%s'\n",
+         GNUNET_i2s (&wm->clientIdentity),
+         GNUNET_a2s (vaddr, alen));
     GNUNET_free (vaddr);
   }
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# TCP WELCOME messages received"),
                             1,
                             GNUNET_NO);
-  session = lookup_session_by_client (plugin,
-                                      client);
+  session = lookup_session_by_client (plugin, client);
   if (NULL != session)
   {
-    if (GNUNET_OK ==
-        GNUNET_SERVER_client_get_address (client,
-                                          &vaddr,
-                                          &alen))
+    if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Found existing session %p for peer `%s'\n",
@@ -3231,41 +3123,41 @@ handle_tcp_welcome (void *cls,
   }
   else
   {
-    if (GNUNET_OK ==
-        GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+    if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
     {
-      if (alen == sizeof(struct sockaddr_in))
+      if (alen == sizeof (struct sockaddr_in))
       {
         s4 = vaddr;
         memset (&t4, '\0', sizeof (t4));
         t4.options = htonl (TCP_OPTIONS_NONE);
         t4.t4_port = s4->sin_port;
         t4.ipv4_addr = s4->sin_addr.s_addr;
-        address = GNUNET_HELLO_address_allocate (&wm->clientIdentity,
-                                                 PLUGIN_NAME,
-                                                 &t4,
-                                                 sizeof(t4),
-                                                 GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+        address =
+          GNUNET_HELLO_address_allocate (&wm->clientIdentity,
+                                         PLUGIN_NAME,
+                                         &t4,
+                                         sizeof (t4),
+                                         GNUNET_HELLO_ADDRESS_INFO_INBOUND);
       }
-      else if (alen == sizeof(struct sockaddr_in6))
+      else if (alen == sizeof (struct sockaddr_in6))
       {
         s6 = vaddr;
         memset (&t6, '\0', sizeof (t6));
         t6.options = htonl (TCP_OPTIONS_NONE);
         t6.t6_port = s6->sin6_port;
-        GNUNET_memcpy (&t6.ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
-        address = GNUNET_HELLO_address_allocate (&wm->clientIdentity,
-                                                 PLUGIN_NAME,
-                                                 &t6,
-                                                 sizeof (t6),
-                                                 GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+        GNUNET_memcpy (&t6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
+        address =
+          GNUNET_HELLO_address_allocate (&wm->clientIdentity,
+                                         PLUGIN_NAME,
+                                         &t6,
+                                         sizeof (t6),
+                                         GNUNET_HELLO_ADDRESS_INFO_INBOUND);
       }
       else
       {
         GNUNET_break (0);
         GNUNET_free_non_null (vaddr);
-        GNUNET_SERVER_receive_done (client,
-                                    GNUNET_SYSERR);
+        GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
         return;
       }
       session = create_session (plugin,
@@ -3281,17 +3173,19 @@ handle_tcp_welcome (void *cls,
            "Creating new%s session %p for peer `%s' client %p\n",
            GNUNET_HELLO_address_check_option (session->address,
                                               GNUNET_HELLO_ADDRESS_INFO_INBOUND)
-           ? " inbound" : "",
+             ? " inbound"
+             : "",
            session,
            tcp_plugin_address_to_string (plugin,
                                          session->address->address,
                                          session->address->address_length),
            client);
       GNUNET_free (vaddr);
-      (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
-                                                &session->target,
-                                                session,
-                                                GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+      (void) GNUNET_CONTAINER_multipeermap_put (
+        plugin->sessionmap,
+        &session->target,
+        session,
+        GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       /* Notify transport and ATS about new session */
       plugin->env->session_start (plugin->env->cls,
                                   session->address,
@@ -3300,11 +3194,10 @@ handle_tcp_welcome (void *cls,
     }
     else
     {
-      LOG(GNUNET_ERROR_TYPE_DEBUG,
-          "Did not obtain TCP socket address for incoming connection\n");
-      GNUNET_break(0);
-      GNUNET_SERVER_receive_done (client,
-                                  GNUNET_SYSERR);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Did not obtain TCP socket address for incoming connection\n");
+      GNUNET_break (0);
+      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
       return;
     }
   }
@@ -3312,8 +3205,7 @@ handle_tcp_welcome (void *cls,
   if (GNUNET_YES != session->expecting_welcome)
   {
     GNUNET_break_op (0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
   session->last_activity = GNUNET_TIME_absolute_get ();
@@ -3322,8 +3214,7 @@ handle_tcp_welcome (void *cls,
   process_pending_messages (session);
   GNUNET_SERVER_client_set_timeout (client,
                                     GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
-  GNUNET_SERVER_receive_done (client,
-                              GNUNET_OK);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 
@@ -3346,12 +3237,11 @@ handle_tcp_data (void *cls,
   uint16_t type;
 
   type = ntohs (message->type);
-  if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) ||
-       (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE == type) )
+  if ((GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) ||
+      (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE == type))
   {
     /* We don't want to propagate WELCOME and NAT Probe messages up! */
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_OK);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
     return;
   }
   session = lookup_session_by_client (plugin, client);
@@ -3362,18 +3252,14 @@ handle_tcp_data (void *cls,
     size_t alen;
 
     GNUNET_assert (GNUNET_OK ==
-                  GNUNET_SERVER_client_get_address (client,
-                                                    &vaddr,
-                                                    &alen));
+                   GNUNET_SERVER_client_get_address (client, &vaddr, &alen));
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Received unexpected %u bytes of type %u from `%s'\n",
          (unsigned int) ntohs (message->size),
          (unsigned int) ntohs (message->type),
-         GNUNET_a2s (vaddr,
-                     alen));
-    GNUNET_break_op(0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+         GNUNET_a2s (vaddr, alen));
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     GNUNET_free_non_null (vaddr);
     return;
   }
@@ -3383,17 +3269,14 @@ handle_tcp_data (void *cls,
     void *vaddr = NULL;
     size_t alen;
 
-    GNUNET_SERVER_client_get_address (client,
-                                      &vaddr,
-                                      &alen);
+    GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Received unexpected %u bytes of type %u from `%s'\n",
          (unsigned int) ntohs (message->size),
          (unsigned int) ntohs (message->type),
          GNUNET_a2s (vaddr, alen));
-    GNUNET_break_op(0);
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     GNUNET_free_non_null (vaddr);
     return;
   }
@@ -3403,9 +3286,7 @@ handle_tcp_data (void *cls,
     void *vaddr = NULL;
     size_t alen;
 
-    GNUNET_SERVER_client_get_address (client,
-                                      &vaddr,
-                                      &alen);
+    GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Passing %u bytes of type %u from `%s' at %s to transport service.\n",
          (unsigned int) ntohs (message->size),
@@ -3420,31 +3301,27 @@ handle_tcp_data (void *cls,
                             ntohs (message->size),
                             GNUNET_NO);
 
-  GNUNET_assert (GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
-                                                               &session->target,
-                                                               session));
-  delay = plugin->env->receive (plugin->env->cls,
-                                session->address,
-                                session,
-                                message);
+  GNUNET_assert (
+    GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
+                                                  &session->target,
+                                                  session));
+  delay =
+    plugin->env->receive (plugin->env->cls, session->address, session, message);
   reschedule_session_timeout (session);
   if (0 == delay.rel_value_us)
   {
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_OK);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
   }
   else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Throttling receiving from `%s' for %s\n",
          GNUNET_i2s (&session->target),
-         GNUNET_STRINGS_relative_time_to_string (delay,
-                                                 GNUNET_YES));
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     GNUNET_SERVER_disable_receive_done_warning (client);
     GNUNET_assert (NULL == session->receive_delay_task);
-    session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay,
-                                                                &delayed_done,
-                                                                session);
+    session->receive_delay_task =
+      GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
   }
 }
 
@@ -3458,8 +3335,7 @@ handle_tcp_data (void *cls,
  * @param client identification of the client
  */
 static void
-connect_notify (void *cls,
-               struct GNUNET_SERVER_Client *client)
+connect_notify (void *cls, struct GNUNET_SERVER_Client *client)
 {
   struct Plugin *plugin = cls;
 
@@ -3471,18 +3347,19 @@ connect_notify (void *cls,
                          plugin->cur_connections,
                          GNUNET_NO);
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           gettext_noop ("# TCP server connect events"),
-                           1,
-                           GNUNET_NO);
+                            gettext_noop ("# TCP server connect events"),
+                            1,
+                            GNUNET_NO);
   if (plugin->cur_connections != plugin->max_connections)
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-             _("TCP connection limit reached, suspending server\n"));
+              _ ("TCP connection limit reached, suspending server\n"));
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           gettext_noop ("# TCP service suspended"),
-                           1,
-                           GNUNET_NO);
-  GNUNET_SERVER_suspend (plugin->server); /* Maximum number of connections rechead */
+                            gettext_noop ("# TCP service suspended"),
+                            1,
+                            GNUNET_NO);
+  GNUNET_SERVER_suspend (
+    plugin->server); /* Maximum number of connections rechead */
 }
 
 
@@ -3495,8 +3372,7 @@ connect_notify (void *cls,
  * @param client identification of the client
  */
 static void
-disconnect_notify (void *cls,
-                   struct GNUNET_SERVER_Client *client)
+disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session;
@@ -3505,8 +3381,7 @@ disconnect_notify (void *cls,
     return;
   GNUNET_assert (plugin->cur_connections >= 1);
   plugin->cur_connections--;
-  session = lookup_session_by_client (plugin,
-                                      client);
+  session = lookup_session_by_client (plugin, client);
   if (NULL == session)
     return; /* unknown, nothing to do */
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3529,11 +3404,11 @@ disconnect_notify (void *cls,
                          plugin->cur_connections,
                          GNUNET_NO);
   GNUNET_STATISTICS_update (session->plugin->env->stats,
-                            gettext_noop ("# network-level TCP disconnect events"),
+                            gettext_noop (
+                              "# network-level TCP disconnect events"),
                             1,
                             GNUNET_NO);
-  tcp_plugin_disconnect_session (plugin,
-                                session);
+  tcp_plugin_disconnect_session (plugin, session);
 }
 
 
@@ -3546,9 +3421,7 @@ disconnect_notify (void *cls,
  * @return number of bytes copied into @a buf
  */
 static size_t
-notify_send_probe (void *cls,
-                   size_t size,
-                   void *buf)
+notify_send_probe (void *cls, size_t size, void *buf)
 {
   struct TCPProbeContext *tcp_probe_ctx = cls;
   struct Plugin *plugin = tcp_probe_ctx->plugin;
@@ -3561,16 +3434,14 @@ notify_send_probe (void *cls,
   if (NULL == buf)
   {
     GNUNET_CONNECTION_destroy (tcp_probe_ctx->sock);
-    GNUNET_free(tcp_probe_ctx);
+    GNUNET_free (tcp_probe_ctx);
     return 0;
   }
-  GNUNET_assert(size >= sizeof(tcp_probe_ctx->message));
-  GNUNET_memcpy (buf,
-         &tcp_probe_ctx->message,
-         sizeof(tcp_probe_ctx->message));
+  GNUNET_assert (size >= sizeof (tcp_probe_ctx->message));
+  GNUNET_memcpy (buf, &tcp_probe_ctx->message, sizeof (tcp_probe_ctx->message));
   GNUNET_SERVER_connect_socket (tcp_probe_ctx->plugin->server,
                                 tcp_probe_ctx->sock);
-  ret = sizeof(tcp_probe_ctx->message);
+  ret = sizeof (tcp_probe_ctx->message);
   GNUNET_free (tcp_probe_ctx);
   return ret;
 }
@@ -3598,9 +3469,7 @@ try_connection_reversal (void *cls,
    * We have received an ICMP response, ostensibly from a peer
    * that wants to connect to us! Send a message to establish a connection.
    */
-  sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
-                                                addr,
-                                                addrlen);
+  sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, addr, addrlen);
   if (NULL == sock)
   {
     /* failed for some odd reason (out of sockets?); ignore attempt */
@@ -3608,23 +3477,23 @@ try_connection_reversal (void *cls,
   }
 
   tcp_probe_ctx = GNUNET_new (struct TCPProbeContext);
-  tcp_probe_ctx->message.header.size
-    = htons (sizeof (struct TCP_NAT_ProbeMessage));
-  tcp_probe_ctx->message.header.type
-    = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
-  tcp_probe_ctx->message.clientIdentity
-    = *plugin->env->my_identity;
+  tcp_probe_ctx->message.header.size =
+    htons (sizeof (struct TCP_NAT_ProbeMessage));
+  tcp_probe_ctx->message.header.type =
+    htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
+  tcp_probe_ctx->message.clientIdentity = *plugin->env->my_identity;
   tcp_probe_ctx->plugin = plugin;
   tcp_probe_ctx->sock = sock;
   GNUNET_CONTAINER_DLL_insert (plugin->probe_head,
                                plugin->probe_tail,
                                tcp_probe_ctx);
-  tcp_probe_ctx->transmit_handle
-    = GNUNET_CONNECTION_notify_transmit_ready (sock,
-                                               ntohs (tcp_probe_ctx->message.header.size),
-                                               GNUNET_TIME_UNIT_FOREVER_REL,
-                                               &notify_send_probe,
-                                               tcp_probe_ctx);
+  tcp_probe_ctx->transmit_handle =
+    GNUNET_CONNECTION_notify_transmit_ready (sock,
+                                             ntohs (tcp_probe_ctx->message
+                                                      .header.size),
+                                             GNUNET_TIME_UNIT_FOREVER_REL,
+                                             &notify_send_probe,
+                                             tcp_probe_ctx);
 }
 
 
@@ -3636,8 +3505,7 @@ try_connection_reversal (void *cls,
  * @return the network type in HBO or #GNUNET_SYSERR
  */
 static enum GNUNET_NetworkType
-tcp_plugin_get_network (void *cls,
-                        struct GNUNET_ATS_Session *session)
+tcp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
 {
   return session->scope;
 }
@@ -3664,25 +3532,25 @@ tcp_plugin_get_network_for_address (void *cls,
   size_t sbs;
 
   addrlen = address->address_length;
-  if (addrlen == sizeof(struct IPv6TcpAddress))
+  if (addrlen == sizeof (struct IPv6TcpAddress))
   {
     GNUNET_assert (NULL != address->address); /* make static analysis happy */
     t6 = address->address;
-    memset (&a6, 0, sizeof(a6));
+    memset (&a6, 0, sizeof (a6));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a6.sin6_len = sizeof (a6);
 #endif
     a6.sin6_family = AF_INET6;
     a6.sin6_port = t6->t6_port;
-    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+    GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
     sb = &a6;
-    sbs = sizeof(a6);
+    sbs = sizeof (a6);
   }
-  else if (addrlen == sizeof(struct IPv4TcpAddress))
+  else if (addrlen == sizeof (struct IPv4TcpAddress))
   {
     GNUNET_assert (NULL != address->address); /* make static analysis happy */
     t4 = address->address;
-    memset (&a4, 0, sizeof(a4));
+    memset (&a4, 0, sizeof (a4));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a4.sin_len = sizeof (a4);
 #endif
@@ -3690,16 +3558,14 @@ tcp_plugin_get_network_for_address (void *cls,
     a4.sin_port = t4->t4_port;
     a4.sin_addr.s_addr = t4->ipv4_addr;
     sb = &a4;
-    sbs = sizeof(a4);
+    sbs = sizeof (a4);
   }
   else
   {
     GNUNET_break (0);
     return GNUNET_NT_UNSPECIFIED;
   }
-  return plugin->env->get_address_type (plugin->env->cls,
-                                        sb,
-                                        sbs);
+  return plugin->env->get_address_type (plugin->env->cls, sb, sbs);
 }
 
 
@@ -3720,14 +3586,10 @@ send_session_info_iter (void *cls,
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session = value;
 
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
   /* FIXME: cannot tell if this is up or not from current
      session state... */
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UP);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
   return GNUNET_OK;
 }
 
@@ -3773,17 +3635,17 @@ tcp_plugin_setup_monitor (void *cls,
 void *
 libgnunet_plugin_transport_tcp_init (void *cls)
 {
-  static const struct GNUNET_SERVER_MessageHandler my_handlers[] = {
-    { &handle_tcp_welcome, NULL,
+  static const struct GNUNET_SERVER_MessageHandler my_handlers[] =
+    {{&handle_tcp_welcome,
+      NULL,
       GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME,
-      sizeof(struct WelcomeMessage) },
-    { &handle_tcp_nat_probe, NULL,
+      sizeof (struct WelcomeMessage)},
+     {&handle_tcp_nat_probe,
+      NULL,
       GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE,
-      sizeof(struct TCP_NAT_ProbeMessage) },
-    { &handle_tcp_data, NULL,
-      GNUNET_MESSAGE_TYPE_ALL, 0 },
-    { NULL, NULL, 0, 0 }
-  };
+      sizeof (struct TCP_NAT_ProbeMessage)},
+     {&handle_tcp_data, NULL, GNUNET_MESSAGE_TYPE_ALL, 0},
+     {NULL, NULL, 0, 0}};
   struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
   struct GNUNET_TRANSPORT_PluginFunctions *api;
   struct Plugin *plugin;
@@ -3794,7 +3656,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
   unsigned int i;
   struct GNUNET_TIME_Relative idle_timeout;
 #ifdef TCP_STEALTH
-  struct GNUNET_NETWORK_Handle *const*lsocks;
+  struct GNUNET_NETWORK_Handle *const *lsocks;
 #endif
   int ret;
   int ret_s;
@@ -3814,27 +3676,28 @@ libgnunet_plugin_transport_tcp_init (void *cls)
   }
 
   GNUNET_assert (NULL != env->cfg);
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (env->cfg,
-                                             "transport-tcp",
-                                             "MAX_CONNECTIONS",
-                                             &max_connections))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                          "transport-tcp",
+                                                          "MAX_CONNECTIONS",
+                                                          &max_connections))
     max_connections = 128;
 
   aport = 0;
-  if ((GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
-                                              "PORT", &bport)) ||
+  if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                           "transport-tcp",
+                                                           "PORT",
+                                                           &bport)) ||
       (bport > 65535) ||
-      ((GNUNET_OK ==
-        GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
-                                               "ADVERTISED-PORT", &aport)) &&
-       (aport > 65535) ))
+      ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                            "transport-tcp",
+                                                            "ADVERTISED-PORT",
+                                                            &aport)) &&
+       (aport > 65535)))
   {
-    LOG(GNUNET_ERROR_TYPE_ERROR,
-        _("Require valid port number for service `%s' in configuration!\n"),
-        "transport-tcp");
-    return NULL ;
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         _ ("Require valid port number for service `%s' in configuration!\n"),
+         "transport-tcp");
+    return NULL;
   }
   if (0 == aport)
     aport = bport;
@@ -3847,8 +3710,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
                                     LEGACY_SERVICE_OPTION_NONE);
     if (NULL == service)
     {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("Failed to start service.\n"));
+      LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to start service.\n"));
       return NULL;
     }
   }
@@ -3857,21 +3719,21 @@ libgnunet_plugin_transport_tcp_init (void *cls)
 
   api = NULL;
   plugin = GNUNET_new (struct Plugin);
-  plugin->sessionmap = GNUNET_CONTAINER_multipeermap_create (max_connections,
-                                                             GNUNET_YES);
+  plugin->sessionmap =
+    GNUNET_CONTAINER_multipeermap_create (max_connections, GNUNET_YES);
   plugin->max_connections = max_connections;
   plugin->open_port = bport;
   plugin->adv_port = aport;
   plugin->env = env;
-  plugin->my_welcome.header.size = htons (sizeof(struct WelcomeMessage));
-  plugin->my_welcome.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME);
+  plugin->my_welcome.header.size = htons (sizeof (struct WelcomeMessage));
+  plugin->my_welcome.header.type =
+    htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME);
   plugin->my_welcome.clientIdentity = *plugin->env->my_identity;
 
-  if ( (NULL != service) &&
-       (GNUNET_YES ==
-        GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
-                                              "transport-tcp",
-                                              "TCP_STEALTH")) )
+  if ((NULL != service) &&
+      (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+                                                           "transport-tcp",
+                                                           "TCP_STEALTH")))
   {
 #ifdef TCP_STEALTH
     plugin->myoptions |= TCP_OPTIONS_TCP_STEALTH;
@@ -3880,59 +3742,57 @@ libgnunet_plugin_transport_tcp_init (void *cls)
     {
       uint32_t len = sizeof (struct WelcomeMessage);
 
-      for (i=0;NULL!=lsocks[i];i++)
+      for (i = 0; NULL != lsocks[i]; i++)
       {
-        if ( (GNUNET_OK !=
-              GNUNET_NETWORK_socket_setsockopt (lsocks[i],
-                                                IPPROTO_TCP,
-                                                TCP_STEALTH,
-                                                env->my_identity,
-                                                sizeof (struct GNUNET_PeerIdentity))) ||
-             (GNUNET_OK !=
-              GNUNET_NETWORK_socket_setsockopt (lsocks[i],
-                                                IPPROTO_TCP,
-                                                TCP_STEALTH_INTEGRITY_LEN,
-                                                &len,
-                                                sizeof (len))) )
+        if (
+          (GNUNET_OK !=
+           GNUNET_NETWORK_socket_setsockopt (lsocks[i],
+                                             IPPROTO_TCP,
+                                             TCP_STEALTH,
+                                             env->my_identity,
+                                             sizeof (
+                                               struct GNUNET_PeerIdentity))) ||
+          (GNUNET_OK !=
+           GNUNET_NETWORK_socket_setsockopt (lsocks[i],
+                                             IPPROTO_TCP,
+                                             TCP_STEALTH_INTEGRITY_LEN,
+                                             &len,
+                                             sizeof (len))))
         {
           /* TCP STEALTH not supported by kernel */
           GNUNET_assert (0 == i);
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("TCP_STEALTH not supported on this platform.\n"));
+                      _ ("TCP_STEALTH not supported on this platform.\n"));
           goto die;
         }
       }
     }
 #else
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("TCP_STEALTH not supported on this platform.\n"));
+                _ ("TCP_STEALTH not supported on this platform.\n"));
     goto die;
 #endif
   }
 
-  if ( (NULL != service) &&
-       (GNUNET_SYSERR !=
-        (ret_s =
-         get_server_addresses ("transport-tcp",
-                              env->cfg,
-                              &addrs,
-                              &addrlens))))
+  if ((NULL != service) &&
+      (GNUNET_SYSERR !=
+       (ret_s =
+          get_server_addresses ("transport-tcp", env->cfg, &addrs, &addrlens))))
   {
-    for (ret = ret_s-1; ret >= 0; ret--)
+    for (ret = ret_s - 1; ret >= 0; ret--)
       LOG (GNUNET_ERROR_TYPE_INFO,
            "Binding to address `%s'\n",
            GNUNET_a2s (addrs[ret], addrlens[ret]));
-    plugin->nat
-      = GNUNET_NAT_register (env->cfg,
-                            "transport-tcp",
-                            IPPROTO_TCP,
-                             (unsigned int) ret_s,
-                             (const struct sockaddr **) addrs,
-                            addrlens,
-                             &tcp_nat_port_map_callback,
-                             &try_connection_reversal,
-                             plugin);
-    for (ret = ret_s -1; ret >= 0; ret--)
+    plugin->nat = GNUNET_NAT_register (env->cfg,
+                                       "transport-tcp",
+                                       IPPROTO_TCP,
+                                       (unsigned int) ret_s,
+                                       (const struct sockaddr **) addrs,
+                                       addrlens,
+                                       &tcp_nat_port_map_callback,
+                                       &try_connection_reversal,
+                                       plugin);
+    for (ret = ret_s - 1; ret >= 0; ret--)
       GNUNET_free (addrs[ret]);
     GNUNET_free_non_null (addrs);
     GNUNET_free_non_null (addrlens);
@@ -3941,7 +3801,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
   {
     plugin->nat = GNUNET_NAT_register (plugin->env->cfg,
                                        "transport-tcp",
-                                      IPPROTO_TCP,
+                                       IPPROTO_TCP,
                                        0,
                                        NULL,
                                        NULL,
@@ -3972,52 +3832,44 @@ libgnunet_plugin_transport_tcp_init (void *cls)
   }
   else
   {
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_time (env->cfg,
-                                             "transport-tcp",
-                                             "TIMEOUT",
-                                             &idle_timeout))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (env->cfg,
+                                                          "transport-tcp",
+                                                          "TIMEOUT",
+                                                          &idle_timeout))
     {
       GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                  "transport-tcp",
                                  "TIMEOUT");
       goto die;
     }
-    plugin->server
-      = GNUNET_SERVER_create_with_sockets (NULL,
-                                           plugin,
-                                          NULL,
-                                           idle_timeout,
-                                          GNUNET_YES);
+    plugin->server = GNUNET_SERVER_create_with_sockets (NULL,
+                                                        plugin,
+                                                        NULL,
+                                                        idle_timeout,
+                                                        GNUNET_YES);
   }
   plugin->handlers = GNUNET_malloc (sizeof (my_handlers));
-  GNUNET_memcpy (plugin->handlers,
-                my_handlers,
-                sizeof(my_handlers));
-  for (i = 0;i < sizeof(my_handlers) / sizeof(struct GNUNET_SERVER_MessageHandler);i++)
+  GNUNET_memcpy (plugin->handlers, my_handlers, sizeof (my_handlers));
+  for (i = 0;
+       i < sizeof (my_handlers) / sizeof (struct GNUNET_SERVER_MessageHandler);
+       i++)
     plugin->handlers[i].callback_cls = plugin;
 
-  GNUNET_SERVER_add_handlers (plugin->server,
-                              plugin->handlers);
-  GNUNET_SERVER_connect_notify (plugin->server,
-                               &connect_notify,
-                               plugin);
-  GNUNET_SERVER_disconnect_notify (plugin->server,
-                                   &disconnect_notify,
-                                   plugin);
-  plugin->nat_wait_conns = GNUNET_CONTAINER_multipeermap_create (16,
-                                                                 GNUNET_YES);
+  GNUNET_SERVER_add_handlers (plugin->server, plugin->handlers);
+  GNUNET_SERVER_connect_notify (plugin->server, &connect_notify, plugin);
+  GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin);
+  plugin->nat_wait_conns =
+    GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
   if (0 != bport)
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("TCP transport listening on port %llu\n"),
+         _ ("TCP transport listening on port %llu\n"),
          bport);
   else
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("TCP transport not listening on any port (client only)\n"));
-  if ( (aport != bport) &&
-       (0 != bport) )
+         _ ("TCP transport not listening on any port (client only)\n"));
+  if ((aport != bport) && (0 != bport))
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("TCP transport advertises itself as being on port %llu\n"),
+         _ ("TCP transport advertises itself as being on port %llu\n"),
          aport);
   /* Initially set connections to 0 */
   GNUNET_STATISTICS_set (plugin->env->stats,
@@ -4026,7 +3878,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
                          GNUNET_NO);
   return api;
 
- die:
+die:
   if (NULL != plugin->nat)
     GNUNET_NAT_unregister (plugin->nat);
   GNUNET_CONTAINER_multipeermap_destroy (plugin->sessionmap);
@@ -4055,11 +3907,10 @@ libgnunet_plugin_transport_tcp_done (void *cls)
 
   if (NULL == plugin)
   {
-    GNUNET_free(api);
-    return NULL ;
+    GNUNET_free (api);
+    return NULL;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Shutting down TCP plugin\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down TCP plugin\n");
 
   /* Removing leftover sessions */
   GNUNET_CONTAINER_multipeermap_iterate (plugin->sessionmap,
@@ -4077,9 +3928,7 @@ libgnunet_plugin_transport_tcp_done (void *cls)
                                  plugin->ppc_dll_tail,
                                  cur);
     GNUNET_RESOLVER_request_cancel (cur->resolver_handle);
-    cur->asc (cur->asc_cls,
-             NULL,
-             GNUNET_OK);
+    cur->asc (cur->asc_cls, NULL, GNUNET_OK);
     GNUNET_free (cur);
   }
 
index b05192e063a52324f78585174d2bd7c357bda3f1..1d34cdd1a82731fb8b813e0a6272302e3c3c83f8 100644 (file)
 #include "gnunet_transport_plugin.h"
 #include "transport.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
 
 /**
  * After how much inactivity should a UDP session time out?
  */
-#define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define UDP_SESSION_TIME_OUT \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 /**
  * Number of messages we can defragment in parallel.  We only really
@@ -86,7 +87,6 @@ struct UDPMessage
    * What is the identity of the sender
    */
   struct GNUNET_PeerIdentity sender;
-
 };
 
 
@@ -144,7 +144,6 @@ struct PrettyPrinterContext
    * Port to add after the IP address.
    */
   uint16_t port;
-
 };
 
 
@@ -248,7 +247,6 @@ struct GNUNET_ATS_Session
 };
 
 
-
 /**
  * Data structure to track defragmentation contexts based
  * on the source of the UDP traffic.
@@ -374,7 +372,6 @@ struct UDP_FragmentationContext
    * Bytes used to send all fragments on wire including UDP overhead
    */
   size_t on_wire_size;
-
 };
 
 
@@ -388,10 +385,9 @@ struct UDP_FragmentationContext
  *               #GNUNET_SYSERR if the target disconnected
  *               or we had a timeout or other trouble sending
  */
-typedef void
-(*QueueContinuation) (void *cls,
-                      struct UDP_MessageWrapper *udpw,
-                      int result);
+typedef void (*QueueContinuation) (void *cls,
+                                   struct UDP_MessageWrapper *udpw,
+                                   int result);
 
 
 /**
@@ -474,7 +470,6 @@ struct UDP_MessageWrapper
    * Payload size of original message.
    */
   size_t payload_size;
-
 };
 
 
@@ -501,7 +496,6 @@ struct UDP_ACK_Message
    * What is the identity of the sender
    */
   struct GNUNET_PeerIdentity sender;
-
 };
 
 GNUNET_NETWORK_STRUCT_END
@@ -529,9 +523,7 @@ notify_session_monitor (struct Plugin *plugin,
     return;
   if (GNUNET_YES == session->in_destroy)
     return; /* already destroyed, just RC>0 left-over actions */
-  memset (&info,
-          0,
-          sizeof (info));
+  memset (&info, 0, sizeof (info));
   info.state = state;
   info.is_inbound = GNUNET_SYSERR; /* hard to say */
   info.num_msg_pending = session->msgs_in_queue;
@@ -541,9 +533,7 @@ notify_session_monitor (struct Plugin *plugin,
      to receive from others) */
   info.session_timeout = session->timeout;
   info.address = session->address;
-  plugin->sic (plugin->sic_cls,
-               session,
-               &info);
+  plugin->sic (plugin->sic_cls, session, &info);
 }
 
 
@@ -563,12 +553,8 @@ send_session_info_iter (void *cls,
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session = value;
 
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_INIT);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UP);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
   return GNUNET_OK;
 }
 
@@ -600,9 +586,7 @@ udp_plugin_setup_monitor (void *cls,
                                            &send_session_info_iter,
                                            plugin);
     /* signal end of first iteration */
-    sic (sic_cls,
-         NULL,
-         NULL);
+    sic (sic_cls, NULL, NULL);
   }
 }
 
@@ -625,9 +609,7 @@ free_session (struct GNUNET_ATS_Session *s)
   }
   if (NULL != s->frag_ctx)
   {
-    GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag,
-                                     NULL,
-                                     NULL);
+    GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag, NULL, NULL);
     GNUNET_free (s->frag_ctx);
     s->frag_ctx = NULL;
   }
@@ -663,8 +645,7 @@ udp_query_keepalive_factor (void *cls)
  * @return the network type
  */
 static enum GNUNET_NetworkType
-udp_plugin_get_network (void *cls,
-                        struct GNUNET_ATS_Session *session)
+udp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
 {
   return session->scope;
 }
@@ -691,25 +672,25 @@ udp_plugin_get_network_for_address (void *cls,
   size_t sbs;
 
   addrlen = address->address_length;
-  if (addrlen == sizeof(struct IPv6UdpAddress))
+  if (addrlen == sizeof (struct IPv6UdpAddress))
   {
     GNUNET_assert (NULL != address->address); /* make static analysis happy */
     u6 = address->address;
-    memset (&a6, 0, sizeof(a6));
+    memset (&a6, 0, sizeof (a6));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a6.sin6_len = sizeof (a6);
 #endif
     a6.sin6_family = AF_INET6;
     a6.sin6_port = u6->u6_port;
-    GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof(struct in6_addr));
+    GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof (struct in6_addr));
     sb = &a6;
-    sbs = sizeof(a6);
+    sbs = sizeof (a6);
   }
-  else if (addrlen == sizeof(struct IPv4UdpAddress))
+  else if (addrlen == sizeof (struct IPv4UdpAddress))
   {
     GNUNET_assert (NULL != address->address); /* make static analysis happy */
     u4 = address->address;
-    memset (&a4, 0, sizeof(a4));
+    memset (&a4, 0, sizeof (a4));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a4.sin_len = sizeof (a4);
 #endif
@@ -717,16 +698,14 @@ udp_plugin_get_network_for_address (void *cls,
     a4.sin_port = u4->u4_port;
     a4.sin_addr.s_addr = u4->ipv4_addr;
     sb = &a4;
-    sbs = sizeof(a4);
+    sbs = sizeof (a4);
   }
   else
   {
     GNUNET_break (0);
     return GNUNET_NT_UNSPECIFIED;
   }
-  return plugin->env->get_address_type (plugin->env->cls,
-                                        sb,
-                                        sbs);
+  return plugin->env->get_address_type (plugin->env->cls, sb, sbs);
 }
 
 
@@ -767,8 +746,7 @@ schedule_select_v4 (struct Plugin *plugin)
   struct UDP_MessageWrapper *udpw;
   struct UDP_MessageWrapper *min_udpw;
 
-  if ( (GNUNET_YES == plugin->enable_ipv4) &&
-       (NULL != plugin->sockv4) )
+  if ((GNUNET_YES == plugin->enable_ipv4) && (NULL != plugin->sockv4))
   {
     /* Find a message ready to send:
      * Flow delay from other peer is expired or not set (0) */
@@ -804,11 +782,11 @@ schedule_select_v4 (struct Plugin *plugin)
                     GNUNET_i2s (&min_udpw->session->target));
       }
     }
-    plugin->select_task_v4
-      GNUNET_SCHEDULER_add_read_net (min_delay,
-                                       plugin->sockv4,
-                                       &udp_plugin_select_v4,
-                                       plugin);
+    plugin->select_task_v4 =
+      GNUNET_SCHEDULER_add_read_net (min_delay,
+                                     plugin->sockv4,
+                                     &udp_plugin_select_v4,
+                                     plugin);
   }
 }
 
@@ -826,8 +804,7 @@ schedule_select_v6 (struct Plugin *plugin)
   struct UDP_MessageWrapper *udpw;
   struct UDP_MessageWrapper *min_udpw;
 
-  if ( (GNUNET_YES == plugin->enable_ipv6) &&
-       (NULL != plugin->sockv6) )
+  if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6))
   {
     min_delay = GNUNET_TIME_UNIT_FOREVER_REL;
     min_udpw = NULL;
@@ -861,11 +838,11 @@ schedule_select_v6 (struct Plugin *plugin)
                     GNUNET_i2s (&min_udpw->session->target));
       }
     }
-    plugin->select_task_v6
-      GNUNET_SCHEDULER_add_read_net (min_delay,
-                                       plugin->sockv6,
-                                       &udp_plugin_select_v6,
-                                       plugin);
+    plugin->select_task_v6 =
+      GNUNET_SCHEDULER_add_read_net (min_delay,
+                                     plugin->sockv6,
+                                     &udp_plugin_select_v6,
+                                     plugin);
   }
 }
 
@@ -885,9 +862,7 @@ schedule_select_v6 (struct Plugin *plugin)
  * @return string representing the same address
  */
 const char *
-udp_address_to_string (void *cls,
-                       const void *addr,
-                       size_t addrlen)
+udp_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
   static char rbuf[INET6_ADDRSTRLEN + 10];
   char buf[INET6_ADDRSTRLEN];
@@ -906,7 +881,7 @@ udp_address_to_string (void *cls,
     return NULL;
   }
 
-  if (addrlen == sizeof(struct IPv6UdpAddress))
+  if (addrlen == sizeof (struct IPv6UdpAddress))
   {
     t6 = addr;
     af = AF_INET6;
@@ -915,7 +890,7 @@ udp_address_to_string (void *cls,
     a6 = t6->ipv6_addr;
     sb = &a6;
   }
-  else if (addrlen == sizeof(struct IPv4UdpAddress))
+  else if (addrlen == sizeof (struct IPv4UdpAddress))
   {
     t4 = addr;
     af = AF_INET;
@@ -929,15 +904,10 @@ udp_address_to_string (void *cls,
     GNUNET_break_op (0);
     return NULL;
   }
-  inet_ntop (af,
-             sb,
-             buf,
-             INET6_ADDRSTRLEN);
+  inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
   GNUNET_snprintf (rbuf,
-                   sizeof(rbuf),
-                   (af == AF_INET6)
-                   ? "%s.%u.[%s]:%u"
-                   : "%s.%u.%s:%u",
+                   sizeof (rbuf),
+                   (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u",
                    PLUGIN_NAME,
                    options,
                    buf,
@@ -1012,44 +982,42 @@ udp_string_to_address (void *cls,
   address++;
 
   if (GNUNET_OK !=
-      GNUNET_STRINGS_to_address_ip (address,
-                                    strlen (address),
-                                    &socket_address))
+      GNUNET_STRINGS_to_address_ip (address, strlen (address), &socket_address))
   {
     GNUNET_break (0);
     GNUNET_free (plugin);
     return GNUNET_SYSERR;
   }
-  GNUNET_free(plugin);
+  GNUNET_free (plugin);
 
   switch (socket_address.ss_family)
   {
-  case AF_INET:
-    {
-      struct IPv4UdpAddress *u4;
-      const struct sockaddr_in *in4 = (const struct sockaddr_in *) &socket_address;
-
-      u4 = GNUNET_new (struct IPv4UdpAddress);
-      u4->options = htonl (options);
-      u4->ipv4_addr = in4->sin_addr.s_addr;
-      u4->u4_port = in4->sin_port;
-      *buf = u4;
-      *added = sizeof (struct IPv4UdpAddress);
-      return GNUNET_OK;
-    }
-  case AF_INET6:
-    {
-      struct IPv6UdpAddress *u6;
-      const struct sockaddr_in6 *in6 = (const struct sockaddr_in6 *) &socket_address;
-
-      u6 = GNUNET_new (struct IPv6UdpAddress);
-      u6->options = htonl (options);
-      u6->ipv6_addr = in6->sin6_addr;
-      u6->u6_port = in6->sin6_port;
-      *buf = u6;
-      *added = sizeof (struct IPv6UdpAddress);
-      return GNUNET_OK;
-    }
+  case AF_INET: {
+    struct IPv4UdpAddress *u4;
+    const struct sockaddr_in *in4 =
+      (const struct sockaddr_in *) &socket_address;
+
+    u4 = GNUNET_new (struct IPv4UdpAddress);
+    u4->options = htonl (options);
+    u4->ipv4_addr = in4->sin_addr.s_addr;
+    u4->u4_port = in4->sin_port;
+    *buf = u4;
+    *added = sizeof (struct IPv4UdpAddress);
+    return GNUNET_OK;
+  }
+  case AF_INET6: {
+    struct IPv6UdpAddress *u6;
+    const struct sockaddr_in6 *in6 =
+      (const struct sockaddr_in6 *) &socket_address;
+
+    u6 = GNUNET_new (struct IPv6UdpAddress);
+    u6->options = htonl (options);
+    u6->ipv6_addr = in6->sin6_addr;
+    u6->u6_port = in6->sin6_port;
+    *buf = u6;
+    *added = sizeof (struct IPv6UdpAddress);
+    return GNUNET_OK;
+  }
   default:
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1064,8 +1032,7 @@ udp_string_to_address (void *cls,
  * @param hostname result from DNS resolver
  */
 static void
-append_port (void *cls,
-             const char *hostname)
+append_port (void *cls, const char *hostname)
 {
   struct PrettyPrinterContext *ppc = cls;
   struct Plugin *plugin = ppc->plugin;
@@ -1078,9 +1045,7 @@ append_port (void *cls,
                                  plugin->ppc_dll_tail,
                                  ppc);
     ppc->resolver_handle = NULL;
-    ppc->asc (ppc->asc_cls,
-              NULL,
-              GNUNET_OK);
+    ppc->asc (ppc->asc_cls, NULL, GNUNET_OK);
     GNUNET_free (ppc);
     return;
   }
@@ -1098,9 +1063,7 @@ append_port (void *cls,
                      ppc->options,
                      hostname,
                      ppc->port);
-  ppc->asc (ppc->asc_cls,
-            ret,
-            GNUNET_OK);
+  ppc->asc (ppc->asc_cls, ret, GNUNET_OK);
   GNUNET_free (ret);
 }
 
@@ -1140,12 +1103,10 @@ udp_plugin_address_pretty_printer (void *cls,
   uint16_t port;
   uint32_t options;
 
-  if (addrlen == sizeof(struct IPv6UdpAddress))
+  if (addrlen == sizeof (struct IPv6UdpAddress))
   {
     u6 = addr;
-    memset (&a6,
-            0,
-            sizeof (a6));
+    memset (&a6, 0, sizeof (a6));
     a6.sin6_family = AF_INET6;
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a6.sin6_len = sizeof (a6);
@@ -1160,9 +1121,7 @@ udp_plugin_address_pretty_printer (void *cls,
   else if (addrlen == sizeof (struct IPv4UdpAddress))
   {
     u4 = addr;
-    memset (&a4,
-            0,
-            sizeof(a4));
+    memset (&a4, 0, sizeof (a4));
     a4.sin_family = AF_INET;
 #if HAVE_SOCKADDR_IN_SIN_LEN
     a4.sin_len = sizeof (a4);
@@ -1172,18 +1131,14 @@ udp_plugin_address_pretty_printer (void *cls,
     port = ntohs (u4->u4_port);
     options = ntohl (u4->options);
     sb = (const struct sockaddr *) &a4;
-    sbs = sizeof(a4);
+    sbs = sizeof (a4);
   }
   else
   {
     /* invalid address */
     GNUNET_break_op (0);
-    asc (asc_cls,
-         NULL,
-         GNUNET_SYSERR);
-    asc (asc_cls,
-         NULL,
-         GNUNET_OK);
+    asc (asc_cls, NULL, GNUNET_SYSERR);
+    asc (asc_cls, NULL, GNUNET_OK);
     return;
   }
   ppc = GNUNET_new (struct PrettyPrinterContext);
@@ -1196,16 +1151,13 @@ udp_plugin_address_pretty_printer (void *cls,
     ppc->ipv6 = GNUNET_YES;
   else
     ppc->ipv6 = GNUNET_NO;
-  GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head,
-                               plugin->ppc_dll_tail,
-                               ppc);
-  ppc->resolver_handle
-    = GNUNET_RESOLVER_hostname_get (sb,
-                                    sbs,
-                                    ! numeric,
-                                    timeout,
-                                    &append_port,
-                                    ppc);
+  GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, plugin->ppc_dll_tail, ppc);
+  ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb,
+                                                       sbs,
+                                                       ! numeric,
+                                                       timeout,
+                                                       &append_port,
+                                                       ppc);
 }
 
 
@@ -1219,11 +1171,9 @@ udp_plugin_address_pretty_printer (void *cls,
  * @return #GNUNET_OK if port is either our open or advertised port
  */
 static int
-check_port (const struct Plugin *plugin,
-            uint16_t in_port)
+check_port (const struct Plugin *plugin, uint16_t in_port)
 {
-  if ( (plugin->port == in_port) ||
-       (plugin->aport == in_port) )
+  if ((plugin->port == in_port) || (plugin->aport == in_port))
     return GNUNET_OK;
   return GNUNET_SYSERR;
 }
@@ -1245,21 +1195,18 @@ check_port (const struct Plugin *plugin,
  *         and transport, #GNUNET_SYSERR if not
  */
 static int
-udp_plugin_check_address (void *cls,
-                          const void *addr,
-                          size_t addrlen)
+udp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
 {
   struct Plugin *plugin = cls;
   const struct IPv4UdpAddress *v4;
   const struct IPv6UdpAddress *v6;
 
-  if (sizeof(struct IPv4UdpAddress) == addrlen)
+  if (sizeof (struct IPv4UdpAddress) == addrlen)
   {
     struct sockaddr_in s4;
 
     v4 = (const struct IPv4UdpAddress *) addr;
-    if (GNUNET_OK != check_port (plugin,
-                                 ntohs (v4->u4_port)))
+    if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port)))
       return GNUNET_SYSERR;
     memset (&s4, 0, sizeof (s4));
     s4.sin_family = AF_INET;
@@ -1270,12 +1217,10 @@ udp_plugin_check_address (void *cls,
     s4.sin_addr.s_addr = v4->ipv4_addr;
 
     if (GNUNET_OK !=
-       GNUNET_NAT_test_address (plugin->nat,
-                                &s4,
-                                sizeof (struct sockaddr_in)))
+        GNUNET_NAT_test_address (plugin->nat, &s4, sizeof (struct sockaddr_in)))
       return GNUNET_SYSERR;
   }
-  else if (sizeof(struct IPv6UdpAddress) == addrlen)
+  else if (sizeof (struct IPv6UdpAddress) == addrlen)
   {
     struct sockaddr_in6 s6;
 
@@ -1290,10 +1235,9 @@ udp_plugin_check_address (void *cls,
     s6.sin6_port = v6->u6_port;
     s6.sin6_addr = v6->ipv6_addr;
 
-    if (GNUNET_OK !=
-       GNUNET_NAT_test_address (plugin->nat,
-                                &s6,
-                                sizeof(struct sockaddr_in6)))
+    if (GNUNET_OK != GNUNET_NAT_test_address (plugin->nat,
+                                              &s6,
+                                              sizeof (struct sockaddr_in6)))
       return GNUNET_SYSERR;
   }
   else
@@ -1319,9 +1263,9 @@ udp_plugin_check_address (void *cls,
  */
 static void
 udp_nat_port_map_callback (void *cls,
-                          void **app_ctx,
+                           void **app_ctx,
                            int add_remove,
-                          enum GNUNET_NAT_AddressClass ac,
+                           enum GNUNET_NAT_AddressClass ac,
                            const struct sockaddr *addr,
                            socklen_t addrlen)
 {
@@ -1334,50 +1278,42 @@ udp_nat_port_map_callback (void *cls,
 
   (void) app_ctx;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       (GNUNET_YES == add_remove)
-       ? "NAT notification to add address `%s'\n"
-       : "NAT notification to remove address `%s'\n",
-       GNUNET_a2s (addr,
-                   addrlen));
+       (GNUNET_YES == add_remove) ? "NAT notification to add address `%s'\n"
+                                  : "NAT notification to remove address `%s'\n",
+       GNUNET_a2s (addr, addrlen));
   /* convert 'address' to our internal format */
   switch (addr->sa_family)
   {
-  case AF_INET:
-    {
-      const struct sockaddr_in *i4;
-
-      GNUNET_assert (sizeof(struct sockaddr_in) == addrlen);
-      i4 = (const struct sockaddr_in *) addr;
-      if (0 == ntohs (i4->sin_port))
-        return; /* Port = 0 means unmapped, ignore these for UDP. */
-      memset (&u4,
-              0,
-              sizeof(u4));
-      u4.options = htonl (plugin->myoptions);
-      u4.ipv4_addr = i4->sin_addr.s_addr;
-      u4.u4_port = i4->sin_port;
-      arg = &u4;
-      args = sizeof (struct IPv4UdpAddress);
-      break;
-    }
-  case AF_INET6:
-    {
-      const struct sockaddr_in6 *i6;
-
-      GNUNET_assert (sizeof(struct sockaddr_in6) == addrlen);
-      i6 = (const struct sockaddr_in6 *) addr;
-      if (0 == ntohs (i6->sin6_port))
-        return; /* Port = 0 means unmapped, ignore these for UDP. */
-      memset (&u6,
-              0,
-              sizeof(u6));
-      u6.options = htonl (plugin->myoptions);
-      u6.ipv6_addr = i6->sin6_addr;
-      u6.u6_port = i6->sin6_port;
-      arg = &u6;
-      args = sizeof (struct IPv6UdpAddress);
-      break;
-    }
+  case AF_INET: {
+    const struct sockaddr_in *i4;
+
+    GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
+    i4 = (const struct sockaddr_in *) addr;
+    if (0 == ntohs (i4->sin_port))
+      return; /* Port = 0 means unmapped, ignore these for UDP. */
+    memset (&u4, 0, sizeof (u4));
+    u4.options = htonl (plugin->myoptions);
+    u4.ipv4_addr = i4->sin_addr.s_addr;
+    u4.u4_port = i4->sin_port;
+    arg = &u4;
+    args = sizeof (struct IPv4UdpAddress);
+    break;
+  }
+  case AF_INET6: {
+    const struct sockaddr_in6 *i6;
+
+    GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
+    i6 = (const struct sockaddr_in6 *) addr;
+    if (0 == ntohs (i6->sin6_port))
+      return; /* Port = 0 means unmapped, ignore these for UDP. */
+    memset (&u6, 0, sizeof (u6));
+    u6.options = htonl (plugin->myoptions);
+    u6.ipv6_addr = i6->sin6_addr;
+    u6.u6_port = i6->sin6_port;
+    arg = &u6;
+    args = sizeof (struct IPv6UdpAddress);
+    break;
+  }
   default:
     GNUNET_break (0);
     return;
@@ -1389,9 +1325,7 @@ udp_nat_port_map_callback (void *cls,
                                            arg,
                                            args,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  plugin->env->notify_address (plugin->env->cls,
-                               add_remove,
-                               address);
+  plugin->env->notify_address (plugin->env->cls, add_remove, address);
   GNUNET_HELLO_address_free (address);
 }
 
@@ -1425,15 +1359,12 @@ struct GNUNET_ATS_SessionCompareContext
  * @return #GNUNET_NO if we found the session, #GNUNET_OK if not
  */
 static int
-session_cmp_it (void *cls,
-                const struct GNUNET_PeerIdentity *key,
-                void *value)
+session_cmp_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 {
   struct GNUNET_ATS_SessionCompareContext *cctx = cls;
   struct GNUNET_ATS_Session *s = value;
 
-  if (0 == GNUNET_HELLO_address_cmp (s->address,
-                                     cctx->address))
+  if (0 == GNUNET_HELLO_address_cmp (s->address, cctx->address))
   {
     GNUNET_assert (GNUNET_NO == s->in_destroy);
     cctx->res = s;
@@ -1466,7 +1397,7 @@ udp_plugin_lookup_session (void *cls,
     GNUNET_break (0);
     return NULL;
   }
-  if (sizeof(struct IPv4UdpAddress) == address->address_length)
+  if (sizeof (struct IPv4UdpAddress) == address->address_length)
   {
     if (NULL == plugin->sockv4)
       return NULL;
@@ -1477,7 +1408,7 @@ udp_plugin_lookup_session (void *cls,
       return NULL;
     }
   }
-  else if (sizeof(struct IPv6UdpAddress) == address->address_length)
+  else if (sizeof (struct IPv6UdpAddress) == address->address_length)
   {
     if (NULL == plugin->sockv6)
       return NULL;
@@ -1509,9 +1440,7 @@ udp_plugin_lookup_session (void *cls,
                                               &cctx);
   if (NULL == cctx.res)
     return NULL;
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Found existing session %p\n",
-       cctx.res);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res);
   return cctx.res;
 }
 
@@ -1534,7 +1463,6 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *s)
 }
 
 
-
 /**
  * Function that will be called whenever the transport service wants to
  * notify the plugin that a session is still active and in use and
@@ -1575,8 +1503,7 @@ udp_plugin_update_session_timeout (void *cls,
  * @param udpw message wrapper to dequeue
  */
 static void
-dequeue (struct Plugin *plugin,
-         struct UDP_MessageWrapper *udpw)
+dequeue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw)
 {
   struct GNUNET_ATS_Session *session = udpw->session;
 
@@ -1588,7 +1515,7 @@ dequeue (struct Plugin *plugin,
   {
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, total bytes in send buffers",
-                              - (long long) udpw->msg_size,
+                              -(long long) udpw->msg_size,
                               GNUNET_NO);
     plugin->bytes_in_buffer -= udpw->msg_size;
   }
@@ -1596,13 +1523,14 @@ dequeue (struct Plugin *plugin,
                             "# UDP, total messages in send buffers",
                             -1,
                             GNUNET_NO);
-  if (sizeof(struct IPv4UdpAddress) == udpw->session->address->address_length)
+  if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
   {
     GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head,
                                  plugin->ipv4_queue_tail,
                                  udpw);
   }
-  else if (sizeof(struct IPv6UdpAddress) == udpw->session->address->address_length)
+  else if (sizeof (struct IPv6UdpAddress) ==
+           udpw->session->address->address_length)
   {
     GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head,
                                  plugin->ipv6_queue_tail,
@@ -1627,8 +1555,7 @@ dequeue (struct Plugin *plugin,
  * @param udpw message wrapper to queue
  */
 static void
-enqueue (struct Plugin *plugin,
-         struct UDP_MessageWrapper *udpw)
+enqueue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw)
 {
   struct GNUNET_ATS_Session *session = udpw->session;
 
@@ -1656,11 +1583,12 @@ enqueue (struct Plugin *plugin,
                             GNUNET_NO);
   if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
   {
-    GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head,
-                                plugin->ipv4_queue_tail,
-                                udpw);
+    GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head,
+                                 plugin->ipv4_queue_tail,
+                                 udpw);
   }
-  else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length)
+  else if (sizeof (struct IPv6UdpAddress) ==
+           udpw->session->address->address_length)
   {
     GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head,
                                  plugin->ipv6_queue_tail,
@@ -1693,8 +1621,7 @@ enqueue (struct Plugin *plugin,
  *               #GNUNET_SYSERR if the transmission failed
  */
 static void
-fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
-                         int result)
+fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, int result)
 {
   struct Plugin *plugin = frag_ctx->plugin;
   struct GNUNET_ATS_Session *s = frag_ctx->session;
@@ -1717,16 +1644,14 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Fragmented message acknowledged after %s (expected at %s)\n",
-         GNUNET_STRINGS_relative_time_to_string (delay,
-                                                 GNUNET_YES),
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
          GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time));
   }
   else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Fragmented message acknowledged after %s (expected at %s)\n",
-         GNUNET_STRINGS_relative_time_to_string (delay,
-                                                 GNUNET_YES),
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
          GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time));
   }
 
@@ -1751,10 +1676,11 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
                               "# UDP, fragmented msgs, bytes payload, sent, success",
                               s->frag_ctx->payload_size,
                               GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, fragmented msgs, bytes overhead, sent, success",
-                              overhead,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, fragmented msgs, bytes overhead, sent, success",
+      overhead,
+      GNUNET_NO);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, total, bytes overhead, sent",
                               overhead,
@@ -1786,41 +1712,35 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
 
   /* Remove remaining fragments from queue, no need to transmit those
      any longer. */
-  if (s->address->address_length == sizeof(struct IPv6UdpAddress))
+  if (s->address->address_length == sizeof (struct IPv6UdpAddress))
   {
     udpw = plugin->ipv6_queue_head;
     while (NULL != udpw)
     {
       tmp = udpw->next;
-      if ( (udpw->frag_ctx != NULL) &&
-          (udpw->frag_ctx == frag_ctx) )
+      if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == frag_ctx))
       {
-       dequeue (plugin,
-                 udpw);
-       GNUNET_free (udpw);
+        dequeue (plugin, udpw);
+        GNUNET_free (udpw);
       }
       udpw = tmp;
     }
   }
-  if (s->address->address_length == sizeof(struct IPv4UdpAddress))
+  if (s->address->address_length == sizeof (struct IPv4UdpAddress))
   {
     udpw = plugin->ipv4_queue_head;
     while (NULL != udpw)
     {
       tmp = udpw->next;
-      if ( (NULL != udpw->frag_ctx) &&
-           (udpw->frag_ctx == frag_ctx) )
+      if ((NULL != udpw->frag_ctx) && (udpw->frag_ctx == frag_ctx))
       {
-        dequeue (plugin,
-                 udpw);
+        dequeue (plugin, udpw);
         GNUNET_free (udpw);
       }
       udpw = tmp;
     }
   }
-  notify_session_monitor (s->plugin,
-                          s,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+  notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
   GNUNET_FRAGMENT_context_destroy (frag_ctx->frag,
                                    &s->last_expected_msg_delay,
                                    &s->last_expected_ack_delay);
@@ -1838,9 +1758,7 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
  * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
 static void
-qc_fragment_sent (void *cls,
-                  struct UDP_MessageWrapper *udpw,
-                  int result)
+qc_fragment_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
 {
   struct Plugin *plugin = cls;
 
@@ -1856,10 +1774,11 @@ qc_fragment_sent (void *cls,
                               "# UDP, fragmented msgs, fragments, sent, success",
                               1,
                               GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, fragmented msgs, fragments bytes, sent, success",
-                              udpw->msg_size,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, fragmented msgs, fragments bytes, sent, success",
+      udpw->msg_size,
+      GNUNET_NO);
   }
   else
   {
@@ -1867,16 +1786,16 @@ qc_fragment_sent (void *cls,
                 "Failed to transmit fragment of message with %u bytes to %s\n",
                 (unsigned int) udpw->payload_size,
                 GNUNET_i2s (&udpw->session->target));
-    fragmented_message_done (udpw->frag_ctx,
-                             GNUNET_SYSERR);
+    fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, fragmented msgs, fragments, sent, failure",
                               1,
                               GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, fragmented msgs, fragments bytes, sent, failure",
-                              udpw->msg_size,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, fragmented msgs, fragments bytes, sent, failure",
+      udpw->msg_size,
+      GNUNET_NO);
   }
 }
 
@@ -1891,8 +1810,7 @@ qc_fragment_sent (void *cls,
  * @param msg the message that was created
  */
 static void
-enqueue_fragment (void *cls,
-                  const struct GNUNET_MessageHeader *msg)
+enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct UDP_FragmentationContext *frag_ctx = cls;
   struct Plugin *plugin = frag_ctx->plugin;
@@ -1900,9 +1818,7 @@ enqueue_fragment (void *cls,
   struct GNUNET_ATS_Session *session = frag_ctx->session;
   size_t msg_len = ntohs (msg->size);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Enqueuing fragment with %u bytes\n",
-       msg_len);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len);
   udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len);
   udpw->session = session;
   udpw->msg_buf = (char *) &udpw[1];
@@ -1911,17 +1827,14 @@ enqueue_fragment (void *cls,
   udpw->timeout = frag_ctx->timeout;
   udpw->start_time = frag_ctx->start_time;
   udpw->transmission_time = frag_ctx->next_frag_time;
-  frag_ctx->next_frag_time
-    GNUNET_TIME_absolute_add (frag_ctx->next_frag_time,
-                                frag_ctx->flow_delay_from_other_peer);
+  frag_ctx->next_frag_time =
+    GNUNET_TIME_absolute_add (frag_ctx->next_frag_time,
+                              frag_ctx->flow_delay_from_other_peer);
   udpw->frag_ctx = frag_ctx;
   udpw->qc = &qc_fragment_sent;
   udpw->qc_cls = plugin;
-  GNUNET_memcpy (udpw->msg_buf,
-                msg,
-                msg_len);
-  enqueue (plugin,
-           udpw);
+  GNUNET_memcpy (udpw->msg_buf, msg, msg_len);
+  enqueue (plugin, udpw);
   if (session->address->address_length == sizeof (struct IPv4UdpAddress))
     schedule_select_v4 (plugin);
   else
@@ -1938,9 +1851,7 @@ enqueue_fragment (void *cls,
  * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
 static void
-qc_message_sent (void *cls,
-                 struct UDP_MessageWrapper *udpw,
-                 int result)
+qc_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
 {
   struct Plugin *plugin = cls;
   size_t overhead;
@@ -1958,15 +1869,13 @@ qc_message_sent (void *cls,
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
            "Message sent via UDP with delay of %s\n",
-           GNUNET_STRINGS_relative_time_to_string (delay,
-                                                   GNUNET_YES));
+           GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     }
     else
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Message sent via UDP with delay of %s\n",
-           GNUNET_STRINGS_relative_time_to_string (delay,
-                                                   GNUNET_YES));
+           GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     }
     udpw->cont (udpw->cont_cls,
                 &udpw->session->target,
@@ -1980,14 +1889,16 @@ qc_message_sent (void *cls,
                               "# UDP, unfragmented msgs, messages, sent, success",
                               1,
                               GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, unfragmented msgs, bytes payload, sent, success",
-                              udpw->payload_size,
-                              GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, unfragmented msgs, bytes overhead, sent, success",
-                              overhead,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, unfragmented msgs, bytes payload, sent, success",
+      udpw->payload_size,
+      GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, unfragmented msgs, bytes overhead, sent, success",
+      overhead,
+      GNUNET_NO);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, total, bytes overhead, sent",
                               overhead,
@@ -2003,14 +1914,16 @@ qc_message_sent (void *cls,
                               "# UDP, unfragmented msgs, messages, sent, failure",
                               1,
                               GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, unfragmented msgs, bytes payload, sent, failure",
-                              udpw->payload_size,
-                              GNUNET_NO);
-    GNUNET_STATISTICS_update (plugin->env->stats,
-                              "# UDP, unfragmented msgs, bytes overhead, sent, failure",
-                              overhead,
-                              GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, unfragmented msgs, bytes payload, sent, failure",
+      udpw->payload_size,
+      GNUNET_NO);
+    GNUNET_STATISTICS_update (
+      plugin->env->stats,
+      "# UDP, unfragmented msgs, bytes overhead, sent, failure",
+      overhead,
+      GNUNET_NO);
   }
 }
 
@@ -2053,18 +1966,18 @@ udp_plugin_send (void *cls,
                  void *cont_cls)
 {
   struct Plugin *plugin = cls;
-  size_t udpmlen = msgbuf_size + sizeof(struct UDPMessage);
+  size_t udpmlen = msgbuf_size + sizeof (struct UDPMessage);
   struct UDP_FragmentationContext *frag_ctx;
   struct UDP_MessageWrapper *udpw;
   struct UDPMessage *udp;
   char mbuf[udpmlen] GNUNET_ALIGN;
   struct GNUNET_TIME_Relative latency;
 
-  if ( (sizeof(struct IPv6UdpAddress) == s->address->address_length) &&
-       (NULL == plugin->sockv6) )
+  if ((sizeof (struct IPv6UdpAddress) == s->address->address_length) &&
+      (NULL == plugin->sockv6))
     return GNUNET_SYSERR;
-  if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) &&
-       (NULL == plugin->sockv4) )
+  if ((sizeof (struct IPv4UdpAddress) == s->address->address_length) &&
+      (NULL == plugin->sockv4))
     return GNUNET_SYSERR;
   if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE)
   {
@@ -2112,22 +2025,19 @@ udp_plugin_send (void *cls,
     udpw->start_time = GNUNET_TIME_absolute_get ();
     udpw->timeout = GNUNET_TIME_relative_to_absolute (to);
     udpw->transmission_time = s->last_transmit_time;
-    s->last_transmit_time
-      GNUNET_TIME_absolute_add (s->last_transmit_time,
-                                  s->flow_delay_from_other_peer);
+    s->last_transmit_time =
+      GNUNET_TIME_absolute_add (s->last_transmit_time,
+                                s->flow_delay_from_other_peer);
     udpw->cont = cont;
     udpw->cont_cls = cont_cls;
     udpw->frag_ctx = NULL;
     udpw->qc = &qc_message_sent;
     udpw->qc_cls = plugin;
-    GNUNET_memcpy (udpw->msg_buf,
-            udp,
-            sizeof (struct UDPMessage));
-    GNUNET_memcpy (&udpw->msg_buf[sizeof(struct UDPMessage)],
-            msgbuf,
-            msgbuf_size);
-    enqueue (plugin,
-             udpw);
+    GNUNET_memcpy (udpw->msg_buf, udp, sizeof (struct UDPMessage));
+    GNUNET_memcpy (&udpw->msg_buf[sizeof (struct UDPMessage)],
+                   msgbuf,
+                   msgbuf_size);
+    enqueue (plugin, udpw);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, unfragmented messages queued total",
                               1,
@@ -2146,9 +2056,7 @@ udp_plugin_send (void *cls,
     /* fragmented message */
     if (NULL != s->frag_ctx)
       return GNUNET_SYSERR;
-    GNUNET_memcpy (&udp[1],
-            msgbuf,
-            msgbuf_size);
+    GNUNET_memcpy (&udp[1], msgbuf, msgbuf_size);
     frag_ctx = GNUNET_new (struct UDP_FragmentationContext);
     frag_ctx->plugin = plugin;
     frag_ctx->session = s;
@@ -2156,12 +2064,12 @@ udp_plugin_send (void *cls,
     frag_ctx->cont_cls = cont_cls;
     frag_ctx->start_time = GNUNET_TIME_absolute_get ();
     frag_ctx->next_frag_time = s->last_transmit_time;
-    frag_ctx->flow_delay_from_other_peer
-      = GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer,
-                                     1 + (msgbuf_size /
-                                          UDP_MTU));
+    frag_ctx->flow_delay_from_other_peer =
+      GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer,
+                                   1 + (msgbuf_size / UDP_MTU));
     frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to);
-    frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */
+    frag_ctx->payload_size =
+      msgbuf_size; /* unfragmented message size without UDP overhead */
     frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */
     frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats,
                                                      UDP_MTU,
@@ -2177,15 +2085,13 @@ udp_plugin_send (void *cls,
     if (latency.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
       LOG (GNUNET_ERROR_TYPE_WARNING,
            "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n",
-           GNUNET_STRINGS_relative_time_to_string (latency,
-                                                   GNUNET_YES),
+           GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES),
            GNUNET_i2s (&s->target),
            (unsigned int) s->msgs_in_queue);
     else
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n",
-           GNUNET_STRINGS_relative_time_to_string (latency,
-                                                   GNUNET_YES),
+           GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES),
            GNUNET_i2s (&s->target),
            (unsigned int) s->msgs_in_queue);
 
@@ -2202,9 +2108,7 @@ udp_plugin_send (void *cls,
                               frag_ctx->payload_size,
                               GNUNET_NO);
   }
-  notify_session_monitor (s->plugin,
-                          s,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+  notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
   return udpmlen;
 }
 
@@ -2236,7 +2140,6 @@ struct FindReceiveContext
    * Number of bytes in @e udp_addr.
    */
   size_t udp_addr_len;
-
 };
 
 
@@ -2259,10 +2162,8 @@ find_receive_context (void *cls,
   struct FindReceiveContext *frc = cls;
   struct DefragContext *e = element;
 
-  if ( (frc->udp_addr_len == e->udp_addr_len) &&
-       (0 == memcmp (frc->udp_addr,
-                     e->udp_addr,
-                     frc->udp_addr_len)) )
+  if ((frc->udp_addr_len == e->udp_addr_len) &&
+      (0 == memcmp (frc->udp_addr, e->udp_addr, frc->udp_addr_len)))
   {
     frc->rc = e;
     return GNUNET_NO;
@@ -2280,8 +2181,7 @@ find_receive_context (void *cls,
  * @return #GNUNET_OK on success
  */
 static int
-udp_disconnect_session (void *cls,
-                        struct GNUNET_ATS_Session *s)
+udp_disconnect_session (void *cls, struct GNUNET_ATS_Session *s)
 {
   struct Plugin *plugin = cls;
   struct UDP_MessageWrapper *udpw;
@@ -2304,13 +2204,11 @@ udp_disconnect_session (void *cls,
   if (NULL != s->frag_ctx)
   {
     /* Remove fragmented message due to disconnect */
-    fragmented_message_done (s->frag_ctx,
-                             GNUNET_SYSERR);
+    fragmented_message_done (s->frag_ctx, GNUNET_SYSERR);
   }
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
-                                                       &s->target,
-                                                       s));
+  GNUNET_assert (
+    GNUNET_YES ==
+    GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, &s->target, s));
   frc.rc = NULL;
   frc.udp_addr = s->address->address;
   frc.udp_addr_len = s->address->address_length;
@@ -2336,11 +2234,8 @@ udp_disconnect_session (void *cls,
     next = udpw->next;
     if (udpw->session == s)
     {
-      dequeue (plugin,
-               udpw);
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_SYSERR);
+      dequeue (plugin, udpw);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
     }
   }
@@ -2350,16 +2245,12 @@ udp_disconnect_session (void *cls,
     next = udpw->next;
     if (udpw->session == s)
     {
-      dequeue (plugin,
-               udpw);
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_SYSERR);
+      dequeue (plugin, udpw);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
     }
   }
-  if ( (NULL != s->frag_ctx) &&
-       (NULL != s->frag_ctx->cont) )
+  if ((NULL != s->frag_ctx) && (NULL != s->frag_ctx->cont))
   {
     /* The 'frag_ctx' itself will be freed in #free_session() a bit
        later, as it might be in use right now */
@@ -2372,12 +2263,8 @@ udp_disconnect_session (void *cls,
                        s->frag_ctx->payload_size,
                        s->frag_ctx->on_wire_size);
   }
-  notify_session_monitor (s->plugin,
-                          s,
-                          GNUNET_TRANSPORT_SS_DONE);
-  plugin->env->session_end (plugin->env->cls,
-                            s->address,
-                            s);
+  notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_DONE);
+  plugin->env->session_end (plugin->env->cls, s->address, s);
   GNUNET_STATISTICS_set (plugin->env->stats,
                          "# UDP sessions active",
                          GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
@@ -2409,17 +2296,17 @@ read_process_ack (struct Plugin *plugin,
   struct GNUNET_TIME_Relative flow_delay;
 
   /* check message format */
-  if (ntohs (msg->size)
-      < sizeof(struct UDP_ACK_Message) + sizeof(struct GNUNET_MessageHeader))
+  if (ntohs (msg->size) <
+      sizeof (struct UDP_ACK_Message) + sizeof (struct GNUNET_MessageHeader))
   {
     GNUNET_break_op (0);
     return;
   }
   udp_ack = (const struct UDP_ACK_Message *) msg;
   ack = (const struct GNUNET_MessageHeader *) &udp_ack[1];
-  if (ntohs (ack->size) != ntohs (msg->size) - sizeof(struct UDP_ACK_Message))
+  if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message))
   {
-    GNUNET_break_op(0);
+    GNUNET_break_op (0);
     return;
   }
 
@@ -2429,8 +2316,7 @@ read_process_ack (struct Plugin *plugin,
                                            udp_addr,
                                            udp_addr_len,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  s = udp_plugin_lookup_session (plugin,
-                                 address);
+  s = udp_plugin_lookup_session (plugin, address);
   if (NULL == s)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -2461,39 +2347,32 @@ read_process_ack (struct Plugin *plugin,
     LOG (GNUNET_ERROR_TYPE_INFO,
          "Asked to disconnect UDP session of %s\n",
          GNUNET_i2s (&udp_ack->sender));
-    udp_disconnect_session (plugin,
-                            s);
+    udp_disconnect_session (plugin, s);
     return;
   }
   flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay);
   if (flow_delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "We received a sending delay of %s for %s\n",
-         GNUNET_STRINGS_relative_time_to_string (flow_delay,
-                                                 GNUNET_YES),
+         GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES),
          GNUNET_i2s (&udp_ack->sender));
   else
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "We received a sending delay of %s for %s\n",
-         GNUNET_STRINGS_relative_time_to_string (flow_delay,
-                                                 GNUNET_YES),
+         GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES),
          GNUNET_i2s (&udp_ack->sender));
   /* Flow delay is for the reassembled packet, however, our delay
      is per packet, so we need to adjust: */
   s->flow_delay_from_other_peer = flow_delay;
 
   /* Handle ACK */
-  if (GNUNET_OK !=
-      GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag,
-                                   ack))
+  if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, ack))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
          (unsigned int) ntohs (msg->size),
          GNUNET_i2s (&udp_ack->sender),
-         udp_address_to_string (plugin,
-                                udp_addr,
-                                udp_addr_len));
+         udp_address_to_string (plugin, udp_addr, udp_addr_len));
     /* Expect more ACKs to arrive */
     return;
   }
@@ -2502,11 +2381,8 @@ read_process_ack (struct Plugin *plugin,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Message from %s at %s full ACK'ed\n",
        GNUNET_i2s (&udp_ack->sender),
-       udp_address_to_string (plugin,
-                              udp_addr,
-                              udp_addr_len));
-  fragmented_message_done (s->frag_ctx,
-                           GNUNET_OK);
+       udp_address_to_string (plugin, udp_addr, udp_addr_len));
+  fragmented_message_done (s->frag_ctx, GNUNET_OK);
 }
 
 
@@ -2528,11 +2404,8 @@ process_inbound_tokenized_messages (void *cls,
   if (GNUNET_YES == session->in_destroy)
     return GNUNET_OK;
   reschedule_session_timeout (session);
-  session->flow_delay_for_other_peer
-    = plugin->env->receive (plugin->env->cls,
-                            session->address,
-                            session,
-                            hdr);
+  session->flow_delay_for_other_peer =
+    plugin->env->receive (plugin->env->cls, session->address, session, hdr);
   return GNUNET_OK;
 }
 
@@ -2552,8 +2425,7 @@ disconnect_and_free_it (void *cls,
 {
   struct Plugin *plugin = cls;
 
-  udp_disconnect_session (plugin,
-                          value);
+  udp_disconnect_session (plugin, value);
   return GNUNET_OK;
 }
 
@@ -2567,8 +2439,7 @@ disconnect_and_free_it (void *cls,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed
  */
 static void
-udp_disconnect (void *cls,
-                const struct GNUNET_PeerIdentity *target)
+udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
 {
   struct Plugin *plugin = cls;
 
@@ -2600,12 +2471,8 @@ session_timeout (void *cls)
   {
     /* not actually our turn yet, but let's at least update
        the monitor, it may think we're about to die ... */
-    notify_session_monitor (s->plugin,
-                            s,
-                            GNUNET_TRANSPORT_SS_UPDATE);
-    s->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
-                                                    &session_timeout,
-                                                    s);
+    notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
+    s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, &session_timeout, s);
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2614,8 +2481,7 @@ session_timeout (void *cls)
        GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT,
                                                GNUNET_YES));
   /* call session destroy function */
-  udp_disconnect_session (plugin,
-                          s);
+  udp_disconnect_session (plugin, s);
 }
 
 
@@ -2639,21 +2505,19 @@ udp_plugin_create_session (void *cls,
   struct GNUNET_ATS_Session *s;
 
   s = GNUNET_new (struct GNUNET_ATS_Session);
-  s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages,
-                              s);
+  s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages, s);
   s->plugin = plugin;
   s->address = GNUNET_HELLO_address_copy (address);
   s->target = address->peer;
   s->last_transmit_time = GNUNET_TIME_absolute_get ();
-  s->last_expected_ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                                              250);
+  s->last_expected_ack_delay =
+    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250);
   s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
   s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO;
   s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
   s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT);
-  s->timeout_task = GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT,
-                                                  &session_timeout,
-                                                  s);
+  s->timeout_task =
+    GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT, &session_timeout, s);
   s->scope = network_type;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2663,18 +2527,16 @@ udp_plugin_create_session (void *cls,
        udp_address_to_string (plugin,
                               address->address,
                               address->address_length));
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONTAINER_multipeermap_put (plugin->sessions,
-                                                    &s->target,
-                                                    s,
-                                                    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+  GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (
+                                plugin->sessions,
+                                &s->target,
+                                s,
+                                GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
   GNUNET_STATISTICS_set (plugin->env->stats,
                          "# UDP sessions active",
                          GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
                          GNUNET_NO);
-  notify_session_monitor (plugin,
-                          s,
-                          GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_INIT);
   return s;
 }
 
@@ -2688,8 +2550,7 @@ udp_plugin_create_session (void *cls,
  * @return the session or NULL of max connections exceeded
  */
 static struct GNUNET_ATS_Session *
-udp_plugin_get_session (void *cls,
-                        const struct GNUNET_HELLO_Address *address)
+udp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *s;
@@ -2702,14 +2563,13 @@ udp_plugin_get_session (void *cls,
     GNUNET_break (0);
     return NULL;
   }
-  if ( (address->address_length != sizeof(struct IPv4UdpAddress)) &&
-       (address->address_length != sizeof(struct IPv6UdpAddress)) )
+  if ((address->address_length != sizeof (struct IPv4UdpAddress)) &&
+      (address->address_length != sizeof (struct IPv6UdpAddress)))
   {
     GNUNET_break_op (0);
     return NULL;
   }
-  if (NULL != (s = udp_plugin_lookup_session (cls,
-                                              address)))
+  if (NULL != (s = udp_plugin_lookup_session (cls, address)))
     return s;
 
   /* need to create new session */
@@ -2746,9 +2606,7 @@ udp_plugin_get_session (void *cls,
                                                   sizeof (v6));
   }
   GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
-  return udp_plugin_create_session (cls,
-                                   address,
-                                   network_type);
+  return udp_plugin_create_session (cls, address, network_type);
 }
 
 
@@ -2774,13 +2632,13 @@ process_udp_message (struct Plugin *plugin,
   GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
   if (0 != ntohl (msg->reserved))
   {
-    GNUNET_break_op(0);
+    GNUNET_break_op (0);
     return;
   }
-  if (ntohs (msg->header.size)
-      < sizeof(struct GNUNET_MessageHeader) + sizeof(struct UDPMessage))
+  if (ntohs (msg->header.size) <
+      sizeof (struct GNUNET_MessageHeader) + sizeof (struct UDPMessage))
   {
-    GNUNET_break_op(0);
+    GNUNET_break_op (0);
     return;
   }
 
@@ -2789,32 +2647,22 @@ process_udp_message (struct Plugin *plugin,
                                            udp_addr,
                                            udp_addr_len,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  if (NULL ==
-      (s = udp_plugin_lookup_session (plugin,
-                                      address)))
+  if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
   {
-    s = udp_plugin_create_session (plugin,
-                                   address,
-                                   network_type);
-    plugin->env->session_start (plugin->env->cls,
-                                address,
-                                s,
-                                s->scope);
-    notify_session_monitor (plugin,
-                            s,
-                            GNUNET_TRANSPORT_SS_UP);
+    s = udp_plugin_create_session (plugin, address, network_type);
+    plugin->env->session_start (plugin->env->cls, address, s, s->scope);
+    notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UP);
   }
   GNUNET_free (address);
 
   s->rc++;
   GNUNET_MST_from_buffer (s->mst,
                           (const char *) &msg[1],
-                          ntohs (msg->header.size) - sizeof(struct UDPMessage),
+                          ntohs (msg->header.size) - sizeof (struct UDPMessage),
                           GNUNET_YES,
                           GNUNET_NO);
   s->rc--;
-  if ( (0 == s->rc) &&
-       (GNUNET_YES == s->in_destroy) )
+  if ((0 == s->rc) && (GNUNET_YES == s->in_destroy))
     free_session (s);
 }
 
@@ -2826,8 +2674,7 @@ process_udp_message (struct Plugin *plugin,
  * @param msg the message
  */
 static void
-fragment_msg_proc (void *cls,
-                   const struct GNUNET_MessageHeader *msg)
+fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct DefragContext *dc = cls;
   const struct UDPMessage *um;
@@ -2837,7 +2684,7 @@ fragment_msg_proc (void *cls,
     GNUNET_break_op (0);
     return;
   }
-  if (ntohs (msg->size) < sizeof(struct UDPMessage))
+  if (ntohs (msg->size) < sizeof (struct UDPMessage))
   {
     GNUNET_break_op (0);
     return;
@@ -2863,9 +2710,7 @@ fragment_msg_proc (void *cls,
  *               #GNUNET_SYSERR if we failed to send the ACK
  */
 static void
-ack_message_sent (void *cls,
-                  struct UDP_MessageWrapper *udpw,
-                  int result)
+ack_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
 {
   struct Plugin *plugin = cls;
 
@@ -2894,13 +2739,11 @@ ack_message_sent (void *cls,
  * @param msg ack to transmit
  */
 static void
-ack_proc (void *cls,
-          uint32_t id,
-          const struct GNUNET_MessageHeader *msg)
+ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
 {
   struct DefragContext *rc = cls;
   struct Plugin *plugin = rc->plugin;
-  size_t msize = sizeof(struct UDP_ACK_Message) + ntohs (msg->size);
+  size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size);
   struct UDP_ACK_Message *udp_ack;
   uint32_t delay;
   struct UDP_MessageWrapper *udpw;
@@ -2922,16 +2765,13 @@ ack_proc (void *cls,
                                            rc->udp_addr,
                                            rc->udp_addr_len,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  s = udp_plugin_lookup_session (plugin,
-                                 address);
+  s = udp_plugin_lookup_session (plugin, address);
   GNUNET_HELLO_address_free (address);
   if (NULL == s)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Trying to transmit ACK to peer `%s' but no session found!\n",
-         udp_address_to_string (plugin,
-                                rc->udp_addr,
-                                rc->udp_addr_len));
+         udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len));
     GNUNET_CONTAINER_heap_remove_node (rc->hnode);
     GNUNET_DEFRAGMENT_context_destroy (rc->defrag);
     GNUNET_free (rc);
@@ -2950,9 +2790,7 @@ ack_proc (void *cls,
     delay = UINT32_MAX - 1; /* largest value we can communicate */
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Sending ACK to `%s' including delay of %s\n",
-       udp_address_to_string (plugin,
-                              rc->udp_addr,
-                              rc->udp_addr_len),
+       udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len),
        GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer,
                                                GNUNET_YES));
   udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize);
@@ -2969,14 +2807,9 @@ ack_proc (void *cls,
   udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK);
   udp_ack->delay = htonl (delay);
   udp_ack->sender = *plugin->env->my_identity;
-  GNUNET_memcpy (&udp_ack[1],
-          msg,
-          ntohs (msg->size));
-  enqueue (plugin,
-           udpw);
-  notify_session_monitor (plugin,
-                          s,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+  GNUNET_memcpy (&udp_ack[1], msg, ntohs (msg->size));
+  enqueue (plugin, udpw);
+  notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
   if (s->address->address_length == sizeof (struct IPv4UdpAddress))
     schedule_select_v4 (plugin);
   else
@@ -3019,46 +2852,41 @@ read_process_fragment (struct Plugin *plugin,
   {
     /* Create a new defragmentation context */
     d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + udp_addr_len);
-    GNUNET_memcpy (&d_ctx[1],
-            udp_addr,
-            udp_addr_len);
+    GNUNET_memcpy (&d_ctx[1], udp_addr, udp_addr_len);
     d_ctx->udp_addr = (const union UdpAddress *) &d_ctx[1];
     d_ctx->udp_addr_len = udp_addr_len;
     d_ctx->network_type = network_type;
     d_ctx->plugin = plugin;
-    d_ctx->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
-                                                      UDP_MTU,
-                                                      UDP_MAX_MESSAGES_IN_DEFRAG,
-                                                      d_ctx,
-                                                      &fragment_msg_proc,
-                                                      &ack_proc);
+    d_ctx->defrag =
+      GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
+                                        UDP_MTU,
+                                        UDP_MAX_MESSAGES_IN_DEFRAG,
+                                        d_ctx,
+                                        &fragment_msg_proc,
+                                        &ack_proc);
     d_ctx->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs,
                                                  d_ctx,
-                                                 (GNUNET_CONTAINER_HeapCostType) now.abs_value_us);
+                                                 (GNUNET_CONTAINER_HeapCostType)
+                                                   now.abs_value_us);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Created new defragmentation context for %u-byte fragment from `%s'\n",
          (unsigned int) ntohs (msg->size),
-         udp_address_to_string (plugin,
-                                udp_addr,
-                                udp_addr_len));
+         udp_address_to_string (plugin, udp_addr, udp_addr_len));
   }
   else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Found existing defragmentation context for %u-byte fragment from `%s'\n",
          (unsigned int) ntohs (msg->size),
-         udp_address_to_string (plugin,
-                                udp_addr,
-                                udp_addr_len));
+         udp_address_to_string (plugin, udp_addr, udp_addr_len));
   }
 
-  if (GNUNET_OK ==
-      GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag,
-                                          msg))
+  if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg))
   {
     /* keep this 'rc' from expiring */
     GNUNET_CONTAINER_heap_update_cost (d_ctx->hnode,
-                                       (GNUNET_CONTAINER_HeapCostType) now.abs_value_us);
+                                       (GNUNET_CONTAINER_HeapCostType)
+                                         now.abs_value_us);
   }
   if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) >
       UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG)
@@ -3083,8 +2911,7 @@ read_process_fragment (struct Plugin *plugin,
  * @param rsock socket to read from
  */
 static void
-udp_select_read (struct Plugin *plugin,
-                 struct GNUNET_NETWORK_Handle *rsock)
+udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
 {
   socklen_t fromlen;
   struct sockaddr_storage addr;
@@ -3101,9 +2928,7 @@ udp_select_read (struct Plugin *plugin,
   enum GNUNET_NetworkType network_type;
 
   fromlen = sizeof (addr);
-  memset (&addr,
-          0,
-          sizeof(addr));
+  memset (&addr, 0, sizeof (addr));
   size = GNUNET_NETWORK_socket_recvfrom (rsock,
                                          buf,
                                          sizeof (buf),
@@ -3121,15 +2946,14 @@ udp_select_read (struct Plugin *plugin,
    *   error indicates a previous send operation resulted in an ICMP Port
    *   Unreachable message.
    */
-  if ( (-1 == size) &&
-       (ECONNRESET == errno) )
+  if ((-1 == size) && (ECONNRESET == errno))
     return;
 #endif
   if (-1 == size)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "UDP failed to receive data: %s\n",
-         STRERROR (errno));
+         strerror (errno));
     /* Connection failure or something. Not a protocol violation. */
     return;
   }
@@ -3137,19 +2961,18 @@ udp_select_read (struct Plugin *plugin,
   /* Check if this is a STUN packet */
   if (GNUNET_NO !=
       GNUNET_NAT_stun_handle_packet (plugin->nat,
-                                    (const struct sockaddr *) &addr,
-                                    fromlen,
-                                    buf,
-                                    size))
+                                     (const struct sockaddr *) &addr,
+                                     fromlen,
+                                     buf,
+                                     size))
     return; /* was STUN, do not process further */
 
-  if (size < sizeof(struct GNUNET_MessageHeader))
+  if (size < sizeof (struct GNUNET_MessageHeader))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "UDP got %u bytes from %s, which is not enough for a GNUnet message header\n",
-         (unsigned int ) size,
-         GNUNET_a2s (sa,
-                     fromlen));
+         (unsigned int) size,
+         GNUNET_a2s (sa, fromlen));
     /* _MAY_ be a connection failure (got partial message) */
     /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */
     GNUNET_break_op (0);
@@ -3160,16 +2983,14 @@ udp_select_read (struct Plugin *plugin,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "UDP received %u-byte message from `%s' type %u\n",
        (unsigned int) size,
-       GNUNET_a2s (sa,
-                   fromlen),
+       GNUNET_a2s (sa, fromlen),
        ntohs (msg->type));
   if (size != ntohs (msg->size))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "UDP malformed message (size %u) header from %s\n",
          (unsigned int) size,
-         GNUNET_a2s (sa,
-                     fromlen));
+         GNUNET_a2s (sa, fromlen));
     GNUNET_break_op (0);
     return;
   }
@@ -3177,9 +2998,7 @@ udp_select_read (struct Plugin *plugin,
                             "# UDP, total bytes received",
                             size,
                             GNUNET_NO);
-  network_type = plugin->env->get_address_type (plugin->env->cls,
-                                                sa,
-                                                fromlen);
+  network_type = plugin->env->get_address_type (plugin->env->cls, sa, fromlen);
   switch (sa->sa_family)
   {
   case AF_INET:
@@ -3215,9 +3034,9 @@ udp_select_read (struct Plugin *plugin,
                              network_type);
     return;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE:
-    if (ntohs (msg->size) < sizeof(struct UDPMessage))
+    if (ntohs (msg->size) < sizeof (struct UDPMessage))
     {
-      GNUNET_break_op(0);
+      GNUNET_break_op (0);
       return;
     }
     process_udp_message (plugin,
@@ -3227,20 +3046,13 @@ udp_select_read (struct Plugin *plugin,
                          network_type);
     return;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK:
-    read_process_ack (plugin,
-                      msg,
-                      int_addr,
-                      int_addr_len);
+    read_process_ack (plugin, msg, int_addr, int_addr_len);
     return;
   case GNUNET_MESSAGE_TYPE_FRAGMENT:
-    read_process_fragment (plugin,
-                           msg,
-                           int_addr,
-                           int_addr_len,
-                           network_type);
+    read_process_fragment (plugin, msg, int_addr, int_addr_len, network_type);
     return;
   default:
-    GNUNET_break_op(0);
+    GNUNET_break_op (0);
     return;
   }
 }
@@ -3265,9 +3077,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
   int removed;
 
   removed = GNUNET_NO;
-  udpw = (sock == plugin->sockv4)
-    ? plugin->ipv4_queue_head
-    : plugin->ipv6_queue_head;
+  udpw = (sock == plugin->sockv4) ? plugin->ipv4_queue_head
+                                  : plugin->ipv6_queue_head;
   while (NULL != udpw)
   {
     session = udpw->session;
@@ -3277,11 +3088,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
     {
       /* Message timed out */
       removed = GNUNET_YES;
-      dequeue (plugin,
-               udpw);
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_SYSERR);
+      dequeue (plugin, udpw);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
 
       if (sock == plugin->sockv4)
@@ -3321,9 +3129,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "Message for peer `%s' (%u bytes) is delayed for %s\n",
              GNUNET_i2s (&udpw->session->target),
-            udpw->payload_size,
-             GNUNET_STRINGS_relative_time_to_string (remaining,
-                                                    GNUNET_YES));
+             udpw->payload_size,
+             GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES));
         udpw = udpw->next;
       }
     }
@@ -3353,13 +3160,9 @@ analyze_send_error (struct Plugin *plugin,
 {
   enum GNUNET_NetworkType type;
 
-  type = plugin->env->get_address_type (plugin->env->cls,
-                                        sa,
-                                        slen);
-  if ( ( (GNUNET_NT_LAN == type) ||
-         (GNUNET_NT_WAN == type) ) &&
-       ( (ENETUNREACH == errno) ||
-         (ENETDOWN == errno) ) )
+  type = plugin->env->get_address_type (plugin->env->cls, sa, slen);
+  if (((GNUNET_NT_LAN == type) || (GNUNET_NT_WAN == type)) &&
+      ((ENETUNREACH == errno) || (ENETDOWN == errno)))
   {
     if (slen == sizeof (struct sockaddr_in))
     {
@@ -3368,10 +3171,9 @@ analyze_send_error (struct Plugin *plugin,
        * This indicates we do not have connectivity
        */
       LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-           _("UDP could not transmit message to `%s': "
-             "Network seems down, please check your network configuration\n"),
-           GNUNET_a2s (sa,
-                       slen));
+           _ ("UDP could not transmit message to `%s': "
+              "Network seems down, please check your network configuration\n"),
+           GNUNET_a2s (sa, slen));
     }
     if (slen == sizeof (struct sockaddr_in6))
     {
@@ -3382,7 +3184,8 @@ analyze_send_error (struct Plugin *plugin,
        * connectivity
        */
       LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-           _("UDP could not transmit IPv6 message! "
+           _ (
+             "UDP could not transmit IPv6 message! "
              "Please check your network configuration and disable IPv6 if your "
              "connection does not have a global IPv6 address\n"));
     }
@@ -3391,9 +3194,8 @@ analyze_send_error (struct Plugin *plugin,
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "UDP could not transmit message to `%s': `%s'\n",
-         GNUNET_a2s (sa,
-                     slen),
-         STRERROR (error));
+         GNUNET_a2s (sa, slen),
+         strerror (error));
   }
 }
 
@@ -3406,8 +3208,7 @@ analyze_send_error (struct Plugin *plugin,
  * @param sock which socket (v4/v6) to send on
  */
 static void
-udp_select_send (struct Plugin *plugin,
-                 struct GNUNET_NETWORK_Handle *sock)
+udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
 {
   ssize_t sent;
   socklen_t slen;
@@ -3419,15 +3220,13 @@ udp_select_send (struct Plugin *plugin,
   struct UDP_MessageWrapper *udpw;
 
   /* Find message(s) to send */
-  while (NULL != (udpw = remove_timeout_messages_and_select (plugin,
-                                                             sock)))
+  while (NULL != (udpw = remove_timeout_messages_and_select (plugin, sock)))
   {
-    if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
+    if (sizeof (struct IPv4UdpAddress) ==
+        udpw->session->address->address_length)
     {
       u4 = udpw->session->address->address;
-      memset (&a4,
-              0,
-              sizeof(a4));
+      memset (&a4, 0, sizeof (a4));
       a4.sin_family = AF_INET;
 #if HAVE_SOCKADDR_IN_SIN_LEN
       a4.sin_len = sizeof (a4);
@@ -3437,12 +3236,11 @@ udp_select_send (struct Plugin *plugin,
       a = (const struct sockaddr *) &a4;
       slen = sizeof (a4);
     }
-    else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length)
+    else if (sizeof (struct IPv6UdpAddress) ==
+             udpw->session->address->address_length)
     {
       u6 = udpw->session->address->address;
-      memset (&a6,
-              0,
-              sizeof(a6));
+      memset (&a6, 0, sizeof (a6));
       a6.sin6_family = AF_INET6;
 #if HAVE_SOCKADDR_IN_SIN_LEN
       a6.sin6_len = sizeof (a6);
@@ -3455,11 +3253,8 @@ udp_select_send (struct Plugin *plugin,
     else
     {
       GNUNET_break (0);
-      dequeue (plugin,
-               udpw);
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_SYSERR);
+      dequeue (plugin, udpw);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
       notify_session_monitor (plugin,
                               udpw->session,
                               GNUNET_TRANSPORT_SS_UPDATE);
@@ -3471,21 +3266,15 @@ udp_select_send (struct Plugin *plugin,
                                          udpw->msg_size,
                                          a,
                                          slen);
-    udpw->session->last_transmit_time
-      = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
-                                  udpw->session->last_transmit_time);
-    dequeue (plugin,
-             udpw);
+    udpw->session->last_transmit_time =
+      GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
+                                udpw->session->last_transmit_time);
+    dequeue (plugin, udpw);
     if (GNUNET_SYSERR == sent)
     {
       /* Failure */
-      analyze_send_error (plugin,
-                          a,
-                          slen,
-                          errno);
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_SYSERR);
+      analyze_send_error (plugin, a, slen, errno);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
       GNUNET_STATISTICS_update (plugin->env->stats,
                                 "# UDP, total, bytes, sent, failure",
                                 sent,
@@ -3502,10 +3291,9 @@ udp_select_send (struct Plugin *plugin,
            "UDP transmitted %u-byte message to  `%s' `%s' (%d: %s)\n",
            (unsigned int) (udpw->msg_size),
            GNUNET_i2s (&udpw->session->target),
-           GNUNET_a2s (a,
-                       slen),
-           (int ) sent,
-           (sent < 0) ? STRERROR (errno) : "ok");
+           GNUNET_a2s (a, slen),
+           (int) sent,
+           (sent < 0) ? strerror (errno) : "ok");
       GNUNET_STATISTICS_update (plugin->env->stats,
                                 "# UDP, total, bytes, sent, success",
                                 sent,
@@ -3516,13 +3304,9 @@ udp_select_send (struct Plugin *plugin,
                                 GNUNET_NO);
       if (NULL != udpw->frag_ctx)
         udpw->frag_ctx->on_wire_size += udpw->msg_size;
-      udpw->qc (udpw->qc_cls,
-                udpw,
-                GNUNET_OK);
+      udpw->qc (udpw->qc_cls, udpw, GNUNET_OK);
     }
-    notify_session_monitor (plugin,
-                            udpw->session,
-                            GNUNET_TRANSPORT_SS_UPDATE);
+    notify_session_monitor (plugin, udpw->session, GNUNET_TRANSPORT_SS_UPDATE);
     GNUNET_free (udpw);
   }
 }
@@ -3549,12 +3333,9 @@ udp_plugin_select_v4 (void *cls)
     return;
   tc = GNUNET_SCHEDULER_get_task_context ();
   if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
-      (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                   plugin->sockv4)))
-    udp_select_read (plugin,
-                     plugin->sockv4);
-  udp_select_send (plugin,
-                   plugin->sockv4);
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)))
+    udp_select_read (plugin, plugin->sockv4);
+  udp_select_send (plugin, plugin->sockv4);
   schedule_select_v4 (plugin);
 }
 
@@ -3576,14 +3357,11 @@ udp_plugin_select_v6 (void *cls)
   if (NULL == plugin->sockv6)
     return;
   tc = GNUNET_SCHEDULER_get_task_context ();
-  if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
-       (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                    plugin->sockv6)) )
-    udp_select_read (plugin,
-                     plugin->sockv6);
-
-  udp_select_send (plugin,
-                   plugin->sockv6);
+  if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv6)))
+    udp_select_read (plugin, plugin->sockv6);
+
+  udp_select_send (plugin, plugin->sockv6);
   schedule_select_v6 (plugin);
 }
 
@@ -3618,20 +3396,16 @@ setup_sockets (struct Plugin *plugin,
   eno = EINVAL;
   if (GNUNET_YES == plugin->enable_ipv6)
   {
-    plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6,
-                                                   SOCK_DGRAM,
-                                                   0);
+    plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0);
     if (NULL == plugin->sockv6)
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling IPv6 since it is not supported on this system!\n"));
+           _ ("Disabling IPv6 since it is not supported on this system!\n"));
       plugin->enable_ipv6 = GNUNET_NO;
     }
     else
     {
-      memset (&server_addrv6,
-              0,
-              sizeof(struct sockaddr_in6));
+      memset (&server_addrv6, 0, sizeof (struct sockaddr_in6));
 #if HAVE_SOCKADDR_IN_SIN_LEN
       server_addrv6.sin6_len = sizeof (struct sockaddr_in6);
 #endif
@@ -3642,10 +3416,9 @@ setup_sockets (struct Plugin *plugin,
         server_addrv6.sin6_addr = in6addr_any;
 
       if (0 == plugin->port) /* autodetect */
-        server_addrv6.sin6_port
-          = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
-                                             33537)
-                   + 32000);
+        server_addrv6.sin6_port = htons (
+          GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) +
+          32000);
       else
         server_addrv6.sin6_port = htons (plugin->port);
       addrlen = sizeof (struct sockaddr_in6);
@@ -3654,15 +3427,12 @@ setup_sockets (struct Plugin *plugin,
       tries = 0;
       while (tries < 10)
       {
-        LOG(GNUNET_ERROR_TYPE_DEBUG,
-            "Binding to IPv6 `%s'\n",
-            GNUNET_a2s (server_addr,
-                        addrlen));
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Binding to IPv6 `%s'\n",
+             GNUNET_a2s (server_addr, addrlen));
         /* binding */
         if (GNUNET_OK ==
-            GNUNET_NETWORK_socket_bind (plugin->sockv6,
-                                        server_addr,
-                                        addrlen))
+            GNUNET_NETWORK_socket_bind (plugin->sockv6, server_addr, addrlen))
           break;
         eno = errno;
         if (0 != plugin->port)
@@ -3671,10 +3441,9 @@ setup_sockets (struct Plugin *plugin,
           break; /* bind failed on specific port */
         }
         /* autodetect */
-        server_addrv6.sin6_port
-          = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
-                                             33537)
-                   + 32000);
+        server_addrv6.sin6_port = htons (
+          GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) +
+          32000);
         tries++;
       }
       if (tries >= 10)
@@ -3691,8 +3460,7 @@ setup_sockets (struct Plugin *plugin,
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "IPv6 UDP socket created listinging at %s\n",
-             GNUNET_a2s (server_addr,
-                         addrlen));
+             GNUNET_a2s (server_addr, addrlen));
         addrs[sockets_created] = server_addr;
         addrlens[sockets_created] = addrlen;
         sockets_created++;
@@ -3700,32 +3468,26 @@ setup_sockets (struct Plugin *plugin,
       else
       {
         LOG (GNUNET_ERROR_TYPE_WARNING,
-             _("Failed to bind UDP socket to %s: %s\n"),
-             GNUNET_a2s (server_addr,
-                         addrlen),
-             STRERROR (eno));
+             _ ("Failed to bind UDP socket to %s: %s\n"),
+             GNUNET_a2s (server_addr, addrlen),
+             strerror (eno));
       }
     }
   }
 
   /* Create IPv4 socket */
   eno = EINVAL;
-  plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET,
-                                                 SOCK_DGRAM,
-                                                 0);
+  plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0);
   if (NULL == plugin->sockv4)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                         "socket");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket");
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("Disabling IPv4 since it is not supported on this system!\n"));
+         _ ("Disabling IPv4 since it is not supported on this system!\n"));
     plugin->enable_ipv4 = GNUNET_NO;
   }
   else
   {
-    memset (&server_addrv4,
-            0,
-            sizeof(struct sockaddr_in));
+    memset (&server_addrv4, 0, sizeof (struct sockaddr_in));
 #if HAVE_SOCKADDR_IN_SIN_LEN
     server_addrv4.sin_len = sizeof (struct sockaddr_in);
 #endif
@@ -3737,10 +3499,8 @@ setup_sockets (struct Plugin *plugin,
 
     if (0 == plugin->port)
       /* autodetect */
-      server_addrv4.sin_port
-        = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
-                                           33537)
-                 + 32000);
+      server_addrv4.sin_port = htons (
+        GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
     else
       server_addrv4.sin_port = htons (plugin->port);
 
@@ -3752,14 +3512,11 @@ setup_sockets (struct Plugin *plugin,
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Binding to IPv4 `%s'\n",
-           GNUNET_a2s (server_addr,
-                       addrlen));
+           GNUNET_a2s (server_addr, addrlen));
 
       /* binding */
       if (GNUNET_OK ==
-          GNUNET_NETWORK_socket_bind (plugin->sockv4,
-                                      server_addr,
-                                      addrlen))
+          GNUNET_NETWORK_socket_bind (plugin->sockv4, server_addr, addrlen))
         break;
       eno = errno;
       if (0 != plugin->port)
@@ -3769,10 +3526,8 @@ setup_sockets (struct Plugin *plugin,
       }
 
       /* autodetect */
-      server_addrv4.sin_port
-        = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
-                                           33537)
-                 + 32000);
+      server_addrv4.sin_port = htons (
+        GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
       tries++;
     }
     if (tries >= 10)
@@ -3790,8 +3545,7 @@ setup_sockets (struct Plugin *plugin,
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "IPv4 socket created on port %s\n",
-           GNUNET_a2s (server_addr,
-                       addrlen));
+           GNUNET_a2s (server_addr, addrlen));
       addrs[sockets_created] = server_addr;
       addrlens[sockets_created] = addrlen;
       sockets_created++;
@@ -3799,24 +3553,22 @@ setup_sockets (struct Plugin *plugin,
     else
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to bind UDP socket to %s: %s\n"),
-           GNUNET_a2s (server_addr,
-                       addrlen),
-           STRERROR (eno));
+           _ ("Failed to bind UDP socket to %s: %s\n"),
+           GNUNET_a2s (server_addr, addrlen),
+           strerror (eno));
     }
   }
 
   if (0 == sockets_created)
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Failed to open UDP sockets\n"));
+    LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to open UDP sockets\n"));
     return 0; /* No sockets created, return */
   }
   schedule_select_v4 (plugin);
   schedule_select_v6 (plugin);
   plugin->nat = GNUNET_NAT_register (plugin->env->cfg,
-                                    "transport-udp",
-                                    IPPROTO_UDP,
+                                     "transport-udp",
+                                     IPPROTO_UDP,
                                      sockets_created,
                                      addrs,
                                      addrlens,
@@ -3869,64 +3621,55 @@ libgnunet_plugin_transport_udp_init (void *cls)
 
   /* Get port number: port == 0 : autodetect a port,
    * > 0 : use this port, not given : 2086 default */
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (env->cfg,
-                                             "transport-udp",
-                                             "PORT",
-                                             &port))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                          "transport-udp",
+                                                          "PORT",
+                                                          &port))
     port = 2086;
   if (port > 65535)
   {
     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                "transport-udp",
                                "PORT",
-                               _("must be in [0,65535]"));
+                               _ ("must be in [0,65535]"));
     return NULL;
   }
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (env->cfg,
-                                             "transport-udp",
-                                             "ADVERTISED_PORT",
-                                             &aport))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                          "transport-udp",
+                                                          "ADVERTISED_PORT",
+                                                          &aport))
     aport = port;
   if (aport > 65535)
   {
     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                "transport-udp",
                                "ADVERTISED_PORT",
-                               _("must be in [0,65535]"));
+                               _ ("must be in [0,65535]"));
     return NULL;
   }
 
   if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
-                                            "nat",
-                                            "DISABLEV6"))
+      GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "nat", "DISABLEV6"))
     enable_v6 = GNUNET_NO;
   else
     enable_v6 = GNUNET_YES;
 
   have_bind4 = GNUNET_NO;
-  memset (&server_addrv4,
-          0,
-          sizeof (server_addrv4));
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_string (env->cfg,
-                                             "transport-udp",
-                                             "BINDTO",
-                                             &bind4_address))
+  memset (&server_addrv4, 0, sizeof (server_addrv4));
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg,
+                                                           "transport-udp",
+                                                           "BINDTO",
+                                                           &bind4_address))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Binding UDP plugin to specific address: `%s'\n",
          bind4_address);
-    if (1 != inet_pton (AF_INET,
-                        bind4_address,
-                        &server_addrv4.sin_addr))
+    if (1 != inet_pton (AF_INET, bind4_address, &server_addrv4.sin_addr))
     {
       GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                  "transport-udp",
                                  "BINDTO",
-                                 _("must be valid IPv4 address"));
+                                 _ ("must be valid IPv4 address"));
       GNUNET_free (bind4_address);
       return NULL;
     }
@@ -3934,26 +3677,21 @@ libgnunet_plugin_transport_udp_init (void *cls)
   }
   GNUNET_free_non_null (bind4_address);
   have_bind6 = GNUNET_NO;
-  memset (&server_addrv6,
-          0,
-          sizeof (server_addrv6));
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_string (env->cfg,
-                                             "transport-udp",
-                                             "BINDTO6",
-                                             &bind6_address))
+  memset (&server_addrv6, 0, sizeof (server_addrv6));
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg,
+                                                           "transport-udp",
+                                                           "BINDTO6",
+                                                           &bind6_address))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Binding udp plugin to specific address: `%s'\n",
          bind6_address);
-    if (1 != inet_pton (AF_INET6,
-                        bind6_address,
-                        &server_addrv6.sin6_addr))
+    if (1 != inet_pton (AF_INET6, bind6_address, &server_addrv6.sin6_addr))
     {
       GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                  "transport-udp",
                                  "BINDTO6",
-                                 _("must be valid IPv6 address"));
+                                 _ ("must be valid IPv6 address"));
       GNUNET_free (bind6_address);
       return NULL;
     }
@@ -3967,9 +3705,10 @@ libgnunet_plugin_transport_udp_init (void *cls)
   if (enable_broadcasting == GNUNET_SYSERR)
     enable_broadcasting = GNUNET_NO;
 
-  enable_broadcasting_recv = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
-                                                                   "transport-udp",
-                                                                   "BROADCAST_RECEIVE");
+  enable_broadcasting_recv =
+    GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+                                          "transport-udp",
+                                          "BROADCAST_RECEIVE");
   if (enable_broadcasting_recv == GNUNET_SYSERR)
     enable_broadcasting_recv = GNUNET_YES;
 
@@ -3979,14 +3718,12 @@ libgnunet_plugin_transport_udp_init (void *cls)
                                            "BROADCAST_INTERVAL",
                                            &interval))
   {
-    interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
-                                              10);
+    interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
   }
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (env->cfg,
-                                             "transport-udp",
-                                             "MAX_BPS",
-                                             &udp_max_bps))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                          "transport-udp",
+                                                          "MAX_BPS",
+                                                          &udp_max_bps))
   {
     /* 50 MB/s == infinity for practical purposes */
     udp_max_bps = 1024 * 1024 * 50;
@@ -4001,23 +3738,21 @@ libgnunet_plugin_transport_udp_init (void *cls)
   p->enable_broadcasting = enable_broadcasting;
   p->enable_broadcasting_receiving = enable_broadcasting_recv;
   p->env = env;
-  p->sessions = GNUNET_CONTAINER_multipeermap_create (16,
-                                                      GNUNET_NO);
-  p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+  p->sessions = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO);
+  p->defrag_ctxs =
+    GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
   GNUNET_BANDWIDTH_tracker_init (&p->tracker,
                                  NULL,
                                  NULL,
-                                 GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps),
+                                 GNUNET_BANDWIDTH_value_init (
+                                   (uint32_t) udp_max_bps),
                                  30);
   res = setup_sockets (p,
                        (GNUNET_YES == have_bind6) ? &server_addrv6 : NULL,
                        (GNUNET_YES == have_bind4) ? &server_addrv4 : NULL);
-  if ( (0 == res) ||
-       ( (NULL == p->sockv4) &&
-         (NULL == p->sockv6) ) )
+  if ((0 == res) || ((NULL == p->sockv4) && (NULL == p->sockv6)))
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-        _("Failed to create UDP network sockets\n"));
+    LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Failed to create UDP network sockets\n"));
     GNUNET_CONTAINER_multipeermap_destroy (p->sessions);
     GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs);
     if (NULL != p->nat)
@@ -4027,9 +3762,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
   }
 
   /* Setup broadcasting and receiving beacons */
-  setup_broadcast (p,
-                   &server_addrv6,
-                   &server_addrv4);
+  setup_broadcast (p, &server_addrv6, &server_addrv4);
 
   api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
   api->cls = p;
@@ -4108,14 +3841,12 @@ libgnunet_plugin_transport_udp_done (void *cls)
   }
   if (NULL != plugin->sockv4)
   {
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (plugin->sockv4));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4));
     plugin->sockv4 = NULL;
   }
   if (NULL != plugin->sockv6)
   {
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (plugin->sockv6));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6));
     plugin->sockv6 = NULL;
   }
   if (NULL != plugin->nat)
@@ -4133,20 +3864,14 @@ libgnunet_plugin_transport_udp_done (void *cls)
   }
   while (NULL != (udpw = plugin->ipv4_queue_head))
   {
-    dequeue (plugin,
-             udpw);
-    udpw->qc (udpw->qc_cls,
-              udpw,
-              GNUNET_SYSERR);
+    dequeue (plugin, udpw);
+    udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
     GNUNET_free (udpw);
   }
   while (NULL != (udpw = plugin->ipv6_queue_head))
   {
-    dequeue (plugin,
-             udpw);
-    udpw->qc (udpw->qc_cls,
-              udpw,
-              GNUNET_SYSERR);
+    dequeue (plugin, udpw);
+    udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
     GNUNET_free (udpw);
   }
   GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions,
index 5d095236d6ea5196a656b0484d8902c4ac713390..2c408ebf5f5f57464ca437612cca4b4e2967ee88 100644 (file)
@@ -68,9 +68,10 @@ enum UNIX_ADDRESS_OPTIONS
 /**
  * How long until we give up on transmitting the welcome message?
  */
-#define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define HOSTNAME_RESOLVE_TIMEOUT \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-unix",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-unix", __VA_ARGS__)
 
 
 GNUNET_NETWORK_STRUCT_BEGIN
@@ -108,7 +109,6 @@ struct UNIXMessage
    * What is the identity of the sender (GNUNET_hash of public key)
    */
   struct GNUNET_PeerIdentity sender;
-
 };
 
 GNUNET_NETWORK_STRUCT_END
@@ -218,13 +218,12 @@ struct GNUNET_ATS_Session
   /**
    * Session timeout task.
    */
-  struct GNUNET_SCHEDULER_Task * timeout_task;
+  struct GNUNET_SCHEDULER_Task *timeout_task;
 
   /**
    * Number of messages we currently have in our write queue.
    */
   unsigned int msgs_in_queue;
-
 };
 
 
@@ -255,17 +254,17 @@ struct Plugin
   /**
    * ID of task used to update our addresses when one expires.
    */
-  struct GNUNET_SCHEDULER_Task * address_update_task;
+  struct GNUNET_SCHEDULER_Task *address_update_task;
 
   /**
    * ID of read task
    */
-  struct GNUNET_SCHEDULER_Task * read_task;
+  struct GNUNET_SCHEDULER_Task *read_task;
 
   /**
    * ID of write task
    */
-  struct GNUNET_SCHEDULER_Task * write_task;
+  struct GNUNET_SCHEDULER_Task *write_task;
 
   /**
    * Number of bytes we currently have in our write queues.
@@ -321,7 +320,6 @@ struct Plugin
    * Are we using an abstract UNIX domain socket?
    */
   int is_abstract;
-
 };
 
 
@@ -352,9 +350,7 @@ notify_session_monitor (struct Plugin *plugin,
      to receive from others) */
   info.session_timeout = session->timeout;
   info.address = session->address;
-  plugin->sic (plugin->sic_cls,
-               session,
-               &info);
+  plugin->sic (plugin->sic_cls, session, &info);
 }
 
 
@@ -370,9 +366,7 @@ notify_session_monitor (struct Plugin *plugin,
  * @return string representing the same address
  */
 static const char *
-unix_plugin_address_to_string (void *cls,
-                               const void *addr,
-                               size_t addrlen)
+unix_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
   static char rbuf[1024];
   struct UnixAddress *ua = (struct UnixAddress *) addr;
@@ -382,25 +376,25 @@ unix_plugin_address_to_string (void *cls,
 
   if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen))
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return NULL;
   }
   addrstr = (char *) &ua[1];
   addr_str_len = ntohl (ua->addrlen);
 
-  if (addr_str_len != addrlen - sizeof(struct UnixAddress))
+  if (addr_str_len != addrlen - sizeof (struct UnixAddress))
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return NULL;
   }
   if ('\0' != addrstr[addr_str_len - 1])
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return NULL;
   }
   if (strlen (addrstr) + 1 != addr_str_len)
   {
-    GNUNET_break(0);
+    GNUNET_break (0);
     return NULL;
   }
 
@@ -430,8 +424,7 @@ unix_plugin_address_to_string (void *cls,
  * @return #GNUNET_OK on success
  */
 static int
-unix_plugin_session_disconnect (void *cls,
-                                struct GNUNET_ATS_Session *session)
+unix_plugin_session_disconnect (void *cls, struct GNUNET_ATS_Session *session)
 {
   struct Plugin *plugin = cls;
   struct UNIXMessageWrapper *msgw;
@@ -443,9 +436,7 @@ unix_plugin_session_disconnect (void *cls,
        unix_plugin_address_to_string (NULL,
                                       session->address->address,
                                       session->address->address_length));
-  plugin->env->session_end (plugin->env->cls,
-                            session->address,
-                            session);
+  plugin->env->session_end (plugin->env->cls, session->address, session);
   next = plugin->msg_head;
   while (NULL != next)
   {
@@ -453,9 +444,7 @@ unix_plugin_session_disconnect (void *cls,
     next = msgw->next;
     if (msgw->session != session)
       continue;
-    GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
-                                 plugin->msg_tail,
-                                 msgw);
+    GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
     session->msgs_in_queue--;
     GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
     session->bytes_in_queue -= msgw->msgsize;
@@ -465,27 +454,27 @@ unix_plugin_session_disconnect (void *cls,
       msgw->cont (msgw->cont_cls,
                   &msgw->session->target,
                   GNUNET_SYSERR,
-                  msgw->payload, 0);
+                  msgw->payload,
+                  0);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
   }
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multipeermap_remove (plugin->session_map,
-                                                      &session->target,
-                                                      session));
+                                                       &session->target,
+                                                       session));
   GNUNET_STATISTICS_set (plugin->env->stats,
-                        "# UNIX sessions active",
-                        GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
-                        GNUNET_NO);
+                         "# UNIX sessions active",
+                         GNUNET_CONTAINER_multipeermap_size (
+                           plugin->session_map),
+                         GNUNET_NO);
   if (NULL != session->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (session->timeout_task);
     session->timeout_task = NULL;
     session->timeout = GNUNET_TIME_UNIT_ZERO_ABS;
   }
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_DONE);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_DONE);
   GNUNET_HELLO_address_free (session->address);
   GNUNET_break (0 == session->bytes_in_queue);
   GNUNET_break (0 == session->msgs_in_queue);
@@ -514,16 +503,16 @@ session_timeout (void *cls)
     notify_session_monitor (session->plugin,
                             session,
                             GNUNET_TRANSPORT_SS_UPDATE);
-    session->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
-                                                          &session_timeout,
-                                                          session);
+    session->timeout_task =
+      GNUNET_SCHEDULER_add_delayed (left, &session_timeout, session);
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Session %p was idle for %s, disconnecting\n",
        session,
-       GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
-                                              GNUNET_YES));
+       GNUNET_STRINGS_relative_time_to_string (
+         GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+         GNUNET_YES));
   unix_plugin_session_disconnect (session->plugin, session);
 }
 
@@ -539,7 +528,8 @@ static void
 reschedule_session_timeout (struct GNUNET_ATS_Session *session)
 {
   GNUNET_assert (NULL != session->timeout_task);
-  session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+  session->timeout =
+    GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
 }
 
 
@@ -551,13 +541,12 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *session)
  * @return converted unix path
  */
 static struct sockaddr_un *
-unix_address_to_sockaddr (const char *unixpath,
-                          socklen_t *sock_len)
+unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len)
 {
   struct sockaddr_un *un;
   size_t slen;
 
-  GNUNET_assert (0 < strlen (unixpath));        /* sanity check */
+  GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
   un = GNUNET_new (struct sockaddr_un);
   un->sun_family = AF_UNIX;
   slen = strlen (unixpath);
@@ -601,14 +590,13 @@ struct LookupCtx
  */
 static int
 lookup_session_it (void *cls,
-                  const struct GNUNET_PeerIdentity * key,
-                  void *value)
+                   const struct GNUNET_PeerIdentity *key,
+                   void *value)
 {
   struct LookupCtx *lctx = cls;
   struct GNUNET_ATS_Session *session = value;
 
-  if (0 == GNUNET_HELLO_address_cmp (lctx->address,
-                                     session->address))
+  if (0 == GNUNET_HELLO_address_cmp (lctx->address, session->address))
   {
     lctx->res = session;
     return GNUNET_NO;
@@ -633,8 +621,9 @@ lookup_session (struct Plugin *plugin,
   lctx.address = address;
   lctx.res = NULL;
   GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
-                                             &address->peer,
-                                             &lookup_session_it, &lctx);
+                                              &address->peer,
+                                              &lookup_session_it,
+                                              &lctx);
   return lctx.res;
 }
 
@@ -707,16 +696,15 @@ unix_real_send (void *cls,
   }
 
   /* Prepare address */
-  unixpath = (const char *)  &addr[1];
-  if (NULL == (un = unix_address_to_sockaddr (unixpath,
-                                              &un_len)))
+  unixpath = (const char *) &addr[1];
+  if (NULL == (un = unix_address_to_sockaddr (unixpath, &un_len)))
   {
     GNUNET_break (0);
     return -1;
   }
 
   if ((GNUNET_YES == plugin->is_abstract) &&
-      (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & ntohl(addr->options) )) )
+      (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & ntohl (addr->options))))
   {
     un->sun_path[0] = '\0';
   }
@@ -729,8 +717,7 @@ resend:
                                        un_len);
   if (GNUNET_SYSERR == sent)
   {
-    if ( (EAGAIN == errno) ||
-        (ENOBUFS == errno) )
+    if ((EAGAIN == errno) || (ENOBUFS == errno))
     {
       GNUNET_free (un);
       return RETRY; /* We have to retry later  */
@@ -741,7 +728,10 @@ resend:
       socklen_t len = sizeof (size);
 
       GNUNET_NETWORK_socket_getsockopt ((struct GNUNET_NETWORK_Handle *)
-                                        send_handle, SOL_SOCKET, SO_SNDBUF, &size,
+                                          send_handle,
+                                        SOL_SOCKET,
+                                        SO_SNDBUF,
+                                        &size,
                                         &len);
       if (size < msgbuf_size)
       {
@@ -752,9 +742,12 @@ resend:
              (unsigned int) msgbuf_size);
         size = ((msgbuf_size / 1000) + 2) * 1000;
         if (GNUNET_OK ==
-            GNUNET_NETWORK_socket_setsockopt ((struct GNUNET_NETWORK_Handle *) send_handle,
-                                              SOL_SOCKET, SO_SNDBUF,
-                                              &size, sizeof (size)))
+            GNUNET_NETWORK_socket_setsockopt ((struct GNUNET_NETWORK_Handle *)
+                                                send_handle,
+                                              SOL_SOCKET,
+                                              SO_SNDBUF,
+                                              &size,
+                                              sizeof (size)))
           goto resend; /* Increased buffer size, retry sending */
         else
         {
@@ -778,9 +771,9 @@ resend:
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "UNIX transmitted %u-byte message to %s (%d: %s)\n",
        (unsigned int) msgbuf_size,
-       GNUNET_a2s ((const struct sockaddr *)un, un_len),
+       GNUNET_a2s ((const struct sockaddr *) un, un_len),
        (int) sent,
-       (sent < 0) ? STRERROR (errno) : "ok");
+       (sent < 0) ? strerror (errno) : "ok");
   GNUNET_free (un);
   return sent;
 }
@@ -794,8 +787,7 @@ resend:
  * @return the network type in HBO or #GNUNET_SYSERR
  */
 static enum GNUNET_NetworkType
-unix_plugin_get_network (void *cls,
-                         struct GNUNET_ATS_Session *session)
+unix_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
 {
   GNUNET_assert (NULL != session);
   return GNUNET_NT_LOOPBACK;
@@ -827,19 +819,18 @@ unix_plugin_get_network_for_address (void *cls,
  * @return the session or NULL of max connections exceeded
  */
 static struct GNUNET_ATS_Session *
-unix_plugin_get_session (void *cls,
-                        const struct GNUNET_HELLO_Address *address)
+unix_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session;
   struct UnixAddress *ua;
-  char * addrstr;
+  char *addrstr;
   uint32_t addr_str_len;
   uint32_t addr_option;
 
   ua = (struct UnixAddress *) address->address;
   if ((NULL == address->address) || (0 == address->address_length) ||
-               (sizeof (struct UnixAddress) > address->address_length))
+      (sizeof (struct UnixAddress) > address->address_length))
   {
     GNUNET_break (0);
     return NULL;
@@ -848,8 +839,8 @@ unix_plugin_get_session (void *cls,
   addr_str_len = ntohl (ua->addrlen);
   addr_option = ntohl (ua->options);
 
-  if ( (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & addr_option)) &&
-    (GNUNET_NO == plugin->is_abstract))
+  if ((0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & addr_option)) &&
+      (GNUNET_NO == plugin->is_abstract))
   {
     return NULL;
   }
@@ -871,13 +862,12 @@ unix_plugin_get_session (void *cls,
   }
 
   /* Check if a session for this address already exists */
-  if (NULL != (session = lookup_session (plugin,
-                                         address)))
-    {
+  if (NULL != (session = lookup_session (plugin, address)))
+  {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Found existing session %p for address `%s'\n",
-        session,
-        unix_plugin_address_to_string (NULL,
+         session,
+         unix_plugin_address_to_string (NULL,
                                         address->address,
                                         address->address_length));
     return session;
@@ -888,29 +878,30 @@ unix_plugin_get_session (void *cls,
   session->target = address->peer;
   session->address = GNUNET_HELLO_address_copy (address);
   session->plugin = plugin;
-  session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
-  session->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
-                                                        &session_timeout,
-                                                        session);
+  session->timeout =
+    GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+  session->timeout_task =
+    GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+                                  &session_timeout,
+                                  session);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Creating a new session %p for address `%s'\n",
        session,
        unix_plugin_address_to_string (NULL,
                                       address->address,
                                       address->address_length));
-  (void) GNUNET_CONTAINER_multipeermap_put (plugin->session_map,
-                                           &address->peer, session,
-                                           GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+  (void) GNUNET_CONTAINER_multipeermap_put (
+    plugin->session_map,
+    &address->peer,
+    session,
+    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   GNUNET_STATISTICS_set (plugin->env->stats,
-                        "# UNIX sessions active",
-                        GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
-                        GNUNET_NO);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_INIT);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UP);
+                         "# UNIX sessions active",
+                         GNUNET_CONTAINER_multipeermap_size (
+                           plugin->session_map),
+                         GNUNET_NO);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
   return session;
 }
 
@@ -967,15 +958,17 @@ unix_demultiplexer (struct Plugin *plugin,
        "Received message from %s\n",
        unix_plugin_address_to_string (NULL, ua, ua_len));
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           "# bytes received via UNIX",
-                           ntohs (currhdr->size),
-                           GNUNET_NO);
+                            "# bytes received via UNIX",
+                            ntohs (currhdr->size),
+                            GNUNET_NO);
 
   /* Look for existing session */
-  address = GNUNET_HELLO_address_allocate (sender,
-                                           PLUGIN_NAME,
-                                           ua, ua_len,
-                                           GNUNET_HELLO_ADDRESS_INFO_NONE); /* UNIX does not have "inbound" sessions */
+  address = GNUNET_HELLO_address_allocate (
+    sender,
+    PLUGIN_NAME,
+    ua,
+    ua_len,
+    GNUNET_HELLO_ADDRESS_INFO_NONE); /* UNIX does not have "inbound" sessions */
   session = lookup_session (plugin, address);
   if (NULL == session)
   {
@@ -991,10 +984,7 @@ unix_demultiplexer (struct Plugin *plugin,
     reschedule_session_timeout (session);
   }
   GNUNET_HELLO_address_free (address);
-  plugin->env->receive (plugin->env->cls,
-                        session->address,
-                        session,
-                        currhdr);
+  plugin->env->receive (plugin->env->cls, session->address, session, currhdr);
 }
 
 
@@ -1024,23 +1014,23 @@ unix_plugin_do_read (struct Plugin *plugin)
   addrlen = sizeof (un);
   memset (&un, 0, sizeof (un));
   ret = GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc,
-                                        buf, sizeof (buf),
+                                        buf,
+                                        sizeof (buf),
                                         (struct sockaddr *) &un,
                                         &addrlen);
   if ((GNUNET_SYSERR == ret) && ((errno == EAGAIN) || (errno == ENOBUFS)))
     return;
   if (GNUNET_SYSERR == ret)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                         "recvfrom");
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
     return;
   }
   else
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Read %d bytes from socket %s\n",
-        (int) ret,
-        un.sun_path);
+         "Read %d bytes from socket %s\n",
+         (int) ret,
+         un.sun_path);
   }
 
   GNUNET_assert (AF_UNIX == (un.sun_family));
@@ -1053,12 +1043,12 @@ unix_plugin_do_read (struct Plugin *plugin)
 
   ua_len = sizeof (struct UnixAddress) + strlen (un.sun_path) + 1;
   ua = GNUNET_malloc (ua_len);
-  ua->addrlen = htonl (strlen (&un.sun_path[0]) +1);
+  ua->addrlen = htonl (strlen (&un.sun_path[0]) + 1);
   GNUNET_memcpy (&ua[1], &un.sun_path[0], strlen (un.sun_path) + 1);
   if (is_abstract)
-    ua->options = htonl(UNIX_OPTIONS_USE_ABSTRACT_SOCKETS);
+    ua->options = htonl (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS);
   else
-    ua->options = htonl(UNIX_OPTIONS_NONE);
+    ua->options = htonl (UNIX_OPTIONS_NONE);
 
   msg = (struct UNIXMessage *) buf;
   csize = ntohs (msg->header.size);
@@ -1069,9 +1059,7 @@ unix_plugin_do_read (struct Plugin *plugin)
     return;
   }
   msgbuf = (char *) &msg[1];
-  GNUNET_memcpy (&sender,
-          &msg->sender,
-          sizeof (struct GNUNET_PeerIdentity));
+  GNUNET_memcpy (&sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity));
   offset = 0;
   tsize = csize - sizeof (struct UNIXMessage);
   while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize)
@@ -1113,11 +1101,9 @@ unix_plugin_do_write (struct Plugin *plugin)
     /* Message has a timeout */
     did_delete = GNUNET_YES;
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Timeout for message with %u bytes \n",
-        (unsigned int) msgw->msgsize);
-    GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
-                                 plugin->msg_tail,
-                                 msgw);
+         "Timeout for message with %u bytes \n",
+         (unsigned int) msgw->msgsize);
+    GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
     session = msgw->session;
     session->msgs_in_queue--;
     GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
@@ -1125,28 +1111,26 @@ unix_plugin_do_write (struct Plugin *plugin)
     GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
     plugin->bytes_in_queue -= msgw->msgsize;
     GNUNET_STATISTICS_set (plugin->env->stats,
-                          "# bytes currently in UNIX buffers",
-                          plugin->bytes_in_queue,
+                           "# bytes currently in UNIX buffers",
+                           plugin->bytes_in_queue,
                            GNUNET_NO);
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             "# UNIX bytes discarded",
-                             msgw->msgsize,
-                             GNUNET_NO);
+                              "# UNIX bytes discarded",
+                              msgw->msgsize,
+                              GNUNET_NO);
     if (NULL != msgw->cont)
       msgw->cont (msgw->cont_cls,
-                 &msgw->session->target,
-                 GNUNET_SYSERR,
-                 msgw->payload,
-                 0);
+                  &msgw->session->target,
+                  GNUNET_SYSERR,
+                  msgw->payload,
+                  0);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
   }
   if (NULL == msgw)
   {
     if (GNUNET_YES == did_delete)
-      notify_session_monitor (plugin,
-                              session,
-                              GNUNET_TRANSPORT_SS_UPDATE);
+      notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
     return; /* Nothing to send at the moment */
   }
   session = msgw->session;
@@ -1160,20 +1144,18 @@ unix_plugin_do_write (struct Plugin *plugin)
                          msgw->session->address->address,
                          msgw->session->address->address_length,
                          msgw->payload,
-                         msgw->cont, msgw->cont_cls);
+                         msgw->cont,
+                         msgw->cont_cls);
   if (RETRY == sent)
   {
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             "# UNIX retry attempts",
-                             1, GNUNET_NO);
-    notify_session_monitor (plugin,
-                            session,
-                            GNUNET_TRANSPORT_SS_UPDATE);
+                              "# UNIX retry attempts",
+                              1,
+                              GNUNET_NO);
+    notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
     return;
   }
-  GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
-                               plugin->msg_tail,
-                               msgw);
+  GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
   session->msgs_in_queue--;
   GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
   session->bytes_in_queue -= msgw->msgsize;
@@ -1181,10 +1163,9 @@ unix_plugin_do_write (struct Plugin *plugin)
   plugin->bytes_in_queue -= msgw->msgsize;
   GNUNET_STATISTICS_set (plugin->env->stats,
                          "# bytes currently in UNIX buffers",
-                         plugin->bytes_in_queue, GNUNET_NO);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+                         plugin->bytes_in_queue,
+                         GNUNET_NO);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
   if (GNUNET_SYSERR == sent)
   {
     /* failed and no retry */
@@ -1192,11 +1173,12 @@ unix_plugin_do_write (struct Plugin *plugin)
       msgw->cont (msgw->cont_cls,
                   &msgw->session->target,
                   GNUNET_SYSERR,
-                  msgw->payload, 0);
+                  msgw->payload,
+                  0);
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             "# UNIX bytes discarded",
-                             msgw->msgsize,
-                             GNUNET_NO);
+                              "# UNIX bytes discarded",
+                              msgw->msgsize,
+                              GNUNET_NO);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
     return;
@@ -1204,15 +1186,15 @@ unix_plugin_do_write (struct Plugin *plugin)
   /* successfully sent bytes */
   GNUNET_break (sent > 0);
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           "# bytes transmitted via UNIX",
-                           msgw->msgsize,
-                           GNUNET_NO);
+                            "# bytes transmitted via UNIX",
+                            msgw->msgsize,
+                            GNUNET_NO);
   if (NULL != msgw->cont)
     msgw->cont (msgw->cont_cls,
                 &msgw->session->target,
-               GNUNET_OK,
-               msgw->payload,
-               msgw->msgsize);
+                GNUNET_OK,
+                msgw->payload,
+                msgw->msgsize);
   GNUNET_free (msgw->msg);
   GNUNET_free (msgw);
 }
@@ -1237,7 +1219,8 @@ unix_plugin_select_read (void *cls)
   plugin->read_task =
     GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
                                    plugin->unix_sock.desc,
-                                   &unix_plugin_select_read, plugin);
+                                   &unix_plugin_select_read,
+                                   plugin);
 }
 
 
@@ -1262,7 +1245,8 @@ unix_plugin_select_write (void *cls)
   plugin->write_task =
     GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
                                     plugin->unix_sock.desc,
-                                    &unix_plugin_select_write, plugin);
+                                    &unix_plugin_select_write,
+                                    plugin);
 }
 
 
@@ -1310,13 +1294,13 @@ unix_plugin_send (void *cls,
 
   if (GNUNET_OK !=
       GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
-                                                   &session->target,
-                                                   session))
+                                                    &session->target,
+                                                    session))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-        "Invalid session for peer `%s' `%s'\n",
-        GNUNET_i2s (&session->target),
-        unix_plugin_address_to_string (NULL,
+         "Invalid session for peer `%s' `%s'\n",
+         GNUNET_i2s (&session->target),
+         unix_plugin_address_to_string (NULL,
                                         session->address->address,
                                         session->address->address_length));
     GNUNET_break (0);
@@ -1333,16 +1317,16 @@ unix_plugin_send (void *cls,
   message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size);
   message->header.size = htons (ssize);
   message->header.type = htons (0);
-  GNUNET_memcpy (&message->sender, plugin->env->my_identity,
-          sizeof (struct GNUNET_PeerIdentity));
+  GNUNET_memcpy (&message->sender,
+                 plugin->env->my_identity,
+                 sizeof (struct GNUNET_PeerIdentity));
   GNUNET_memcpy (&message[1], msgbuf, msgbuf_size);
   wrapper = GNUNET_new (struct UNIXMessageWrapper);
   wrapper->msg = message;
   wrapper->msgsize = ssize;
   wrapper->payload = msgbuf_size;
   wrapper->priority = priority;
-  wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
-                                               to);
+  wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), to);
   wrapper->cont = cont;
   wrapper->cont_cls = cont_cls;
   wrapper->session = session;
@@ -1353,17 +1337,16 @@ unix_plugin_send (void *cls,
   session->bytes_in_queue += ssize;
   session->msgs_in_queue++;
   GNUNET_STATISTICS_set (plugin->env->stats,
-                        "# bytes currently in UNIX buffers",
-                        plugin->bytes_in_queue,
-                        GNUNET_NO);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UPDATE);
+                         "# bytes currently in UNIX buffers",
+                         plugin->bytes_in_queue,
+                         GNUNET_NO);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
   if (NULL == plugin->write_task)
     plugin->write_task =
       GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
                                       plugin->unix_sock.desc,
-                                      &unix_plugin_select_write, plugin);
+                                      &unix_plugin_select_write,
+                                      plugin);
   return ssize;
 }
 
@@ -1381,15 +1364,14 @@ unix_transport_server_start (void *cls)
   struct sockaddr_un *un;
   socklen_t un_len;
 
-  un = unix_address_to_sockaddr (plugin->unix_socket_path,
-                                 &un_len);
+  un = unix_address_to_sockaddr (plugin->unix_socket_path, &un_len);
   if (GNUNET_YES == plugin->is_abstract)
   {
     plugin->unix_socket_path[0] = '@';
     un->sun_path[0] = '\0';
   }
   plugin->unix_sock.desc =
-      GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
+    GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
   if (NULL == plugin->unix_sock.desc)
   {
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
@@ -1400,33 +1382,32 @@ unix_transport_server_start (void *cls)
   {
     if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path))
     {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot create path to `%s'\n"),
-          un->sun_path);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _ ("Cannot create path to `%s'\n"),
+           un->sun_path);
       GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
       plugin->unix_sock.desc = NULL;
       GNUNET_free (un);
       return GNUNET_SYSERR;
     }
   }
-  if (GNUNET_OK !=
-      GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc,
-                                  (const struct sockaddr *) un, un_len))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc,
+                                               (const struct sockaddr *) un,
+                                               un_len))
   {
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
-    LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot bind to `%s'\n"),
-        un->sun_path);
+    LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Cannot bind to `%s'\n"), un->sun_path);
     GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
     plugin->unix_sock.desc = NULL;
     GNUNET_free (un);
     return GNUNET_SYSERR;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Bound to `%s'\n",
-       plugin->unix_socket_path);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", plugin->unix_socket_path);
   plugin->read_task =
     GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
                                    plugin->unix_sock.desc,
-                                   &unix_plugin_select_read, plugin);
+                                   &unix_plugin_select_read,
+                                   plugin);
   GNUNET_free (un);
   return 1;
 }
@@ -1449,18 +1430,15 @@ unix_transport_server_start (void *cls)
  *
  */
 static int
-unix_plugin_check_address (void *cls,
-                           const void *addr,
-                           size_t addrlen)
+unix_plugin_check_address (void *cls, const void *addr, size_t addrlen)
 {
-  struct Pluginplugin = cls;
+  struct Plugin *plugin = cls;
   const struct UnixAddress *ua = addr;
   char *addrstr;
   size_t addr_str_len;
 
-  if ( (NULL == addr) ||
-       (0 == addrlen) ||
-       (sizeof (struct UnixAddress) > addrlen) )
+  if ((NULL == addr) || (0 == addrlen) ||
+      (sizeof (struct UnixAddress) > addrlen))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1479,7 +1457,7 @@ unix_plugin_check_address (void *cls,
   }
 
   if (0 == strcmp (plugin->unix_socket_path, addrstr))
-       return GNUNET_OK;
+    return GNUNET_OK;
   return GNUNET_SYSERR;
 }
 
@@ -1499,7 +1477,8 @@ unix_plugin_check_address (void *cls,
  * @param asc_cls closure for @a asc
  */
 static void
-unix_plugin_address_pretty_printer (void *cls, const char *type,
+unix_plugin_address_pretty_printer (void *cls,
+                                    const char *type,
                                     const void *addr,
                                     size_t addrlen,
                                     int numeric,
@@ -1509,15 +1488,11 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
 {
   const char *ret;
 
-  if ( (NULL != addr) && (addrlen > 0))
-    ret = unix_plugin_address_to_string (NULL,
-                                         addr,
-                                         addrlen);
+  if ((NULL != addr) && (addrlen > 0))
+    ret = unix_plugin_address_to_string (NULL, addr, addrlen);
   else
     ret = NULL;
-  asc (asc_cls,
-       ret,
-       (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
+  asc (asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
   asc (asc_cls, NULL, GNUNET_OK);
 }
 
@@ -1538,7 +1513,8 @@ static int
 unix_plugin_string_to_address (void *cls,
                                const char *addr,
                                uint16_t addrlen,
-                               void **buf, size_t *added)
+                               void **buf,
+                               size_t *added)
 {
   struct UnixAddress *ua;
   char *address;
@@ -1587,7 +1563,7 @@ unix_plugin_string_to_address (void *cls,
   }
   address[0] = '\0';
   address++;
-  if (0 != strcmp(plugin, PLUGIN_NAME))
+  if (0 != strcmp (plugin, PLUGIN_NAME))
   {
     GNUNET_break (0);
     GNUNET_free (plugin);
@@ -1624,9 +1600,11 @@ address_notification (void *cls)
   len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
   ua = GNUNET_malloc (len);
   ua->options = htonl (plugin->myoptions);
-  ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
+  ua->addrlen = htonl (strlen (plugin->unix_socket_path) + 1);
   unix_path = (char *) &ua[1];
-  GNUNET_memcpy (unix_path, plugin->unix_socket_path, strlen (plugin->unix_socket_path) + 1);
+  GNUNET_memcpy (unix_path,
+                 plugin->unix_socket_path,
+                 strlen (plugin->unix_socket_path) + 1);
 
   plugin->address_update_task = NULL;
   address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
@@ -1634,9 +1612,7 @@ address_notification (void *cls)
                                            ua,
                                            len,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  plugin->env->notify_address (plugin->env->cls,
-                               GNUNET_YES,
-                               address);
+  plugin->env->notify_address (plugin->env->cls, GNUNET_YES, address);
   GNUNET_free (ua);
   GNUNET_free (address);
 }
@@ -1652,8 +1628,8 @@ address_notification (void *cls)
  */
 static int
 get_session_delete_it (void *cls,
-                      const struct GNUNET_PeerIdentity *key,
-                      void *value)
+                       const struct GNUNET_PeerIdentity *key,
+                       void *value)
 {
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session = value;
@@ -1677,8 +1653,9 @@ unix_plugin_peer_disconnect (void *cls,
   struct Plugin *plugin = cls;
 
   GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
-                                             target,
-                                             &get_session_delete_it, plugin);
+                                              target,
+                                              &get_session_delete_it,
+                                              plugin);
 }
 
 
@@ -1699,12 +1676,8 @@ send_session_info_iter (void *cls,
   struct Plugin *plugin = cls;
   struct GNUNET_ATS_Session *session = value;
 
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_INIT);
-  notify_session_monitor (plugin,
-                          session,
-                          GNUNET_TRANSPORT_SS_UP);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
   return GNUNET_OK;
 }
 
@@ -1786,9 +1759,10 @@ libgnunet_plugin_transport_unix_init (void *cls)
 
   /* Initialize my flags */
 #ifdef LINUX
-  plugin->is_abstract = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
-                                                              "testing",
-                                                              "USE_ABSTRACT_SOCKETS");
+  plugin->is_abstract =
+    GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
+                                          "testing",
+                                          "USE_ABSTRACT_SOCKETS");
 #endif
   plugin->myoptions = UNIX_OPTIONS_NONE;
   if (GNUNET_YES == plugin->is_abstract)
@@ -1812,16 +1786,15 @@ libgnunet_plugin_transport_unix_init (void *cls)
   sockets_created = unix_transport_server_start (plugin);
   if ((0 == sockets_created) || (GNUNET_SYSERR == sockets_created))
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-        _("Failed to open UNIX listen socket\n"));
+    LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to open UNIX listen socket\n"));
     GNUNET_free (api);
     GNUNET_free (plugin->unix_socket_path);
     GNUNET_free (plugin);
     return NULL;
   }
   plugin->session_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
-  plugin->address_update_task = GNUNET_SCHEDULER_add_now (&address_notification,
-                                                          plugin);
+  plugin->address_update_task =
+    GNUNET_SCHEDULER_add_now (&address_notification, plugin);
   return api;
 }
 
@@ -1838,7 +1811,7 @@ libgnunet_plugin_transport_unix_done (void *cls)
   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
   struct Plugin *plugin = api->cls;
   struct GNUNET_HELLO_Address *address;
-  struct UNIXMessageWrapper * msgw;
+  struct UNIXMessageWrapper *msgw;
   struct UnixAddress *ua;
   size_t len;
   struct GNUNET_ATS_Session *session;
@@ -1851,26 +1824,23 @@ libgnunet_plugin_transport_unix_done (void *cls)
   len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
   ua = GNUNET_malloc (len);
   ua->options = htonl (plugin->myoptions);
-  ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
+  ua->addrlen = htonl (strlen (plugin->unix_socket_path) + 1);
   GNUNET_memcpy (&ua[1],
-          plugin->unix_socket_path,
-          strlen (plugin->unix_socket_path) + 1);
+                 plugin->unix_socket_path,
+                 strlen (plugin->unix_socket_path) + 1);
   address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
                                            PLUGIN_NAME,
-                                           ua, len,
+                                           ua,
+                                           len,
                                            GNUNET_HELLO_ADDRESS_INFO_NONE);
-  plugin->env->notify_address (plugin->env->cls,
-                               GNUNET_NO,
-                               address);
+  plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address);
 
   GNUNET_free (address);
   GNUNET_free (ua);
 
   while (NULL != (msgw = plugin->msg_head))
   {
-    GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
-                                 plugin->msg_tail,
-                                 msgw);
+    GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
     session = msgw->session;
     session->msgs_in_queue--;
     GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
@@ -1881,7 +1851,8 @@ libgnunet_plugin_transport_unix_done (void *cls)
       msgw->cont (msgw->cont_cls,
                   &msgw->session->target,
                   GNUNET_SYSERR,
-                  msgw->payload, 0);
+                  msgw->payload,
+                  0);
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
   }
@@ -1908,7 +1879,7 @@ libgnunet_plugin_transport_unix_done (void *cls)
     plugin->unix_sock.desc = NULL;
   }
   GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map,
-                                        &get_session_delete_it,
+                                         &get_session_delete_it,
                                          plugin);
   GNUNET_CONTAINER_multipeermap_destroy (plugin->session_map);
   GNUNET_break (0 == plugin->bytes_in_queue);
index cfb0883618d5fb9d2ac1c446aa6c22e9b20130c0..999e8827a35a16849733baf2da9063c0613d8c17 100644 (file)
  * is this value divided by the number of address families.
  * Default is 5s.
  */
-#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define CONNECT_RETRY_TIMEOUT \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
 
-
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-connection", syscall)
 
 
 /**
@@ -78,14 +79,13 @@ struct GNUNET_CONNECTION_TransmitHandle
   /**
    * Task called on timeout.
    */
-  struct GNUNET_SCHEDULER_Task * timeout_task;
+  struct GNUNET_SCHEDULER_Task *timeout_task;
 
   /**
    * At what number of bytes available in the
    * write buffer should the notify method be called?
    */
   size_t notify_size;
-
 };
 
 
@@ -129,7 +129,7 @@ struct AddressProbe
   /**
    * Task waiting for the connection to finish connecting.
    */
-  struct GNUNET_SCHEDULER_Task * task;
+  struct GNUNET_SCHEDULER_Task *task;
 };
 
 
@@ -263,7 +263,6 @@ struct GNUNET_CONNECTION_Handle
    * Handle to subsequent connection after proxy handshake completes,
    */
   struct GNUNET_CONNECTION_Handle *proxy_handshake;
-
 };
 
 
@@ -357,9 +356,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
 
   addrlen = sizeof (addr);
   sock =
-      GNUNET_NETWORK_socket_accept (lsock,
-                                   (struct sockaddr *) &addr,
-                                   &addrlen);
+    GNUNET_NETWORK_socket_accept (lsock, (struct sockaddr *) &addr, &addrlen);
   if (NULL == sock)
   {
     if (EAGAIN != errno)
@@ -375,8 +372,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
 
   sa = (struct sockaddr *) addr;
   v6 = (struct sockaddr_in6 *) addr;
-  if ( (AF_INET6 == sa->sa_family) &&
-       (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)) )
+  if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)))
   {
     /* convert to V4 address */
     v4 = GNUNET_new (struct sockaddr_in);
@@ -386,9 +382,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
     v4->sin_len = (u_char) sizeof (struct sockaddr_in);
 #endif
     GNUNET_memcpy (&v4->sin_addr,
-            &((char *) &v6->sin6_addr)[sizeof (struct in6_addr) -
-                                       sizeof (struct in_addr)],
-            sizeof (struct in_addr));
+                   &((char *) &v6->sin6_addr)[sizeof (struct in6_addr) -
+                                              sizeof (struct in_addr)],
+                   sizeof (struct in_addr));
     v4->sin_port = v6->sin6_port;
     uaddr = v4;
     addrlen = sizeof (struct sockaddr_in);
@@ -403,21 +399,18 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
   {
 #if HAVE_GETPEEREID
     /* most BSDs */
-    if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock),
-                        &gc.uid,
-                        &gc.gid))
+    if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock), &gc.uid, &gc.gid))
       gcp = &gc;
 #else
 #ifdef SO_PEERCRED
     /* largely traditional GNU/Linux */
     olen = sizeof (uc);
-    if ( (0 ==
-         getsockopt (GNUNET_NETWORK_get_fd (sock),
-                     SOL_SOCKET,
-                     SO_PEERCRED,
-                     &uc,
-                     &olen)) &&
-        (olen == sizeof (uc)) )
+    if ((0 == getsockopt (GNUNET_NETWORK_get_fd (sock),
+                          SOL_SOCKET,
+                          SO_PEERCRED,
+                          &uc,
+                          &olen)) &&
+        (olen == sizeof (uc)))
     {
       gc.uid = uc.uid;
       gc.gid = uc.gid;
@@ -441,20 +434,15 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
 #endif
   }
 
-  if ( (NULL != access_cb) &&
-       (GNUNET_YES != (aret = access_cb (access_cb_cls,
-                                        gcp,
-                                        uaddr,
-                                        addrlen))) )
+  if ((NULL != access_cb) &&
+      (GNUNET_YES != (aret = access_cb (access_cb_cls, gcp, uaddr, addrlen))))
   {
     if (GNUNET_NO == aret)
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Access denied to `%s'\n"),
-           GNUNET_a2s (uaddr,
-                       addrlen));
+           _ ("Access denied to `%s'\n"),
+           GNUNET_a2s (uaddr, addrlen));
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_shutdown (sock,
-                                                  SHUT_RDWR));
+                  GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR));
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
     GNUNET_free (uaddr);
     return NULL;
@@ -466,9 +454,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
   connection->addrlen = addrlen;
   connection->sock = sock;
   LOG (GNUNET_ERROR_TYPE_INFO,
-       _("Accepting connection from `%s': %p\n"),
-       GNUNET_a2s (uaddr,
-                  addrlen),
+       _ ("Accepting connection from `%s': %p\n"),
+       GNUNET_a2s (uaddr, addrlen),
        connection);
   return connection;
 }
@@ -503,14 +490,13 @@ GNUNET_CONNECTION_get_address (struct GNUNET_CONNECTION_Handle *connection,
  * @param errcode error code to send
  */
 static void
-signal_receive_error (struct GNUNET_CONNECTION_Handle *connection,
-                      int errcode)
+signal_receive_error (struct GNUNET_CONNECTION_Handle *connection, int errcode)
 {
   GNUNET_CONNECTION_Receiver receiver;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Receive encounters error (%s), connection closed (%p)\n",
-       STRERROR (errcode),
+       strerror (errcode),
        connection);
   GNUNET_assert (NULL != (receiver = connection->receiver));
   connection->receiver = NULL;
@@ -549,21 +535,18 @@ signal_receive_timeout (struct GNUNET_CONNECTION_Handle *connection)
  * @param ecode error code (errno)
  */
 static void
-signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection,
-                      int ecode)
+signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection, int ecode)
 {
   GNUNET_CONNECTION_TransmitReadyNotify notify;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Transmission encounterd error (%s), connection closed (%p)\n",
-       STRERROR (ecode),
+       strerror (ecode),
        connection);
   if (NULL != connection->sock)
   {
-    (void) GNUNET_NETWORK_socket_shutdown (connection->sock,
-                                           SHUT_RDWR);
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (connection->sock));
+    (void) GNUNET_NETWORK_socket_shutdown (connection->sock, SHUT_RDWR);
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
     connection->sock = NULL;
     GNUNET_assert (NULL == connection->write_task);
   }
@@ -576,12 +559,10 @@ signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection,
     return;
   }
   if (NULL == connection->nth.notify_ready)
-    return;                     /* nobody to tell about it */
+    return; /* nobody to tell about it */
   notify = connection->nth.notify_ready;
   connection->nth.notify_ready = NULL;
-  notify (connection->nth.notify_ready_cls,
-         0,
-         NULL);
+  notify (connection->nth.notify_ready_cls, 0, NULL);
 }
 
 
@@ -597,7 +578,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection)
   LOG (GNUNET_ERROR_TYPE_INFO,
        "Failed to establish TCP connection to `%s:%u', no further addresses to try.\n",
        connection->hostname,
-    connection->port);
+       connection->port);
   GNUNET_break (NULL == connection->ap_head);
   GNUNET_break (NULL == connection->ap_tail);
   GNUNET_break (GNUNET_NO == connection->dns_active);
@@ -608,15 +589,13 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection)
   /* signal errors for jobs that used to wait on the connection */
   connection->destroy_later = 1;
   if (NULL != connection->receiver)
-    signal_receive_error (connection,
-                          ECONNREFUSED);
+    signal_receive_error (connection, ECONNREFUSED);
   if (NULL != connection->nth.notify_ready)
   {
     GNUNET_assert (NULL != connection->nth.timeout_task);
     GNUNET_SCHEDULER_cancel (connection->nth.timeout_task);
     connection->nth.timeout_task = NULL;
-    signal_transmit_error (connection,
-                           ECONNREFUSED);
+    signal_transmit_error (connection, ECONNREFUSED);
   }
   if (-1 == connection->destroy_later)
   {
@@ -658,21 +637,21 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Connection to `%s' succeeded! (%p)\n",
-       GNUNET_a2s (connection->addr,
-                  connection->addrlen),
+       GNUNET_a2s (connection->addr, connection->addrlen),
        connection);
   /* trigger jobs that waited for the connection */
   if (NULL != connection->receiver)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Connection succeeded, starting with receiving data (%p)\n",
-        connection);
+         connection);
     GNUNET_assert (NULL == connection->read_task);
     connection->read_task =
-      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
-                                     (connection->receive_timeout),
-                                    connection->sock,
-                                     &receive_ready, connection);
+      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (
+                                       connection->receive_timeout),
+                                     connection->sock,
+                                     &receive_ready,
+                                     connection);
   }
   if (NULL != connection->nth.notify_ready)
   {
@@ -684,9 +663,11 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection)
     connection->nth.timeout_task = NULL;
     GNUNET_assert (connection->write_task == NULL);
     connection->write_task =
-        GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
-                                        (connection->nth.transmit_timeout), connection->sock,
-                                        &transmit_ready, connection);
+      GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (
+                                        connection->nth.transmit_timeout),
+                                      connection->sock,
+                                      &transmit_ready,
+                                      connection);
   }
 }
 
@@ -708,28 +689,24 @@ connect_probe_continuation (void *cls)
   socklen_t len;
 
   GNUNET_assert (NULL != ap->sock);
-  GNUNET_CONTAINER_DLL_remove (connection->ap_head,
-                              connection->ap_tail,
-                              ap);
+  GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, ap);
   len = sizeof (error);
   errno = 0;
   error = 0;
   tc = GNUNET_SCHEDULER_get_task_context ();
-  if ( (0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) ||
-       (GNUNET_OK !=
-       GNUNET_NETWORK_socket_getsockopt (ap->sock,
-                                         SOL_SOCKET,
-                                         SO_ERROR,
-                                         &error,
-                                         &len)) ||
-       (0 != error) )
+  if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) ||
+      (GNUNET_OK != GNUNET_NETWORK_socket_getsockopt (ap->sock,
+                                                      SOL_SOCKET,
+                                                      SO_ERROR,
+                                                      &error,
+                                                      &len)) ||
+      (0 != error))
   {
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_NETWORK_socket_close (ap->sock));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock));
     GNUNET_free (ap);
-    if ( (NULL == connection->ap_head) &&
-        (GNUNET_NO == connection->dns_active) &&
-        (NULL == connection->proxy_handshake) )
+    if ((NULL == connection->ap_head) &&
+        (GNUNET_NO == connection->dns_active) &&
+        (NULL == connection->proxy_handshake))
       connect_fail_continuation (connection);
     return;
   }
@@ -745,9 +722,7 @@ connect_probe_continuation (void *cls)
   {
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
     GNUNET_SCHEDULER_cancel (pos->task);
-    GNUNET_CONTAINER_DLL_remove (connection->ap_head,
-                                connection->ap_tail,
-                                pos);
+    GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos);
     GNUNET_free (pos);
   }
   connect_success_continuation (connection);
@@ -774,14 +749,13 @@ try_connect_using_address (void *cls,
   if (NULL == addr)
   {
     connection->dns_active = NULL;
-    if ((NULL == connection->ap_head) &&
-        (NULL == connection->sock) &&
+    if ((NULL == connection->ap_head) && (NULL == connection->sock) &&
         (NULL == connection->proxy_handshake))
       connect_fail_continuation (connection);
     return;
   }
   if (NULL != connection->sock)
-    return;                     /* already connected */
+    return; /* already connected */
   GNUNET_assert (NULL == connection->addr);
   /* try to connect */
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -807,23 +781,20 @@ try_connect_using_address (void *cls,
   default:
     GNUNET_break (0);
     GNUNET_free (ap);
-    return;                     /* not supported by us */
+    return; /* not supported by us */
   }
-  ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family,
-                                          SOCK_STREAM, 0);
+  ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0);
   if (NULL == ap->sock)
   {
     GNUNET_free (ap);
-    return;                     /* not supported by OS */
+    return; /* not supported by OS */
   }
   LOG (GNUNET_ERROR_TYPE_INFO,
        "Trying to connect to `%s' (%p)\n",
        GNUNET_a2s (ap->addr, ap->addrlen),
        connection);
   if ((GNUNET_OK !=
-       GNUNET_NETWORK_socket_connect (ap->sock,
-                                     ap->addr,
-                                     ap->addrlen)) &&
+       GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) &&
       (EINPROGRESS != errno))
   {
     /* maybe refused / unsupported address, try next */
@@ -836,14 +807,16 @@ try_connect_using_address (void *cls,
   delay = CONNECT_RETRY_TIMEOUT;
   if (NULL != connection->nth.notify_ready)
     delay = GNUNET_TIME_relative_min (delay,
-                                     GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
+                                      GNUNET_TIME_absolute_get_remaining (
+                                        connection->nth.transmit_timeout));
   if (NULL != connection->receiver)
     delay = GNUNET_TIME_relative_min (delay,
-                                     GNUNET_TIME_absolute_get_remaining (connection->receive_timeout));
+                                      GNUNET_TIME_absolute_get_remaining (
+                                        connection->receive_timeout));
   ap->task = GNUNET_SCHEDULER_add_write_net (delay,
-                                            ap->sock,
-                                            &connect_probe_continuation,
-                                            ap);
+                                             ap->sock,
+                                             &connect_probe_continuation,
+                                             ap);
 }
 
 
@@ -858,25 +831,25 @@ try_connect_using_address (void *cls,
  * @return the connection handle
  */
 struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                       const char *hostname,
-                                       uint16_t port)
+GNUNET_CONNECTION_create_from_connect (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *hostname,
+  uint16_t port)
 {
   struct GNUNET_CONNECTION_Handle *connection;
 
-  GNUNET_assert (0 < strlen (hostname));        /* sanity check */
+  GNUNET_assert (0 < strlen (hostname)); /* sanity check */
   connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
   connection->cfg = cfg;
   connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
   connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
   connection->port = port;
   connection->hostname = GNUNET_strdup (hostname);
-  connection->dns_active =
-      GNUNET_RESOLVER_ip_get (connection->hostname,
-                             AF_UNSPEC,
-                              CONNECT_RETRY_TIMEOUT,
-                              &try_connect_using_address,
-                             connection);
+  connection->dns_active = GNUNET_RESOLVER_ip_get (connection->hostname,
+                                                   AF_UNSPEC,
+                                                   CONNECT_RETRY_TIMEOUT,
+                                                   &try_connect_using_address,
+                                                   connection);
   return connection;
 }
 
@@ -891,14 +864,15 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
  * @return the connection handle, NULL on systems without UNIX support
  */
 struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                                   const char *unixpath)
+GNUNET_CONNECTION_create_from_connect_to_unixpath (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *unixpath)
 {
 #ifdef AF_UNIX
   struct GNUNET_CONNECTION_Handle *connection;
   struct sockaddr_un *un;
 
-  GNUNET_assert (0 < strlen (unixpath));        /* sanity check */
+  GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
   un = GNUNET_new (struct sockaddr_un);
   un->sun_family = AF_UNIX;
   GNUNET_strlcpy (un->sun_path, unixpath, sizeof (un->sun_path));
@@ -907,7 +881,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
     int abstract;
 
     abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                                    "TESTING",
+                                                     "TESTING",
                                                      "USE_ABSTRACT_SOCKETS");
     if (GNUNET_YES == abstract)
       un->sun_path[0] = '\0';
@@ -924,9 +898,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
   connection->hostname = NULL;
   connection->addr = (struct sockaddr *) un;
   connection->addrlen = sizeof (struct sockaddr_un);
-  connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX,
-                                                  SOCK_STREAM,
-                                                  0);
+  connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
   if (NULL == connection->sock)
   {
     GNUNET_free (connection->addr);
@@ -934,15 +906,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
     GNUNET_free (connection);
     return NULL;
   }
-  if ( (GNUNET_OK !=
-       GNUNET_NETWORK_socket_connect (connection->sock,
-                                      connection->addr,
-                                      connection->addrlen)) &&
-       (EINPROGRESS != errno) )
+  if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (connection->sock,
+                                                   connection->addr,
+                                                   connection->addrlen)) &&
+      (EINPROGRESS != errno))
   {
     /* Just return; we expect everything to work eventually so don't fail HARD */
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_NETWORK_socket_close (connection->sock));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
     connection->sock = NULL;
     return connection;
   }
@@ -971,17 +941,14 @@ GNUNET_CONNECTION_connect_socket (struct GNUNET_NETWORK_Handle *s,
 {
   struct GNUNET_CONNECTION_Handle *connection;
 
-  if ( (GNUNET_OK !=
-        GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) &&
-       (EINPROGRESS != errno) )
+  if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) &&
+      (EINPROGRESS != errno))
   {
     /* maybe refused / unsupported address, try next */
-    LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG,
-                  "connect");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "connect");
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Attempt to connect to `%s' failed\n",
-         GNUNET_a2s (serv_addr,
-                     addrlen));
+         GNUNET_a2s (serv_addr, addrlen));
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
     return NULL;
   }
@@ -1018,13 +985,10 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
   s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0);
   if (NULL == s)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
-                 "socket");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "socket");
     return NULL;
   }
-  return GNUNET_CONNECTION_connect_socket (s,
-                                          serv_addr,
-                                          addrlen);
+  return GNUNET_CONNECTION_connect_socket (s, serv_addr, addrlen);
 }
 
 
@@ -1039,12 +1003,10 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
 int
 GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *connection)
 {
-  if ((NULL != connection->ap_head) ||
-      (NULL != connection->dns_active) ||
+  if ((NULL != connection->ap_head) || (NULL != connection->dns_active) ||
       (NULL != connection->proxy_handshake))
-    return GNUNET_YES;          /* still trying to connect */
-  if ( (0 != connection->destroy_later) ||
-       (NULL == connection->sock) )
+    return GNUNET_YES; /* still trying to connect */
+  if ((0 != connection->destroy_later) || (NULL == connection->sock))
     return GNUNET_NO;
   return GNUNET_YES;
 }
@@ -1067,9 +1029,7 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
     connection->destroy_later = -1;
     return;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Shutting down connection (%p)\n",
-       connection);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection);
   GNUNET_assert (NULL == connection->nth.notify_ready);
   GNUNET_assert (NULL == connection->receiver);
   if (NULL != connection->write_task)
@@ -1098,27 +1058,21 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
   {
     /* GNUNET_CONNECTION_destroy (connection->proxy_handshake); */
     connection->proxy_handshake->destroy_later = -1;
-    connection->proxy_handshake = NULL;  /* Not leaked ??? */
+    connection->proxy_handshake = NULL; /* Not leaked ??? */
   }
   while (NULL != (pos = connection->ap_head))
   {
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
     GNUNET_SCHEDULER_cancel (pos->task);
-    GNUNET_CONTAINER_DLL_remove (connection->ap_head,
-                                connection->ap_tail,
-                                pos);
+    GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos);
     GNUNET_free (pos);
   }
-  if ( (NULL != connection->sock) &&
-       (GNUNET_YES != connection->persist) )
+  if ((NULL != connection->sock) && (GNUNET_YES != connection->persist))
   {
     if ((GNUNET_OK !=
-         GNUNET_NETWORK_socket_shutdown (connection->sock,
-                                         SHUT_RDWR)) &&
-       (ENOTCONN != errno) &&
-       (ECONNRESET != errno) )
-      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                    "shutdown");
+         GNUNET_NETWORK_socket_shutdown (connection->sock, SHUT_RDWR)) &&
+        (ENOTCONN != errno) && (ECONNRESET != errno))
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "shutdown");
   }
   if (NULL != connection->sock)
   {
@@ -1129,7 +1083,8 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
     }
     else
     {
-      GNUNET_NETWORK_socket_free_memory_only_ (connection->sock); /* at least no memory leak (we deliberately
+      GNUNET_NETWORK_socket_free_memory_only_ (
+        connection->sock); /* at least no memory leak (we deliberately
                                                                   * leak the socket in this special case) ... */
     }
   }
@@ -1160,12 +1115,12 @@ receive_ready (void *cls)
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Receive from `%s' encounters error: timeout (%s, %p)\n",
-        GNUNET_a2s (connection->addr,
-                    connection->addrlen),
-        GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout),
-                                                GNUNET_YES),
-        connection);
+         "Receive from `%s' encounters error: timeout (%s, %p)\n",
+         GNUNET_a2s (connection->addr, connection->addrlen),
+         GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (
+                                                   connection->receive_timeout),
+                                                 GNUNET_YES),
+         connection);
     signal_receive_timeout (connection);
     return;
   }
@@ -1175,12 +1130,9 @@ receive_ready (void *cls)
     signal_receive_error (connection, ECONNREFUSED);
     return;
   }
-  GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                            connection->sock));
+  GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, connection->sock));
 RETRY:
-  ret = GNUNET_NETWORK_socket_recv (connection->sock,
-                                    buffer,
-                                    connection->max);
+  ret = GNUNET_NETWORK_socket_recv (connection->sock, buffer, connection->max);
   if (-1 == ret)
   {
     if (EINTR == errno)
@@ -1192,8 +1144,7 @@ RETRY:
        "receive_ready read %u/%u bytes from `%s' (%p)!\n",
        (unsigned int) ret,
        connection->max,
-       GNUNET_a2s (connection->addr,
-                   connection->addrlen),
+       GNUNET_a2s (connection->addr, connection->addrlen),
        connection);
   GNUNET_assert (NULL != (receiver = connection->receiver));
   connection->receiver = NULL;
@@ -1238,22 +1189,18 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
   if (NULL != connection->sock)
   {
     connection->read_task =
-      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
-                                     (connection->receive_timeout),
+      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (
+                                       connection->receive_timeout),
                                      connection->sock,
                                      &receive_ready,
                                      connection);
     return GNUNET_OK;
   }
-  if ((NULL == connection->dns_active) &&
-      (NULL == connection->ap_head) &&
+  if ((NULL == connection->dns_active) && (NULL == connection->ap_head) &&
       (NULL == connection->proxy_handshake))
   {
     connection->receiver = NULL;
-    receiver (receiver_cls,
-             NULL, 0,
-             NULL, 0,
-             ETIMEDOUT);
+    receiver (receiver_cls, NULL, 0, NULL, 0, ETIMEDOUT);
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -1297,13 +1244,11 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
   size_t size;
   GNUNET_CONNECTION_TransmitReadyNotify notify;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "process_notify is running\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "process_notify is running\n");
   GNUNET_assert (NULL == connection->write_task);
   if (NULL == (notify = connection->nth.notify_ready))
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "No one to notify\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "No one to notify\n");
     return GNUNET_NO;
   }
   used = connection->write_buffer_off - connection->write_buffer_pos;
@@ -1311,8 +1256,7 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
   size = connection->nth.notify_size;
   if (size > avail)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Not enough buffer\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough buffer\n");
     return GNUNET_NO;
   }
   connection->nth.notify_ready = NULL;
@@ -1327,9 +1271,9 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
   }
   avail = connection->write_buffer_size - connection->write_buffer_off;
   GNUNET_assert (avail >= size);
-  size =
-      notify (connection->nth.notify_ready_cls, avail,
-              &connection->write_buffer[connection->write_buffer_off]);
+  size = notify (connection->nth.notify_ready_cls,
+                 avail,
+                 &connection->write_buffer[connection->write_buffer_off]);
   GNUNET_assert (size <= avail);
   if (0 != size)
     connection->write_buffer_off += size;
@@ -1358,15 +1302,12 @@ transmit_timeout (void *cls)
        "Transmit to `%s:%u/%s' fails, time out reached (%p).\n",
        connection->hostname,
        connection->port,
-       GNUNET_a2s (connection->addr,
-                   connection->addrlen),
+       GNUNET_a2s (connection->addr, connection->addrlen),
        connection);
   notify = connection->nth.notify_ready;
   GNUNET_assert (NULL != notify);
   connection->nth.notify_ready = NULL;
-  notify (connection->nth.notify_ready_cls,
-         0,
-         NULL);
+  notify (connection->nth.notify_ready_cls, 0, NULL);
 }
 
 
@@ -1393,9 +1334,7 @@ connect_error (void *cls)
   connection->write_task = NULL;
   notify = connection->nth.notify_ready;
   connection->nth.notify_ready = NULL;
-  notify (connection->nth.notify_ready_cls,
-         0,
-         NULL);
+  notify (connection->nth.notify_ready_cls, 0, NULL);
 }
 
 
@@ -1413,9 +1352,7 @@ transmit_ready (void *cls)
   ssize_t ret;
   size_t have;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "transmit_ready running (%p).\n",
-       connection);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready running (%p).\n", connection);
   GNUNET_assert (NULL != connection->write_task);
   connection->write_task = NULL;
   GNUNET_assert (NULL == connection->nth.timeout_task);
@@ -1424,8 +1361,7 @@ transmit_ready (void *cls)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Transmit to `%s' fails, time out reached (%p).\n",
-         GNUNET_a2s (connection->addr,
-                     connection->addrlen),
+         GNUNET_a2s (connection->addr, connection->addrlen),
          connection);
     notify = connection->nth.notify_ready;
     GNUNET_assert (NULL != notify);
@@ -1441,8 +1377,7 @@ transmit_ready (void *cls)
      * Hence retry.  */
     goto SCHEDULE_WRITE;
   }
-  if (! GNUNET_NETWORK_fdset_isset (tc->write_ready,
-                                   connection->sock))
+  if (! GNUNET_NETWORK_fdset_isset (tc->write_ready, connection->sock))
   {
     GNUNET_assert (NULL == connection->write_task);
     /* special circumstances (in particular, shutdown): not yet ready
@@ -1454,7 +1389,7 @@ transmit_ready (void *cls)
       (connection->write_buffer_size < connection->nth.notify_size))
   {
     connection->write_buffer =
-        GNUNET_realloc (connection->write_buffer, connection->nth.notify_size);
+      GNUNET_realloc (connection->write_buffer, connection->nth.notify_size);
     connection->write_buffer_size = connection->nth.notify_size;
   }
   process_notify (connection);
@@ -1465,13 +1400,15 @@ transmit_ready (void *cls)
     return;
   }
   GNUNET_assert (have <= connection->write_buffer_size);
-  GNUNET_assert (have + connection->write_buffer_pos <= connection->write_buffer_size);
+  GNUNET_assert (have + connection->write_buffer_pos <=
+                 connection->write_buffer_size);
   GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
 RETRY:
   ret =
-      GNUNET_NETWORK_socket_send (connection->sock,
-                                 &connection->write_buffer[connection->write_buffer_pos],
-                                 have);
+    GNUNET_NETWORK_socket_send (connection->sock,
+                                &connection
+                                   ->write_buffer[connection->write_buffer_pos],
+                                have);
   if (-1 == ret)
   {
     if (EINTR == errno)
@@ -1488,8 +1425,7 @@ RETRY:
        "Connection transmitted %u/%u bytes to `%s' (%p)\n",
        (unsigned int) ret,
        have,
-       GNUNET_a2s (connection->addr,
-                  connection->addrlen),
+       GNUNET_a2s (connection->addr, connection->addrlen),
        connection);
   connection->write_buffer_pos += ret;
   if (connection->write_buffer_pos == connection->write_buffer_off)
@@ -1498,25 +1434,25 @@ RETRY:
     connection->write_buffer_pos = 0;
     connection->write_buffer_off = 0;
   }
-  if ( (0 == connection->write_buffer_off) &&
-       (NULL == connection->nth.notify_ready) )
-    return;                     /* all data sent! */
+  if ((0 == connection->write_buffer_off) &&
+      (NULL == connection->nth.notify_ready))
+    return; /* all data sent! */
   /* not done writing, schedule more */
 SCHEDULE_WRITE:
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Re-scheduling transmit_ready (more to do) (%p).\n",
        connection);
   have = connection->write_buffer_off - connection->write_buffer_pos;
-  GNUNET_assert ( (NULL != connection->nth.notify_ready) ||
-                 (have > 0) );
+  GNUNET_assert ((NULL != connection->nth.notify_ready) || (have > 0));
   if (NULL == connection->write_task)
     connection->write_task =
-        GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready ==
-                                         NULL) ? GNUNET_TIME_UNIT_FOREVER_REL :
-                                        GNUNET_TIME_absolute_get_remaining
-                                        (connection->nth.transmit_timeout),
-                                        connection->sock,
-                                       &transmit_ready, connection);
+      GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready == NULL)
+                                        ? GNUNET_TIME_UNIT_FOREVER_REL
+                                        : GNUNET_TIME_absolute_get_remaining (
+                                            connection->nth.transmit_timeout),
+                                      connection->sock,
+                                      &transmit_ready,
+                                      connection);
 }
 
 
@@ -1535,11 +1471,12 @@ SCHEDULE_WRITE:
  *         NULL if we are already going to notify someone else (busy)
  */
 struct GNUNET_CONNECTION_TransmitHandle *
-GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connection,
-                                         size_t size,
-                                         struct GNUNET_TIME_Relative timeout,
-                                         GNUNET_CONNECTION_TransmitReadyNotify notify,
-                                        void *notify_cls)
+GNUNET_CONNECTION_notify_transmit_ready (
+  struct GNUNET_CONNECTION_Handle *connection,
+  size_t size,
+  struct GNUNET_TIME_Relative timeout,
+  GNUNET_CONNECTION_TransmitReadyNotify notify,
+  void *notify_cls)
 {
   if (NULL != connection->nth.notify_ready)
   {
@@ -1557,15 +1494,13 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
   connection->nth.notify_size = size;
   connection->nth.transmit_timeout = GNUNET_TIME_relative_to_absolute (timeout);
   GNUNET_assert (NULL == connection->nth.timeout_task);
-  if ((NULL == connection->sock) &&
-      (NULL == connection->ap_head) &&
-      (NULL == connection->dns_active) &&
-      (NULL == connection->proxy_handshake))
+  if ((NULL == connection->sock) && (NULL == connection->ap_head) &&
+      (NULL == connection->dns_active) && (NULL == connection->proxy_handshake))
   {
     if (NULL != connection->write_task)
       GNUNET_SCHEDULER_cancel (connection->write_task);
-    connection->write_task = GNUNET_SCHEDULER_add_now (&connect_error,
-                                                       connection);
+    connection->write_task =
+      GNUNET_SCHEDULER_add_now (&connect_error, connection);
     return &connection->nth;
   }
   if (NULL != connection->write_task)
@@ -1577,10 +1512,11 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
          "Scheduling transmission (%p).\n",
          connection);
     connection->write_task =
-        GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
-                                        (connection->nth.transmit_timeout),
-                                        connection->sock,
-                                       &transmit_ready, connection);
+      GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (
+                                        connection->nth.transmit_timeout),
+                                      connection->sock,
+                                      &transmit_ready,
+                                      connection);
     return &connection->nth;
   }
   /* not yet connected, wait for connection */
@@ -1588,9 +1524,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
        "Need to wait to schedule transmission for connection, adding timeout task (%p).\n",
        connection);
   connection->nth.timeout_task =
-    GNUNET_SCHEDULER_add_delayed (timeout,
-                                  &transmit_timeout,
-                                 connection);
+    GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, connection);
   return &connection->nth;
 }
 
@@ -1601,7 +1535,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
  * @param th notification to cancel
  */
 void
-GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_TransmitHandle *th)
+GNUNET_CONNECTION_notify_transmit_ready_cancel (
+  struct GNUNET_CONNECTION_TransmitHandle *th)
 {
   GNUNET_assert (NULL != th->notify_ready);
   th->notify_ready = NULL;
@@ -1625,9 +1560,11 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_Transmi
  * @return connection to be proxied
  */
 struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph)
+GNUNET_CONNECTION_create_proxied_from_handshake (
+  struct GNUNET_CONNECTION_Handle *cph)
 {
-  struct GNUNET_CONNECTION_Handle *proxied = GNUNET_CONNECTION_create_from_existing (NULL);
+  struct GNUNET_CONNECTION_Handle *proxied =
+    GNUNET_CONNECTION_create_from_existing (NULL);
 
   proxied->proxy_handshake = cph;
   return proxied;
index 19508a39f0fe13bf8b59a4226a32474073db117a..e59fa4a1c28c219a79e41f23a7ff561dc6e57a82 100644 (file)
@@ -224,7 +224,6 @@ struct LEGACY_SERVICE_Context
    * Our options.
    */
   enum LEGACY_SERVICE_Options options;
-
 };
 
 
@@ -247,7 +246,7 @@ write_test (void *cls, size_t size, void *buf)
   if (size < sizeof (struct GNUNET_MessageHeader))
   {
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return 0;                   /* client disconnected */
+    return 0; /* client disconnected */
   }
   msg = (struct GNUNET_MessageHeader *) buf;
   msg->type = htons (GNUNET_MESSAGE_TYPE_TEST);
@@ -265,7 +264,8 @@ write_test (void *cls, size_t size, void *buf)
  * @param message the actual message
  */
 static void
-handle_test (void *cls, struct GNUNET_SERVER_Client *client,
+handle_test (void *cls,
+             struct GNUNET_SERVER_Client *client,
              const struct GNUNET_MessageHeader *message)
 {
   /* simply bounce message back to acknowledge */
@@ -273,7 +273,8 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client,
       GNUNET_SERVER_notify_transmit_ready (client,
                                            sizeof (struct GNUNET_MessageHeader),
                                            GNUNET_TIME_UNIT_FOREVER_REL,
-                                           &write_test, client))
+                                           &write_test,
+                                           client))
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
 }
 
@@ -283,11 +284,12 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client,
  * "callback_cls" fields will be replaced with the specific service
  * struct.
  */
-static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
-  {&handle_test, NULL, GNUNET_MESSAGE_TYPE_TEST,
-   sizeof (struct GNUNET_MessageHeader)},
-  {NULL, NULL, 0, 0}
-};
+static const struct GNUNET_SERVER_MessageHandler defhandlers[] =
+  {{&handle_test,
+    NULL,
+    GNUNET_MESSAGE_TYPE_TEST,
+    sizeof (struct GNUNET_MessageHeader)},
+   {NULL, NULL, 0, 0}};
 
 
 /* ****************** service core routines ************** */
@@ -304,8 +306,10 @@ static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
  *   for unknown address family (will be denied).
  */
 static int
-check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
-              const struct sockaddr *addr, socklen_t addrlen)
+check_access (void *cls,
+              const struct GNUNET_CONNECTION_Credentials *uc,
+              const struct sockaddr *addr,
+              socklen_t addrlen)
 {
   struct LEGACY_SERVICE_Context *sctx = cls;
   const struct sockaddr_in *i4;
@@ -319,32 +323,33 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
     i4 = (const struct sockaddr_in *) addr;
     ret = ((NULL == sctx->v4_allowed) ||
            (check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) &&
-        ((NULL == sctx->v4_denied) ||
-         (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr)));
+          ((NULL == sctx->v4_denied) ||
+           (! check_ipv4_listed (sctx->v4_denied, &i4->sin_addr)));
     break;
   case AF_INET6:
     GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
     i6 = (const struct sockaddr_in6 *) addr;
     ret = ((NULL == sctx->v6_allowed) ||
            (check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) &&
-        ((NULL == sctx->v6_denied) ||
-         (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr)));
+          ((NULL == sctx->v6_denied) ||
+           (! check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr)));
     break;
 #ifndef WINDOWS
   case AF_UNIX:
-    ret = GNUNET_OK;            /* controlled using file-system ACL now */
+    ret = GNUNET_OK; /* controlled using file-system ACL now */
     break;
 #endif
   default:
-    LOG (GNUNET_ERROR_TYPE_WARNING, _("Unknown address family %d\n"),
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         _ ("Unknown address family %d\n"),
          addr->sa_family);
     return GNUNET_SYSERR;
   }
   if (GNUNET_OK != ret)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Access from `%s' denied to service `%s'\n"),
-        GNUNET_a2s (addr, addrlen),
+         _ ("Access from `%s' denied to service `%s'\n"),
+         GNUNET_a2s (addr, addrlen),
          sctx->service_name);
   }
   return ret;
@@ -363,9 +368,10 @@ get_pid_file_name (struct LEGACY_SERVICE_Context *sctx)
 {
   char *pif;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
-                                               "PIDFILE", &pif))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg,
+                                                            sctx->service_name,
+                                                            "PIDFILE",
+                                                            &pif))
     return NULL;
   return pif;
 }
@@ -387,7 +393,7 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
 {
   char *opt;
 
-  if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
+  if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
   {
     *ret = NULL;
     return GNUNET_OK;
@@ -395,12 +401,15 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
   GNUNET_break (GNUNET_OK ==
                 GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
                                                        sctx->service_name,
-                                                       option, &opt));
+                                                       option,
+                                                       &opt));
   if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt)))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
-         opt, sctx->service_name, option);
+         _ ("Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
+         opt,
+         sctx->service_name,
+         option);
     GNUNET_free (opt);
     return GNUNET_SYSERR;
   }
@@ -425,7 +434,7 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
 {
   char *opt;
 
-  if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
+  if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
   {
     *ret = NULL;
     return GNUNET_OK;
@@ -433,12 +442,15 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
   GNUNET_break (GNUNET_OK ==
                 GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
                                                        sctx->service_name,
-                                                       option, &opt));
+                                                       option,
+                                                       &opt));
   if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt)))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
-         opt, sctx->service_name, option);
+         _ ("Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
+         opt,
+         sctx->service_name,
+         option);
     GNUNET_free (opt);
     return GNUNET_SYSERR;
   }
@@ -507,10 +519,11 @@ add_unixpath (struct sockaddr **saddrs,
  *              set to NULL).
  */
 int
-LEGACY_SERVICE_get_server_addresses (const char *service_name,
-                                     const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                     struct sockaddr ***addrs,
-                                     socklen_t ** addr_lens)
+LEGACY_SERVICE_get_server_addresses (
+  const char *service_name,
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  struct sockaddr ***addrs,
+  socklen_t **addr_lens)
 {
   int disablev6;
   struct GNUNET_NETWORK_Handle *desc;
@@ -534,8 +547,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
   {
     if (GNUNET_SYSERR ==
-        (disablev6 =
-         GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
+        (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                           service_name,
+                                                           "DISABLEV6")))
       return GNUNET_SYSERR;
   }
   else
@@ -554,8 +568,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
-           service_name, STRERROR (errno));
+           _ (
+             "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+           service_name,
+           strerror (errno));
       disablev6 = GNUNET_YES;
     }
     else
@@ -568,18 +584,19 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
   port = 0;
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
   {
-    if (GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
-                                              "PORT", &port))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                            service_name,
+                                                            "PORT",
+                                                            &port))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
     }
     if (port > 65535)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Require valid port number for service `%s' in configuration!\n"),
+           _ ("Require valid port number for service `%s' in configuration!\n"),
            service_name);
       return GNUNET_SYSERR;
     }
@@ -588,8 +605,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
   if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
-                                                         "BINDTO", &hostname));
+                  GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                         service_name,
+                                                         "BINDTO",
+                                                         &hostname));
   }
   else
     hostname = NULL;
@@ -599,9 +618,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
 #ifdef AF_UNIX
   if ((GNUNET_YES ==
        GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
-                                              &unixpath)) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                             service_name,
+                                                             "UNIXPATH",
+                                                             &unixpath)) &&
       (0 < strlen (unixpath)))
   {
     /* probe UNIX support */
@@ -610,12 +630,11 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
     if (strlen (unixpath) >= sizeof (s_un.sun_path))
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
+           _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
+           unixpath,
            (unsigned long long) sizeof (s_un.sun_path));
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
-      LOG (GNUNET_ERROR_TYPE_INFO,
-          _("Using `%s' instead\n"),
-           unixpath);
+      LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
     }
 #ifdef LINUX
     abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -624,12 +643,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
     if (GNUNET_SYSERR == abstract)
       abstract = GNUNET_NO;
 #endif
-    if ((GNUNET_YES != abstract)
-        && (GNUNET_OK !=
-            GNUNET_DISK_directory_create_for_file (unixpath)))
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                               "mkdir",
-                               unixpath);
+    if ((GNUNET_YES != abstract) &&
+        (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
   }
   if (NULL != unixpath)
   {
@@ -645,9 +661,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+           _ (
+             "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
            service_name,
-           STRERROR (errno));
+           strerror (errno));
       GNUNET_free (unixpath);
       unixpath = NULL;
     }
@@ -662,7 +679,8 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
   if ((0 == port) && (NULL == unixpath))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+         _ (
+           "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
          service_name);
     GNUNET_free_non_null (hostname);
     return GNUNET_SYSERR;
@@ -693,7 +711,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
         (NULL == res))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to resolve `%s': %s\n"),
+           _ ("Failed to resolve `%s': %s\n"),
            hostname,
            gai_strerror (ret));
       GNUNET_free (hostname);
@@ -712,7 +730,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
     if (0 == i)
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Failed to find %saddress for `%s'.\n"),
+           _ ("Failed to find %saddress for `%s'.\n"),
            disablev6 ? "IPv4 " : "",
            hostname);
       freeaddrinfo (res);
@@ -738,11 +756,13 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
       if ((disablev6) && (AF_INET6 == pos->ai_family))
         continue;
       if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
-        continue;               /* not TCP */
+        continue; /* not TCP */
       if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
-        continue;               /* huh? */
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
-           service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+        continue; /* huh? */
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Service `%s' will bind to `%s'\n",
+           service_name,
+           GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
       if (AF_INET == pos->ai_family)
       {
         GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
@@ -854,7 +874,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
    * to create a GNUnet API that boxes a HANDLE (the way it is done with socks)
    */
   lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10);
-  if ( (0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
+  if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
     return GNUNET_NO;
   fail = 1;
   do
@@ -867,7 +887,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
     if ((0 == ret) || (sizeof (count) != rd) || (0 == count))
       break;
     sctx->lsocks =
-        GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1));
+      GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1));
 
     fail2 = 1;
     for (i = 0; i < count; i++)
@@ -877,12 +897,17 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
       SOCKET s;
 
       ret = ReadFile (lsocks_pipe, &size, sizeof (size), &rd, NULL);
-      if ( (0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size) )
+      if ((0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size))
         break;
       ret = ReadFile (lsocks_pipe, &pi, sizeof (pi), &rd, NULL);
-      if ( (0 == ret) || (sizeof (pi) != rd))
+      if ((0 == ret) || (sizeof (pi) != rd))
         break;
-      s = WSASocketA (pi.iAddressFamily, pi.iSocketType, pi.iProtocol, &pi, 0, WSA_FLAG_OVERLAPPED);
+      s = WSASocketA (pi.iAddressFamily,
+                      pi.iSocketType,
+                      pi.iProtocol,
+                      &pi,
+                      0,
+                      WSA_FLAG_OVERLAPPED);
       sctx->lsocks[i] = GNUNET_NETWORK_socket_box_native (s);
       if (NULL == sctx->lsocks[i])
         break;
@@ -893,15 +918,14 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
       break;
     sctx->lsocks[count] = NULL;
     fail = 0;
-  }
-  while (fail);
+  } while (fail);
 
   CloseHandle (lsocks_pipe);
 
   if (fail)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Could not access a pre-bound socket, will try to bind myself\n"));
+         _ ("Could not access a pre-bound socket, will try to bind myself\n"));
     for (i = 0; (i < count) && (NULL != sctx->lsocks[i]); i++)
       GNUNET_break (0 == GNUNET_NETWORK_socket_close (sctx->lsocks[i]));
     GNUNET_free_non_null (sctx->lsocks);
@@ -943,15 +967,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
   int flags;
 #endif
 
-  if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, "TIMEOUT"))
+  if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
+                                       sctx->service_name,
+                                       "TIMEOUT"))
   {
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->service_name,
-                                             "TIMEOUT", &idleout))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
+                                                          sctx->service_name,
+                                                          "TIMEOUT",
+                                                          &idleout))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Specified value for `%s' of service `%s' is invalid\n"),
-           "TIMEOUT", sctx->service_name);
+           _ ("Specified value for `%s' of service `%s' is invalid\n"),
+           "TIMEOUT",
+           sctx->service_name);
       return GNUNET_SYSERR;
     }
     sctx->timeout = idleout;
@@ -959,17 +987,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
   else
     sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
 
-  if (GNUNET_CONFIGURATION_have_value
-      (sctx->cfg, sctx->service_name, "TOLERANT"))
+  if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
+                                       sctx->service_name,
+                                       "TOLERANT"))
   {
     if (GNUNET_SYSERR ==
-        (tolerant =
-         GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
-                                               "TOLERANT")))
+        (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+                                                          sctx->service_name,
+                                                          "TOLERANT")))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
-           _("Specified value for `%s' of service `%s' is invalid\n"),
-           "TOLERANT", sctx->service_name);
+           _ ("Specified value for `%s' of service `%s' is invalid\n"),
+           "TOLERANT",
+           sctx->service_name);
       return GNUNET_SYSERR;
     }
   }
@@ -979,11 +1009,11 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
 #ifndef MINGW
   errno = 0;
   if ((NULL != (nfds = getenv ("LISTEN_FDS"))) &&
-      (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
+      (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
       (cnt + 4 < FD_SETSIZE))
   {
     sctx->lsocks =
-        GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1));
+      GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1));
     while (0 < cnt--)
     {
       flags = fcntl (3 + cnt, F_GETFD);
@@ -992,8 +1022,8 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
            (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt))))
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _
-             ("Could not access pre-bound socket %u, will try to bind myself\n"),
+             _ (
+               "Could not access pre-bound socket %u, will try to bind myself\n"),
              (unsigned int) 3 + cnt);
         cnt++;
         while (sctx->lsocks[cnt] != NULL)
@@ -1014,17 +1044,18 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
 #endif
 
   if ((NULL == sctx->lsocks) &&
-      (GNUNET_SYSERR ==
-       LEGACY_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg,
-                                            &sctx->addrs, &sctx->addrlens)))
+      (GNUNET_SYSERR == LEGACY_SERVICE_get_server_addresses (sctx->service_name,
+                                                             sctx->cfg,
+                                                             &sctx->addrs,
+                                                             &sctx->addrlens)))
     return GNUNET_SYSERR;
   sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
-  sctx->match_uid =
-      GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
-                                            "UNIX_MATCH_UID");
-  sctx->match_gid =
-      GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
-                                            "UNIX_MATCH_GID");
+  sctx->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+                                                          sctx->service_name,
+                                                          "UNIX_MATCH_UID");
+  sctx->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+                                                          sctx->service_name,
+                                                          "UNIX_MATCH_GID");
   process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM");
   process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM");
   process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6");
@@ -1046,9 +1077,10 @@ get_user_name (struct LEGACY_SERVICE_Context *sctx)
 {
   char *un;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
-                                               "USERNAME", &un))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg,
+                                                            sctx->service_name,
+                                                            "USERNAME",
+                                                            &un))
     return NULL;
   return un;
 }
@@ -1071,14 +1103,14 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
   int len;
 
   if (NULL == (pif = get_pid_file_name (sctx)))
-    return GNUNET_OK;           /* no file desired */
+    return GNUNET_OK; /* no file desired */
   user = get_user_name (sctx);
   rdir = GNUNET_strdup (pif);
   len = strlen (rdir);
   while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
     len--;
   rdir[len] = '\0';
-  if (0 != ACCESS (rdir, F_OK))
+  if (0 != access (rdir, F_OK))
   {
     /* we get to create a directory -- and claim it
      * as ours! */
@@ -1086,7 +1118,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
     if ((NULL != user) && (0 < strlen (user)))
       GNUNET_DISK_file_change_owner (rdir, user);
   }
-  if (0 != ACCESS (rdir, W_OK | X_OK))
+  if (0 != access (rdir, W_OK | X_OK))
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir);
     GNUNET_free (rdir);
@@ -1095,7 +1127,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
     return GNUNET_SYSERR;
   }
   GNUNET_free (rdir);
-  pidfd = FOPEN (pif, "w");
+  pidfd = fopen (pif, "w");
   if (NULL == pidfd)
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif);
@@ -1103,9 +1135,9 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
     GNUNET_free_non_null (user);
     return GNUNET_SYSERR;
   }
-  if (0 > FPRINTF (pidfd, "%u", pid))
+  if (0 > fprintf (pidfd, "%u", pid))
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif);
-  GNUNET_break (0 == FCLOSE (pidfd));
+  GNUNET_break (0 == fclose (pidfd));
   if ((NULL != user) && (0 < strlen (user)))
     GNUNET_DISK_file_change_owner (pif, user);
   GNUNET_free_non_null (user);
@@ -1146,29 +1178,37 @@ service_task (void *cls)
 
   GNUNET_RESOLVER_connect (sctx->cfg);
   if (NULL != sctx->lsocks)
-    sctx->server
-      = GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks,
-                                           sctx->timeout, sctx->require_found);
+    sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
+                                                      sctx,
+                                                      sctx->lsocks,
+                                                      sctx->timeout,
+                                                      sctx->require_found);
   else
-    sctx->server
-      = GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens,
-                              sctx->timeout, sctx->require_found);
+    sctx->server = GNUNET_SERVER_create (&check_access,
+                                         sctx,
+                                         sctx->addrs,
+                                         sctx->addrlens,
+                                         sctx->timeout,
+                                         sctx->require_found);
   if (NULL == sctx->server)
   {
     if (NULL != sctx->addrs)
       for (i = 0; NULL != sctx->addrs[i]; i++)
         LOG (GNUNET_ERROR_TYPE_INFO,
-             _("Failed to start `%s' at `%s'\n"),
-             sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+             _ ("Failed to start `%s' at `%s'\n"),
+             sctx->service_name,
+             GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
     sctx->ret = GNUNET_SYSERR;
     return;
   }
 #ifndef WINDOWS
   if (NULL != sctx->addrs)
     for (i = 0; NULL != sctx->addrs[i]; i++)
-      if ((AF_UNIX == sctx->addrs[i]->sa_family)
-          && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
-        GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
+      if ((AF_UNIX == sctx->addrs[i]->sa_family) &&
+          ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0]))
+        GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)
+                                        sctx->addrs[i])
+                                       ->sun_path,
                                      sctx->match_uid,
                                      sctx->match_gid);
 #endif
@@ -1178,8 +1218,7 @@ service_task (void *cls)
   {
     /* install a task that will kill the server
      * process if the scheduler ever gets a shutdown signal */
-    sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                                        sctx);
+    sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, sctx);
   }
   sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
   GNUNET_memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers));
@@ -1189,8 +1228,8 @@ service_task (void *cls)
   GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers);
   if (-1 != sctx->ready_confirm_fd)
   {
-    GNUNET_break (1 == WRITE (sctx->ready_confirm_fd, ".", 1));
-    GNUNET_break (0 == CLOSE (sctx->ready_confirm_fd));
+    GNUNET_break (1 == write (sctx->ready_confirm_fd, ".", 1));
+    GNUNET_break (0 == close (sctx->ready_confirm_fd));
     sctx->ready_confirm_fd = -1;
     write_pid_file (sctx, getpid ());
   }
@@ -1199,8 +1238,10 @@ service_task (void *cls)
     i = 0;
     while (NULL != sctx->addrs[i])
     {
-      LOG (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"),
-           sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+      LOG (GNUNET_ERROR_TYPE_INFO,
+           _ ("Service `%s' runs at %s\n"),
+           sctx->service_name,
+           GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
       i++;
     }
   }
@@ -1222,7 +1263,7 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
   int nullfd;
   int filedes[2];
 
-  if (0 != PIPE (filedes))
+  if (0 != pipe (filedes))
   {
     LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe");
     return GNUNET_SYSERR;
@@ -1238,9 +1279,9 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
     /* Parent */
     char c;
 
-    GNUNET_break (0 == CLOSE (filedes[1]));
+    GNUNET_break (0 == close (filedes[1]));
     c = 'X';
-    if (1 != READ (filedes[0], &c, sizeof (char)))
+    if (1 != read (filedes[0], &c, sizeof (char)))
       LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "read");
     fflush (stdout);
     switch (c)
@@ -1248,33 +1289,34 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
     case '.':
       exit (0);
     case 'I':
-      LOG (GNUNET_ERROR_TYPE_INFO, _("Service process failed to initialize\n"));
+      LOG (GNUNET_ERROR_TYPE_INFO,
+           _ ("Service process failed to initialize\n"));
       break;
     case 'S':
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Service process could not initialize server function\n"));
+           _ ("Service process could not initialize server function\n"));
       break;
     case 'X':
       LOG (GNUNET_ERROR_TYPE_INFO,
-           _("Service process failed to report status\n"));
+           _ ("Service process failed to report status\n"));
       break;
     }
-    exit (1);                   /* child reported error */
+    exit (1); /* child reported error */
   }
-  GNUNET_break (0 == CLOSE (0));
-  GNUNET_break (0 == CLOSE (1));
-  GNUNET_break (0 == CLOSE (filedes[0]));
-  nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
+  GNUNET_break (0 == close (0));
+  GNUNET_break (0 == close (1));
+  GNUNET_break (0 == close (filedes[0]));
+  nullfd = open ("/dev/null", O_RDWR | O_APPEND);
   if (nullfd < 0)
     return GNUNET_SYSERR;
   /* set stdin/stdout to /dev/null */
   if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0))
   {
     LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2");
-    (void) CLOSE (nullfd);
+    (void) close (nullfd);
     return GNUNET_SYSERR;
   }
-  (void) CLOSE (nullfd);
+  (void) close (nullfd);
   /* Detach from controlling terminal */
   pid = setsid ();
   if (-1 == pid)
@@ -1301,7 +1343,7 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
   char *user;
 
   if (NULL == (user = get_user_name (sctx)))
-    return GNUNET_OK;           /* keep */
+    return GNUNET_OK; /* keep */
 #ifndef MINGW
   struct passwd *pws;
 
@@ -1310,8 +1352,9 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
   if (NULL == pws)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Cannot obtain information about user `%s': %s\n"), user,
-         errno == 0 ? _("No such user") : STRERROR (errno));
+         _ ("Cannot obtain information about user `%s': %s\n"),
+         user,
+         errno == 0 ? _ ("No such user") : strerror (errno));
     GNUNET_free (user);
     return GNUNET_SYSERR;
   }
@@ -1324,8 +1367,10 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
     if ((0 != setregid (pws->pw_gid, pws->pw_gid)) ||
         (0 != setreuid (pws->pw_uid, pws->pw_uid)))
     {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot change user/group to `%s': %s\n"),
-           user, STRERROR (errno));
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _ ("Cannot change user/group to `%s': %s\n"),
+           user,
+           strerror (errno));
       GNUNET_free (user);
       return GNUNET_SYSERR;
     }
@@ -1347,8 +1392,8 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx)
   char *pif = get_pid_file_name (sctx);
 
   if (NULL == pif)
-    return;                     /* no PID file */
-  if (0 != UNLINK (pif))
+    return; /* no PID file */
+  if (0 != unlink (pif))
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", pif);
   GNUNET_free (pif);
 }
@@ -1368,13 +1413,19 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx)
  *         if we shutdown nicely
  */
 int
-LEGACY_SERVICE_run (int argc, char *const *argv,
+LEGACY_SERVICE_run (int argc,
+                    char *const *argv,
                     const char *service_name,
                     enum LEGACY_SERVICE_Options options,
                     LEGACY_SERVICE_Main task,
                     void *task_cls)
 {
-#define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0)
+#define HANDLE_ERROR  \
+  do                  \
+  {                   \
+    GNUNET_break (0); \
+    goto shutdown;    \
+  } while (0)
 
   int err;
   int ret;
@@ -1391,18 +1442,18 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
   struct GNUNET_CONFIGURATION_Handle *cfg;
   const char *xdg;
 
-  struct GNUNET_GETOPT_CommandLineOption service_options[] = {
-    GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn),
-    GNUNET_GETOPT_option_flag ('d',
-                                  "daemonize",
-                                  gettext_noop ("do daemonize (detach from terminal)"),
-                                  &do_daemonize),
-    GNUNET_GETOPT_option_help (NULL),
-    GNUNET_GETOPT_option_loglevel (&loglev),
-    GNUNET_GETOPT_option_logfile (&logfile),
-    GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption service_options[] =
+    {GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn),
+     GNUNET_GETOPT_option_flag ('d',
+                                "daemonize",
+                                gettext_noop (
+                                  "do daemonize (detach from terminal)"),
+                                &do_daemonize),
+     GNUNET_GETOPT_option_help (NULL),
+     GNUNET_GETOPT_option_loglevel (&loglev),
+     GNUNET_GETOPT_option_logfile (&logfile),
+     GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
+     GNUNET_GETOPT_OPTION_END};
   err = 1;
   do_daemonize = 0;
   logfile = NULL;
@@ -1445,7 +1496,7 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Malformed configuration file `%s', exit ...\n"),
+                  _ ("Malformed configuration file `%s', exit ...\n"),
                   opt_cfg_fn);
       goto shutdown;
     }
@@ -1455,13 +1506,13 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Malformed configuration, exit ...\n"));
+                  _ ("Malformed configuration, exit ...\n"));
       goto shutdown;
     }
     if (0 != strcmp (opt_cfg_fn, cfg_fn))
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Could not access configuration file `%s'\n"),
-                 opt_cfg_fn);
+                  _ ("Could not access configuration file `%s'\n"),
+                  opt_cfg_fn);
   }
   if (GNUNET_OK != setup_service (&sctx))
     goto shutdown;
@@ -1473,12 +1524,14 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
        "Service `%s' runs with configuration from `%s'\n",
        service_name,
        opt_cfg_fn);
-  if ((GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING",
-                                              "SKEW_OFFSET", &skew_offset)) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING",
-                                              "SKEW_VARIANCE", &skew_variance)))
+  if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg,
+                                                           "TESTING",
+                                                           "SKEW_OFFSET",
+                                                           &skew_offset)) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg,
+                                                           "TESTING",
+                                                           "SKEW_VARIANCE",
+                                                           &skew_variance)))
   {
     clock_offset = skew_offset - skew_variance;
     GNUNET_TIME_set_offset (clock_offset);
@@ -1495,21 +1548,21 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
 shutdown:
   if (-1 != sctx.ready_confirm_fd)
   {
-    if (1 != WRITE (sctx.ready_confirm_fd, err ? "I" : "S", 1))
+    if (1 != write (sctx.ready_confirm_fd, err ? "I" : "S", 1))
       LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write");
-    GNUNET_break (0 == CLOSE (sctx.ready_confirm_fd));
+    GNUNET_break (0 == close (sctx.ready_confirm_fd));
   }
 #if HAVE_MALLINFO
   {
     char *counter;
 
-    if ( (GNUNET_YES ==
-         GNUNET_CONFIGURATION_have_value (sctx.cfg, service_name,
-                                          "GAUGER_HEAP")) &&
-        (GNUNET_OK ==
-         GNUNET_CONFIGURATION_get_value_string (sctx.cfg, service_name,
-                                                "GAUGER_HEAP",
-                                                &counter)) )
+    if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx.cfg,
+                                                        service_name,
+                                                        "GAUGER_HEAP")) &&
+        (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx.cfg,
+                                                             service_name,
+                                                             "GAUGER_HEAP",
+                                                             &counter)))
     {
       struct mallinfo mi;
 
@@ -1551,13 +1604,13 @@ shutdown:
 struct LEGACY_SERVICE_Context *
 LEGACY_SERVICE_start (const char *service_name,
                       const struct GNUNET_CONFIGURATION_Handle *cfg,
-                     enum LEGACY_SERVICE_Options options)
+                      enum LEGACY_SERVICE_Options options)
 {
   int i;
   struct LEGACY_SERVICE_Context *sctx;
 
   sctx = GNUNET_new (struct LEGACY_SERVICE_Context);
-  sctx->ready_confirm_fd = -1;  /* no daemonizing */
+  sctx->ready_confirm_fd = -1; /* no daemonizing */
   sctx->ret = GNUNET_OK;
   sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
   sctx->service_name = service_name;
@@ -1571,13 +1624,18 @@ LEGACY_SERVICE_start (const char *service_name,
     return NULL;
   }
   if (NULL != sctx->lsocks)
-    sctx->server =
-        GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks,
-                                           sctx->timeout, sctx->require_found);
+    sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
+                                                      sctx,
+                                                      sctx->lsocks,
+                                                      sctx->timeout,
+                                                      sctx->require_found);
   else
-    sctx->server =
-        GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens,
-                              sctx->timeout, sctx->require_found);
+    sctx->server = GNUNET_SERVER_create (&check_access,
+                                         sctx,
+                                         sctx->addrs,
+                                         sctx->addrlens,
+                                         sctx->timeout,
+                                         sctx->require_found);
 
   if (NULL == sctx->server)
   {
@@ -1587,9 +1645,11 @@ LEGACY_SERVICE_start (const char *service_name,
 #ifndef WINDOWS
   if (NULL != sctx->addrs)
     for (i = 0; NULL != sctx->addrs[i]; i++)
-      if ((AF_UNIX == sctx->addrs[i]->sa_family)
-          && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
-        GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
+      if ((AF_UNIX == sctx->addrs[i]->sa_family) &&
+          ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0]))
+        GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)
+                                        sctx->addrs[i])
+                                       ->sun_path,
                                      sctx->match_uid,
                                      sctx->match_gid);
 #endif
@@ -1624,7 +1684,7 @@ LEGACY_SERVICE_get_server (struct LEGACY_SERVICE_Context *ctx)
  * @return NULL if there are no listen sockets, otherwise NULL-terminated
  *              array of listen sockets.
  */
-struct GNUNET_NETWORK_Handle *const*
+struct GNUNET_NETWORK_Handle *const *
 LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx)
 {
   return ctx->lsocks;
@@ -1645,13 +1705,13 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
   {
     char *counter;
 
-    if ( (GNUNET_YES ==
-         GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name,
-                                          "GAUGER_HEAP")) &&
-        (GNUNET_OK ==
-         GNUNET_CONFIGURATION_get_value_string (sctx->cfg, sctx->service_name,
-                                                "GAUGER_HEAP",
-                                                &counter)) )
+    if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx->cfg,
+                                                        sctx->service_name,
+                                                        "GAUGER_HEAP")) &&
+        (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
+                                                             sctx->service_name,
+                                                             "GAUGER_HEAP",
+                                                             &counter)))
     {
       struct mallinfo mi;
 
index 13f1dc9b3066f7fa0b9ec5715e11dbfa3396cb46..e7b1ad012ef294af99d02ce3c491775f9cf4b118 100644 (file)
Binary files a/src/transport/test_plugin_hostkey and b/src/transport/test_plugin_hostkey differ
index 0c94fa5c90bfc74f6b725c749b865622956dc324..2c6ce8e5f6bc05207c32763143cd0c23f61dc154 100644 (file)
@@ -71,7 +71,7 @@ report ()
     delta = 1;
   datarate = (total_bytes_recv * 1000 * 1000) / delta;
 
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Throughput was %llu b/s\n",
            datarate);
   ccc->global_ret = GNUNET_OK;
@@ -160,11 +160,11 @@ measure (void *cls)
   counter++;
   if ((DURATION.rel_value_us / 1000 / 1000LL) < counter)
   {
-    FPRINTF (stderr, "%s",  ".\n");
+    fprintf (stderr, "%s",  ".\n");
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  FPRINTF (stderr, "%s",  ".");
+  fprintf (stderr, "%s",  ".");
   measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                                &measure,
                                                NULL);
index 98f1170ff5e1c7ca284ff4572de1cd71bdb6fec9..4cc63766edbbe9aa5573f8b113fc6c82dc6697dd 100644 (file)
@@ -217,10 +217,10 @@ custom_shutdown (void *cls)
   }
 
   result = 0;
-  FPRINTF (stderr, "\n");
+  fprintf (stderr, "\n");
   if (stats[0].switch_attempts > 0)
   {
-    FPRINTF (
+    fprintf (
       stderr,
       "Peer 1 tried %u times to switch and succeeded %u times, failed %u times\n",
       stats[0].switch_attempts,
@@ -234,13 +234,13 @@ custom_shutdown (void *cls)
   }
   else if (stats[0].addresses_avail > 1)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Peer 1 had %u addresses available, but did not try to switch\n",
              stats[0].addresses_avail);
   }
   if (stats[1].switch_attempts > 0)
   {
-    FPRINTF (
+    fprintf (
       stderr,
       "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n",
       stats[1].switch_attempts,
@@ -254,7 +254,7 @@ custom_shutdown (void *cls)
   }
   else if (stats[1].addresses_avail > 1)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Peer 2 had %u addresses available, but did not try to switch\n",
              stats[1].addresses_avail);
   }
@@ -262,14 +262,14 @@ custom_shutdown (void *cls)
   if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
       (bytes_sent_after_switch == 0))
   {
-    FPRINTF (stderr, "No data sent after switching!\n");
+    fprintf (stderr, "No data sent after switching!\n");
     GNUNET_break (0);
     result++;
   }
   if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
       (bytes_recv_after_switch == 0))
   {
-    FPRINTF (stderr, "No data received after switching!\n");
+    fprintf (stderr, "No data received after switching!\n");
     GNUNET_break (0);
     result++;
   }
@@ -353,11 +353,11 @@ progress_indicator (void *cls)
   counter++;
   if ((TIMEOUT.rel_value_us / 1000 / 1000LL) < counter)
   {
-    FPRINTF (stderr, "%s", ".\n");
+    fprintf (stderr, "%s", ".\n");
   }
   else
   {
-    FPRINTF (stderr, "%s", ".");
+    fprintf (stderr, "%s", ".");
     measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                                  &progress_indicator,
                                                  NULL);
index 8442b92e8870fb5a08d5c792343cc9d0940d0450..a26a92880df0daae0627c9940f1a6f8537206148 100644 (file)
@@ -179,7 +179,7 @@ custom_shutdown (void *cls)
   if (0 == delta)
     delta = 1;
   rate = (1000LL* 1000ll * total_bytes) / (1024 * delta);
-  FPRINTF (stderr,
+  fprintf (stderr,
            "\nThroughput was %llu KiBytes/s\n",
            rate);
   {
@@ -274,7 +274,7 @@ notify_receive (void *cls,
   }
   if (0 == (n % (TOTAL_MSGS / xhdr / 100)))
   {
-    FPRINTF (stderr, "%s",  ".");
+    fprintf (stderr, "%s",  ".");
   }
   if (n == TOTAL_MSGS / xhdr)
   {
index a00e0aeb6003a8ac096c0c63780cec2751e9e439..f562dd19624f4257e432dc278c29d3acd58daebd 100644 (file)
@@ -120,13 +120,13 @@ timer (void *cls)
   if (time_running.rel_value_us ==
       GNUNET_TIME_relative_max (time_running, WAIT).rel_value_us)
   {
-    FPRINTF (stderr, "%s",  "100%%\n");
+    fprintf (stderr, "%s",  "100%%\n");
     shutdown_flag = GNUNET_YES;
     GNUNET_SCHEDULER_shutdown ();
   }
   else
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
             "%u%%..",
             percentage);
     timer_task =
index 1cd2441151422e91164e89df8dfe8f13c5d05664..0ecd6fda12490a15cde53dc07270cce65488f3e1 100644 (file)
@@ -80,7 +80,7 @@ static struct GNUNET_SCHEDULER_Task * timeout_task;
 static struct GNUNET_SCHEDULER_Task * stage_task;
 
 #if VERBOSE
-#define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
+#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
 #else
 #define OKPP do { ok++; } while (0)
 #endif
index def9b02e12730c161fe937c5f2b9bc2fae121bee..1df249e4070303f769533727f1ea3fa82bd3e0fa 100644 (file)
@@ -25,7 +25,7 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-bio",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-bio", __VA_ARGS__)
 
 #ifndef PATH_MAX
 /**
@@ -116,8 +116,7 @@ GNUNET_BIO_read_open (const char *fn)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
  */
 int
-GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h,
-                       char **emsg)
+GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg)
 {
   int err;
 
@@ -144,7 +143,8 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h,
 int
 GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
                  const char *what,
-                 void *result, size_t len)
+                 void *result,
+                 size_t len)
 {
   char *dst = result;
   size_t min;
@@ -162,39 +162,34 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
     {
       if (min > len - pos)
         min = len - pos;
-      GNUNET_memcpy (&dst[pos],
-                    &h->buffer[h->pos],
-                    min);
+      GNUNET_memcpy (&dst[pos], &h->buffer[h->pos], min);
       h->pos += min;
       pos += min;
     }
     if (pos == len)
-      return GNUNET_OK;         /* done! */
+      return GNUNET_OK; /* done! */
     GNUNET_assert (((off_t) h->have) == h->pos);
     /* fill buffer */
-    ret = GNUNET_DISK_file_read (h->fd,
-                                h->buffer,
-                                h->size);
+    ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size);
     if (-1 == ret)
     {
       GNUNET_asprintf (&h->emsg,
-                      _("Error reading `%s': %s"),
-                      what,
-                       STRERROR (errno));
+                       _ ("Error reading `%s': %s"),
+                       what,
+                       strerror (errno));
       return GNUNET_SYSERR;
     }
     if (0 == ret)
     {
       GNUNET_asprintf (&h->emsg,
-                      _("Error reading `%s': %s"),
-                      what,
-                       _("End of file"));
+                       _ ("Error reading `%s': %s"),
+                       what,
+                       _ ("End of file"));
       return GNUNET_SYSERR;
     }
     h->pos = 0;
     h->have = ret;
-  }
-  while (pos < len);            /* should always be true */
+  } while (pos < len); /* should always be true */
   return GNUNET_OK;
 }
 
@@ -245,7 +240,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
   if (GNUNET_OK != GNUNET_BIO_read_int32 (h, &big))
   {
     GNUNET_free_non_null (h->emsg);
-    GNUNET_asprintf (&h->emsg, _("Error reading length of string `%s'"), what);
+    GNUNET_asprintf (&h->emsg, _ ("Error reading length of string `%s'"), what);
     return GNUNET_SYSERR;
   }
   if (0 == big)
@@ -255,8 +250,11 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
   }
   if (big > max_length)
   {
-    GNUNET_asprintf (&h->emsg, _("String `%s' longer than allowed (%u > %u)"),
-                     what, big, max_length);
+    GNUNET_asprintf (&h->emsg,
+                     _ ("String `%s' longer than allowed (%u > %u)"),
+                     what,
+                     big,
+                     max_length);
     return GNUNET_SYSERR;
   }
   buf = GNUNET_malloc (big);
@@ -291,9 +289,7 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
   char *buf;
   struct GNUNET_CONTAINER_MetaData *meta;
 
-  if (GNUNET_OK !=
-      GNUNET_BIO_read_int32 (h,
-                            (int32_t *) & size))
+  if (GNUNET_OK != GNUNET_BIO_read_int32 (h, (int32_t *) &size))
     return GNUNET_SYSERR;
   if (size == 0)
   {
@@ -303,30 +299,23 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
   if (size > MAX_META_DATA)
   {
     GNUNET_asprintf (&h->emsg,
-                     _("Serialized metadata `%s' larger than allowed (%u>%u)"),
+                     _ ("Serialized metadata `%s' larger than allowed (%u>%u)"),
                      what,
-                    size,
-                    MAX_META_DATA);
+                     size,
+                     MAX_META_DATA);
     return GNUNET_SYSERR;
   }
   buf = GNUNET_malloc (size);
-  if (GNUNET_OK !=
-      GNUNET_BIO_read (h,
-                      what,
-                      buf,
-                      size))
+  if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
   {
     GNUNET_free (buf);
     return GNUNET_SYSERR;
   }
-  meta = GNUNET_CONTAINER_meta_data_deserialize (buf,
-                                                size);
+  meta = GNUNET_CONTAINER_meta_data_deserialize (buf, size);
   if (NULL == meta)
   {
     GNUNET_free (buf);
-    GNUNET_asprintf (&h->emsg,
-                    _("Metadata `%s' failed to deserialize"),
-                    what);
+    GNUNET_asprintf (&h->emsg, _ ("Metadata `%s' failed to deserialize"), what);
     return GNUNET_SYSERR;
   }
   GNUNET_free (buf);
@@ -346,18 +335,13 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
  */
 int
 GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h,
-                        const char *file,
+                         const char *file,
                          int line,
-                        int32_t * i)
+                         int32_t *i)
 {
   int32_t big;
 
-  if (GNUNET_OK !=
-      GNUNET_BIO_read_fn (h,
-                         file,
-                         line,
-                         &big,
-                         sizeof (int32_t)))
+  if (GNUNET_OK != GNUNET_BIO_read_fn (h, file, line, &big, sizeof (int32_t)))
     return GNUNET_SYSERR;
   *i = ntohl (big);
   return GNUNET_OK;
@@ -381,12 +365,7 @@ GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
 {
   int64_t big;
 
-  if (GNUNET_OK !=
-      GNUNET_BIO_read_fn (h,
-                         file,
-                         line,
-                         &big,
-                         sizeof (int64_t)))
+  if (GNUNET_OK != GNUNET_BIO_read_fn (h, file, line, &big, sizeof (int64_t)))
     return GNUNET_SYSERR;
   *i = GNUNET_ntohll (big);
   return GNUNET_OK;
@@ -432,11 +411,12 @@ GNUNET_BIO_write_open (const char *fn)
   struct GNUNET_DISK_FileHandle *fd;
   struct GNUNET_BIO_WriteHandle *h;
 
-  fd = GNUNET_DISK_file_open (fn,
-                              GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE
-                              | GNUNET_DISK_OPEN_CREATE,
-                              GNUNET_DISK_PERM_USER_READ |
-                              GNUNET_DISK_PERM_USER_WRITE);
+  fd =
+    GNUNET_DISK_file_open (fn,
+                           GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE |
+                             GNUNET_DISK_OPEN_CREATE,
+                           GNUNET_DISK_PERM_USER_READ |
+                             GNUNET_DISK_PERM_USER_WRITE);
   if (NULL == fd)
     return NULL;
   h = GNUNET_malloc (sizeof (struct GNUNET_BIO_WriteHandle) + BIO_BUFFER_SIZE);
@@ -459,8 +439,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h)
   int ret;
 
   ret = GNUNET_SYSERR;
-  if ( (NULL != h->fd) &&
-       (GNUNET_OK == (ret = GNUNET_BIO_flush (h))) )
+  if ((NULL != h->fd) && (GNUNET_OK == (ret = GNUNET_BIO_flush (h))))
     GNUNET_DISK_file_close (h->fd);
   GNUNET_free (h);
   return ret;
@@ -479,14 +458,12 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h)
 {
   ssize_t ret;
 
-  ret = GNUNET_DISK_file_write (h->fd,
-                               h->buffer,
-                               h->have);
+  ret = GNUNET_DISK_file_write (h->fd, h->buffer, h->have);
   if (ret != (ssize_t) h->have)
   {
     GNUNET_DISK_file_close (h->fd);
     h->fd = NULL;
-    return GNUNET_SYSERR;     /* error */
+    return GNUNET_SYSERR; /* error */
   }
   h->have = 0;
   return GNUNET_OK;
@@ -503,7 +480,7 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h)
  */
 int
 GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
-                 const void *buffer,
+                  const void *buffer,
                   size_t n)
 {
   const char *src = buffer;
@@ -519,18 +496,15 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
     min = h->size - h->have;
     if (min > n - pos)
       min = n - pos;
-    GNUNET_memcpy (&h->buffer[h->have],
-                  &src[pos],
-                  min);
+    GNUNET_memcpy (&h->buffer[h->have], &src[pos], min);
     pos += min;
     h->have += min;
     if (pos == n)
-      return GNUNET_OK;         /* done */
+      return GNUNET_OK; /* done */
     GNUNET_assert (h->have == h->size);
     if (GNUNET_OK != GNUNET_BIO_flush (h))
-      return GNUNET_SYSERR;     /* error */
-  }
-  while (pos < n);              /* should always be true */
+      return GNUNET_SYSERR; /* error */
+  } while (pos < n); /* should always be true */
   GNUNET_break (0);
   return GNUNET_OK;
 }
@@ -544,8 +518,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
-                        const char *s)
+GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s)
 {
   uint32_t slen;
 
@@ -575,9 +548,11 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
   if (m == NULL)
     return GNUNET_BIO_write_int32 (h, 0);
   buf = NULL;
-  size =
-      GNUNET_CONTAINER_meta_data_serialize (m, &buf, MAX_META_DATA,
-                                            GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+  size = GNUNET_CONTAINER_meta_data_serialize (
+    m,
+    &buf,
+    MAX_META_DATA,
+    GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
   if (size == -1)
   {
     GNUNET_free (buf);
@@ -602,8 +577,7 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
-                        int32_t i)
+GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i)
 {
   int32_t big;
 
@@ -620,8 +594,7 @@ GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h,
-                        int64_t i)
+GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i)
 {
   int64_t big;
 
index 20333ce560e61ece8b85881b924eb4fb25e38d84..94890a7f4352ef4c4506774a21bb440089ba7d5e 100644 (file)
 #include <malloc/malloc.h>
 #endif
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-common-allocation",__VA_ARGS__)
+#define LOG(kind, ...) \
+  GNUNET_log_from (kind, "util-common-allocation", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-common-allocation", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-common-allocation", syscall)
 
 #ifndef INT_MAX
 #define INT_MAX 0x7FFFFFFF
@@ -61,24 +63,17 @@ static LONG mem_used = 0;
  * @return pointer to size bytes of memory
  */
 void *
-GNUNET_xmalloc_ (size_t size,
-                const char *filename,
-                int linenumber)
+GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber)
 {
   void *ret;
 
   /* As a security precaution, we generally do not allow very large
    * allocations using the default 'GNUNET_malloc()' macro */
-  GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED,
-                   filename,
-                   linenumber);
-  ret = GNUNET_xmalloc_unchecked_ (size,
-                                  filename,
-                                  linenumber);
+  GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber);
+  ret = GNUNET_xmalloc_unchecked_ (size, filename, linenumber);
   if (NULL == ret)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                 "malloc");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
     GNUNET_assert (0);
   }
   return ret;
@@ -101,21 +96,22 @@ GNUNET_xmalloc_ (size_t size,
  */
 void **
 GNUNET_xnew_array_2d_ (size_t n,
-                      size_t m,
-                      size_t elementSize,
+                       size_t m,
+                       size_t elementSize,
                        const char *filename,
-                      int linenumber)
+                       int linenumber)
 {
-       /* use char pointer internally to avoid void pointer arithmetic warnings */
-       char **ret = GNUNET_xmalloc_ (n * sizeof (void *) +  /* 1. dim header */
-                                     n * m * elementSize,   /* element data */
-                                     filename, linenumber);
-
-       for (size_t i = 0; i < n; i++)
-               ret[i] = (char *)ret +          /* base address */
-                        n * sizeof (void *) +  /* skip 1. dim header */
-                        i * m * elementSize;   /* skip to 2. dim row header */
-       return (void **)ret;
+  /* use char pointer internally to avoid void pointer arithmetic warnings */
+  char **ret = GNUNET_xmalloc_ (n * sizeof (void *) + /* 1. dim header */
+                                  n * m * elementSize, /* element data */
+                                filename,
+                                linenumber);
+
+  for (size_t i = 0; i < n; i++)
+    ret[i] = (char *) ret + /* base address */
+             n * sizeof (void *) + /* skip 1. dim header */
+             i * m * elementSize; /* skip to 2. dim row header */
+  return (void **) ret;
 }
 
 
@@ -135,29 +131,34 @@ GNUNET_xnew_array_2d_ (size_t n,
  * @return allocated memory, never NULL
  */
 void ***
-GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize,
-                       const char *filename, int linenumber)
+GNUNET_xnew_array_3d_ (size_t n,
+                       size_t m,
+                       size_t o,
+                       size_t elementSize,
+                       const char *filename,
+                       int linenumber)
 {
-       /* use char pointer internally to avoid void pointer arithmetic warnings */
-       char ***ret = GNUNET_xmalloc_ (n * sizeof (void **) +    /* 1. dim header */
-                                      n * m * sizeof (void *) + /* 2. dim header */
-                                      n * m * o * elementSize,  /* element data */
-                                      filename, linenumber);
-
-       for (size_t i = 0; i < n; i++)
-       {
-               /* need to cast to (char *) temporarily for byte level acuracy */
-               ret[i] = (char **)((char *)ret +             /* base address */
-                                  n * sizeof (void **) +    /* skip 1. dim header */
-                                  i * m * sizeof (void *)); /* skip to 2. dim header */
-               for (size_t j = 0; j < m; j++)
-                       ret[i][j] = (char *)ret +              /* base address */
-                                   n * sizeof (void **) +     /* skip 1. dim header */
-                                   n * m * sizeof (void *) +  /* skip 2. dim header */
-                                   i * m * o * elementSize +  /* skip to 2. dim part */
-                                       j * o * elementSize;   /* skip to 3. dim row data */
-       }
-       return (void ***)ret;
+  /* use char pointer internally to avoid void pointer arithmetic warnings */
+  char ***ret = GNUNET_xmalloc_ (n * sizeof (void **) + /* 1. dim header */
+                                   n * m * sizeof (void *) + /* 2. dim header */
+                                   n * m * o * elementSize, /* element data */
+                                 filename,
+                                 linenumber);
+
+  for (size_t i = 0; i < n; i++)
+  {
+    /* need to cast to (char *) temporarily for byte level acuracy */
+    ret[i] = (char **) ((char *) ret + /* base address */
+                        n * sizeof (void **) + /* skip 1. dim header */
+                        i * m * sizeof (void *)); /* skip to 2. dim header */
+    for (size_t j = 0; j < m; j++)
+      ret[i][j] = (char *) ret + /* base address */
+                  n * sizeof (void **) + /* skip 1. dim header */
+                  n * m * sizeof (void *) + /* skip 2. dim header */
+                  i * m * o * elementSize + /* skip to 2. dim part */
+                  j * o * elementSize; /* skip to 3. dim row data */
+  }
+  return (void ***) ret;
 }
 
 
@@ -174,8 +175,8 @@ GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize,
  */
 void *
 GNUNET_xmemdup_ (const void *buf,
-                size_t size,
-                const char *filename,
+                 size_t size,
+                 const char *filename,
                  int linenumber)
 {
   void *ret;
@@ -215,9 +216,7 @@ GNUNET_xmemdup_ (const void *buf,
  * @return pointer to size bytes of memory, NULL if we do not have enough memory
  */
 void *
-GNUNET_xmalloc_unchecked_ (size_t size,
-                          const char *filename,
-                          int linenumber)
+GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber)
 {
   void *result;
 
@@ -256,10 +255,7 @@ GNUNET_xmalloc_unchecked_ (size_t size,
  * @return pointer to size bytes of memory
  */
 void *
-GNUNET_xrealloc_ (void *ptr,
-                  size_t n,
-                  const char *filename,
-                  int linenumber)
+GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber)
 {
   (void) filename;
   (void) linenumber;
@@ -272,8 +268,7 @@ GNUNET_xrealloc_ (void *ptr,
   ptr = realloc (ptr, n);
   if ((NULL == ptr) && (n > 0))
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                 "realloc");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc");
     GNUNET_assert (0);
   }
 #ifdef W32_MEM_LIMIT
@@ -283,10 +278,10 @@ GNUNET_xrealloc_ (void *ptr,
 }
 
 
-# if __BYTE_ORDER == __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define BAADFOOD_STR "\x0D\xF0\xAD\xBA"
 #endif
-# if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
 #define BAADFOOD_STR "\xBA\xAD\xF0\x0D"
 #endif
 
@@ -311,13 +306,9 @@ GNUNET_xrealloc_ (void *ptr,
  * @param linenumber where in the code was the call to GNUNET_free
  */
 void
-GNUNET_xfree_ (void *ptr,
-              const char *filename,
-              int linenumber)
+GNUNET_xfree_ (void *ptr, const char *filename, int linenumber)
 {
-  GNUNET_assert_at (NULL != ptr,
-                   filename,
-                   linenumber);
+  GNUNET_assert_at (NULL != ptr, filename, linenumber);
 #ifdef W32_MEM_LIMIT
   ptr = &((size_t *) ptr)[-1];
   mem_used -= *((size_t *) ptr);
@@ -330,9 +321,9 @@ GNUNET_xfree_ (void *ptr,
     size_t s = M_SIZE (ptr);
     size_t i;
 
-    for (i=0;i<s/8;i++)
+    for (i = 0; i < s / 8; i++)
       base[i] = baadfood;
-    GNUNET_memcpy (&base[s/8], &baadfood, s % 8);
+    GNUNET_memcpy (&base[s / 8], &baadfood, s % 8);
   }
 #endif
 #endif
@@ -349,31 +340,22 @@ GNUNET_xfree_ (void *ptr,
  * @return `strdup(@a str)`
  */
 char *
-GNUNET_xstrdup_ (const char *str,
-                const char *filename,
-                int linenumber)
+GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber)
 {
   char *res;
   size_t slen;
 
-  GNUNET_assert_at (str != NULL,
-                   filename,
-                   linenumber);
+  GNUNET_assert_at (str != NULL, filename, linenumber);
   slen = strlen (str) + 1;
-  res = GNUNET_xmalloc_ (slen,
-                        filename,
-                        linenumber);
-  GNUNET_memcpy (res,
-         str,
-         slen);
+  res = GNUNET_xmalloc_ (slen, filename, linenumber);
+  GNUNET_memcpy (res, str, slen);
   return res;
 }
 
 
 #if ! HAVE_STRNLEN
 static size_t
-strnlen (const char *s,
-        size_t n)
+strnlen (const char *s, size_t n)
 {
   const char *e;
 
@@ -396,22 +378,17 @@ strnlen (const char *s,
  */
 char *
 GNUNET_xstrndup_ (const char *str,
-                 size_t len,
-                 const char *filename,
+                  size_t len,
+                  const char *filename,
                   int linenumber)
 {
   char *res;
 
   if (0 == len)
     return GNUNET_strdup ("");
-  GNUNET_assert_at (NULL != str,
-                   filename,
-                   linenumber);
-  len = strnlen (str,
-                len);
-  res = GNUNET_xmalloc_ (len + 1,
-                        filename,
-                        linenumber);
+  GNUNET_assert_at (NULL != str, filename, linenumber);
+  len = strnlen (str, len);
+  res = GNUNET_xmalloc_ (len + 1, filename, linenumber);
   GNUNET_memcpy (res, str, len);
   /* res[len] = '\0'; 'malloc' zeros out anyway */
   return res;
@@ -432,11 +409,11 @@ GNUNET_xstrndup_ (const char *str,
  */
 void
 GNUNET_xgrow_ (void **old,
-              size_t elementSize,
-              unsigned int *oldCount,
-         unsigned int newCount,
-              const char *filename,
-              int linenumber)
+               size_t elementSize,
+               unsigned int *oldCount,
+               unsigned int newCount,
+               const char *filename,
+               int linenumber)
 {
   void *tmp;
   size_t size;
@@ -452,7 +429,7 @@ GNUNET_xgrow_ (void **old,
     tmp = GNUNET_xmalloc_ (size, filename, linenumber);
     if (NULL != *old)
     {
-      GNUNET_memcpy (tmp, *old, elementSize * GNUNET_MIN(*oldCount, newCount));
+      GNUNET_memcpy (tmp, *old, elementSize * GNUNET_MIN (*oldCount, newCount));
     }
   }
 
@@ -474,20 +451,18 @@ GNUNET_xgrow_ (void **old,
  * @return number of bytes in `*@a buf`, excluding 0-termination
  */
 int
-GNUNET_asprintf (char **buf,
-                 const char *format,
-                 ...)
+GNUNET_asprintf (char **buf, const char *format, ...)
 {
   int ret;
   va_list args;
 
   va_start (args, format);
-  ret = VSNPRINTF (NULL, 0, format, args);
+  ret = vsnprintf (NULL, 0, format, args);
   va_end (args);
   GNUNET_assert (ret >= 0);
   *buf = GNUNET_malloc (ret + 1);
   va_start (args, format);
-  ret = VSPRINTF (*buf, format, args);
+  ret = vsprintf (*buf, format, args);
   va_end (args);
   return ret;
 }
@@ -503,21 +478,15 @@ GNUNET_asprintf (char **buf,
  * @return number of bytes written to buf or negative value on error
  */
 int
-GNUNET_snprintf (char *buf,
-                size_t size,
-                const char *format, ...)
+GNUNET_snprintf (char *buf, size_t size, const char *format, ...)
 {
   int ret;
   va_list args;
 
   va_start (args, format);
-  ret = VSNPRINTF (buf,
-                  size,
-                  format,
-                  args);
+  ret = vsnprintf (buf, size, format, args);
   va_end (args);
-  GNUNET_assert ( (ret >= 0) &&
-                 (((size_t) ret) < size) );
+  GNUNET_assert ((ret >= 0) && (((size_t) ret) < size));
   return ret;
 }
 
@@ -537,9 +506,7 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg)
   msize = ntohs (msg->size);
   GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
   ret = GNUNET_malloc (msize);
-  GNUNET_memcpy (ret,
-                msg,
-                msize);
+  GNUNET_memcpy (ret, msg, msize);
   return ret;
 }
 
index 19bbbdb81e41a3c169f4a59e2cb18f68cf934300..d3666ae7d8e6083401323988fda7a74b44ff4cbf 100644 (file)
@@ -107,8 +107,7 @@ static __thread struct GNUNET_AsyncScopeSave current_async_scope;
  * Note that this message maybe truncated to the first BULK_TRACK_SIZE
  * characters, in which case it is NOT 0-terminated!
  */
-static GNUNET_THREAD_LOCAL char last_bulk[BULK_TRACK_SIZE]
-  __nonstring;
+static GNUNET_THREAD_LOCAL char last_bulk[BULK_TRACK_SIZE] __nonstring;
 
 /**
  * Type of the last bulk message.
@@ -325,7 +324,7 @@ log_rotate (const char *new_name)
   {
     /* Note: can't log errors during logging (recursion!), so this
        operation MUST silently fail... */
-    (void) UNLINK (discard);
+    (void) unlink (discard);
     GNUNET_free (discard);
   }
   rotation[rotation_off % ROTATION_KEEP] = GNUNET_strdup (new_name);
@@ -377,14 +376,14 @@ setup_log_file (const struct tm *tm)
     fprintf (stderr,
              "Failed to create directory for `%s': %s\n",
              fn,
-             STRERROR (errno));
+             strerror (errno));
     return GNUNET_SYSERR;
   }
 #if WINDOWS
   altlog_fd =
-    OPEN (fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE);
+    open (fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE);
 #else
-  altlog_fd = OPEN (fn,
+  altlog_fd = open (fn,
                     O_APPEND | O_WRONLY | O_CREAT,
                     S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 #endif
@@ -841,7 +840,7 @@ output_message (enum GNUNET_ErrorType kind,
        * this way if the output is going to logfiles or robots
        * instead.
        */
-      FPRINTF (GNUNET_stderr, "* %s", msg);
+      fprintf (GNUNET_stderr, "* %s", msg);
     }
     else if (GNUNET_YES == current_async_scope.have_scope)
     {
@@ -857,7 +856,7 @@ output_message (enum GNUNET_ErrorType kind,
       GNUNET_assert (NULL != end);
       *end = '\0';
       skip_log = 0;
-      FPRINTF (GNUNET_stderr,
+      fprintf (GNUNET_stderr,
                "%s %s(%s) %s %s",
                datestr,
                comp,
@@ -867,7 +866,7 @@ output_message (enum GNUNET_ErrorType kind,
     }
     else
     {
-      FPRINTF (GNUNET_stderr,
+      fprintf (GNUNET_stderr,
                "%s %s %s %s",
                datestr,
                comp,
@@ -991,7 +990,7 @@ mylog (enum GNUNET_ErrorType kind,
   va_list vacp;
 
   va_copy (vacp, va);
-  size = VSNPRINTF (NULL, 0, message, vacp) + 1;
+  size = vsnprintf (NULL, 0, message, vacp) + 1;
   GNUNET_assert (0 != size);
   va_end (vacp);
   memset (date, 0, DATE_STR_SIZE);
@@ -1065,7 +1064,7 @@ mylog (enum GNUNET_ErrorType kind,
         abort ();
     }
 #endif
-    VSNPRINTF (buf, size, message, va);
+    vsnprintf (buf, size, message, va);
 #if ! (defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY)
     if (NULL != tmptr)
       (void) setup_log_file (tmptr);
index a38438ba833c6ebd58cd4f6534683a5dc99ac3f8..f327071de63199b4cb8fa202b2910b9ef7976579 100644 (file)
 #include "gnunet_configuration_lib.h"
 #include "gnunet_disk_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
 
 /**
  * @brief configuration entry
@@ -95,7 +96,6 @@ struct GNUNET_CONFIGURATION_Handle
    * #GNUNET_SYSERR on error (i.e. last save failed)
    */
   int dirty;
-
 };
 
 
@@ -152,23 +152,20 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
  */
 int
 GNUNET_CONFIGURATION_parse_and_run (const char *filename,
-                                   GNUNET_CONFIGURATION_Callback cb,
-                                   void *cb_cls)
+                                    GNUNET_CONFIGURATION_Callback cb,
+                                    void *cb_cls)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   int ret;
 
   cfg = GNUNET_CONFIGURATION_create ();
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_load (cfg,
-                                 filename))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, filename))
   {
     GNUNET_break (0);
     GNUNET_CONFIGURATION_destroy (cfg);
     return GNUNET_SYSERR;
   }
-  ret = cb (cb_cls,
-           cfg);
+  ret = cb (cb_cls, cfg);
   GNUNET_CONFIGURATION_destroy (cfg);
   return ret;
 }
@@ -187,9 +184,9 @@ GNUNET_CONFIGURATION_parse_and_run (const char *filename,
  */
 int
 GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
-                                 const char *mem,
-                                 size_t size,
-                                 const char *basedir)
+                                  const char *mem,
+                                  size_t size,
+                                  const char *basedir)
 {
   char *line;
   char *line_orig;
@@ -224,7 +221,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     else
     {
-      line_orig = GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
+      line_orig =
+        GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
       r_bytes += line_size + 1;
     }
     line = line_orig;
@@ -246,51 +244,46 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
       continue;
 
     /* remove tailing whitespace */
-    for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));i--)
+    for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));
+         i--)
       line[i] = '\0';
 
     /* remove leading whitespace */
-    for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++);
+    for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++)
+      ;
 
     /* ignore comments */
-    if ( ('#' == line[0]) || ('%' == line[0]) )
+    if (('#' == line[0]) || ('%' == line[0]))
       continue;
 
     /* handle special "@INLINE@" directive */
-    if (0 == strncasecmp (line,
-                         "@INLINE@ ",
-                         strlen ("@INLINE@ ")))
+    if (0 == strncasecmp (line, "@INLINE@ ", strlen ("@INLINE@ ")))
     {
       /* @INLINE@ value */
       value = &line[strlen ("@INLINE@ ")];
       if (NULL != basedir)
       {
-       char *fn;
-
-       GNUNET_asprintf (&fn,
-                        "%s/%s",
-                        basedir,
-                        value);
-       if (GNUNET_OK !=
-           GNUNET_CONFIGURATION_parse (cfg,
-                                       fn))
-       {
-         GNUNET_free (fn);
-         ret = GNUNET_SYSERR;    /* failed to parse included config */
-         break;
-       }
-       GNUNET_free (fn);
+        char *fn;
+
+        GNUNET_asprintf (&fn, "%s/%s", basedir, value);
+        if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, fn))
+        {
+          GNUNET_free (fn);
+          ret = GNUNET_SYSERR; /* failed to parse included config */
+          break;
+        }
+        GNUNET_free (fn);
       }
       else
       {
-       LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Ignoring parsing @INLINE@ configurations, not allowed!\n");
-       ret = GNUNET_SYSERR;
-       break;
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Ignoring parsing @INLINE@ configurations, not allowed!\n");
+        ret = GNUNET_SYSERR;
+        break;
       }
       continue;
     }
-    if ( ('[' == line[0]) && (']' == line[line_size - 1]) )
+    if (('[' == line[0]) && (']' == line[line_size - 1]))
     {
       /* [value] */
       line[line_size - 1] = '\0';
@@ -304,23 +297,25 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
       /* tag = value */
       tag = GNUNET_strndup (line, eq - line);
       /* remove tailing whitespace */
-      for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));i--)
-       tag[i] = '\0';
+      for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));
+           i--)
+        tag[i] = '\0';
 
       /* Strip whitespace */
       value = eq + 1;
       while (isspace ((unsigned char) value[0]))
-       value++;
-      for (i = strlen (value) - 1; (i >= 1) && (isspace ((unsigned char) value[i]));i--)
-       value[i] = '\0';
+        value++;
+      for (i = strlen (value) - 1;
+           (i >= 1) && (isspace ((unsigned char) value[i]));
+           i--)
+        value[i] = '\0';
 
       /* remove quotes */
       i = 0;
-      if ( ('"' == value[0]) &&
-          ('"' == value[strlen (value) - 1]) )
+      if (('"' == value[0]) && ('"' == value[strlen (value) - 1]))
       {
-       value[strlen (value) - 1] = '\0';
-       value++;
+        value[strlen (value) - 1] = '\0';
+        value++;
       }
       GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
       GNUNET_free (tag);
@@ -328,14 +323,14 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     /* parse error */
     LOG (GNUNET_ERROR_TYPE_WARNING,
-        _("Syntax error while deserializing in line %u\n"),
-        nr);
+         _ ("Syntax error while deserializing in line %u\n"),
+         nr);
     ret = GNUNET_SYSERR;
     break;
   }
   GNUNET_free_non_null (line_orig);
   GNUNET_free (section);
-  GNUNET_assert ( (GNUNET_OK != ret) || (r_bytes == size) );
+  GNUNET_assert ((GNUNET_OK != ret) || (r_bytes == size));
   return ret;
 }
 
@@ -362,55 +357,40 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
   ssize_t sret;
 
   fn = GNUNET_STRINGS_filename_expand (filename);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Asked to parse config file `%s'\n",
-       fn);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to parse config file `%s'\n", fn);
   if (NULL == fn)
     return GNUNET_SYSERR;
-  dirty = cfg->dirty;           /* back up value! */
+  dirty = cfg->dirty; /* back up value! */
   if (GNUNET_SYSERR ==
-      GNUNET_DISK_file_size (fn,
-                            &fs64,
-                            GNUNET_YES,
-                            GNUNET_YES))
+      GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-        "Error while determining the file size of `%s'\n",
+         "Error while determining the file size of `%s'\n",
          fn);
     GNUNET_free (fn);
     return GNUNET_SYSERR;
   }
   if (fs64 > SIZE_MAX)
   {
-    GNUNET_break (0);          /* File size is more than the heap size */
+    GNUNET_break (0); /* File size is more than the heap size */
     GNUNET_free (fn);
     return GNUNET_SYSERR;
   }
   fs = fs64;
   mem = GNUNET_malloc (fs);
-  sret = GNUNET_DISK_fn_read (fn,
-                             mem,
-                             fs);
-  if ( (sret < 0) ||
-       (fs != (size_t) sret) )
+  sret = GNUNET_DISK_fn_read (fn, mem, fs);
+  if ((sret < 0) || (fs != (size_t) sret))
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-        _("Error while reading file `%s'\n"),
-         fn);
+    LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Error while reading file `%s'\n"), fn);
     GNUNET_free (fn);
     GNUNET_free (mem);
     return GNUNET_SYSERR;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Deserializing contents of file `%s'\n",
-       fn);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn);
   endsep = strrchr (fn, (int) '/');
   if (NULL != endsep)
     *endsep = '\0';
-  ret = GNUNET_CONFIGURATION_deserialize (cfg,
-                                         mem,
-                                         fs,
-                                         fn);
+  ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, fn);
   GNUNET_free (fn);
   GNUNET_free (mem);
   /* restore dirty flag - anything we set in the meantime
@@ -444,7 +424,7 @@ GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
  */
 char *
 GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                               size_t *size)
+                                size_t *size)
 {
   struct ConfigSection *sec;
   struct ConfigEntry *ent;
@@ -466,16 +446,16 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
     {
       if (NULL != ent->val)
       {
-       /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
-       pos = ent->val;
-       while (NULL != (pos = strstr (pos, "\n")))
-       {
-         m_size++;
-         pos++;
-       }
-       /* For each key = value pair we need to add 4 characters (2
+        /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
+        pos = ent->val;
+        while (NULL != (pos = strstr (pos, "\n")))
+        {
+          m_size++;
+          pos++;
+        }
+        /* For each key = value pair we need to add 4 characters (2
           spaces and 1 equal-to character and 1 new line) */
-       m_size += strlen (ent->key) + strlen (ent->val) + 4;
+        m_size += strlen (ent->key) + strlen (ent->val) + 4;
       }
     }
     /* A new line after section end */
@@ -498,23 +478,23 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
     {
       if (NULL != ent->val)
       {
-       val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
-       strcpy (val, ent->val);
+        val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
+        strcpy (val, ent->val);
         while (NULL != (pos = strstr (val, "\n")))
         {
           memmove (&pos[2], &pos[1], strlen (&pos[1]));
           pos[0] = '\\';
           pos[1] = 'n';
         }
-       len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
-       GNUNET_free (val);
-       GNUNET_memcpy (mem + c_size, cbuf, len);
-       c_size += len;
-       GNUNET_free (cbuf);
+        len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
+        GNUNET_free (val);
+        GNUNET_memcpy (mem + c_size, cbuf, len);
+        c_size += len;
+        GNUNET_free (cbuf);
       }
     }
     GNUNET_memcpy (mem + c_size, "\n", 1);
-    c_size ++;
+    c_size++;
     sec = sec->next;
   }
   GNUNET_assert (c_size == m_size);
@@ -548,25 +528,26 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
     return GNUNET_SYSERR;
   }
   cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size);
-  sret = GNUNET_DISK_fn_write (fn, cfg_buf, size,
-                              GNUNET_DISK_PERM_USER_READ
-                              | GNUNET_DISK_PERM_USER_WRITE
-                              | GNUNET_DISK_PERM_GROUP_READ
-                              | GNUNET_DISK_PERM_GROUP_WRITE);
-  if ( (sret < 0) ||
-       (size != (size_t) sret) )
+  sret = GNUNET_DISK_fn_write (fn,
+                               cfg_buf,
+                               size,
+                               GNUNET_DISK_PERM_USER_READ |
+                                 GNUNET_DISK_PERM_USER_WRITE |
+                                 GNUNET_DISK_PERM_GROUP_READ |
+                                 GNUNET_DISK_PERM_GROUP_WRITE);
+  if ((sret < 0) || (size != (size_t) sret))
   {
     GNUNET_free (fn);
     GNUNET_free (cfg_buf);
     LOG (GNUNET_ERROR_TYPE_WARNING,
-        "Writing configuration to file `%s' failed\n",
+         "Writing configuration to file `%s' failed\n",
          filename);
     cfg->dirty = GNUNET_SYSERR; /* last write failed */
     return GNUNET_SYSERR;
   }
   GNUNET_free (fn);
   GNUNET_free (cfg_buf);
-  cfg->dirty = GNUNET_NO;       /* last write succeeded */
+  cfg->dirty = GNUNET_NO; /* last write succeeded */
   return GNUNET_OK;
 }
 
@@ -589,7 +570,7 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
   for (spos = cfg->sections; NULL != spos; spos = spos->next)
     for (epos = spos->entries; NULL != epos; epos = epos->next)
       if (NULL != epos->val)
-       iter (iter_cls, spos->name, epos->key, epos->val);
+        iter (iter_cls, spos->name, epos->key, epos->val);
 }
 
 
@@ -602,11 +583,11 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
  * @param iter_cls closure for @a iter
  */
 void
-GNUNET_CONFIGURATION_iterate_section_values (const struct
-                                             GNUNET_CONFIGURATION_Handle *cfg,
-                                             const char *section,
-                                             GNUNET_CONFIGURATION_Iterator iter,
-                                             void *iter_cls)
+GNUNET_CONFIGURATION_iterate_section_values (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  GNUNET_CONFIGURATION_Iterator iter,
+  void *iter_cls)
 {
   struct ConfigSection *spos;
   struct ConfigEntry *epos;
@@ -630,9 +611,10 @@ GNUNET_CONFIGURATION_iterate_section_values (const struct
  * @param iter_cls closure for @a iter
  */
 void
-GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                       GNUNET_CONFIGURATION_Section_Iterator iter,
-                                       void *iter_cls)
+GNUNET_CONFIGURATION_iterate_sections (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  GNUNET_CONFIGURATION_Section_Iterator iter,
+  void *iter_cls)
 {
   struct ConfigSection *spos;
   struct ConfigSection *next;
@@ -757,8 +739,8 @@ find_section (const struct GNUNET_CONFIGURATION_Handle *cfg,
  */
 static struct ConfigEntry *
 find_entry (const struct GNUNET_CONFIGURATION_Handle *cfg,
-           const char *section,
-           const char *key)
+            const char *section,
+            const char *key)
 {
   struct ConfigSection *sec;
   struct ConfigEntry *pos;
@@ -786,15 +768,14 @@ static void
 compare_entries (void *cls,
                  const char *section,
                  const char *option,
-                const char *value)
+                 const char *value)
 {
   struct DiffHandle *dh = cls;
   struct ConfigEntry *entNew;
 
   entNew = find_entry (dh->cfg_default, section, option);
-  if ( (NULL != entNew) &&
-       (NULL != entNew->val) &&
-       (0 == strcmp (entNew->val, value)) )
+  if ((NULL != entNew) && (NULL != entNew->val) &&
+      (0 == strcmp (entNew->val, value)))
     return;
   GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value);
 }
@@ -808,8 +789,9 @@ compare_entries (void *cls,
  * @return configuration with only the differences, never NULL
  */
 struct GNUNET_CONFIGURATION_Handle *
-GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cfg_default,
-                              const struct GNUNET_CONFIGURATION_Handle *cfg_new)
+GNUNET_CONFIGURATION_get_diff (
+  const struct GNUNET_CONFIGURATION_Handle *cfg_default,
+  const struct GNUNET_CONFIGURATION_Handle *cfg_new)
 {
   struct DiffHandle diffHandle;
 
@@ -829,10 +811,10 @@ GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cfg_def
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
-                                  *cfg_default,
-                                  const struct GNUNET_CONFIGURATION_Handle
-                                  *cfg_new, const char *filename)
+GNUNET_CONFIGURATION_write_diffs (
+  const struct GNUNET_CONFIGURATION_Handle *cfg_default,
+  const struct GNUNET_CONFIGURATION_Handle *cfg_new,
+  const char *filename)
 {
   int ret;
   struct GNUNET_CONFIGURATION_Handle *diff;
@@ -854,7 +836,8 @@ GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
  */
 void
 GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
-                                       const char *section, const char *option,
+                                       const char *section,
+                                       const char *option,
                                        const char *value)
 {
   struct ConfigSection *sec;
@@ -904,19 +887,13 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
 void
 GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
                                        const char *section,
-                                      const char *option,
+                                       const char *option,
                                        unsigned long long number)
 {
   char s[64];
 
-  GNUNET_snprintf (s,
-                  64,
-                  "%llu",
-                  number);
-  GNUNET_CONFIGURATION_set_value_string (cfg,
-                                        section,
-                                        option,
-                                        s);
+  GNUNET_snprintf (s, 64, "%llu", number);
+  GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s);
 }
 
 
@@ -930,10 +907,11 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                      const char *section,
-                                       const char *option,
-                                       unsigned long long *number)
+GNUNET_CONFIGURATION_get_value_number (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  unsigned long long *number)
 {
   struct ConfigEntry *e;
   char dummy[2];
@@ -942,10 +920,7 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
     return GNUNET_SYSERR;
   if (NULL == e->val)
     return GNUNET_SYSERR;
-  if (1 != SSCANF (e->val,
-                  "%llu%1s",
-                  number,
-                  dummy))
+  if (1 != sscanf (e->val, "%llu%1s", number, dummy))
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
@@ -961,10 +936,11 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_float  (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                      const char *section,
-                                       const char *option,
-                                       float *number)
+GNUNET_CONFIGURATION_get_value_float (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  float *number)
 {
   struct ConfigEntry *e;
   char dummy[2];
@@ -973,16 +949,12 @@ GNUNET_CONFIGURATION_get_value_float  (const struct GNUNET_CONFIGURATION_Handle
     return GNUNET_SYSERR;
   if (NULL == e->val)
     return GNUNET_SYSERR;
-  if (1 != SSCANF (e->val,
-                  "%f%1s",
-                  number,
-                  dummy))
+  if (1 != sscanf (e->val, "%f%1s", number, dummy))
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
 
 
-
 /**
  * Get a configuration value that should be a relative time.
  *
@@ -993,27 +965,25 @@ GNUNET_CONFIGURATION_get_value_float  (const struct GNUNET_CONFIGURATION_Handle
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                     const char *section,
-                                     const char *option,
-                                     struct GNUNET_TIME_Relative *time)
+GNUNET_CONFIGURATION_get_value_time (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  struct GNUNET_TIME_Relative *time)
 {
   struct ConfigEntry *e;
   int ret;
 
-  if (NULL == (e = find_entry (cfg,
-                               section,
-                               option)))
+  if (NULL == (e = find_entry (cfg, section, option)))
     return GNUNET_SYSERR;
   if (NULL == e->val)
     return GNUNET_SYSERR;
-  ret = GNUNET_STRINGS_fancy_time_to_relative (e->val,
-                                               time);
+  ret = GNUNET_STRINGS_fancy_time_to_relative (e->val, time);
   if (GNUNET_OK != ret)
     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                section,
                                option,
-                               _("Not a valid relative time specification"));
+                               _ ("Not a valid relative time specification"));
   return ret;
 }
 
@@ -1028,10 +998,11 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *c
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                     const char *section,
-                                     const char *option,
-                                     unsigned long long *size)
+GNUNET_CONFIGURATION_get_value_size (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  unsigned long long *size)
 {
   struct ConfigEntry *e;
 
@@ -1054,15 +1025,15 @@ GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *c
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                       const char *section,
-                                       const char *option,
-                                       char **value)
+GNUNET_CONFIGURATION_get_value_string (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  char **value)
 {
   struct ConfigEntry *e;
 
-  if ( (NULL == (e = find_entry (cfg, section, option))) ||
-       (NULL == e->val) )
+  if ((NULL == (e = find_entry (cfg, section, option))) || (NULL == e->val))
   {
     *value = NULL;
     return GNUNET_SYSERR;
@@ -1085,11 +1056,12 @@ GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                       const char *section,
-                                       const char *option,
-                                       const char *const *choices,
-                                       const char **value)
+GNUNET_CONFIGURATION_get_value_choice (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  const char *const *choices,
+  const char **value)
 {
   struct ConfigEntry *e;
   unsigned int i;
@@ -1102,8 +1074,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
   if (NULL == choices[i])
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Configuration value '%s' for '%s'"
-           " in section '%s' is not in set of legal choices\n"),
+         _ ("Configuration value '%s' for '%s'"
+            " in section '%s' is not in set of legal choices\n"),
          e->val,
          option,
          section);
@@ -1138,10 +1110,8 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
   size_t data_size;
 
   if (GNUNET_OK !=
-      (res = GNUNET_CONFIGURATION_get_value_string (cfg,
-                                                    section,
-                                                    option,
-                                                    &enc)))
+      (res =
+         GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &enc)))
     return res;
   data_size = (strlen (enc) * 5) / 8;
   if (data_size != buf_size)
@@ -1150,9 +1120,7 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
     return GNUNET_SYSERR;
   }
   if (GNUNET_OK !=
-      GNUNET_STRINGS_string_to_data (enc,
-                                     strlen (enc),
-                                     buf, buf_size))
+      GNUNET_STRINGS_string_to_data (enc, strlen (enc), buf, buf_size))
   {
     GNUNET_free (enc);
     return GNUNET_SYSERR;
@@ -1221,17 +1189,15 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
   if (depth > 128)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Recursive expansion suspected, aborting $-expansion for term `%s'\n"),
+         _ (
+           "Recursive expansion suspected, aborting $-expansion for term `%s'\n"),
          orig);
     return orig;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Asked to $-expand %s\n",
-       orig);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig);
   if ('$' != orig[0])
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Doesn't start with $ - not expanding\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n");
     return orig;
   }
   erased_char = 0;
@@ -1254,7 +1220,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
         break;
       case '\0':
         LOG (GNUNET_ERROR_TYPE_WARNING,
-             _("Missing closing `%s' in option `%s'\n"),
+             _ ("Missing closing `%s' in option `%s'\n"),
              "}",
              orig);
         return orig;
@@ -1271,8 +1237,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
     {
       *def = '\0';
       def++;
-      if ( ('-' == *def) ||
-           ('=' == *def) )
+      if (('-' == *def) || ('=' == *def))
         def++;
       def = GNUNET_strdup (def);
     }
@@ -1282,10 +1247,8 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
     start = &orig[1];
     def = NULL;
     i = 0;
-    while ( (orig[i] != '/') &&
-            (orig[i] != '\\') &&
-            (orig[i] != '\0')  &&
-            (orig[i] != ' ') )
+    while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0') &&
+           (orig[i] != ' '))
       i++;
     if (orig[i] == '\0')
     {
@@ -1305,10 +1268,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
        post,
        def);
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             "PATHS",
-                                             start,
-                                             &prefix))
+      GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", start, &prefix))
   {
     if (NULL == (env = getenv (start)))
     {
@@ -1322,15 +1282,17 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
       if (erased_pos)
         *erased_pos = erased_char;
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"),
-           start, orig);
+           _ (
+             "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"),
+           start,
+           orig);
       GNUNET_free (start);
       return orig;
     }
     prefix = GNUNET_strdup (env);
   }
   prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix);
-  if ( (erased_pos) && ('}' != erased_char) )
+  if ((erased_pos) && ('}' != erased_char))
   {
     len = strlen (prefix) + 1;
     prefix = GNUNET_realloc (prefix, len + 1);
@@ -1364,8 +1326,9 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
  * @return $-expanded string
  */
 char *
-GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                    char *orig)
+GNUNET_CONFIGURATION_expand_dollar (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  char *orig)
 {
   char *dup;
   size_t i;
@@ -1397,18 +1360,18 @@ GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cf
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                         const char *section,
-                                         const char *option,
-                                         char **value)
+GNUNET_CONFIGURATION_get_value_filename (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  char **value)
 {
   char *tmp;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp))
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Failed to retrieve filename\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to retrieve filename\n");
     *value = NULL;
     return GNUNET_SYSERR;
   }
@@ -1431,16 +1394,17 @@ GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handl
  * @return #GNUNET_YES, #GNUNET_NO or #GNUNET_SYSERR
  */
 int
-GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                      const char *section,
-                                      const char *option)
+GNUNET_CONFIGURATION_get_value_yesno (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option)
 {
-  static const char *yesno[] = { "YES", "NO", NULL };
+  static const char *yesno[] = {"YES", "NO", NULL};
   const char *val;
   int ret;
 
   ret =
-      GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val);
+    GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val);
   if (ret == GNUNET_SYSERR)
     return ret;
   if (val == yesno[0])
@@ -1460,11 +1424,12 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *
  * @return number of filenames iterated over, -1 on error
  */
 int
-GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                              const char *section,
-                                              const char *option,
-                                              GNUNET_FileNameCallback cb,
-                                              void *cb_cls)
+GNUNET_CONFIGURATION_iterate_value_filenames (
+  const struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  GNUNET_FileNameCallback cb,
+  void *cb_cls)
 {
   char *list;
   char *pos;
@@ -1590,20 +1555,23 @@ test_match (void *cls, const char *fn)
  *         #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg,
-                                            const char *section,
-                                            const char *option,
-                                            const char *value)
+GNUNET_CONFIGURATION_append_value_filename (
+  struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  const char *value)
 {
   char *escaped;
   char *old;
   char *nw;
 
   if (GNUNET_SYSERR ==
-      GNUNET_CONFIGURATION_iterate_value_filenames (cfg, section, option,
+      GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
+                                                    section,
+                                                    option,
                                                     &test_match,
                                                     (void *) value))
-    return GNUNET_NO;           /* already exists */
+    return GNUNET_NO; /* already exists */
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
     old = GNUNET_strdup ("");
@@ -1634,10 +1602,11 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *
  *         #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
-                                            *cfg, const char *section,
-                                            const char *option,
-                                            const char *value)
+GNUNET_CONFIGURATION_remove_value_filename (
+  struct GNUNET_CONFIGURATION_Handle *cfg,
+  const char *section,
+  const char *option,
+  const char *value)
 {
   char *list;
   char *pos;
@@ -1719,16 +1688,14 @@ static int
 parse_configuration_file (void *cls, const char *filename)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-  char * ext;
+  char *ext;
   int ret;
 
   /* Examine file extension */
   ext = strrchr (filename, '.');
   if ((NULL == ext) || (0 != strcmp (ext, ".conf")))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Skipping file `%s'\n",
-                filename);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skipping file `%s'\n", filename);
     return GNUNET_OK;
   }
 
@@ -1747,13 +1714,11 @@ parse_configuration_file (void *cls, const char *filename)
  */
 int
 GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg,
-                               const char *defaults_d)
+                                const char *defaults_d)
 {
   if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_scan (defaults_d,
-                                  &parse_configuration_file,
-                                  cfg))
-    return GNUNET_SYSERR;       /* no configuration at all found */
+      GNUNET_DISK_directory_scan (defaults_d, &parse_configuration_file, cfg))
+    return GNUNET_SYSERR; /* no configuration at all found */
   return GNUNET_OK;
 }
 
index a41c0cf8ac84bc7d92012db8d2ecd0fb877505ef..fe7d8642180d9aa440efe979caa320f30f35ffc0 100644 (file)
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-container-bloomfilter", __VA_ARGS__)
+#define LOG(kind, ...) \
+  GNUNET_log_from (kind, "util-container-bloomfilter", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-container-bloomfilter", syscall)
+#define LOG_strerror(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-container-bloomfilter", syscall)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-container-bloomfilter", syscall, filename)
+#define LOG_strerror_FILE(kind, syscall, filename)             \
+  GNUNET_log_from_strerror_file (kind,                         \
+                                 "util-container-bloomfilter", \
+                                 syscall,                      \
+                                 filename)
 
 struct GNUNET_CONTAINER_BloomFilter
 {
@@ -75,7 +81,6 @@ struct GNUNET_CONTAINER_BloomFilter
    * Size of bitArray in bytes
    */
   size_t bitArraySize;
-
 };
 
 
@@ -86,8 +91,8 @@ struct GNUNET_CONTAINER_BloomFilter
  * @return addresses set per element in the bf
  */
 size_t
-GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINER_BloomFilter
-                                       *bf)
+GNUNET_CONTAINER_bloomfilter_get_element_addresses (
+  const struct GNUNET_CONTAINER_BloomFilter *bf)
 {
   if (bf == NULL)
     return 0;
@@ -102,8 +107,8 @@ GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINE
  * @return number of bytes used for the data of the bloom filter
  */
 size_t
-GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter
-                                       *bf)
+GNUNET_CONTAINER_bloomfilter_get_size (
+  const struct GNUNET_CONTAINER_BloomFilter *bf)
 {
   if (bf == NULL)
     return 0;
@@ -118,10 +123,11 @@ GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter
  * @return copy of the bf
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter
-                                   *bf)
+GNUNET_CONTAINER_bloomfilter_copy (
+  const struct GNUNET_CONTAINER_BloomFilter *bf)
 {
-  return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray, bf->bitArraySize,
+  return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray,
+                                            bf->bitArraySize,
                                             bf->addressesPerElement);
 }
 
@@ -193,7 +199,8 @@ testBit (char *bitArray, unsigned int bitIdx)
  * @param fh A file to keep the 4 bit address usage counters in
  */
 static void
-incrementBit (char *bitArray, unsigned int bitIdx,
+incrementBit (char *bitArray,
+              unsigned int bitIdx,
               const struct GNUNET_DISK_FileHandle *fh)
 {
   off_t fileSlot;
@@ -241,7 +248,8 @@ incrementBit (char *bitArray, unsigned int bitIdx,
  * @param fh A file to keep the 4bit address usage counters in
  */
 static void
-decrementBit (char *bitArray, unsigned int bitIdx,
+decrementBit (char *bitArray,
+              unsigned int bitIdx,
               const struct GNUNET_DISK_FileHandle *fh)
 {
   off_t fileslot;
@@ -251,15 +259,16 @@ decrementBit (char *bitArray, unsigned int bitIdx,
   unsigned int targetLoc;
 
   if (GNUNET_DISK_handle_invalid (fh))
-    return;                     /* cannot decrement! */
+    return; /* cannot decrement! */
   /* Each char slot in the counter file holds two 4 bit counters */
   fileslot = bitIdx / 2;
   targetLoc = bitIdx % 2;
-  if (GNUNET_SYSERR == GNUNET_DISK_file_seek (fh, fileslot, GNUNET_DISK_SEEK_SET))
-    {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "seek");
-      return;
-    }
+  if (GNUNET_SYSERR ==
+      GNUNET_DISK_file_seek (fh, fileslot, GNUNET_DISK_SEEK_SET))
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "seek");
+    return;
+  }
   if (1 != GNUNET_DISK_file_read (fh, &value, 1))
     value = 0;
   low = value & 0xF;
@@ -285,11 +294,12 @@ decrementBit (char *bitArray, unsigned int bitIdx,
     }
   }
   value = ((high << 4) | low);
-  if (GNUNET_SYSERR == GNUNET_DISK_file_seek (fh, fileslot, GNUNET_DISK_SEEK_SET))
-    {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "seek");
-      return;
-    }
+  if (GNUNET_SYSERR ==
+      GNUNET_DISK_file_seek (fh, fileslot, GNUNET_DISK_SEEK_SET))
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "seek");
+    return;
+  }
   GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1));
 }
 
@@ -319,13 +329,13 @@ make_empty_file (const struct GNUNET_DISK_FileHandle *fh, size_t size)
     {
       res = GNUNET_DISK_file_write (fh, buffer, sizeof (buffer));
       if (res >= 0)
-       bytesleft -= res;
+        bytesleft -= res;
     }
     else
     {
       res = GNUNET_DISK_file_write (fh, buffer, bytesleft);
       if (res >= 0)
-       bytesleft -= res;
+        bytesleft -= res;
     }
     if (GNUNET_SYSERR == res)
       return GNUNET_SYSERR;
@@ -346,7 +356,7 @@ make_empty_file (const struct GNUNET_DISK_FileHandle *fh, size_t size)
  * @return GNUNET_YES to continue, GNUNET_NO to stop early
  */
 typedef int (*BitIterator) (void *cls,
-                            const struct GNUNET_CONTAINER_BloomFilter * bf,
+                            const struct GNUNET_CONTAINER_BloomFilter *bf,
                             unsigned int bit);
 
 
@@ -361,7 +371,9 @@ typedef int (*BitIterator) (void *cls,
  */
 static void
 iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf,
-             BitIterator callback, void *arg, const struct GNUNET_HashCode *key)
+             BitIterator callback,
+             void *arg,
+             const struct GNUNET_HashCode *key)
 {
   struct GNUNET_HashCode tmp[2];
   int bitCount;
@@ -378,9 +390,10 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf,
     while (slot < (sizeof (struct GNUNET_HashCode) / sizeof (uint32_t)))
     {
       if (GNUNET_YES !=
-          callback (arg, bf,
-                    ntohl ((((uint32_t *) & tmp[round & 1])[slot])) %
-                    ((bf->bitArraySize * 8LL))))
+          callback (arg,
+                    bf,
+                    ntohl ((((uint32_t *) &tmp[round & 1])[slot])) %
+                      ((bf->bitArraySize * 8LL))))
         return;
       slot++;
       bitCount--;
@@ -389,7 +402,8 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf,
     }
     if (bitCount > 0)
     {
-      GNUNET_CRYPTO_hash (&tmp[round & 1], sizeof (struct GNUNET_HashCode),
+      GNUNET_CRYPTO_hash (&tmp[round & 1],
+                          sizeof (struct GNUNET_HashCode),
                           &tmp[(round + 1) & 1]);
       round++;
       slot = 0;
@@ -407,7 +421,8 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return GNUNET_YES
  */
 static int
-incrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
+incrementBitCallback (void *cls,
+                      const struct GNUNET_CONTAINER_BloomFilter *bf,
                       unsigned int bit)
 {
   struct GNUNET_CONTAINER_BloomFilter *b = cls;
@@ -426,7 +441,8 @@ incrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return GNUNET_YES
  */
 static int
-decrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
+decrementBitCallback (void *cls,
+                      const struct GNUNET_CONTAINER_BloomFilter *bf,
                       unsigned int bit)
 {
   struct GNUNET_CONTAINER_BloomFilter *b = cls;
@@ -445,7 +461,8 @@ decrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return YES if the bit is set, NO if not
  */
 static int
-testBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
+testBitCallback (void *cls,
+                 const struct GNUNET_CONTAINER_BloomFilter *bf,
                  unsigned int bit)
 {
   int *arg = cls;
@@ -472,7 +489,8 @@ testBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return the bloomfilter
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
+GNUNET_CONTAINER_bloomfilter_load (const char *filename,
+                                   size_t size,
                                    unsigned int k)
 {
   struct GNUNET_CONTAINER_BloomFilter *bf;
@@ -489,25 +507,22 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
   if (size < BUFFSIZE)
     size = BUFFSIZE;
   ui = 1;
-  while ( (ui < size) &&
-         (ui * 2 > ui) )
+  while ((ui < size) && (ui * 2 > ui))
     ui *= 2;
-  size = ui;                    /* make sure it's a power of 2 */
+  size = ui; /* make sure it's a power of 2 */
 
   bf = GNUNET_new (struct GNUNET_CONTAINER_BloomFilter);
   /* Try to open a bloomfilter file */
   if (GNUNET_YES == GNUNET_DISK_file_test (filename))
-    bf->fh =
-      GNUNET_DISK_file_open (filename,
-                             GNUNET_DISK_OPEN_READWRITE,
-                             GNUNET_DISK_PERM_USER_READ |
-                             GNUNET_DISK_PERM_USER_WRITE);
+    bf->fh = GNUNET_DISK_file_open (filename,
+                                    GNUNET_DISK_OPEN_READWRITE,
+                                    GNUNET_DISK_PERM_USER_READ |
+                                      GNUNET_DISK_PERM_USER_WRITE);
   if (NULL != bf->fh)
   {
     /* file existed, try to read it! */
     must_read = GNUNET_YES;
-    if (GNUNET_OK !=
-       GNUNET_DISK_file_handle_size (bf->fh, &fsize))
+    if (GNUNET_OK != GNUNET_DISK_file_handle_size (bf->fh, &fsize))
     {
       GNUNET_DISK_file_close (bf->fh);
       GNUNET_free (bf);
@@ -516,22 +531,22 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
     if (0 == fsize)
     {
       /* found existing empty file, just overwrite */
-      if (GNUNET_OK !=
-         make_empty_file (bf->fh, size * 4LL))
+      if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
       {
-       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                            "write");
-       GNUNET_DISK_file_close (bf->fh);
-       GNUNET_free (bf);
-       return NULL;
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "write");
+        GNUNET_DISK_file_close (bf->fh);
+        GNUNET_free (bf);
+        return NULL;
       }
     }
     else if (fsize != ((off_t) size) * 4LL)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Size of file on disk is incorrect for this Bloom filter (want %llu, have %llu)\n"),
-                 (unsigned long long) (size * 4LL),
-                 (unsigned long long) fsize);
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_ERROR,
+        _ (
+          "Size of file on disk is incorrect for this Bloom filter (want %llu, have %llu)\n"),
+        (unsigned long long) (size * 4LL),
+        (unsigned long long) fsize);
       GNUNET_DISK_file_close (bf->fh);
       GNUNET_free (bf);
       return NULL;
@@ -541,21 +556,19 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
   {
     /* file did not exist, don't read, just create */
     must_read = GNUNET_NO;
-    bf->fh =
-      GNUNET_DISK_file_open (filename,
-                             GNUNET_DISK_OPEN_CREATE |
-                             GNUNET_DISK_OPEN_READWRITE,
-                             GNUNET_DISK_PERM_USER_READ |
-                             GNUNET_DISK_PERM_USER_WRITE);
+    bf->fh = GNUNET_DISK_file_open (filename,
+                                    GNUNET_DISK_OPEN_CREATE |
+                                      GNUNET_DISK_OPEN_READWRITE,
+                                    GNUNET_DISK_PERM_USER_READ |
+                                      GNUNET_DISK_PERM_USER_WRITE);
     if (NULL == bf->fh)
-      {
-       GNUNET_free (bf);
-       return NULL;
-      }
+    {
+      GNUNET_free (bf);
+      return NULL;
+    }
     if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                          "write");
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "write");
       GNUNET_DISK_file_close (bf->fh);
       GNUNET_free (bf);
       return NULL;
@@ -583,14 +596,10 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
   {
     int res;
 
-    res = GNUNET_DISK_file_read (bf->fh,
-                                rbuff,
-                                BUFFSIZE);
+    res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE);
     if (res == -1)
     {
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                        "read",
-                        bf->filename);
+      LOG_strerror_FILE (GNUNET_ERROR_TYPE_WARNING, "read", bf->filename);
       GNUNET_free (rbuff);
       GNUNET_free (bf->filename);
       GNUNET_DISK_file_close (bf->fh);
@@ -598,7 +607,7 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
       return NULL;
     }
     if (res == 0)
-      break;                    /* is ok! we just did not use that many bits yet */
+      break; /* is ok! we just did not use that many bits yet */
     for (i = 0; i < res; i++)
     {
       if ((rbuff[i] & 0x0F) != 0)
@@ -608,7 +617,7 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
     }
     if (res < BUFFSIZE)
       break;
-    pos += BUFFSIZE * 2;        /* 2 bits per byte in the buffer */
+    pos += BUFFSIZE * 2; /* 2 bits per byte in the buffer */
   }
   GNUNET_free (rbuff);
   return bf;
@@ -629,7 +638,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
  * @return the bloomfilter
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size,
+GNUNET_CONTAINER_bloomfilter_init (const char *data,
+                                   size_t size,
                                    unsigned int k)
 {
   struct GNUNET_CONTAINER_BloomFilter *bf;
@@ -663,9 +673,10 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size,
  * @return #GNUNET_SYSERR if the data array is not big enough
  */
 int
-GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct
-                                           GNUNET_CONTAINER_BloomFilter *bf,
-                                           char *data, size_t size)
+GNUNET_CONTAINER_bloomfilter_get_raw_data (
+  const struct GNUNET_CONTAINER_BloomFilter *bf,
+  char *data,
+  size_t size)
 {
   if (NULL == bf)
     return GNUNET_SYSERR;
@@ -721,8 +732,9 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf)
  * @return #GNUNET_YES if the element is in the filter, #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter *bf,
-                                  const struct GNUNET_HashCode * e)
+GNUNET_CONTAINER_bloomfilter_test (
+  const struct GNUNET_CONTAINER_BloomFilter *bf,
+  const struct GNUNET_HashCode *e)
 {
   int res;
 
@@ -742,7 +754,7 @@ GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter *bf
  */
 void
 GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
-                                  const struct GNUNET_HashCode * e)
+                                  const struct GNUNET_HashCode *e)
 {
   if (NULL == bf)
     return;
@@ -763,7 +775,7 @@ GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
 int
 GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
                                  const char *data,
-                                size_t size)
+                                 size_t size)
 {
   unsigned int i;
   unsigned int n;
@@ -796,8 +808,9 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return #GNUNET_OK on success
  */
 int
-GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
-                                  const struct GNUNET_CONTAINER_BloomFilter *to_or)
+GNUNET_CONTAINER_bloomfilter_or2 (
+  struct GNUNET_CONTAINER_BloomFilter *bf,
+  const struct GNUNET_CONTAINER_BloomFilter *to_or)
 {
   unsigned int i;
   unsigned int n;
@@ -839,10 +852,7 @@ GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf,
     return;
   if (NULL == bf->filename)
     return;
-  iterateBits (bf,
-              &decrementBitCallback,
-              bf,
-              e);
+  iterateBits (bf, &decrementBitCallback, bf, e);
 }
 
 /**
@@ -860,7 +870,7 @@ void
 GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
                                      GNUNET_CONTAINER_HashCodeIterator iterator,
                                      void *iterator_cls,
-                                    size_t size,
+                                     size_t size,
                                      unsigned int k)
 {
   struct GNUNET_HashCode hc;
@@ -870,17 +880,14 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
   i = 1;
   while (i < size)
     i *= 2;
-  size = i;                     /* make sure it's a power of 2 */
+  size = i; /* make sure it's a power of 2 */
   bf->addressesPerElement = k;
   bf->bitArraySize = size;
   bf->bitArray = GNUNET_malloc (size);
   if (NULL != bf->filename)
-    make_empty_file (bf->fh,
-                    bf->bitArraySize * 4LL);
-  while (GNUNET_YES == iterator (iterator_cls,
-                                &hc))
-    GNUNET_CONTAINER_bloomfilter_add (bf,
-                                     &hc);
+    make_empty_file (bf->fh, bf->bitArraySize * 4LL);
+  while (GNUNET_YES == iterator (iterator_cls, &hc))
+    GNUNET_CONTAINER_bloomfilter_add (bf, &hc);
 }
 
 /* end of container_bloomfilter.c */
index 1031b302ec23ca64ed3c38b5e131fb137d4be7d8..c556d805d3af28a936a5b53b2402c881f8e783a1 100644 (file)
 #include <gcrypt.h>
 #include "gnunet_util_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-ecc", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-ecc", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-crypto-ecc", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-crypto-ecc", syscall)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-crypto-ecc", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util-crypto-ecc", syscall, filename)
 
 /**
  * Log an error message at log-level 'level' that indicates
  * a failure of the command 'cmd' with the message given
  * by gcry_strerror(rc).
  */
-#define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
+#define LOG_GCRY(level, cmd, rc)                      \
+  do                                                  \
+  {                                                   \
+    LOG (level,                                       \
+         _ ("`%s' failed at %s:%d with error: %s\n"), \
+         cmd,                                         \
+         __FILE__,                                    \
+         __LINE__,                                    \
+         gcry_strerror (rc));                         \
+  } while (0)
 
 
 /**
@@ -86,11 +97,12 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
     return NULL;
   while (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
-    fd = GNUNET_DISK_file_open (filename,
-                                GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE
-                                | GNUNET_DISK_OPEN_FAILIFEXISTS,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
+    fd =
+      GNUNET_DISK_file_open (filename,
+                             GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE |
+                               GNUNET_DISK_OPEN_FAILIFEXISTS,
+                             GNUNET_DISK_PERM_USER_READ |
+                               GNUNET_DISK_PERM_USER_WRITE);
     if (NULL == fd)
     {
       if (EEXIST == errno)
@@ -98,10 +110,10 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
         if (GNUNET_YES != GNUNET_DISK_file_test (filename))
         {
           /* must exist but not be accessible, fail for good! */
-          if (0 != ACCESS (filename, R_OK))
+          if (0 != access (filename, R_OK))
             LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename);
           else
-            GNUNET_break (0);   /* what is going on!? */
+            GNUNET_break (0); /* what is going on!? */
           return NULL;
         }
         continue;
@@ -111,7 +123,8 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
     }
     cnt = 0;
     while (GNUNET_YES !=
-           GNUNET_DISK_file_lock (fd, 0,
+           GNUNET_DISK_file_lock (fd,
+                                  0,
                                   sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey),
                                   GNUNET_YES))
     {
@@ -120,27 +133,29 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"),
-            filename,
-             STRERROR (ec));
+             _ ("Could not acquire lock on file `%s': %s...\n"),
+             filename,
+             strerror (ec));
       }
     }
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("Creating a new private key.  This may take a while.\n"));
+         _ ("Creating a new private key.  This may take a while.\n"));
     priv = GNUNET_CRYPTO_eddsa_key_create ();
     GNUNET_assert (NULL != priv);
     GNUNET_assert (sizeof (*priv) ==
                    GNUNET_DISK_file_write (fd, priv, sizeof (*priv)));
     GNUNET_DISK_file_sync (fd);
     if (GNUNET_YES !=
-        GNUNET_DISK_file_unlock (fd, 0,
+        GNUNET_DISK_file_unlock (fd,
+                                 0,
                                  sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
       LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
     GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
     return priv;
   }
   /* key file exists already, read it! */
-  fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+  fd = GNUNET_DISK_file_open (filename,
+                              GNUNET_DISK_OPEN_READ,
                               GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
@@ -151,7 +166,8 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
   while (1)
   {
     if (GNUNET_YES !=
-        GNUNET_DISK_file_lock (fd, 0,
+        GNUNET_DISK_file_lock (fd,
+                               0,
                                sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey),
                                GNUNET_NO))
     {
@@ -159,11 +175,13 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"), filename,
-             STRERROR (ec));
-        LOG (GNUNET_ERROR_TYPE_ERROR,
-             _
-             ("This may be ok if someone is currently generating a private key.\n"));
+             _ ("Could not acquire lock on file `%s': %s...\n"),
+             filename,
+             strerror (ec));
+        LOG (
+          GNUNET_ERROR_TYPE_ERROR,
+          _ (
+            "This may be ok if someone is currently generating a private key.\n"));
       }
       short_wait ();
       continue;
@@ -173,57 +191,56 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
       /* eh, what!? File we opened is now gone!? */
       LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
       if (GNUNET_YES !=
-          GNUNET_DISK_file_unlock (fd, 0,
-                                   sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
+          GNUNET_DISK_file_unlock (fd,
+                                   0,
+                                   sizeof (
+                                     struct GNUNET_CRYPTO_EddsaPrivateKey)))
         LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
       GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
 
       return NULL;
     }
-    if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
+    if (GNUNET_OK !=
+        GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
       fs = 0;
     if (fs < sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey))
     {
       /* maybe we got the read lock before the key generating
        * process had a chance to get the write lock; give it up! */
       if (GNUNET_YES !=
-          GNUNET_DISK_file_unlock (fd, 0,
-                                   sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
+          GNUNET_DISK_file_unlock (fd,
+                                   0,
+                                   sizeof (
+                                     struct GNUNET_CRYPTO_EddsaPrivateKey)))
         LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
       if (0 == ++cnt % 10)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
+             _ (
+               "When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
              filename,
-            (unsigned int) fs,
+             (unsigned int) fs,
              (unsigned int) sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("This may be ok if someone is currently generating a key.\n"));
+             _ ("This may be ok if someone is currently generating a key.\n"));
       }
-      short_wait ();                /* wait a bit longer! */
+      short_wait (); /* wait a bit longer! */
       continue;
     }
     break;
   }
   fs = sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  sret = GNUNET_DISK_file_read (fd,
-                               priv,
-                               fs);
-  GNUNET_assert ( (sret >= 0) &&
-                 (fs == (size_t) sret) );
+  sret = GNUNET_DISK_file_read (fd, priv, fs);
+  GNUNET_assert ((sret >= 0) && (fs == (size_t) sret));
   if (GNUNET_YES !=
       GNUNET_DISK_file_unlock (fd,
-                              0,
+                               0,
                                sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                      "fcntl",
-                      filename);
-  GNUNET_assert (GNUNET_YES ==
-                GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
 #if CRYPTO_BUG
-  if (GNUNET_OK !=
-      check_eddsa_key (priv))
+  if (GNUNET_OK != check_eddsa_key (priv))
   {
     GNUNET_break (0);
     GNUNET_free (priv);
@@ -258,16 +275,16 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
   uint64_t fs;
   ssize_t sret;
 
-  if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_create_for_file (filename))
+  if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
   while (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
-    fd = GNUNET_DISK_file_open (filename,
-                                GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE
-                                | GNUNET_DISK_OPEN_FAILIFEXISTS,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
+    fd =
+      GNUNET_DISK_file_open (filename,
+                             GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE |
+                               GNUNET_DISK_OPEN_FAILIFEXISTS,
+                             GNUNET_DISK_PERM_USER_READ |
+                               GNUNET_DISK_PERM_USER_WRITE);
     if (NULL == fd)
     {
       if (EEXIST == errno)
@@ -275,25 +292,21 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
         if (GNUNET_YES != GNUNET_DISK_file_test (filename))
         {
           /* must exist but not be accessible, fail for good! */
-          if (0 != ACCESS (filename, R_OK))
-            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
-                              "access",
-                              filename);
+          if (0 != access (filename, R_OK))
+            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename);
           else
-            GNUNET_break (0);   /* what is going on!? */
+            GNUNET_break (0); /* what is going on!? */
           return NULL;
         }
         continue;
       }
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
-                        "open",
-                        filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
       return NULL;
     }
     cnt = 0;
     while (GNUNET_YES !=
            GNUNET_DISK_file_lock (fd,
-                                 0,
+                                  0,
                                   sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
                                   GNUNET_YES))
     {
@@ -302,46 +315,41 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"),
-            filename,
-             STRERROR (ec));
+             _ ("Could not acquire lock on file `%s': %s...\n"),
+             filename,
+             strerror (ec));
       }
     }
     LOG (GNUNET_ERROR_TYPE_INFO,
-         _("Creating a new private key.  This may take a while.\n"));
+         _ ("Creating a new private key.  This may take a while.\n"));
     priv = GNUNET_CRYPTO_ecdsa_key_create ();
     GNUNET_assert (NULL != priv);
     GNUNET_assert (sizeof (*priv) ==
-                   GNUNET_DISK_file_write (fd,
-                                          priv,
-                                          sizeof (*priv)));
+                   GNUNET_DISK_file_write (fd, priv, sizeof (*priv)));
     GNUNET_DISK_file_sync (fd);
     if (GNUNET_YES !=
-        GNUNET_DISK_file_unlock (fd, 0,
+        GNUNET_DISK_file_unlock (fd,
+                                 0,
                                  sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                        "fcntl",
-                        filename);
-    GNUNET_assert (GNUNET_YES ==
-                  GNUNET_DISK_file_close (fd));
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+    GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
     return priv;
   }
   /* key file exists already, read it! */
   fd = GNUNET_DISK_file_open (filename,
-                             GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_OPEN_READ,
                               GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
-                      "open",
-                      filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
     return NULL;
   }
   cnt = 0;
   while (1)
   {
     if (GNUNET_YES !=
-        GNUNET_DISK_file_lock (fd, 0,
+        GNUNET_DISK_file_lock (fd,
+                               0,
                                sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
                                GNUNET_NO))
     {
@@ -349,78 +357,70 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"),
-            filename,
-             STRERROR (ec));
-        LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("This may be ok if someone is currently generating a private key.\n"));
+             _ ("Could not acquire lock on file `%s': %s...\n"),
+             filename,
+             strerror (ec));
+        LOG (
+          GNUNET_ERROR_TYPE_ERROR,
+          _ (
+            "This may be ok if someone is currently generating a private key.\n"));
       }
       short_wait ();
       continue;
     }
-    if (GNUNET_YES !=
-       GNUNET_DISK_file_test (filename))
+    if (GNUNET_YES != GNUNET_DISK_file_test (filename))
     {
       /* eh, what!? File we opened is now gone!? */
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                        "stat",
-                        filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
       if (GNUNET_YES !=
-          GNUNET_DISK_file_unlock (fd, 0,
-                                   sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                          "fcntl",
-                          filename);
-      GNUNET_assert (GNUNET_OK ==
-                    GNUNET_DISK_file_close (fd));
+          GNUNET_DISK_file_unlock (fd,
+                                   0,
+                                   sizeof (
+                                     struct GNUNET_CRYPTO_EcdsaPrivateKey)))
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+      GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
 
       return NULL;
     }
     if (GNUNET_OK !=
-       GNUNET_DISK_file_size (filename,
-                              &fs,
-                              GNUNET_YES,
-                              GNUNET_YES))
+        GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
       fs = 0;
     if (fs < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))
     {
       /* maybe we got the read lock before the key generating
        * process had a chance to get the write lock; give it up! */
       if (GNUNET_YES !=
-          GNUNET_DISK_file_unlock (fd, 0,
-                                   sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                          "fcntl",
-                          filename);
+          GNUNET_DISK_file_unlock (fd,
+                                   0,
+                                   sizeof (
+                                     struct GNUNET_CRYPTO_EcdsaPrivateKey)))
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
       if (0 == ++cnt % 10)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
-             filename, (unsigned int) fs,
+             _ (
+               "When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
+             filename,
+             (unsigned int) fs,
              (unsigned int) sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("This may be ok if someone is currently generating a key.\n"));
+             _ ("This may be ok if someone is currently generating a key.\n"));
       }
-      short_wait ();                /* wait a bit longer! */
+      short_wait (); /* wait a bit longer! */
       continue;
     }
     break;
   }
   fs = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  sret = GNUNET_DISK_file_read (fd,
-                               priv,
-                               fs);
-  GNUNET_assert ( (sret >= 0) &&
-                 (fs == (size_t) sret) );
+  sret = GNUNET_DISK_file_read (fd, priv, fs);
+  GNUNET_assert ((sret >= 0) && (fs == (size_t) sret));
   if (GNUNET_YES !=
-      GNUNET_DISK_file_unlock (fd, 0,
+      GNUNET_DISK_file_unlock (fd,
+                               0,
                                sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                      "fcntl",
-                      filename);
-  GNUNET_assert (GNUNET_YES ==
-                GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
   return priv;
 }
 
@@ -434,7 +434,8 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
  *   permission denied)
  */
 struct GNUNET_CRYPTO_EddsaPrivateKey *
-GNUNET_CRYPTO_eddsa_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
+GNUNET_CRYPTO_eddsa_key_create_from_configuration (
+  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
   char *fn;
@@ -465,7 +466,7 @@ GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
   if (NULL == (priv = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Could not load peer's private key\n"));
+                _ ("Could not load peer's private key\n"));
     return GNUNET_SYSERR;
   }
   GNUNET_CRYPTO_eddsa_key_get_public (priv, &dst->public_key);
index 71eaab87aefd32f6c1dbddec97640c5af3fb06d5..58cab082ece5fbfb2b9720136a44ef6c4b408e4e 100644 (file)
@@ -80,7 +80,7 @@ glibc_weak_rand32 ()
 static double
 get_weak_random ()
 {
-  return ((double) RANDOM () / RAND_MAX);
+  return ((double) random () / RAND_MAX);
 }
 
 
@@ -93,7 +93,7 @@ get_weak_random ()
 void
 GNUNET_CRYPTO_seed_weak_random (int32_t seed)
 {
-  SRANDOM (seed);
+  srandom (seed);
 }
 
 
@@ -324,7 +324,7 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
 
   if (! gcry_check_version (NEED_LIBGCRYPT_VERSION))
   {
-    FPRINTF (
+    fprintf (
       stderr,
       _ ("libgcrypt has not the expected version (version %s is required).\n"),
       NEED_LIBGCRYPT_VERSION);
@@ -334,14 +334,14 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
   gcry_set_allocation_handler (&w_malloc, &w_malloc, &w_check, &realloc, &free);
   /* Disable use of secure memory */
   if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0)))
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Failed to set libgcrypt option %s: %s\n",
              "DISABLE_SECMEM",
              gcry_strerror (rc));
   /* Otherwise gnunet-ecc takes forever to complete, besides
      we are fine with "just" using GCRY_STRONG_RANDOM */
   if ((rc = gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0)))
-    FPRINTF (stderr,
+    fprintf (stderr,
              "Failed to set libgcrypt option %s: %s\n",
              "ENABLE_QUICK_RANDOM",
              gcry_strerror (rc));
index f395a375ea2b533e97c7dcd30ed74d8d69a81b5d..c1f24e4c8e00e3f8392e03f0896ac1a6b6f3f8ca 100644 (file)
 #include "gnunet_strings_lib.h"
 #include "gnunet_disk_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-disk", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-disk", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-disk", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-disk", syscall)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-disk", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util-disk", syscall, filename)
 
 /**
  * Block size for IO for copying files.
@@ -54,9 +56,9 @@
 #endif
 
 #ifndef S_ISLNK
-#define        _IFMT           0170000 /* type of file */
-#define        _IFLNK          0120000 /* symbolic link */
-#define  S_ISLNK(m)    (((m)&_IFMT) == _IFLNK)
+#define _IFMT 0170000 /* type of file */
+#define _IFLNK 0120000 /* symbolic link */
+#define S_ISLNK(m) (((m) &_IFMT) == _IFLNK)
 #endif
 
 
@@ -147,7 +149,8 @@ getSizeRec (void *cls, const char *fn)
 {
   struct GetFileSizeData *gfsd = cls;
 
-#if defined (HAVE_STAT64) && !(defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
+#if defined(HAVE_STAT64) && \
+  ! (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
   STRUCT_STAT64 buf;
 
   if (0 != STAT64 (fn, &buf))
@@ -158,7 +161,7 @@ getSizeRec (void *cls, const char *fn)
 #else
   struct stat buf;
 
-  if (0 != STAT (fn, &buf))
+  if (0 != stat (fn, &buf))
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_DEBUG, "stat", fn);
     return GNUNET_SYSERR;
@@ -169,10 +172,10 @@ getSizeRec (void *cls, const char *fn)
     errno = EISDIR;
     return GNUNET_SYSERR;
   }
-  if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))
+  if ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))
     gfsd->total += buf.st_size;
-  if ((S_ISDIR (buf.st_mode)) && (0 == ACCESS (fn, X_OK)) &&
-      ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)))
+  if ((S_ISDIR (buf.st_mode)) && (0 == access (fn, X_OK)) &&
+      ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)))
   {
     if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &getSizeRec, gfsd))
       return GNUNET_SYSERR;
@@ -191,9 +194,9 @@ int
 GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
 {
 #ifdef MINGW
-  return ((!h) || (h->h == INVALID_HANDLE_VALUE)) ? GNUNET_YES : GNUNET_NO;
+  return ((! h) || (h->h == INVALID_HANDLE_VALUE)) ? GNUNET_YES : GNUNET_NO;
 #else
-  return ((!h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO;
+  return ((! h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO;
 #endif
 }
 
@@ -205,14 +208,13 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
-                             off_t *size)
+GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, off_t *size)
 {
 #if WINDOWS
   BOOL b;
   LARGE_INTEGER li;
   b = GetFileSizeEx (fh->h, &li);
-  if (!b)
+  if (! b)
   {
     SetErrnoFromWinError (GetLastError ());
     return GNUNET_SYSERR;
@@ -221,7 +223,7 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
 #else
   struct stat sbuf;
 
-  if (0 != FSTAT (fh->fd, &sbuf))
+  if (0 != fstat (fh->fd, &sbuf))
     return GNUNET_SYSERR;
   *size = sbuf.st_size;
 #endif
@@ -239,7 +241,7 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
  */
 off_t
 GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h,
-                      off_t offset,
+                       off_t offset,
                        enum GNUNET_DISK_Seek whence)
 {
   if (h == NULL)
@@ -253,7 +255,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h,
   LARGE_INTEGER new_pos;
   BOOL b;
 
-  static DWORD t[] = { FILE_BEGIN, FILE_CURRENT, FILE_END };
+  static DWORD t[] = {FILE_BEGIN, FILE_CURRENT, FILE_END};
   li.QuadPart = offset;
 
   b = SetFilePointerEx (h->h, li, &new_pos, t[whence]);
@@ -264,7 +266,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h,
   }
   return (off_t) new_pos.QuadPart;
 #else
-  static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END };
+  static int t[] = {SEEK_SET, SEEK_CUR, SEEK_END};
 
   return lseek (h->fd, offset, t[whence]);
 #endif
@@ -287,9 +289,9 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h,
  */
 int
 GNUNET_DISK_file_size (const char *filename,
-                      uint64_t * size,
+                       uint64_t *size,
                        int include_symbolic_links,
-                      int single_file_mode)
+                       int single_file_mode)
 {
   struct GetFileSizeData gfsd;
   int ret;
@@ -320,8 +322,9 @@ GNUNET_DISK_file_size (const char *filename,
  * @return #GNUNET_OK on success
  */
 int
-GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
-                                  uint64_t * ino)
+GNUNET_DISK_file_get_identifiers (const char *filename,
+                                  uint64_t *dev,
+                                  uint64_t *ino)
 {
 #if WINDOWS
   {
@@ -337,12 +340,13 @@ GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
       return GNUNET_SYSERR;
     succ = GetFileInformationByHandle (fh->h, &info);
     GNUNET_DISK_file_close (fh);
-    if (!succ)
+    if (! succ)
     {
       return GNUNET_SYSERR;
     }
     *dev = info.dwVolumeSerialNumber;
-    *ino = ((((uint64_t) info.nFileIndexHigh) << (sizeof (DWORD) * 8)) | info.nFileIndexLow);
+    *ino = ((((uint64_t) info.nFileIndexHigh) << (sizeof (DWORD) * 8)) |
+            info.nFileIndexLow);
   }
 #else /* !WINDOWS */
 #if HAVE_STAT
@@ -376,8 +380,8 @@ GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
     {
       return GNUNET_SYSERR;
     }
-    *dev = ((uint64_t) fbuf.f_fsid.val[0]) << 32 ||
-        ((uint64_t) fbuf.f_fsid.val[1]);
+    *dev =
+      ((uint64_t) fbuf.f_fsid.val[0]) << 32 || ((uint64_t) fbuf.f_fsid.val[1]);
   }
 #else
   *dev = 0;
@@ -402,9 +406,9 @@ mktemp_name (const char *t)
 
   if ((t[0] != '/') && (t[0] != '\\')
 #if WINDOWS
-      && !(isalpha ((int) t[0]) && (t[0] != '\0') && (t[1] == ':'))
+      && ! (isalpha ((int) t[0]) && (t[0] != '\0') && (t[1] == ':'))
 #endif
-      )
+  )
   {
     /* FIXME: This uses system codepage on W32, not UTF-8 */
     tmpdir = getenv ("TMPDIR");
@@ -506,11 +510,10 @@ GNUNET_DISK_fix_permissions (const char *fn,
   else if (GNUNET_YES == require_gid_match)
     mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP;
   else
-    mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
+    mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH |
+           S_IWOTH | S_IXOTH;
   if (0 != chmod (fn, mode))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                              "chmod",
-                              fn);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "chmod", fn);
 }
 
 #endif
@@ -565,15 +568,10 @@ GNUNET_DISK_file_backup (const char *fil)
   num = 0;
   do
   {
-    GNUNET_snprintf (target, slen,
-                    "%s.%u~",
-                    fil,
-                    num++);
+    GNUNET_snprintf (target, slen, "%s.%u~", fil, num++);
   } while (0 == access (target, F_OK));
   if (0 != rename (fil, target))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                             "rename",
-                             fil);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "rename", fil);
   GNUNET_free (target);
 }
 
@@ -606,7 +604,7 @@ GNUNET_DISK_mktemp (const char *t)
     return NULL;
   }
   umask (omask);
-  if (0 != CLOSE (fd))
+  if (0 != close (fd))
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "close", fn);
   return fn;
 }
@@ -625,29 +623,29 @@ GNUNET_DISK_mktemp (const char *t)
  *           does not exist or stat'ed
  */
 int
-GNUNET_DISK_directory_test (const char *fil,
-                            int is_readable)
+GNUNET_DISK_directory_test (const char *fil, int is_readable)
 {
   struct stat filestat;
   int ret;
 
-  ret = STAT (fil, &filestat);
+  ret = stat (fil, &filestat);
   if (ret != 0)
   {
     if (errno != ENOENT)
       LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", fil);
     return GNUNET_SYSERR;
   }
-  if (!S_ISDIR (filestat.st_mode))
+  if (! S_ISDIR (filestat.st_mode))
   {
     LOG (GNUNET_ERROR_TYPE_INFO,
-         "A file already exits with the same name %s\n", fil);
+         "A file already exits with the same name %s\n",
+         fil);
     return GNUNET_NO;
   }
   if (GNUNET_YES == is_readable)
-    ret = ACCESS (fil, R_OK | X_OK);
+    ret = access (fil, R_OK | X_OK);
   else
-    ret = ACCESS (fil, X_OK);
+    ret = access (fil, X_OK);
   if (ret < 0)
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", fil);
@@ -676,7 +674,7 @@ GNUNET_DISK_file_test (const char *fil)
   if (rdir == NULL)
     return GNUNET_SYSERR;
 
-  ret = STAT (rdir, &filestat);
+  ret = stat (rdir, &filestat);
   if (ret != 0)
   {
     if (errno != ENOENT)
@@ -688,12 +686,12 @@ GNUNET_DISK_file_test (const char *fil)
     GNUNET_free (rdir);
     return GNUNET_NO;
   }
-  if (!S_ISREG (filestat.st_mode))
+  if (! S_ISREG (filestat.st_mode))
   {
     GNUNET_free (rdir);
     return GNUNET_NO;
   }
-  if (ACCESS (rdir, F_OK) < 0)
+  if (access (rdir, F_OK) < 0)
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", rdir);
     GNUNET_free (rdir);
@@ -728,7 +726,7 @@ GNUNET_DISK_directory_create (const char *dir)
 
   len = strlen (rdir);
 #ifndef MINGW
-  pos = 1;                      /* skip heading '/' */
+  pos = 1; /* skip heading '/' */
 #else
   /* Local or Network path? */
   if (strncmp (rdir, "\\\\", 2) == 0)
@@ -746,7 +744,7 @@ GNUNET_DISK_directory_create (const char *dir)
   }
   else
   {
-    pos = 3;                    /* strlen("C:\\") */
+    pos = 3; /* strlen("C:\\") */
   }
 #endif
   /* Check which low level directories already exist */
@@ -796,11 +794,13 @@ GNUNET_DISK_directory_create (const char *dir)
       if (GNUNET_SYSERR == ret)
       {
 #ifndef MINGW
-        ret = mkdir (rdir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);        /* 755 */
+        ret = mkdir (rdir,
+                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
+                       S_IXOTH); /* 755 */
 #else
         wchar_t wrdir[MAX_PATH + 1];
-        if (ERROR_SUCCESS == plibc_conv_to_win_pathwconv(rdir, wrdir))
-          ret = !CreateDirectoryW (wrdir, NULL);
+        if (ERROR_SUCCESS == plibc_conv_to_win_pathwconv (rdir, wrdir))
+          ret = ! CreateDirectoryW (wrdir, NULL);
         else
           ret = 1;
 #endif
@@ -843,7 +843,7 @@ GNUNET_DISK_directory_create_for_file (const char *filename)
     errno = EINVAL;
     return GNUNET_SYSERR;
   }
-  if (0 == ACCESS (rdir, W_OK))
+  if (0 == access (rdir, W_OK))
   {
     GNUNET_free (rdir);
     return GNUNET_OK;
@@ -860,7 +860,7 @@ GNUNET_DISK_directory_create_for_file (const char *filename)
     rdir = GNUNET_strdup ("/");
   }
   ret = GNUNET_DISK_directory_create (rdir);
-  if ((GNUNET_OK == ret) && (0 != ACCESS (rdir, W_OK)))
+  if ((GNUNET_OK == ret) && (0 != access (rdir, W_OK)))
     ret = GNUNET_NO;
   eno = errno;
   GNUNET_free (rdir);
@@ -893,7 +893,7 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
 
   if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
   {
-    if (!ReadFile (h->h, result, len, &bytes_read, NULL))
+    if (! ReadFile (h->h, result, len, &bytes_read, NULL))
     {
       SetErrnoFromWinError (GetLastError ());
       return GNUNET_SYSERR;
@@ -901,7 +901,7 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
   }
   else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
-    if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
+    if (! ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
     {
       if (GetLastError () != ERROR_IO_PENDING)
       {
@@ -939,8 +939,8 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
  */
 ssize_t
 GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
-                                   void *result,
-                                   size_t len)
+                                    void *result,
+                                    size_t len)
 {
   if (NULL == h)
   {
@@ -953,7 +953,7 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
 
   if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
   {
-    if (!ReadFile (h->h, result, len, &bytes_read, NULL))
+    if (! ReadFile (h->h, result, len, &bytes_read, NULL))
     {
       SetErrnoFromWinError (GetLastError ());
       return GNUNET_SYSERR;
@@ -961,26 +961,25 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
   }
   else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
-    if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
+    if (! ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
     {
       if (GetLastError () != ERROR_IO_PENDING)
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "Error reading from pipe: %u\n", GetLastError ());
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Error reading from pipe: %u\n",
+             GetLastError ());
         SetErrnoFromWinError (GetLastError ());
         return GNUNET_SYSERR;
       }
       else
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "ReadFile() queued a read, cancelling\n");
+        LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadFile() queued a read, cancelling\n");
         CancelIo (h->h);
         errno = EAGAIN;
         return GNUNET_SYSERR;
       }
     }
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Read %u bytes\n",
-         bytes_read);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes\n", bytes_read);
   }
   else
   {
@@ -997,11 +996,11 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
     (void) fcntl (h->fd, F_SETFL, flags | O_NONBLOCK);
   ret = read (h->fd, result, len);
   if (0 == (flags & O_NONBLOCK))
-    {
-      int eno = errno;
-      (void) fcntl (h->fd, F_SETFL, flags);
-      errno = eno;
-    }
+  {
+    int eno = errno;
+    (void) fcntl (h->fd, F_SETFL, flags);
+    errno = eno;
+  }
   return ret;
 #endif
 }
@@ -1016,17 +1015,13 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
  * @return number of bytes read, #GNUNET_SYSERR on failure
  */
 ssize_t
-GNUNET_DISK_fn_read (const char *fn,
-                     void *result,
-                     size_t len)
+GNUNET_DISK_fn_read (const char *fn, void *result, size_t len)
 {
   struct GNUNET_DISK_FileHandle *fh;
   ssize_t ret;
   int eno;
 
-  fh = GNUNET_DISK_file_open (fn,
-                              GNUNET_DISK_OPEN_READ,
-                              GNUNET_DISK_PERM_NONE);
+  fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE);
   if (NULL == fh)
     return GNUNET_SYSERR;
   ret = GNUNET_DISK_file_read (fh, result, len);
@@ -1046,9 +1041,9 @@ GNUNET_DISK_fn_read (const char *fn,
  * @return number of bytes written on success, #GNUNET_SYSERR on error
  */
 ssize_t
-GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
+GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
                         const void *buffer,
-                       size_t n)
+                        size_t n)
 {
   if (NULL == h)
   {
@@ -1061,7 +1056,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
 
   if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
   {
-    if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
+    if (! WriteFile (h->h, buffer, n, &bytes_written, NULL))
     {
       SetErrnoFromWinError (GetLastError ());
       return GNUNET_SYSERR;
@@ -1070,46 +1065,50 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
   else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "It is a pipe trying to write %u bytes\n", n);
-    if (!WriteFile (h->h, buffer, n, &bytes_written, h->oOverlapWrite))
+    if (! WriteFile (h->h, buffer, n, &bytes_written, h->oOverlapWrite))
     {
       if (GetLastError () != ERROR_IO_PENDING)
       {
         SetErrnoFromWinError (GetLastError ());
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n",
-            GetLastError ());
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Error writing to pipe: %u\n",
+             GetLastError ());
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Will get overlapped result\n");
-      if (!GetOverlappedResult (h->h, h->oOverlapWrite, &bytes_written, TRUE))
+      if (! GetOverlappedResult (h->h, h->oOverlapWrite, &bytes_written, TRUE))
       {
         SetErrnoFromWinError (GetLastError ());
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Error getting overlapped result while writing to pipe: %u\n",
-            GetLastError ());
+             "Error getting overlapped result while writing to pipe: %u\n",
+             GetLastError ());
         return GNUNET_SYSERR;
       }
     }
     else
     {
       DWORD ovr;
-      if (!GetOverlappedResult (h->h, h->oOverlapWrite, &ovr, TRUE))
+      if (! GetOverlappedResult (h->h, h->oOverlapWrite, &ovr, TRUE))
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Error getting control overlapped result while writing to pipe: %u\n",
-            GetLastError ());
+             "Error getting control overlapped result while writing to pipe: %u\n",
+             GetLastError ());
       }
       else
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-            "Wrote %u bytes (ovr says %u), picking the greatest\n",
-            bytes_written, ovr);
+             "Wrote %u bytes (ovr says %u), picking the greatest\n",
+             bytes_written,
+             ovr);
       }
     }
     if (bytes_written == 0)
     {
       if (n > 0)
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes, returning -1 with EAGAIN\n", bytes_written);
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Wrote %u bytes, returning -1 with EAGAIN\n",
+             bytes_written);
         errno = EAGAIN;
         return GNUNET_SYSERR;
       }
@@ -1136,7 +1135,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
  * @return number of bytes written on success, #GNUNET_SYSERR on error
  */
 ssize_t
-GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
+GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h,
                                  const void *buffer,
                                  size_t n)
 {
@@ -1150,28 +1149,28 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
   DWORD bytes_written;
   /* We do a non-overlapped write, which is as blocking as it gets */
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing %u bytes\n", n);
-  if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
+  if (! WriteFile (h->h, buffer, n, &bytes_written, NULL))
   {
     SetErrnoFromWinError (GetLastError ());
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n",
-        GetLastError ());
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Error writing to pipe: %u\n",
+         GetLastError ());
     return GNUNET_SYSERR;
   }
   if (bytes_written == 0 && n > 0)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for pipe to clean\n");
     WaitForSingleObject (h->h, INFINITE);
-    if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
+    if (! WriteFile (h->h, buffer, n, &bytes_written, NULL))
     {
       SetErrnoFromWinError (GetLastError ());
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n",
-          GetLastError ());
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Error writing to pipe: %u\n",
+           GetLastError ());
       return GNUNET_SYSERR;
     }
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Wrote %u bytes\n",
-       bytes_written);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes\n", bytes_written);
   return bytes_written;
 #else
   int flags;
@@ -1208,9 +1207,11 @@ GNUNET_DISK_fn_write (const char *fn,
   struct GNUNET_DISK_FileHandle *fh;
   ssize_t ret;
 
-  fh = GNUNET_DISK_file_open (fn,
-                              GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE
-                              | GNUNET_DISK_OPEN_CREATE, mode);
+  fh =
+    GNUNET_DISK_file_open (fn,
+                           GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE |
+                             GNUNET_DISK_OPEN_CREATE,
+                           mode);
   if (! fh)
     return GNUNET_SYSERR;
   ret = GNUNET_DISK_file_write (fh, buffer, n);
@@ -1248,45 +1249,39 @@ GNUNET_DISK_directory_scan (const char *dir_name,
   dname = GNUNET_STRINGS_filename_expand (dir_name);
   if (NULL == dname)
     return GNUNET_SYSERR;
-  while ( (strlen (dname) > 0) &&
-          (dname[strlen (dname) - 1] == DIR_SEPARATOR) )
+  while ((strlen (dname) > 0) && (dname[strlen (dname) - 1] == DIR_SEPARATOR))
     dname[strlen (dname) - 1] = '\0';
-  if (0 != STAT (dname, &istat))
+  if (0 != stat (dname, &istat))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "stat",
-                       dname);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", dname);
     GNUNET_free (dname);
     return GNUNET_SYSERR;
   }
   if (! S_ISDIR (istat.st_mode))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Expected `%s' to be a directory!\n"),
+         _ ("Expected `%s' to be a directory!\n"),
          dir_name);
     GNUNET_free (dname);
     return GNUNET_SYSERR;
   }
   errno = 0;
-  dinfo = OPENDIR (dname);
-  if ( (EACCES == errno) ||
-       (NULL == dinfo) )
+  dinfo = opendir (dname);
+  if ((EACCES == errno) || (NULL == dinfo))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "opendir",
-                       dname);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "opendir", dname);
     if (NULL != dinfo)
-      CLOSEDIR (dinfo);
+      closedir (dinfo);
     GNUNET_free (dname);
     return GNUNET_SYSERR;
   }
   name_len = 256;
   n_size = strlen (dname) + name_len + strlen (DIR_SEPARATOR_STR) + 1;
   name = GNUNET_malloc (n_size);
-  while (NULL != (finfo = READDIR (dinfo)))
+  while (NULL != (finfo = readdir (dinfo)))
   {
-    if ( (0 == strcmp (finfo->d_name, ".")) ||
-         (0 == strcmp (finfo->d_name, "..")) )
+    if ((0 == strcmp (finfo->d_name, ".")) ||
+        (0 == strcmp (finfo->d_name, "..")))
       continue;
     if (NULL != callback)
     {
@@ -1304,16 +1299,14 @@ GNUNET_DISK_directory_scan (const char *dir_name,
                        n_size,
                        "%s%s%s",
                        dname,
-                       (0 == strcmp (dname,
-                                     DIR_SEPARATOR_STR))
-                       ? ""
-                       : DIR_SEPARATOR_STR,
+                       (0 == strcmp (dname, DIR_SEPARATOR_STR))
+                         ? ""
+                         : DIR_SEPARATOR_STR,
                        finfo->d_name);
-      ret = callback (callback_cls,
-                      name);
+      ret = callback (callback_cls, name);
       if (GNUNET_OK != ret)
       {
-        CLOSEDIR (dinfo);
+        closedir (dinfo);
         GNUNET_free (name);
         GNUNET_free (dname);
         if (GNUNET_NO == ret)
@@ -1323,7 +1316,7 @@ GNUNET_DISK_directory_scan (const char *dir_name,
     }
     count++;
   }
-  CLOSEDIR (dinfo);
+  closedir (dinfo);
   GNUNET_free (name);
   GNUNET_free (dname);
   return count;
@@ -1339,8 +1332,7 @@ GNUNET_DISK_directory_scan (const char *dir_name,
  * @return #GNUNET_OK
  */
 static int
-remove_helper (void *unused,
-               const char *fn)
+remove_helper (void *unused, const char *fn)
 {
   (void) unused;
   (void) GNUNET_DISK_directory_remove (fn);
@@ -1365,35 +1357,26 @@ GNUNET_DISK_directory_remove (const char *filename)
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  if (0 != LSTAT (filename, &istat))
-    return GNUNET_NO;           /* file may not exist... */
-  (void) CHMOD (filename,
-                S_IWUSR | S_IRUSR | S_IXUSR);
-  if (0 == UNLINK (filename))
+  if (0 != lstat (filename, &istat))
+    return GNUNET_NO; /* file may not exist... */
+  (void) chmod (filename, S_IWUSR | S_IRUSR | S_IXUSR);
+  if (0 == unlink (filename))
     return GNUNET_OK;
-  if ( (errno != EISDIR) &&
-       /* EISDIR is not sufficient in all cases, e.g.
+  if ((errno != EISDIR) &&
+      /* EISDIR is not sufficient in all cases, e.g.
         * sticky /tmp directory may result in EPERM on BSD.
         * So we also explicitly check "isDirectory" */
-       (GNUNET_YES !=
-        GNUNET_DISK_directory_test (filename,
-                                    GNUNET_YES)) )
+      (GNUNET_YES != GNUNET_DISK_directory_test (filename, GNUNET_YES)))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "rmdir",
-                       filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename);
     return GNUNET_SYSERR;
   }
   if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_scan (filename,
-                                  &remove_helper,
-                                  NULL))
+      GNUNET_DISK_directory_scan (filename, &remove_helper, NULL))
     return GNUNET_SYSERR;
-  if (0 != RMDIR (filename))
+  if (0 != rmdir (filename))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "rmdir",
-                       filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename);
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -1408,8 +1391,7 @@ GNUNET_DISK_directory_remove (const char *filename)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_DISK_file_copy (const char *src,
-                       const char *dst)
+GNUNET_DISK_file_copy (const char *src, const char *dst)
 {
   char *buf;
   uint64_t pos;
@@ -1419,41 +1401,30 @@ GNUNET_DISK_file_copy (const char *src,
   struct GNUNET_DISK_FileHandle *in;
   struct GNUNET_DISK_FileHandle *out;
 
-  if (GNUNET_OK !=
-      GNUNET_DISK_file_size (src,
-                             &size,
-                             GNUNET_YES,
-                             GNUNET_YES))
-  {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                              "stat",
-                              src);
+  if (GNUNET_OK != GNUNET_DISK_file_size (src, &size, GNUNET_YES, GNUNET_YES))
+  {
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "stat", src);
     return GNUNET_SYSERR;
   }
   pos = 0;
-  in = GNUNET_DISK_file_open (src,
-                              GNUNET_DISK_OPEN_READ,
-                              GNUNET_DISK_PERM_NONE);
+  in =
+    GNUNET_DISK_file_open (src, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE);
   if (! in)
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                              "open",
-                              src);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", src);
     return GNUNET_SYSERR;
   }
   out =
-      GNUNET_DISK_file_open (dst,
-                             GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE |
+    GNUNET_DISK_file_open (dst,
+                           GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE |
                              GNUNET_DISK_OPEN_FAILIFEXISTS,
-                             GNUNET_DISK_PERM_USER_READ |
+                           GNUNET_DISK_PERM_USER_READ |
                              GNUNET_DISK_PERM_USER_WRITE |
                              GNUNET_DISK_PERM_GROUP_READ |
                              GNUNET_DISK_PERM_GROUP_WRITE);
-  if (!out)
+  if (! out)
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                              "open",
-                              dst);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", dst);
     GNUNET_DISK_file_close (in);
     return GNUNET_SYSERR;
   }
@@ -1463,17 +1434,11 @@ GNUNET_DISK_file_copy (const char *src,
     len = COPY_BLK_SIZE;
     if (len > size - pos)
       len = size - pos;
-    sret = GNUNET_DISK_file_read (in,
-                                 buf,
-                                 len);
-    if ( (sret < 0) ||
-        (len != (size_t) sret) )
+    sret = GNUNET_DISK_file_read (in, buf, len);
+    if ((sret < 0) || (len != (size_t) sret))
       goto FAIL;
-    sret = GNUNET_DISK_file_write (out,
-                                  buf,
-                                  len);
-    if ( (sret < 0) ||
-        (len != (size_t) sret) )
+    sret = GNUNET_DISK_file_write (out, buf, len);
+    if ((sret < 0) || (len != (size_t) sret))
       goto FAIL;
     pos += len;
   }
@@ -1503,8 +1468,7 @@ GNUNET_DISK_filename_canonicalize (char *fn)
   {
     c = *idx;
 
-    if (c == '/' || c == '\\' || c == ':' ||
-       c == '*' || c == '?' || c == '"' ||
+    if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' ||
         c == '<' || c == '>' || c == '|')
     {
       *idx = '_';
@@ -1513,7 +1477,6 @@ GNUNET_DISK_filename_canonicalize (char *fn)
 }
 
 
-
 /**
  * @brief Change owner of a file
  *
@@ -1522,8 +1485,7 @@ GNUNET_DISK_filename_canonicalize (char *fn)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  */
 int
-GNUNET_DISK_file_change_owner (const char *filename,
-                               const char *user)
+GNUNET_DISK_file_change_owner (const char *filename, const char *user)
 {
 #ifndef MINGW
   struct passwd *pws;
@@ -1532,18 +1494,14 @@ GNUNET_DISK_file_change_owner (const char *filename,
   if (NULL == pws)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Cannot obtain information about user `%s': %s\n"),
+         _ ("Cannot obtain information about user `%s': %s\n"),
          user,
-         STRERROR (errno));
+         strerror (errno));
     return GNUNET_SYSERR;
   }
-  if (0 != chown (filename,
-                  pws->pw_uid,
-                  pws->pw_gid))
+  if (0 != chown (filename, pws->pw_uid, pws->pw_gid))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "chown",
-                       filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "chown", filename);
     return GNUNET_SYSERR;
   }
 #endif
@@ -1590,12 +1548,18 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh,
   diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
   memset (&o, 0, sizeof (OVERLAPPED));
-  o.Offset = (DWORD) (lock_start & 0xFFFFFFFF);;
-  o.OffsetHigh = (DWORD) (((lock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
-
-  if (!LockFileEx
-      (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY,
-       0, diff_low, diff_high, &o))
+  o.Offset = (DWORD) (lock_start & 0xFFFFFFFF);
+  ;
+  o.OffsetHigh =
+    (DWORD) (((lock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
+
+  if (! LockFileEx (fh->h,
+                    (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) |
+                      LOCKFILE_FAIL_IMMEDIATELY,
+                    0,
+                    diff_low,
+                    diff_high,
+                    &o))
   {
     SetErrnoFromWinError (GetLastError ());
     return GNUNET_SYSERR;
@@ -1643,10 +1607,12 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh,
   diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
   memset (&o, 0, sizeof (OVERLAPPED));
-  o.Offset = (DWORD) (unlock_start & 0xFFFFFFFF);;
-  o.OffsetHigh = (DWORD) (((unlock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
+  o.Offset = (DWORD) (unlock_start & 0xFFFFFFFF);
+  ;
+  o.OffsetHigh = (DWORD) (
+    ((unlock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
-  if (!UnlockFileEx (fh->h, 0, diff_low, diff_high, &o))
+  if (! UnlockFileEx (fh->h, 0, diff_low, diff_high, &o))
   {
     SetErrnoFromWinError (GetLastError ());
     return GNUNET_SYSERR;
@@ -1694,7 +1660,7 @@ GNUNET_DISK_file_open (const char *fn,
 #ifndef MINGW
   mode = 0;
   if (GNUNET_DISK_OPEN_READWRITE == (flags & GNUNET_DISK_OPEN_READWRITE))
-    oflags = O_RDWR;            /* note: O_RDWR is NOT always O_RDONLY | O_WRONLY */
+    oflags = O_RDWR; /* note: O_RDWR is NOT always O_RDONLY | O_WRONLY */
   else if (flags & GNUNET_DISK_OPEN_READ)
     oflags = O_RDONLY;
   else if (flags & GNUNET_DISK_OPEN_WRITE)
@@ -1706,26 +1672,28 @@ GNUNET_DISK_file_open (const char *fn,
     return NULL;
   }
   if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
-      oflags |= (O_CREAT | O_EXCL);
+    oflags |= (O_CREAT | O_EXCL);
   if (flags & GNUNET_DISK_OPEN_TRUNCATE)
     oflags |= O_TRUNC;
   if (flags & GNUNET_DISK_OPEN_APPEND)
     oflags |= O_APPEND;
-  if(GNUNET_NO == GNUNET_DISK_file_test(fn))
-   {
-      if (flags & GNUNET_DISK_OPEN_CREATE )
-       {
-         (void) GNUNET_DISK_directory_create_for_file (expfn);
-         oflags |= O_CREAT;
-         mode = translate_unix_perms (perm);
-       }
+  if (GNUNET_NO == GNUNET_DISK_file_test (fn))
+  {
+    if (flags & GNUNET_DISK_OPEN_CREATE)
+    {
+      (void) GNUNET_DISK_directory_create_for_file (expfn);
+      oflags |= O_CREAT;
+      mode = translate_unix_perms (perm);
+    }
   }
 
-  fd = open (expfn, oflags
+  fd = open (expfn,
+             oflags
 #if O_CLOEXEC
-            | O_CLOEXEC
+               | O_CLOEXEC
 #endif
-            | O_LARGEFILE, mode);
+               | O_LARGEFILE,
+             mode);
   if (fd == -1)
   {
     if (0 == (flags & GNUNET_DISK_OPEN_FAILIFEXISTS))
@@ -1767,10 +1735,14 @@ GNUNET_DISK_file_open (const char *fn,
     disp = OPEN_EXISTING;
   }
 
-  if (ERROR_SUCCESS == plibc_conv_to_win_pathwconv(expfn, wexpfn))
-    h = CreateFileW (wexpfn, access,
-                    FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
-                    disp, FILE_ATTRIBUTE_NORMAL, NULL);
+  if (ERROR_SUCCESS == plibc_conv_to_win_pathwconv (expfn, wexpfn))
+    h = CreateFileW (wexpfn,
+                     access,
+                     FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
+                     NULL,
+                     disp,
+                     FILE_ATTRIBUTE_NORMAL,
+                     NULL);
   else
     h = INVALID_HANDLE_VALUE;
   if (h == INVALID_HANDLE_VALUE)
@@ -1844,7 +1816,7 @@ GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h)
   }
   if (h->oOverlapWrite)
   {
-    if (!CloseHandle (h->oOverlapWrite->hEvent))
+    if (! CloseHandle (h->oOverlapWrite->hEvent))
     {
       SetErrnoFromWinError (GetLastError ());
       LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "close");
@@ -1888,8 +1860,8 @@ GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh)
     ftype = GNUNET_DISK_HANLDE_TYPE_PIPE;
     break;
   case FILE_TYPE_UNKNOWN:
-    if ( (GetLastError () == NO_ERROR) ||
-         (GetLastError () == ERROR_INVALID_HANDLE) )
+    if ((GetLastError () == NO_ERROR) ||
+        (GetLastError () == ERROR_INVALID_HANDLE))
     {
       if (0 != ResetEvent (osfh))
         ftype = GNUNET_DISK_HANLDE_TYPE_EVENT;
@@ -1938,8 +1910,7 @@ GNUNET_DISK_get_handle_from_int_fd (int fno)
 {
   struct GNUNET_DISK_FileHandle *fh;
 
-  if ( (((off_t) -1) == lseek (fno, 0, SEEK_CUR)) &&
-       (EBADF == errno) )
+  if ((((off_t) -1) == lseek (fno, 0, SEEK_CUR)) && (EBADF == errno))
     return NULL; /* invalid FD */
 
 #ifndef WINDOWS
@@ -2019,7 +1990,8 @@ struct GNUNET_DISK_MapHandle
 void *
 GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
                       struct GNUNET_DISK_MapHandle **m,
-                      enum GNUNET_DISK_MapType access, size_t len)
+                      enum GNUNET_DISK_MapType access,
+                      size_t len)
 {
   if (NULL == h)
   {
@@ -2062,7 +2034,7 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
   }
 
   (*m)->addr = MapViewOfFile ((*m)->h, mapAccess, 0, 0, len);
-  if (!(*m)->addr)
+  if (! (*m)->addr)
   {
     SetErrnoFromWinError (GetLastError ());
     CloseHandle ((*m)->h);
@@ -2111,7 +2083,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h)
   ret = UnmapViewOfFile (h->addr) ? GNUNET_OK : GNUNET_SYSERR;
   if (ret != GNUNET_OK)
     SetErrnoFromWinError (GetLastError ());
-  if (!CloseHandle (h->h) && (ret == GNUNET_OK))
+  if (! CloseHandle (h->h) && (ret == GNUNET_OK))
   {
     ret = GNUNET_SYSERR;
     SetErrnoFromWinError (GetLastError ());
@@ -2155,7 +2127,7 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h)
 
 #if WINDOWS
 #ifndef PIPE_BUF
-#define PIPE_BUF        512
+#define PIPE_BUF 512
 #endif
 /* Copyright Bob Byrnes  <byrnes <at> curl.com>
    http://permalink.gmane.org/gmane.os.cygwin.patches/2121
@@ -2168,9 +2140,12 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h)
    Note that the return value is either NO_ERROR or GetLastError,
    unlike CreatePipe, which returns a bool for success or failure.  */
 static int
-create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
-                        LPSECURITY_ATTRIBUTES sa_ptr, DWORD psize,
-                        DWORD dwReadMode, DWORD dwWriteMode)
+create_selectable_pipe (PHANDLE read_pipe_ptr,
+                        PHANDLE write_pipe_ptr,
+                        LPSECURITY_ATTRIBUTES sa_ptr,
+                        DWORD psize,
+                        DWORD dwReadMode,
+                        DWORD dwWriteMode)
 {
   /* Default to error. */
   *read_pipe_ptr = *write_pipe_ptr = INVALID_HANDLE_VALUE;
@@ -2191,10 +2166,15 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
   {
     static volatile LONG pipe_unique_id;
 
-    snprintf (pipename, sizeof pipename, "\\\\.\\pipe\\gnunet-%d-%ld",
-              getpid (), InterlockedIncrement ((LONG *) & pipe_unique_id));
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "CreateNamedPipe: name = %s, size = %lu\n",
-         pipename, psize);
+    snprintf (pipename,
+              sizeof pipename,
+              "\\\\.\\pipe\\gnunet-%d-%ld",
+              getpid (),
+              InterlockedIncrement ((LONG *) &pipe_unique_id));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "CreateNamedPipe: name = %s, size = %lu\n",
+         pipename,
+         psize);
     /* Use CreateNamedPipe instead of CreatePipe, because the latter
      * returns a write handle that does not permit FILE_READ_ATTRIBUTES
      * access, on versions of win32 earlier than WinXP SP2.
@@ -2203,10 +2183,15 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
      * It's important to only allow a single instance, to ensure that
      * the pipe was not created earlier by some other process, even if
      * the pid has been reused.  */
-    read_pipe = CreateNamedPipeA (pipename, PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE | dwReadMode, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1,   /* max instances */
-                                  psize,        /* output buffer size */
-                                  psize,        /* input buffer size */
-                                  NMPWAIT_USE_DEFAULT_WAIT, sa_ptr);
+    read_pipe = CreateNamedPipeA (pipename,
+                                  PIPE_ACCESS_INBOUND |
+                                    FILE_FLAG_FIRST_PIPE_INSTANCE | dwReadMode,
+                                  PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
+                                  1, /* max instances */
+                                  psize, /* output buffer size */
+                                  psize, /* input buffer size */
+                                  NMPWAIT_USE_DEFAULT_WAIT,
+                                  sa_ptr);
 
     if (read_pipe != INVALID_HANDLE_VALUE)
     {
@@ -2233,10 +2218,12 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
        * Return an anonymous pipe as the best approximation.  */
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "CreateNamedPipe not implemented, resorting to "
-           "CreatePipe: size = %lu\n", psize);
+           "CreatePipe: size = %lu\n",
+           psize);
       if (CreatePipe (read_pipe_ptr, write_pipe_ptr, sa_ptr, psize))
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "pipe read handle = %p, write handle = %p\n",
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "pipe read handle = %p, write handle = %p\n",
              *read_pipe_ptr,
              *write_pipe_ptr);
         return GNUNET_OK;
@@ -2254,8 +2241,12 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
 
   /* Open the named pipe for writing.
    * Be sure to permit FILE_READ_ATTRIBUTES access.  */
-  write_pipe = CreateFileA (pipename, GENERIC_WRITE | FILE_READ_ATTRIBUTES, 0,  /* share mode */
-                            sa_ptr, OPEN_EXISTING, dwWriteMode, /* flags and attributes */
+  write_pipe = CreateFileA (pipename,
+                            GENERIC_WRITE | FILE_READ_ATTRIBUTES,
+                            0, /* share mode */
+                            sa_ptr,
+                            OPEN_EXISTING,
+                            dwWriteMode, /* flags and attributes */
                             0); /* handle to template file */
 
   if (write_pipe == INVALID_HANDLE_VALUE)
@@ -2287,9 +2278,9 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
  */
 struct GNUNET_DISK_PipeHandle *
 GNUNET_DISK_pipe (int blocking_read,
-                 int blocking_write,
-                 int inherit_read,
-                 int inherit_write)
+                  int blocking_write,
+                  int inherit_read,
+                  int inherit_write)
 {
 #ifndef MINGW
   int fd[2];
@@ -2302,14 +2293,11 @@ GNUNET_DISK_pipe (int blocking_read,
   if (ret == -1)
   {
     eno = errno;
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                 "pipe");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe");
     errno = eno;
     return NULL;
   }
-  return GNUNET_DISK_pipe_from_fd (blocking_read,
-                                  blocking_write,
-                                  fd);
+  return GNUNET_DISK_pipe_from_fd (blocking_read, blocking_write, fd);
 #else
   struct GNUNET_DISK_PipeHandle *p;
   BOOL ret;
@@ -2329,11 +2317,13 @@ GNUNET_DISK_pipe (int blocking_read,
    * Pipes are not seekable, and need no offsets, which is
    * probably why it works for them.
    */
-  ret =
-      create_selectable_pipe (&p->fd[0]->h, &p->fd[1]->h, NULL, 0,
-                              FILE_FLAG_OVERLAPPED,
-                              FILE_FLAG_OVERLAPPED);
-  if (!ret)
+  ret = create_selectable_pipe (&p->fd[0]->h,
+                                &p->fd[1]->h,
+                                NULL,
+                                0,
+                                FILE_FLAG_OVERLAPPED,
+                                FILE_FLAG_OVERLAPPED);
+  if (! ret)
   {
     SetErrnoFromWinError (GetLastError ());
     save_errno = errno;
@@ -2343,9 +2333,13 @@ GNUNET_DISK_pipe (int blocking_read,
     errno = save_errno;
     return NULL;
   }
-  if (!DuplicateHandle
-      (GetCurrentProcess (), p->fd[0]->h, GetCurrentProcess (), &tmp_handle, 0,
-       inherit_read == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS))
+  if (! DuplicateHandle (GetCurrentProcess (),
+                         p->fd[0]->h,
+                         GetCurrentProcess (),
+                         &tmp_handle,
+                         0,
+                         inherit_read == GNUNET_YES ? TRUE : FALSE,
+                         DUPLICATE_SAME_ACCESS))
   {
     SetErrnoFromWinError (GetLastError ());
     save_errno = errno;
@@ -2360,9 +2354,13 @@ GNUNET_DISK_pipe (int blocking_read,
   CloseHandle (p->fd[0]->h);
   p->fd[0]->h = tmp_handle;
 
-  if (!DuplicateHandle
-      (GetCurrentProcess (), p->fd[1]->h, GetCurrentProcess (), &tmp_handle, 0,
-       inherit_write == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS))
+  if (! DuplicateHandle (GetCurrentProcess (),
+                         p->fd[1]->h,
+                         GetCurrentProcess (),
+                         &tmp_handle,
+                         0,
+                         inherit_write == GNUNET_YES ? TRUE : FALSE,
+                         DUPLICATE_SAME_ACCESS))
   {
     SetErrnoFromWinError (GetLastError ());
     save_errno = errno;
@@ -2423,14 +2421,14 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
   {
     p->fd[0] = GNUNET_new (struct GNUNET_DISK_FileHandle);
     p->fd[0]->fd = fd[0];
-    if (!blocking_read)
+    if (! blocking_read)
     {
       flags = fcntl (fd[0], F_GETFL);
       flags |= O_NONBLOCK;
       if (0 > fcntl (fd[0], F_SETFL, flags))
       {
-       ret = -1;
-       eno = errno;
+        ret = -1;
+        eno = errno;
       }
     }
     flags = fcntl (fd[0], F_GETFD);
@@ -2446,14 +2444,14 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
   {
     p->fd[1] = GNUNET_new (struct GNUNET_DISK_FileHandle);
     p->fd[1]->fd = fd[1];
-    if (!blocking_write)
+    if (! blocking_write)
     {
       flags = fcntl (fd[1], F_GETFL);
       flags |= O_NONBLOCK;
       if (0 > fcntl (fd[1], F_SETFL, flags))
       {
-       ret = -1;
-       eno = errno;
+        ret = -1;
+        eno = errno;
       }
     }
     flags = fcntl (fd[1], F_GETFD);
@@ -2663,7 +2661,8 @@ GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p,
  */
 int
 GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh,
-                                   void *dst, size_t dst_len)
+                                   void *dst,
+                                   size_t dst_len)
 {
   if (NULL == fh)
     return GNUNET_SYSERR;
@@ -2689,29 +2688,20 @@ GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh,
  * @return #GNUNET_OK on success
  */
 static int
-purge_cfg_dir (void *cls,
-              const struct GNUNET_CONFIGURATION_Handle *cfg)
+purge_cfg_dir (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *option = cls;
   char *tmpname;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                               "PATHS",
-                                               option,
-                                               &tmpname))
-  {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                               "PATHS",
-                               option);
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", option, &tmpname))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PATHS", option);
     return GNUNET_NO;
   }
-  if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_remove (tmpname))
+  if (GNUNET_SYSERR == GNUNET_DISK_directory_remove (tmpname))
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                              "remove",
-                              tmpname);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "remove", tmpname);
     GNUNET_free (tmpname);
     return GNUNET_OK;
   }
@@ -2728,13 +2718,12 @@ purge_cfg_dir (void *cls,
  * @param option option with the dir name to purge
  */
 void
-GNUNET_DISK_purge_cfg_dir (const char *cfg_filename,
-                           const char *option)
+GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, const char *option)
 {
   GNUNET_break (GNUNET_OK ==
-               GNUNET_CONFIGURATION_parse_and_run (cfg_filename,
-                                                   &purge_cfg_dir,
-                                                   (void *) option));
+                GNUNET_CONFIGURATION_parse_and_run (cfg_filename,
+                                                    &purge_cfg_dir,
+                                                    (void *) option));
 }
 
 
index a16a9a7dd2fdd7c7586d85729cc3ac235af6a375..aa0c2191a9edcedb53f9982f402b5a84ba1df565 100644 (file)
@@ -28,7 +28,8 @@
 /**
  * Timeout for retrying DNS queries.
  */
-#define DNS_RETRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
+#define DNS_RETRANSMIT_DELAY \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
 
 
 /**
@@ -92,7 +93,6 @@ struct GNUNET_DNSSTUB_RequestSocket
    * Number of bytes in @a request.
    */
   size_t request_len;
-
 };
 
 
@@ -149,7 +149,6 @@ struct GNUNET_DNSSTUB_Context
    * Length of @e sockets array.
    */
   unsigned int num_sockets;
-
 };
 
 
@@ -223,13 +222,11 @@ open_socket (int af)
     return NULL;
   }
   sa->sa_family = af;
-  if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret,
-                                              sa,
-                                              alen))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret, sa, alen))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Could not bind to any port: %s\n"),
-               STRERROR (errno));
+                _ ("Could not bind to any port: %s\n"),
+                strerror (errno));
     GNUNET_NETWORK_socket_close (ret);
     return NULL;
   }
@@ -249,7 +246,7 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx)
 {
   struct GNUNET_DNSSTUB_RequestSocket *rs;
 
-  for (unsigned int i=0;i<256;i++)
+  for (unsigned int i = 0; i < 256; i++)
   {
     rs = &ctx->sockets[GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
                                                  ctx->num_sockets)];
@@ -259,9 +256,7 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx)
   if (NULL != rs->rc)
   {
     /* signal "failure" */
-    rs->rc (rs->rc_cls,
-            NULL,
-            0);
+    rs->rc (rs->rc_cls, NULL, 0);
     rs->rc = NULL;
   }
   if (NULL != rs->read_task)
@@ -294,16 +289,14 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx)
  */
 static int
 do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
-            struct GNUNET_NETWORK_Handle *dnsout)
+             struct GNUNET_NETWORK_Handle *dnsout)
 {
   struct GNUNET_DNSSTUB_Context *ctx = rs->ctx;
   ssize_t r;
   int len;
 
 #ifndef MINGW
-  if (0 != ioctl (GNUNET_NETWORK_get_fd (dnsout),
-                  FIONREAD,
-                  &len))
+  if (0 != ioctl (GNUNET_NETWORK_get_fd (dnsout), FIONREAD, &len))
   {
     /* conservative choice: */
     len = UINT16_MAX;
@@ -312,9 +305,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
   /* port the code above? */
   len = UINT16_MAX;
 #endif
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Receiving %d byte DNS reply\n",
-             len);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving %d byte DNS reply\n", len);
   {
     unsigned char buf[len] GNUNET_ALIGN;
     int found;
@@ -323,18 +314,15 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
     struct GNUNET_TUN_DnsHeader *dns;
 
     addrlen = sizeof (addr);
-    memset (&addr,
-            0,
-            sizeof (addr));
+    memset (&addr, 0, sizeof (addr));
     r = GNUNET_NETWORK_socket_recvfrom (dnsout,
-                                       buf,
+                                        buf,
                                         sizeof (buf),
-                                       (struct sockaddr*) &addr,
+                                        (struct sockaddr *) &addr,
                                         &addrlen);
     if (-1 == r)
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                           "recvfrom");
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "recvfrom");
       GNUNET_NETWORK_socket_close (dnsout);
       return GNUNET_SYSERR;
     }
@@ -343,8 +331,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
     {
       if (0 == memcmp (&addr,
                        &ds->ss,
-                       GNUNET_MIN (sizeof (struct sockaddr_storage),
-                                   addrlen)))
+                       GNUNET_MIN (sizeof (struct sockaddr_storage), addrlen)))
       {
         found = GNUNET_YES;
         break;
@@ -353,26 +340,24 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
     if (GNUNET_NO == found)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Received DNS response from server we never asked (ignored)");
+                  "Received DNS response from server we never asked (ignored)");
       return GNUNET_NO;
     }
     if (sizeof (struct GNUNET_TUN_DnsHeader) > (size_t) r)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Received DNS response that is too small (%u bytes)"),
-                 (unsigned int) r);
+                  _ ("Received DNS response that is too small (%u bytes)"),
+                  (unsigned int) r);
       return GNUNET_NO;
     }
     dns = (struct GNUNET_TUN_DnsHeader *) buf;
     if (NULL == rs->rc)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Request timeout or cancelled; ignoring reply\n");
+                  "Request timeout or cancelled; ignoring reply\n");
       return GNUNET_NO;
     }
-    rs->rc (rs->rc_cls,
-            dns,
-            r);
+    rs->rc (rs->rc_cls, dns, r);
   }
   return GNUNET_OK;
 }
@@ -401,17 +386,16 @@ schedule_read (struct GNUNET_DNSSTUB_RequestSocket *rs)
     GNUNET_SCHEDULER_cancel (rs->read_task);
   rset = GNUNET_NETWORK_fdset_create ();
   if (NULL != rs->dnsout4)
-    GNUNET_NETWORK_fdset_set (rset,
-                              rs->dnsout4);
+    GNUNET_NETWORK_fdset_set (rset, rs->dnsout4);
   if (NULL != rs->dnsout6)
-    GNUNET_NETWORK_fdset_set (rset,
-                              rs->dnsout6);
-  rs->read_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                              GNUNET_TIME_UNIT_FOREVER_REL,
-                                              rset,
-                                              NULL,
-                                              &read_response,
-                                               rs);
+    GNUNET_NETWORK_fdset_set (rset, rs->dnsout6);
+  rs->read_task =
+    GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+                                 GNUNET_TIME_UNIT_FOREVER_REL,
+                                 rset,
+                                 NULL,
+                                 &read_response,
+                                 rs);
   GNUNET_NETWORK_fdset_destroy (rset);
 }
 
@@ -430,19 +414,13 @@ read_response (void *cls)
   rs->read_task = NULL;
   tc = GNUNET_SCHEDULER_get_task_context ();
   /* read and process ready sockets */
-  if ( (NULL != rs->dnsout4) &&
-       (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                    rs->dnsout4)) &&
-       (GNUNET_SYSERR ==
-        do_dns_read (rs,
-                     rs->dnsout4)) )
+  if ((NULL != rs->dnsout4) &&
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, rs->dnsout4)) &&
+      (GNUNET_SYSERR == do_dns_read (rs, rs->dnsout4)))
     rs->dnsout4 = NULL;
-  if ( (NULL != rs->dnsout6) &&
-       (GNUNET_NETWORK_fdset_isset (tc->read_ready,
-                                    rs->dnsout6)) &&
-       (GNUNET_SYSERR ==
-        do_dns_read (rs,
-                     rs->dnsout6)) )
+  if ((NULL != rs->dnsout6) &&
+      (GNUNET_NETWORK_fdset_isset (tc->read_ready, rs->dnsout6)) &&
+      (GNUNET_SYSERR == do_dns_read (rs, rs->dnsout6)))
     rs->dnsout6 = NULL;
   /* re-schedule read task */
   schedule_read (rs);
@@ -465,9 +443,8 @@ transmit_query (void *cls)
   struct DnsServer *ds;
   struct GNUNET_NETWORK_Handle *dnsout;
 
-  rs->retry_task = GNUNET_SCHEDULER_add_delayed (ctx->retry_freq,
-                                                 &transmit_query,
-                                                 rs);
+  rs->retry_task =
+    GNUNET_SCHEDULER_add_delayed (ctx->retry_freq, &transmit_query, rs);
   ds = rs->ds_pos;
   rs->ds_pos = ds->next;
   if (NULL == rs->ds_pos)
@@ -499,22 +476,19 @@ transmit_query (void *cls)
                 "Unable to use configure DNS server, skipping\n");
     return;
   }
-  if (GNUNET_SYSERR ==
-      GNUNET_NETWORK_socket_sendto (dnsout,
-                                   rs->request,
-                                   rs->request_len,
-                                    sa,
-                                    salen))
+  if (GNUNET_SYSERR == GNUNET_NETWORK_socket_sendto (dnsout,
+                                                     rs->request,
+                                                     rs->request_len,
+                                                     sa,
+                                                     salen))
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to send DNS request to %s: %s\n"),
-               GNUNET_a2s (sa,
-                            salen),
-                STRERROR (errno));
+                _ ("Failed to send DNS request to %s: %s\n"),
+                GNUNET_a2s (sa, salen),
+                strerror (errno));
   else
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               _("Sent DNS request to %s\n"),
-               GNUNET_a2s (sa,
-                            salen));
+                _ ("Sent DNS request to %s\n"),
+                GNUNET_a2s (sa, salen));
   schedule_read (rs);
 }
 
@@ -531,10 +505,10 @@ transmit_query (void *cls)
  */
 struct GNUNET_DNSSTUB_RequestSocket *
 GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
-                        const void *request,
-                        size_t request_len,
-                        GNUNET_DNSSTUB_ResultCallback rc,
-                        void *rc_cls)
+                        const void *request,
+                        size_t request_len,
+                        GNUNET_DNSSTUB_ResultCallback rc,
+                        void *rc_cls)
 {
   struct GNUNET_DNSSTUB_RequestSocket *rs;
 
@@ -553,11 +527,9 @@ GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
   rs->ds_pos = ctx->dns_head;
   rs->rc = rc;
   rs->rc_cls = rc_cls;
-  rs->request = GNUNET_memdup (request,
-                               request_len);
+  rs->request = GNUNET_memdup (request, request_len);
   rs->request_len = request_len;
-  rs->retry_task = GNUNET_SCHEDULER_add_now (&transmit_query,
-                                             rs);
+  rs->retry_task = GNUNET_SCHEDULER_add_now (&transmit_query, rs);
   return rs;
 }
 
@@ -603,8 +575,8 @@ GNUNET_DNSSTUB_start (unsigned int num_sockets)
   }
   ctx = GNUNET_new (struct GNUNET_DNSSTUB_Context);
   ctx->num_sockets = num_sockets;
-  ctx->sockets = GNUNET_new_array (num_sockets,
-                                   struct GNUNET_DNSSTUB_RequestSocket);
+  ctx->sockets =
+    GNUNET_new_array (num_sockets, struct GNUNET_DNSSTUB_RequestSocket);
   ctx->retry_freq = DNS_RETRANSMIT_DELAY;
   return ctx;
 }
@@ -627,9 +599,7 @@ GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx,
   struct in6_addr i6;
 
   ds = GNUNET_new (struct DnsServer);
-  if (1 == inet_pton (AF_INET,
-                      dns_ip,
-                      &i4))
+  if (1 == inet_pton (AF_INET, dns_ip, &i4))
   {
     struct sockaddr_in *s4 = (struct sockaddr_in *) &ds->ss;
 
@@ -640,9 +610,7 @@ GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx,
     s4->sin_len = (u_char) sizeof (struct sockaddr_in);
 #endif
   }
-  else if (1 == inet_pton (AF_INET6,
-                           dns_ip,
-                           &i6))
+  else if (1 == inet_pton (AF_INET6, dns_ip, &i6))
   {
     struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) &ds->ss;
 
@@ -661,9 +629,7 @@ GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx,
     GNUNET_free (ds);
     return GNUNET_SYSERR;
   }
-  GNUNET_CONTAINER_DLL_insert (ctx->dns_head,
-                               ctx->dns_tail,
-                               ds);
+  GNUNET_CONTAINER_DLL_insert (ctx->dns_head, ctx->dns_tail, ds);
   return GNUNET_OK;
 }
 
@@ -686,23 +652,17 @@ GNUNET_DNSSTUB_add_dns_sa (struct GNUNET_DNSSTUB_Context *ctx,
   switch (sa->sa_family)
   {
   case AF_INET:
-    GNUNET_memcpy (&ds->ss,
-                   sa,
-                   sizeof (struct sockaddr_in));
+    GNUNET_memcpy (&ds->ss, sa, sizeof (struct sockaddr_in));
     break;
   case AF_INET6:
-    GNUNET_memcpy (&ds->ss,
-                   sa,
-                   sizeof (struct sockaddr_in6));
+    GNUNET_memcpy (&ds->ss, sa, sizeof (struct sockaddr_in6));
     break;
   default:
     GNUNET_break (0);
     GNUNET_free (ds);
     return GNUNET_SYSERR;
   }
-  GNUNET_CONTAINER_DLL_insert (ctx->dns_head,
-                               ctx->dns_tail,
-                               ds);
+  GNUNET_CONTAINER_DLL_insert (ctx->dns_head, ctx->dns_tail, ds);
   return GNUNET_OK;
 }
 
@@ -734,12 +694,10 @@ GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx)
 
   while (NULL != (ds = ctx->dns_head))
   {
-    GNUNET_CONTAINER_DLL_remove (ctx->dns_head,
-                                 ctx->dns_tail,
-                                 ds);
+    GNUNET_CONTAINER_DLL_remove (ctx->dns_head, ctx->dns_tail, ds);
     GNUNET_free (ds);
   }
-  for (unsigned int i=0;i<ctx->num_sockets;i++)
+  for (unsigned int i = 0; i < ctx->num_sockets; i++)
     cleanup_rs (&ctx->sockets[i]);
   GNUNET_free (ctx->sockets);
   GNUNET_free (ctx);
index 048f52ee0dc5ea4815cf9c6fb2486c90453d023d..678e2a61f16436cc751f96bb101aa661142dd9d4 100644 (file)
@@ -563,7 +563,7 @@ GN_getopt_internal (int argc,
     if (ambig && ! exact)
     {
       if (GNopterr)
-        FPRINTF (stderr,
+        fprintf (stderr,
                  _ ("%s: option `%s' is ambiguous\n"),
                  argv[0],
                  argv[GNoptind]);
@@ -588,13 +588,13 @@ GN_getopt_internal (int argc,
           {
             if (argv[GNoptind - 1][1] == '-')
               /* --option */
-              FPRINTF (stderr,
+              fprintf (stderr,
                        _ ("%s: option `--%s' does not allow an argument\n"),
                        argv[0],
                        pfound->name);
             else
               /* +option or -option */
-              FPRINTF (stderr,
+              fprintf (stderr,
                        _ ("%s: option `%c%s' does not allow an argument\n"),
                        argv[0],
                        argv[GNoptind - 1][0],
@@ -614,7 +614,7 @@ GN_getopt_internal (int argc,
         {
           if (GNopterr)
           {
-            FPRINTF (stderr,
+            fprintf (stderr,
                      _ ("%s: option `%s' requires an argument\n"),
                      argv[0],
                      argv[GNoptind - 1]);
@@ -645,13 +645,13 @@ GN_getopt_internal (int argc,
       {
         if (argv[GNoptind][1] == '-')
           /* --option */
-          FPRINTF (stderr,
+          fprintf (stderr,
                    _ ("%s: unrecognized option `--%s'\n"),
                    argv[0],
                    nextchar);
         else
           /* +option or -option */
-          FPRINTF (stderr,
+          fprintf (stderr,
                    _ ("%s: unrecognized option `%c%s'\n"),
                    argv[0],
                    argv[GNoptind][0],
@@ -679,9 +679,9 @@ GN_getopt_internal (int argc,
       {
         if (posixly_correct)
           /* 1003.2 specifies the format of this message.  */
-          FPRINTF (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
+          fprintf (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
         else
-          FPRINTF (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
+          fprintf (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
       }
       return '?';
     }
@@ -709,7 +709,7 @@ GN_getopt_internal (int argc,
         if (GNopterr)
         {
           /* 1003.2 specifies the format of this message.  */
-          FPRINTF (stderr,
+          fprintf (stderr,
                    _ ("%s: option requires an argument -- %c\n"),
                    argv[0],
                    c);
@@ -759,7 +759,7 @@ GN_getopt_internal (int argc,
       if (ambig && ! exact)
       {
         if (GNopterr)
-          FPRINTF (stderr,
+          fprintf (stderr,
                    _ ("%s: option `-W %s' is ambiguous\n"),
                    argv[0],
                    argv[GNoptind]);
@@ -779,7 +779,7 @@ GN_getopt_internal (int argc,
           else
           {
             if (GNopterr)
-              FPRINTF (stderr,
+              fprintf (stderr,
                        _ ("%s: option `-W %s' does not allow an argument\n"),
                        argv[0],
                        pfound->name);
@@ -795,7 +795,7 @@ GN_getopt_internal (int argc,
           else
           {
             if (GNopterr)
-              FPRINTF (stderr,
+              fprintf (stderr,
                        _ ("%s: option `%s' requires an argument\n"),
                        argv[0],
                        argv[GNoptind - 1]);
@@ -845,7 +845,7 @@ GN_getopt_internal (int argc,
           if (GNopterr)
           {
             /* 1003.2 specifies the format of this message.  */
-            FPRINTF (stderr,
+            fprintf (stderr,
                      _ ("%s: option requires an argument -- %c\n"),
                      argv[0],
                      c);
@@ -972,7 +972,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
     }
     if (i == count)
     {
-      FPRINTF (stderr, _ ("Use %s to get a list of options.\n"), "--help");
+      fprintf (stderr, _ ("Use %s to get a list of options.\n"), "--help");
       cont = GNUNET_SYSERR;
     }
   }
@@ -983,7 +983,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
      is the only option that was provided */
   if ((NULL != have_exclusive) && (optmatch > 1))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("Option `%s' can't be used with other options.\n"),
              have_exclusive);
     cont = GNUNET_SYSERR;
@@ -995,7 +995,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
     {
       if ((0 == seen[count]) && (allOptions[count].option_mandatory))
       {
-        FPRINTF (stderr,
+        fprintf (stderr,
                  _ ("Missing mandatory option `%s'.\n"),
                  allOptions[count].name);
         cont = GNUNET_SYSERR;
index 80d1037bb6d46a7b65d9dbce8b1f5d643646ebdf..f53441508fce4ebd53e2a1c5d88e62357fa9f2d2 100644 (file)
@@ -184,7 +184,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
 
   if (0 != pd->is_gnu)
     printf ("General help using GNU software: http://www.gnu.org/gethelp/\n");
-  
+
   return GNUNET_NO;
 }
 
@@ -544,9 +544,9 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   char dummy[2];
 
   (void) ctx;
-  if (1 != SSCANF (value, "%llu%1s", val, dummy))
+  if (1 != sscanf (value, "%llu%1s", val, dummy))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
@@ -607,7 +607,7 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   (void) ctx;
   if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (value, val))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass relative time to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
@@ -669,7 +669,7 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   (void) ctx;
   if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (value, val))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass absolute time to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
@@ -732,15 +732,15 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   (void) ctx;
   if ('-' == *value)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ (
                "Your input for the '%s' option has to be a non negative number \n"),
              option);
     return GNUNET_SYSERR;
   }
-  if (1 != SSCANF (value, "%u%1s", val, dummy))
+  if (1 != sscanf (value, "%u%1s", val, dummy))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
@@ -801,16 +801,16 @@ set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   char dummy[2];
 
   (void) ctx;
-  if (1 != SSCANF (value, "%u%1s", &v, dummy))
+  if (1 != sscanf (value, "%u%1s", &v, dummy))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass a number to the `%s' option.\n"),
              option);
     return GNUNET_SYSERR;
   }
   if (v > UINT16_MAX)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _ ("You must pass a number below %u to the `%s' option.\n"),
              (unsigned int) UINT16_MAX,
              option);
index d2253337cd14421fb6d0d78ad7d0097ee05416f0..e7a170b81fb67e2428f10721864569a7db277d64 100644 (file)
@@ -31,7 +31,7 @@
 /**
  * Number of characters a Base32-encoded public key requires.
  */
-#define KEY_STR_LEN sizeof(struct GNUNET_CRYPTO_EddsaPublicKey)*8/5+1
+#define KEY_STR_LEN sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) * 8 / 5 + 1
 
 /**
  * Flag for listing public key.
@@ -91,7 +91,7 @@ create_keys (const char *fn, const char *prefix)
 
   if (NULL == (f = fopen (fn, "w+")))
   {
-    fprintf (stderr, _("Failed to open `%s': %s\n"), fn, STRERROR (errno));
+    fprintf (stderr, _ ("Failed to open `%s': %s\n"), fn, strerror (errno));
     return;
   }
   if (NULL != prefix)
@@ -116,7 +116,7 @@ create_keys (const char *fn, const char *prefix)
        * rest = 5%8 = 5 (bits)
        * mask = ~(2**(8 - 5) - 1) = ~(2**3 - 1) = ~(8 - 1) = ~b111 = b11111000
        */
-      mask = ~ ((int)pow (2, 8 - rest) - 1);
+      mask = ~((int) pow (2, 8 - rest) - 1);
       target_byte = ((unsigned char *) &target_pub)[n] & mask;
     }
     else
@@ -126,21 +126,15 @@ create_keys (const char *fn, const char *prefix)
     }
     s = GNUNET_CRYPTO_eddsa_public_key_to_string (&target_pub);
     fprintf (stderr,
-             _("Generating %u keys like %s, please wait"),
+             _ ("Generating %u keys like %s, please wait"),
              make_keys,
              s);
     GNUNET_free (s);
-    fprintf (stderr,
-             "\nattempt %s [%u, %X]\n",
-             vanity,
-             (unsigned int) n,
-             mask);
+    fprintf (stderr, "\nattempt %s [%u, %X]\n", vanity, (unsigned int) n, mask);
   }
   else
   {
-    fprintf (stderr,
-             _("Generating %u keys, please wait"),
-             make_keys);
+    fprintf (stderr, _ ("Generating %u keys, please wait"), make_keys);
     /* Just so old (debian) versions of GCC calm down with the warnings. */
     n = rest = target_byte = mask = 0;
   }
@@ -150,8 +144,8 @@ create_keys (const char *fn, const char *prefix)
     fprintf (stderr, ".");
     if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create ()))
     {
-       GNUNET_break (0);
-       break;
+      GNUNET_break (0);
+      break;
     }
     if (NULL != prefix)
     {
@@ -176,38 +170,32 @@ create_keys (const char *fn, const char *prefix)
       }
     }
     if (GNUNET_TESTING_HOSTKEYFILESIZE !=
-       fwrite (pk, 1,
-               GNUNET_TESTING_HOSTKEYFILESIZE, f))
+        fwrite (pk, 1, GNUNET_TESTING_HOSTKEYFILESIZE, f))
     {
       fprintf (stderr,
-              _("\nFailed to write to `%s': %s\n"),
-              fn,
-              STRERROR (errno));
+               _ ("\nFailed to write to `%s': %s\n"),
+               fn,
+               strerror (errno));
       GNUNET_free (pk);
       break;
     }
     GNUNET_free (pk);
   }
   if (UINT_MAX == make_keys)
-    fprintf (stderr,
-            _("\nFinished!\n"));
+    fprintf (stderr, _ ("\nFinished!\n"));
   else
-    fprintf (stderr,
-            _("\nError, %u keys not generated\n"),
-             make_keys);
+    fprintf (stderr, _ ("\nError, %u keys not generated\n"), make_keys);
   fclose (f);
 }
 
 
 static void
-print_hex (const char *msg,
-           const void *buf,
-           size_t size)
+print_hex (const char *msg, const void *buf, size_t size)
 {
   printf ("%s: ", msg);
   for (size_t i = 0; i < size; i++)
   {
-    printf ("%02hhx", ((const uint8_t *)buf)[i]);
+    printf ("%02hhx", ((const uint8_t *) buf)[i]);
   }
   printf ("\n");
 }
@@ -230,7 +218,8 @@ print_examples_ecdh ()
   GNUNET_CRYPTO_ecdhe_key_get_public (dh_priv1, dh_pub1);
   GNUNET_CRYPTO_ecdhe_key_get_public (dh_priv2, dh_pub2);
 
-  GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv1, 32, buf, 128));
+  GNUNET_assert (NULL !=
+                 GNUNET_STRINGS_data_to_string (dh_priv1, 32, buf, 128));
   printf ("ECDHE key 1:\n");
   printf ("private: %s\n", buf);
   print_hex ("private(hex)", dh_priv1, sizeof *dh_priv1);
@@ -238,7 +227,8 @@ print_examples_ecdh ()
   printf ("public: %s\n", buf);
   print_hex ("public(hex)", dh_pub1, sizeof *dh_pub1);
 
-  GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv2, 32, buf, 128));
+  GNUNET_assert (NULL !=
+                 GNUNET_STRINGS_data_to_string (dh_priv2, 32, buf, 128));
   printf ("ECDHE key 2:\n");
   printf ("private: %s\n", buf);
   print_hex ("private(hex)", dh_priv2, sizeof *dh_priv2);
@@ -246,7 +236,8 @@ print_examples_ecdh ()
   printf ("public: %s\n", buf);
   print_hex ("public(hex)", dh_pub2, sizeof *dh_pub2);
 
-  GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecc_ecdh (dh_priv1, dh_pub2, &hash));
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CRYPTO_ecc_ecdh (dh_priv1, dh_pub2, &hash));
   GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (&hash, 64, buf, 128));
   printf ("ECDH shared secret: %s\n", buf);
 
@@ -282,56 +273,39 @@ print_key (const char *filename)
   unsigned int c;
   ssize_t sret;
 
-  if (GNUNET_YES !=
-      GNUNET_DISK_file_test (filename))
+  if (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
-    fprintf (stderr,
-             _("Hostkeys file `%s' not found\n"),
-             filename);
+    fprintf (stderr, _ ("Hostkeys file `%s' not found\n"), filename);
     return;
   }
 
   /* Check hostkey file size, read entire thing into memory */
   if (GNUNET_OK !=
-      GNUNET_DISK_file_size (filename,
-                            &fs,
-                            GNUNET_YES,
-                            GNUNET_YES))
+      GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
     fs = 0;
   if (0 == fs)
   {
-    fprintf (stderr,
-             _("Hostkeys file `%s' is empty\n"),
-             filename);
-    return;       /* File is empty */
+    fprintf (stderr, _ ("Hostkeys file `%s' is empty\n"), filename);
+    return; /* File is empty */
   }
   if (0 != (fs % GNUNET_TESTING_HOSTKEYFILESIZE))
   {
-    fprintf (stderr,
-             _("Incorrect hostkey file format: %s\n"),
-             filename);
+    fprintf (stderr, _ ("Incorrect hostkey file format: %s\n"), filename);
     return;
   }
   fd = GNUNET_DISK_file_open (filename,
-                             GNUNET_DISK_OPEN_READ,
-                             GNUNET_DISK_PERM_NONE);
+                              GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                             "open",
-                             filename);
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
     return;
   }
   hostkeys_data = GNUNET_malloc (fs);
-  sret = GNUNET_DISK_file_read (fd,
-                               hostkeys_data,
-                               fs);
-  if ( (sret < 0) ||
-       (fs != (size_t) sret) )
+  sret = GNUNET_DISK_file_read (fd, hostkeys_data, fs);
+  if ((sret < 0) || (fs != (size_t) sret))
   {
-    fprintf (stderr,
-             _("Could not read hostkey file: %s\n"),
-             filename);
+    fprintf (stderr, _ ("Could not read hostkey file: %s\n"), filename);
     GNUNET_free (hostkeys_data);
     GNUNET_DISK_file_close (fd);
     return;
@@ -344,8 +318,8 @@ print_key (const char *filename)
   for (c = 0; (c < total_hostkeys) && (c < list_keys_count); c++)
   {
     GNUNET_memcpy (&private_key,
-            hostkeys_data + (c * GNUNET_TESTING_HOSTKEYFILESIZE),
-            GNUNET_TESTING_HOSTKEYFILESIZE);
+                   hostkeys_data + (c * GNUNET_TESTING_HOSTKEYFILESIZE),
+                   GNUNET_TESTING_HOSTKEYFILESIZE);
     GNUNET_CRYPTO_eddsa_key_get_public (&private_key, &public_key);
     hostkey_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&public_key);
     if (NULL != hostkey_str)
@@ -377,7 +351,7 @@ run (void *cls,
   (void) cls;
   (void) cfgfile;
   (void) cfg;
-  
+
   if (print_examples_flag)
   {
     print_examples ();
@@ -385,9 +359,7 @@ run (void *cls,
   }
   if (NULL == args[0])
   {
-    FPRINTF (stderr,
-             "%s",
-             _("No hostkey file specified on command line\n"));
+    fprintf (stderr, "%s", _ ("No hostkey file specified on command line\n"));
     return;
   }
   if (list_keys)
@@ -407,12 +379,12 @@ run (void *cls,
     struct GNUNET_CRYPTO_EddsaPrivateKey pk;
     struct GNUNET_CRYPTO_EddsaPublicKey pub;
 
-    keyfile = GNUNET_DISK_file_open (args[0], GNUNET_DISK_OPEN_READ,
+    keyfile = GNUNET_DISK_file_open (args[0],
+                                     GNUNET_DISK_OPEN_READ,
                                      GNUNET_DISK_PERM_NONE);
     if (NULL == keyfile)
       return;
-    while (sizeof (pk) ==
-          GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk)))
+    while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk)))
     {
       GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub);
       if (print_public_key_hex)
@@ -422,19 +394,18 @@ run (void *cls,
       else if (print_public_key)
       {
         str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
-        FPRINTF (stdout, "%s\n", str);
+        fprintf (stdout, "%s\n", str);
         GNUNET_free (str);
       }
       else if (print_private_key)
       {
         str = GNUNET_CRYPTO_eddsa_private_key_to_string (&pk);
-        FPRINTF (stdout, "%s\n", str);
+        fprintf (stdout, "%s\n", str);
         GNUNET_free (str);
       }
     }
     GNUNET_DISK_file_close (keyfile);
   }
-
 }
 
 
@@ -446,59 +417,66 @@ run (void *cls,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('i',
-                               "iterate",
-                               gettext_noop ("list keys included in a file (for testing)"),
-                               &list_keys),
-    GNUNET_GETOPT_option_uint ('e',
-                               "end=",
-                               "COUNT",
-                               gettext_noop ("number of keys to list included in a file (for testing)"),
-                               &list_keys_count),
-    GNUNET_GETOPT_option_uint ('g',
-                               "generate-keys",
-                               "COUNT",
-                               gettext_noop ("create COUNT public-private key pairs (for testing)"),
-                               &make_keys),
-    GNUNET_GETOPT_option_flag ('p',
-                               "print-public-key",
-                               gettext_noop ("print the public key in ASCII format"),
-                               &print_public_key),
-    GNUNET_GETOPT_option_flag ('P',
-                               "print-private-key",
-                               gettext_noop ("print the private key in ASCII format"),
-                               &print_private_key),
-    GNUNET_GETOPT_option_flag ('x',
-                               "print-hex",
-                               gettext_noop ("print the public key in HEX format"),
-                               &print_public_key_hex),
-    GNUNET_GETOPT_option_flag ('E',
-                               "examples",
-                               gettext_noop ("print examples of ECC operations (used for compatibility testing)"),
-                               &print_examples_flag),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('i',
+                                "iterate",
+                                gettext_noop (
+                                  "list keys included in a file (for testing)"),
+                                &list_keys),
+     GNUNET_GETOPT_option_uint (
+       'e',
+       "end=",
+       "COUNT",
+       gettext_noop ("number of keys to list included in a file (for testing)"),
+       &list_keys_count),
+     GNUNET_GETOPT_option_uint (
+       'g',
+       "generate-keys",
+       "COUNT",
+       gettext_noop ("create COUNT public-private key pairs (for testing)"),
+       &make_keys),
+     GNUNET_GETOPT_option_flag ('p',
+                                "print-public-key",
+                                gettext_noop (
+                                  "print the public key in ASCII format"),
+                                &print_public_key),
+     GNUNET_GETOPT_option_flag ('P',
+                                "print-private-key",
+                                gettext_noop (
+                                  "print the private key in ASCII format"),
+                                &print_private_key),
+     GNUNET_GETOPT_option_flag ('x',
+                                "print-hex",
+                                gettext_noop (
+                                  "print the public key in HEX format"),
+                                &print_public_key_hex),
+     GNUNET_GETOPT_option_flag (
+       'E',
+       "examples",
+       gettext_noop (
+         "print examples of ECC operations (used for compatibility testing)"),
+       &print_examples_flag),
+     GNUNET_GETOPT_OPTION_END};
   int ret;
 
   list_keys_count = UINT32_MAX;
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                    &argc, &argv))
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc,
+         GNUNET_PROGRAM_run (argc,
                              argv,
                              "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]",
-                            gettext_noop ("Manipulate GNUnet private ECC key files"),
-                            options,
+                             gettext_noop (
+                               "Manipulate GNUnet private ECC key files"),
+                             options,
                              &run,
-                             NULL)) ? 0 : 1;
-  GNUNET_free ((void*) argv);
+                             NULL))
+          ? 0
+          : 1;
+  GNUNET_free ((void *) argv);
   return ret;
 }
 
index e5d58b4b65a939503a5ad61d438aa351d0ff8794..3aba5fb1e9dfc01214c6083400ae1203f85983aa 100644 (file)
@@ -49,7 +49,7 @@ print_hostname (void *cls,
   (void) cls;
   if (NULL == hostname)
     return;
-  FPRINTF (stdout,
+  fprintf (stdout,
           "%s\n",
           hostname);
 }
@@ -70,7 +70,7 @@ print_sockaddr (void *cls,
   (void) cls;
   if (NULL == addr)
     return;
-  FPRINTF (stdout,
+  fprintf (stdout,
           "%s\n",
           GNUNET_a2s (addr,
                       addrlen));
index f4149a39832564f67c03aa28b4302d2029e4de8e..6f9690c99bb5ecb07ce14a7a1215b3bdba60ca67 100644 (file)
@@ -144,7 +144,7 @@ find_proof (void *cls)
     if (nse_work_required <= count_leading_zeroes (&result))
     {
       proof = counter;
-      FPRINTF (stdout,
+      fprintf (stdout,
                "Proof of work found: %llu!\n",
                (unsigned long long) proof);
       GNUNET_SCHEDULER_shutdown ();
@@ -236,7 +236,7 @@ run (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Private Key file: %s\n", pkfn);
   if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create_from_file (pkfn)))
   {
-    FPRINTF (stderr, _ ("Loading hostkey from `%s' failed.\n"), pkfn);
+    fprintf (stderr, _ ("Loading hostkey from `%s' failed.\n"), pkfn);
     GNUNET_free (pkfn);
     return;
   }
index 7eb2ce6d941953ba022d9391d5001ec412f3620f..aa452d22bb01b9719a5f8c44fdbcb1d3be25f465 100644 (file)
@@ -70,7 +70,6 @@ struct GNUNET_HELPER_SendHandle
    * Current write position.
    */
   unsigned int wpos;
-
 };
 
 
@@ -177,17 +176,14 @@ struct GNUNET_HELPER_Handle
  * @return #GNUNET_OK on success; #GNUNET_SYSERR on error
  */
 int
-GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h,
-                   int soft_kill)
+GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill)
 {
   struct GNUNET_HELPER_SendHandle *sh;
   int ret;
 
   while (NULL != (sh = h->sh_head))
   {
-    GNUNET_CONTAINER_DLL_remove (h->sh_head,
-                                h->sh_tail,
-                                sh);
+    GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh);
     if (NULL != sh->cont)
       sh->cont (sh->cont_cls, GNUNET_NO);
     GNUNET_free (sh);
@@ -264,19 +260,14 @@ GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h)
   }
   while (NULL != (sh = h->sh_head))
   {
-    GNUNET_CONTAINER_DLL_remove (h->sh_head,
-                                h->sh_tail,
-                                sh);
+    GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh);
     if (NULL != sh->cont)
       sh->cont (sh->cont_cls, GNUNET_NO);
     GNUNET_free (sh);
   }
   /* purge MST buffer */
   if (NULL != h->mst)
-    (void) GNUNET_MST_from_buffer (h->mst,
-                                   NULL, 0,
-                                   GNUNET_YES,
-                                   GNUNET_NO);
+    (void) GNUNET_MST_from_buffer (h->mst, NULL, 0, GNUNET_YES, GNUNET_NO);
   return ret;
 }
 
@@ -289,8 +280,7 @@ GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h)
  *          stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper
  */
 static void
-stop_helper (struct GNUNET_HELPER_Handle *h,
-            int soft_kill)
+stop_helper (struct GNUNET_HELPER_Handle *h, int soft_kill)
 {
   if (NULL != h->restart_task)
   {
@@ -332,9 +322,9 @@ helper_read (void *cls)
   {
     /* On read-error, restart the helper */
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Error reading from `%s': %s\n"),
-               h->binary_name,
-               STRERROR (errno));
+                _ ("Error reading from `%s': %s\n"),
+                h->binary_name,
+                strerror (errno));
     if (NULL != h->exp_cb)
     {
       h->exp_cb (h->cb_cls);
@@ -343,9 +333,11 @@ helper_read (void *cls)
     }
     stop_helper (h, GNUNET_NO);
     /* Restart the helper */
-    h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
-                                                                                  h->retry_back_off),
-                                                   &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
   if (0 == t)
@@ -353,8 +345,8 @@ helper_read (void *cls)
     /* this happens if the helper is shut down via a
        signal, so it is not a "hard" error */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Got 0 bytes from helper `%s' (EOF)\n",
-               h->binary_name);
+                "Got 0 bytes from helper `%s' (EOF)\n",
+                h->binary_name);
     if (NULL != h->exp_cb)
     {
       h->exp_cb (h->cb_cls);
@@ -363,28 +355,27 @@ helper_read (void *cls)
     }
     stop_helper (h, GNUNET_NO);
     /* Restart the helper */
-    h->restart_task
-      = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
-                                                                  h->retry_back_off),
-                                    &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Got %u bytes from helper `%s'\n",
-             (unsigned int) t,
-             h->binary_name);
+              "Got %u bytes from helper `%s'\n",
+              (unsigned int) t,
+              h->binary_name);
   h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                h->fh_from_helper,
-                                                &helper_read, h);
+                                                 h->fh_from_helper,
+                                                 &helper_read,
+                                                 h);
   if (GNUNET_SYSERR ==
-      GNUNET_MST_from_buffer (h->mst,
-                              buf, t,
-                              GNUNET_NO,
-                              GNUNET_NO))
+      GNUNET_MST_from_buffer (h->mst, buf, t, GNUNET_NO, GNUNET_NO))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to parse inbound message from helper `%s'\n"),
-               h->binary_name);
+                _ ("Failed to parse inbound message from helper `%s'\n"),
+                h->binary_name);
     if (NULL != h->exp_cb)
     {
       h->exp_cb (h->cb_cls);
@@ -393,9 +384,11 @@ helper_read (void *cls)
     }
     stop_helper (h, GNUNET_NO);
     /* Restart the helper */
-    h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
-                                                                                 h->retry_back_off),
-                                                   &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
 }
@@ -409,46 +402,53 @@ helper_read (void *cls)
 static void
 start_helper (struct GNUNET_HELPER_Handle *h)
 {
-  h->helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
-  h->helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
-  if ( (h->helper_in == NULL) || (h->helper_out == NULL))
+  h->helper_in =
+    GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
+  h->helper_out =
+    GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
+  if ((h->helper_in == NULL) || (h->helper_out == NULL))
   {
     /* out of file descriptors? try again later... */
     stop_helper (h, GNUNET_NO);
-    h->restart_task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
-                                                                 h->retry_back_off),
-                                   &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting HELPER process `%s'\n",
-             h->binary_name);
+              "Starting HELPER process `%s'\n",
+              h->binary_name);
   h->fh_from_helper =
-      GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ);
+    GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ);
   h->fh_to_helper =
-      GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
-  h->helper_proc =
-    GNUNET_OS_start_process_vap (h->with_control_pipe, GNUNET_OS_INHERIT_STD_ERR,
-                                h->helper_in, h->helper_out, NULL,
-                                h->binary_name,
-                                h->binary_argv);
+    GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
+  h->helper_proc = GNUNET_OS_start_process_vap (h->with_control_pipe,
+                                                GNUNET_OS_INHERIT_STD_ERR,
+                                                h->helper_in,
+                                                h->helper_out,
+                                                NULL,
+                                                h->binary_name,
+                                                h->binary_argv);
   if (NULL == h->helper_proc)
   {
     /* failed to start process? try again later... */
     stop_helper (h, GNUNET_NO);
-    h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
-                                                                                 h->retry_back_off),
-                                                   &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
   GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE);
   GNUNET_DISK_pipe_close_end (h->helper_in, GNUNET_DISK_PIPE_END_READ);
   if (NULL != h->mst)
     h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                  h->fh_from_helper,
-                                                  &helper_read,
-                                                  h);
+                                                   h->fh_from_helper,
+                                                   &helper_read,
+                                                   h);
 }
 
 
@@ -460,7 +460,7 @@ start_helper (struct GNUNET_HELPER_Handle *h)
 static void
 restart_task (void *cls)
 {
-  struct GNUNET_HELPER_Handle*h = cls;
+  struct GNUNET_HELPER_Handle *h = cls;
 
   h->restart_task = NULL;
   h->retry_back_off++;
@@ -489,11 +489,11 @@ restart_task (void *cls)
  */
 struct GNUNET_HELPER_Handle *
 GNUNET_HELPER_start (int with_control_pipe,
-                    const char *binary_name,
-                    char *const binary_argv[],
-                    GNUNET_MessageTokenizerCallback cb,
-                    GNUNET_HELPER_ExceptionCallback exp_cb,
-                    void *cb_cls)
+                     const char *binary_name,
+                     char *const binary_argv[],
+                     GNUNET_MessageTokenizerCallback cb,
+                     GNUNET_HELPER_ExceptionCallback exp_cb,
+                     void *cb_cls)
 {
   struct GNUNET_HELPER_Handle *h;
   unsigned int c;
@@ -505,15 +505,15 @@ GNUNET_HELPER_start (int with_control_pipe,
     h->binary_name = GNUNET_OS_get_libexec_binary_path (binary_name);
   else
     h->binary_name = GNUNET_strdup (binary_name);
-  for (c = 0; NULL != binary_argv[c]; c++);
+  for (c = 0; NULL != binary_argv[c]; c++)
+    ;
   h->binary_argv = GNUNET_malloc (sizeof (char *) * (c + 1));
   for (c = 0; NULL != binary_argv[c]; c++)
     h->binary_argv[c] = GNUNET_strdup (binary_argv[c]);
   h->binary_argv[c] = NULL;
   h->cb_cls = cb_cls;
   if (NULL != cb)
-    h->mst = GNUNET_MST_create (cb,
-                                h->cb_cls);
+    h->mst = GNUNET_MST_create (cb, h->cb_cls);
   h->exp_cb = exp_cb;
   h->retry_back_off = 0;
   start_helper (h);
@@ -541,9 +541,7 @@ GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h)
   GNUNET_assert (NULL == h->restart_task);
   while (NULL != (sh = h->sh_head))
   {
-    GNUNET_CONTAINER_DLL_remove (h->sh_head,
-                                h->sh_tail,
-                                sh);
+    GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh);
     if (NULL != sh->cont)
       sh->cont (sh->cont_cls, GNUNET_SYSERR);
     GNUNET_free (sh);
@@ -566,8 +564,7 @@ GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h)
  *          stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper
  */
 void
-GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h,
-                   int soft_kill)
+GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill)
 {
   h->exp_cb = NULL;
   stop_helper (h, soft_kill);
@@ -591,21 +588,20 @@ helper_write (void *cls)
   h->write_task = NULL;
   if (NULL == (sh = h->sh_head))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Helper write had no work!\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Helper write had no work!\n");
     return; /* how did this happen? */
   }
-  buf = (const char*) sh->msg;
+  buf = (const char *) sh->msg;
   t = GNUNET_DISK_file_write (h->fh_to_helper,
-                             &buf[sh->wpos],
-                             ntohs (sh->msg->size) - sh->wpos);
+                              &buf[sh->wpos],
+                              ntohs (sh->msg->size) - sh->wpos);
   if (-1 == t)
   {
     /* On write-error, restart the helper */
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Error writing to `%s': %s\n"),
-               h->binary_name,
-               STRERROR (errno));
+                _ ("Error writing to `%s': %s\n"),
+                h->binary_name,
+                strerror (errno));
     if (NULL != h->exp_cb)
     {
       h->exp_cb (h->cb_cls);
@@ -613,33 +609,34 @@ helper_write (void *cls)
       return;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Stopping and restarting helper task!\n");
+                "Stopping and restarting helper task!\n");
     stop_helper (h, GNUNET_NO);
     /* Restart the helper */
-    h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
-                                                                                 h->retry_back_off),
-                                                   &restart_task, h);
+    h->restart_task = GNUNET_SCHEDULER_add_delayed (
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                     h->retry_back_off),
+      &restart_task,
+      h);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Transmitted %u bytes to %s\n",
-             (unsigned int) t,
-             h->binary_name);
+              "Transmitted %u bytes to %s\n",
+              (unsigned int) t,
+              h->binary_name);
   sh->wpos += t;
   if (sh->wpos == ntohs (sh->msg->size))
   {
-    GNUNET_CONTAINER_DLL_remove (h->sh_head,
-                                h->sh_tail,
-                                sh);
+    GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh);
     if (NULL != sh->cont)
       sh->cont (sh->cont_cls, GNUNET_YES);
     GNUNET_free (sh);
   }
   if (NULL != h->sh_head)
-    h->write_task = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                    h->fh_to_helper,
-                                                    &helper_write,
-                                                    h);
+    h->write_task =
+      GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                       h->fh_to_helper,
+                                       &helper_write,
+                                       h);
 }
 
 
@@ -658,34 +655,32 @@ helper_write (void *cls)
  */
 struct GNUNET_HELPER_SendHandle *
 GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h,
-                   const struct GNUNET_MessageHeader *msg,
-                   int can_drop,
-                   GNUNET_HELPER_Continuation cont,
-                   void *cont_cls)
+                    const struct GNUNET_MessageHeader *msg,
+                    int can_drop,
+                    GNUNET_HELPER_Continuation cont,
+                    void *cont_cls)
 {
   struct GNUNET_HELPER_SendHandle *sh;
   uint16_t mlen;
 
   if (NULL == h->fh_to_helper)
     return NULL;
-  if ( (GNUNET_YES == can_drop) &&
-       (NULL != h->sh_head) )
+  if ((GNUNET_YES == can_drop) && (NULL != h->sh_head))
     return NULL;
   mlen = ntohs (msg->size);
   sh = GNUNET_malloc (sizeof (struct GNUNET_HELPER_SendHandle) + mlen);
-  sh->msg = (const struct GNUNET_MessageHeader*) &sh[1];
+  sh->msg = (const struct GNUNET_MessageHeader *) &sh[1];
   GNUNET_memcpy (&sh[1], msg, mlen);
   sh->h = h;
   sh->cont = cont;
   sh->cont_cls = cont_cls;
-  GNUNET_CONTAINER_DLL_insert_tail (h->sh_head,
-                                   h->sh_tail,
-                                   sh);
+  GNUNET_CONTAINER_DLL_insert_tail (h->sh_head, h->sh_tail, sh);
   if (NULL == h->write_task)
-    h->write_task = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                    h->fh_to_helper,
-                                                    &helper_write,
-                                                    h);
+    h->write_task =
+      GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                       h->fh_to_helper,
+                                       &helper_write,
+                                       h);
 
   return sh;
 }
index 8dacd431d4b741ae700da9afa9f5daff961d6fc8..3e5a998119c5a5d9c075492042224c1adec7ce8b 100644 (file)
@@ -107,7 +107,7 @@ GNUNET_OS_project_data_get ()
   {
     char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
     if (NULL != path)
-      BINDTEXTDOMAIN (PACKAGE, path);
+      bindtextdomain (PACKAGE, path);
     GNUNET_free (path);
     gettextinit = 1;
   }
@@ -127,7 +127,7 @@ GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd)
   {
     char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
     if (NULL != path)
-      BINDTEXTDOMAIN (PACKAGE, path);
+      bindtextdomain (PACKAGE, path);
     GNUNET_free (path);
     gettextinit = 1;
   }
@@ -152,7 +152,7 @@ get_path_from_proc_maps ()
   char *lgu;
 
   GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ());
-  if (NULL == (f = FOPEN (fn, "r")))
+  if (NULL == (f = fopen (fn, "r")))
     return NULL;
   while (NULL != fgets (line, sizeof (line), f))
   {
@@ -162,11 +162,11 @@ get_path_from_proc_maps ()
         (NULL != (lgu = strstr (dir, current_pd->libname))))
     {
       lgu[0] = '\0';
-      FCLOSE (f);
+      fclose (f);
       return GNUNET_strdup (dir);
     }
   }
-  FCLOSE (f);
+  fclose (f);
   return NULL;
 }
 
@@ -666,7 +666,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
       {
         GNUNET_asprintf (&dirname,
                          DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
-                         "%s" DIR_SEPARATOR_STR,
+                                           "%s" DIR_SEPARATOR_STR,
                          current_pd->project_dirname);
         GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
       }
@@ -674,7 +674,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
       {
         GNUNET_asprintf (&dirname,
                          DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
-                         "%s" DIR_SEPARATOR_STR,
+                                           "%s" DIR_SEPARATOR_STR,
                          current_pd->project_dirname);
         GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
       }
@@ -696,22 +696,22 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
   case GNUNET_OS_IPK_DATADIR:
     GNUNET_asprintf (&dirname,
                      DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
-                     "%s" DIR_SEPARATOR_STR,
+                                       "%s" DIR_SEPARATOR_STR,
                      current_pd->project_dirname);
     break;
   case GNUNET_OS_IPK_LOCALEDIR:
     dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
-                             "locale" DIR_SEPARATOR_STR);
+                                               "locale" DIR_SEPARATOR_STR);
     break;
   case GNUNET_OS_IPK_ICONDIR:
     dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
-                             "icons" DIR_SEPARATOR_STR);
+                                               "icons" DIR_SEPARATOR_STR);
     break;
   case GNUNET_OS_IPK_DOCDIR:
     GNUNET_asprintf (&dirname,
                      DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
-                     "doc" DIR_SEPARATOR_STR
-                     "%s" DIR_SEPARATOR_STR,
+                                       "doc" DIR_SEPARATOR_STR
+                                       "%s" DIR_SEPARATOR_STR,
                      current_pd->project_dirname);
     break;
   case GNUNET_OS_IPK_LIBEXECDIR:
@@ -719,7 +719,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
     {
       GNUNET_asprintf (&dirname,
                        DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
-                       "libexec" DIR_SEPARATOR_STR,
+                                         "libexec" DIR_SEPARATOR_STR,
                        current_pd->project_dirname);
       GNUNET_asprintf (&tmp,
                        "%s%s%s%s",
@@ -740,8 +740,8 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
       {
         GNUNET_asprintf (&dirname,
                          DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
-                         "%s" DIR_SEPARATOR_STR
-                         "libexec" DIR_SEPARATOR_STR,
+                                           "%s" DIR_SEPARATOR_STR
+                                           "libexec" DIR_SEPARATOR_STR,
                          current_pd->project_dirname);
         GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
       }
@@ -749,8 +749,8 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
       {
         GNUNET_asprintf (&dirname,
                          DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
-                         "%s" DIR_SEPARATOR_STR
-                         "libexec" DIR_SEPARATOR_STR,
+                                           "%s" DIR_SEPARATOR_STR
+                                           "libexec" DIR_SEPARATOR_STR,
                          current_pd->project_dirname);
         GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
       }
@@ -766,7 +766,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
     }
     GNUNET_asprintf (&dirname,
                      DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
-                     "libexec" DIR_SEPARATOR_STR,
+                                       "libexec" DIR_SEPARATOR_STR,
                      current_pd->project_dirname);
     break;
   default:
@@ -844,14 +844,14 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
                                            "PATHS",
                                            "SUID_BINARY_PATH",
                                            &path);
-  if ((NULL == path)||(0 == strlen (path)))
+  if ((NULL == path) || (0 == strlen (path)))
     return GNUNET_OS_get_libexec_binary_path (progname);
   path_len = strlen (path);
   GNUNET_asprintf (&binary,
                    "%s%s%s",
                    path,
                    (path[path_len - 1] == DIR_SEPARATOR) ? ""
-                   : DIR_SEPARATOR_STR,
+                                                         : DIR_SEPARATOR_STR,
                    progname);
   cache = path;
   return binary;
@@ -926,7 +926,7 @@ GNUNET_OS_check_helper_binary (const char *binary,
          binary);
     return GNUNET_SYSERR;
   }
-  if (0 != ACCESS (p, X_OK))
+  if (0 != access (p, X_OK))
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", p);
     GNUNET_free (p);
@@ -940,7 +940,7 @@ GNUNET_OS_check_helper_binary (const char *binary,
     return GNUNET_YES;
   }
 #endif
-  if (0 != STAT (p, &statbuf))
+  if (0 != stat (p, &statbuf))
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", p);
     GNUNET_free (p);
@@ -973,16 +973,16 @@ GNUNET_OS_check_helper_binary (const char *binary,
 
     // Start the child process.
     if (! (CreateProcess (
-             p, // current windows (2k3 and up can handle / instead of \ in paths))
-             parameters, // execute dryrun/priviliege checking mode
-             NULL, // Process handle not inheritable
-             NULL, // Thread handle not inheritable
-             FALSE, // Set handle inheritance to FALSE
-             CREATE_DEFAULT_ERROR_MODE, // No creation flags
-             NULL, // Use parent's environment block
-             NULL, // Use parent's starting directory
-             &start, // Pointer to STARTUPINFO structure
-             &proc) // Pointer to PROCESS_INFORMATION structure
+          p, // current windows (2k3 and up can handle / instead of \ in paths))
+          parameters, // execute dryrun/priviliege checking mode
+          NULL, // Process handle not inheritable
+          NULL, // Thread handle not inheritable
+          FALSE, // Set handle inheritance to FALSE
+          CREATE_DEFAULT_ERROR_MODE, // No creation flags
+          NULL, // Use parent's environment block
+          NULL, // Use parent's starting directory
+          &start, // Pointer to STARTUPINFO structure
+          &proc) // Pointer to PROCESS_INFORMATION structure
            ))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
index 03d4bde9e12956e51079d96ea6f34d3f426e2882..17baa0df8af7f7d0bce574337dd17e76710c56fb 100644 (file)
 #include "disk.h"
 #include <unistr.h>
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-os-priority", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-os-priority", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-os-priority", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-os-priority", syscall)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-os-priority", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util-os-priority", syscall, filename)
 
 #define GNUNET_OS_CONTROL_PIPE "GNUNET_OS_CONTROL_PIPE"
 
@@ -107,16 +109,12 @@ parent_control_handler (void *cls)
   ssize_t ret;
 
   pch = NULL;
-  ret = GNUNET_DISK_file_read (control_pipe,
-                              &sig,
-                              sizeof (sig));
+  ret = GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig));
   if (sizeof (sig) != ret)
   {
     if (-1 == ret)
-      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                   "GNUNET_DISK_file_read");
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Closing control pipe\n");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing control pipe\n");
     GNUNET_DISK_file_close (control_pipe);
     control_pipe = NULL;
     GNUNET_SCHEDULER_cancel (spch);
@@ -124,16 +122,15 @@ parent_control_handler (void *cls)
     return;
   }
   pipe_fd = getenv (GNUNET_OS_CONTROL_PIPE);
-  GNUNET_assert ( (NULL == pipe_fd) ||
-                 (strlen (pipe_fd) <= 0) );
+  GNUNET_assert ((NULL == pipe_fd) || (strlen (pipe_fd) <= 0));
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Got control code %d from parent via pipe %s\n",
        sig,
        pipe_fd);
   pch = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       control_pipe,
-                                       &parent_control_handler,
-                                       control_pipe);
+                                        control_pipe,
+                                        &parent_control_handler,
+                                        control_pipe);
   GNUNET_SIGNAL_raise ((int) sig);
 }
 
@@ -162,10 +159,10 @@ GNUNET_OS_install_parent_control_handler (void *cls)
     return;
   }
   env_buf = getenv (GNUNET_OS_CONTROL_PIPE);
-  if ( (NULL == env_buf) || (strlen (env_buf) <= 0) )
+  if ((NULL == env_buf) || (strlen (env_buf) <= 0))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Not installing a handler because $%s is empty\n",
+         "Not installing a handler because $%s is empty\n",
          GNUNET_OS_CONTROL_PIPE);
     putenv (GNUNET_OS_CONTROL_PIPE "=");
     return;
@@ -174,35 +171,32 @@ GNUNET_OS_install_parent_control_handler (void *cls)
   pipe_fd = strtoull (env_buf, &env_buf_end, 16);
   if ((0 != errno) || (env_buf == env_buf_end))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                      "strtoull",
-                      env_buf);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "strtoull", env_buf);
     putenv (GNUNET_OS_CONTROL_PIPE "=");
     return;
   }
-#if !defined (WINDOWS)
+#if ! defined(WINDOWS)
   if (pipe_fd >= FD_SETSIZE)
 #else
-  if ((FILE_TYPE_UNKNOWN == GetFileType ((HANDLE) (uintptr_t) pipe_fd))
-      && (0 != GetLastError ()))
+  if ((FILE_TYPE_UNKNOWN == GetFileType ((HANDLE) (uintptr_t) pipe_fd)) &&
+      (0 != GetLastError ()))
 #endif
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "GNUNET_OS_CONTROL_PIPE `%s' contains garbage?\n",
-        env_buf);
+         env_buf);
     putenv (GNUNET_OS_CONTROL_PIPE "=");
     return;
   }
 #if WINDOWS
-  control_pipe = GNUNET_DISK_get_handle_from_w32_handle ((HANDLE) (uintptr_t) pipe_fd);
+  control_pipe =
+    GNUNET_DISK_get_handle_from_w32_handle ((HANDLE) (uintptr_t) pipe_fd);
 #else
   control_pipe = GNUNET_DISK_get_handle_from_int_fd ((int) pipe_fd);
 #endif
   if (NULL == control_pipe)
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                      "open",
-                      env_buf);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "open", env_buf);
     putenv (GNUNET_OS_CONTROL_PIPE "=");
     return;
   }
@@ -210,11 +204,10 @@ GNUNET_OS_install_parent_control_handler (void *cls)
        "Adding parent control handler pipe `%s' to the scheduler\n",
        env_buf);
   pch = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       control_pipe,
-                                       &parent_control_handler,
-                                       control_pipe);
-  spch = GNUNET_SCHEDULER_add_shutdown (&shutdown_pch,
+                                        control_pipe,
+                                        &parent_control_handler,
                                         control_pipe);
+  spch = GNUNET_SCHEDULER_add_shutdown (&shutdown_pch, control_pipe);
   putenv (GNUNET_OS_CONTROL_PIPE "=");
 }
 
@@ -248,8 +241,7 @@ GNUNET_OS_process_current ()
  * @return 0 on success, -1 on error
  */
 int
-GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc,
-                       int sig)
+GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
 {
   int ret;
   char csig;
@@ -258,19 +250,17 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc,
   if (NULL != proc->control_pipe)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Sending signal %d to pid: %u via pipe\n",
-        sig,
-        proc->pid);
-    ret = GNUNET_DISK_file_write (proc->control_pipe,
-                                 &csig,
-                                 sizeof (csig));
+         "Sending signal %d to pid: %u via pipe\n",
+         sig,
+         proc->pid);
+    ret = GNUNET_DISK_file_write (proc->control_pipe, &csig, sizeof (csig));
     if (sizeof (csig) == ret)
       return 0;
   }
   /* pipe failed or non-existent, try other methods */
   switch (sig)
   {
-#if !defined (WINDOWS)
+#if ! defined(WINDOWS)
   case SIGHUP:
 #endif
   case SIGINT:
@@ -279,62 +269,62 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc,
 #if (SIGTERM != GNUNET_TERM_SIG)
   case GNUNET_TERM_SIG:
 #endif
-#if defined(WINDOWS) && !defined(__CYGWIN__)
+#if defined(WINDOWS) && ! defined(__CYGWIN__)
+  {
+    DWORD exitcode;
+    int must_kill = GNUNET_YES;
+    if (0 != GetExitCodeProcess (proc->handle, &exitcode))
+      must_kill = (exitcode == STILL_ACTIVE) ? GNUNET_YES : GNUNET_NO;
+    if (GNUNET_YES == must_kill)
     {
-      DWORD exitcode;
-      int must_kill = GNUNET_YES;
-      if (0 != GetExitCodeProcess (proc->handle, &exitcode))
-        must_kill = (exitcode == STILL_ACTIVE) ? GNUNET_YES : GNUNET_NO;
-      if (GNUNET_YES == must_kill)
+      if (0 == SafeTerminateProcess (proc->handle, 0, 0))
       {
-        if (0 == SafeTerminateProcess (proc->handle, 0, 0))
+        DWORD error_code = GetLastError ();
+        if ((error_code != WAIT_TIMEOUT) &&
+            (error_code != ERROR_PROCESS_ABORTED))
         {
-          DWORD error_code = GetLastError ();
-          if ( (error_code != WAIT_TIMEOUT) &&
-              (error_code != ERROR_PROCESS_ABORTED) )
-          {
-            LOG ((error_code == ERROR_ACCESS_DENIED) ?
-                GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING,
-                "SafeTermiateProcess failed with code %lu\n",
-                error_code);
-            /* The problem here is that a process that is already dying
+          LOG ((error_code == ERROR_ACCESS_DENIED) ? GNUNET_ERROR_TYPE_INFO
+                                                   : GNUNET_ERROR_TYPE_WARNING,
+               "SafeTermiateProcess failed with code %lu\n",
+               error_code);
+          /* The problem here is that a process that is already dying
              * might cause SafeTerminateProcess to fail with
              * ERROR_ACCESS_DENIED, but the process WILL die eventually.
              * If we really had a permissions problem, hanging up (which
              * is what will happen in process_wait() in that case) is
              * a valid option.
              */
-            if (ERROR_ACCESS_DENIED == error_code)
-            {
-              errno = 0;
-            }
-            else
-            {
-              SetErrnoFromWinError (error_code);
-              return -1;
-            }
+          if (ERROR_ACCESS_DENIED == error_code)
+          {
+            errno = 0;
+          }
+          else
+          {
+            SetErrnoFromWinError (error_code);
+            return -1;
           }
         }
       }
     }
+  }
     return 0;
 #else
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Sending signal %d to pid: %u via system call\n",
          sig,
          proc->pid);
-    return PLIBC_KILL (proc->pid, sig);
+    return kill (proc->pid, sig);
 #endif
   default:
-#if defined (WINDOWS)
+#if defined(WINDOWS)
     errno = EINVAL;
     return -1;
 #else
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Sending signal %d to pid: %u via system call\n",
-        sig,
-        proc->pid);
-    return PLIBC_KILL (proc->pid, sig);
+         "Sending signal %d to pid: %u via system call\n",
+         sig,
+         proc->pid);
+    return kill (proc->pid, sig);
 #endif
   }
 }
@@ -348,7 +338,7 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc,
  * @return the current process id
  */
 pid_t
-GNUNET_OS_process_get_pid (struct GNUNET_OS_Process * proc)
+GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc)
 {
   return proc->pid;
 }
@@ -365,7 +355,7 @@ GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc)
 {
   if (NULL != proc->control_pipe)
     GNUNET_DISK_file_close (proc->control_pipe);
-#if defined (WINDOWS)
+#if defined(WINDOWS)
   if (NULL != proc->handle)
     CloseHandle (proc->handle);
 #endif
@@ -425,7 +415,8 @@ CreateCustomEnvTable (char **vars)
   win32_env_table = GetEnvironmentStringsA ();
   if (NULL == win32_env_table)
     return NULL;
-  for (c = 0, var_ptr = vars; *var_ptr; var_ptr += 2, c++) ;
+  for (c = 0, var_ptr = vars; *var_ptr; var_ptr += 2, c++)
+    ;
   n_var = c;
   index = GNUNET_malloc (sizeof (char *) * n_var);
   for (c = 0; c < n_var; c++)
@@ -448,7 +439,7 @@ CreateCustomEnvTable (char **vars)
         break;
       }
     }
-    if (!found)
+    if (! found)
       tablesize += len + 1;
     ptr += len + 1;
   }
@@ -476,7 +467,7 @@ CreateCustomEnvTable (char **vars)
         break;
       }
     }
-    if (!found)
+    if (! found)
     {
       strcpy (result_ptr, ptr);
       result_ptr += len + 1;
@@ -519,17 +510,14 @@ CreateCustomEnvTable (char **vars)
  * @param flags open flags (O_RDONLY, O_WRONLY)
  */
 static void
-open_dev_null (int target_fd,
-              int flags)
+open_dev_null (int target_fd, int flags)
 {
   int fd;
 
   fd = open ("/dev/null", flags);
   if (-1 == fd)
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                             "open",
-                             "/dev/null");
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", "/dev/null");
     return;
   }
   if (fd == target_fd)
@@ -565,12 +553,12 @@ open_dev_null (int target_fd,
 static struct GNUNET_OS_Process *
 start_process (int pipe_control,
                enum GNUNET_OS_InheritStdioFlags std_inheritance,
-              struct GNUNET_DISK_PipeHandle *pipe_stdin,
-              struct GNUNET_DISK_PipeHandle *pipe_stdout,
-              struct GNUNET_DISK_PipeHandle *pipe_stderr,
-              const SOCKTYPE *lsocks,
-              const char *filename,
-              char *const argv[])
+               struct GNUNET_DISK_PipeHandle *pipe_stdin,
+               struct GNUNET_DISK_PipeHandle *pipe_stdout,
+               struct GNUNET_DISK_PipeHandle *pipe_stderr,
+               const SOCKTYPE *lsocks,
+               const char *filename,
+               char *const argv[])
 {
 #ifndef MINGW
   pid_t ret;
@@ -601,22 +589,19 @@ start_process (int pipe_control,
     struct GNUNET_DISK_PipeHandle *childpipe;
     int dup_childpipe_read_fd = -1;
 
-    childpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO,
-                                 GNUNET_YES, GNUNET_NO);
+    childpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_YES, GNUNET_NO);
     if (NULL == childpipe)
       return NULL;
-    childpipe_read = GNUNET_DISK_pipe_detach_end (childpipe,
-                                                 GNUNET_DISK_PIPE_END_READ);
-    childpipe_write = GNUNET_DISK_pipe_detach_end (childpipe,
-                                                  GNUNET_DISK_PIPE_END_WRITE);
+    childpipe_read =
+      GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_READ);
+    childpipe_write =
+      GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_WRITE);
     GNUNET_DISK_pipe_close (childpipe);
-    if ( (NULL == childpipe_read) ||
-        (NULL == childpipe_write) ||
-        (GNUNET_OK !=
-         GNUNET_DISK_internal_file_handle_ (childpipe_read,
-                                            &childpipe_read_fd,
-                                            sizeof (int))) ||
-        (-1 == (dup_childpipe_read_fd = dup (childpipe_read_fd))))
+    if ((NULL == childpipe_read) || (NULL == childpipe_write) ||
+        (GNUNET_OK != GNUNET_DISK_internal_file_handle_ (childpipe_read,
+                                                         &childpipe_read_fd,
+                                                         sizeof (int))) ||
+        (-1 == (dup_childpipe_read_fd = dup (childpipe_read_fd))))
     {
       if (NULL != childpipe_read)
         GNUNET_DISK_file_close (childpipe_read);
@@ -636,39 +621,48 @@ start_process (int pipe_control,
   }
   if (NULL != pipe_stdin)
   {
-    GNUNET_assert (GNUNET_OK ==
-                  GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                     (pipe_stdin, GNUNET_DISK_PIPE_END_READ),
-                                                     &fd_stdin_read, sizeof (int)));
-    GNUNET_assert (GNUNET_OK ==
-                  GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                     (pipe_stdin, GNUNET_DISK_PIPE_END_WRITE),
-                                                     &fd_stdin_write, sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stdin, GNUNET_DISK_PIPE_END_READ),
+        &fd_stdin_read,
+        sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stdin, GNUNET_DISK_PIPE_END_WRITE),
+        &fd_stdin_write,
+        sizeof (int)));
   }
   if (NULL != pipe_stdout)
   {
-    GNUNET_assert (GNUNET_OK ==
-                  GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                     (pipe_stdout,
-                                                      GNUNET_DISK_PIPE_END_WRITE),
-                                                     &fd_stdout_write, sizeof (int)));
-    GNUNET_assert (GNUNET_OK ==
-                  GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                     (pipe_stdout, GNUNET_DISK_PIPE_END_READ),
-                                                     &fd_stdout_read, sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stdout, GNUNET_DISK_PIPE_END_WRITE),
+        &fd_stdout_write,
+        sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stdout, GNUNET_DISK_PIPE_END_READ),
+        &fd_stdout_read,
+        sizeof (int)));
   }
   if (NULL != pipe_stderr)
   {
-    GNUNET_assert (GNUNET_OK ==
-                   GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                      (pipe_stderr,
-                                                       GNUNET_DISK_PIPE_END_READ),
-                                                      &fd_stderr_read, sizeof (int)));
-    GNUNET_assert (GNUNET_OK ==
-                   GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                                      (pipe_stderr,
-                                                       GNUNET_DISK_PIPE_END_WRITE),
-                                                      &fd_stderr_write, sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stderr, GNUNET_DISK_PIPE_END_READ),
+        &fd_stderr_read,
+        sizeof (int)));
+    GNUNET_assert (
+      GNUNET_OK ==
+      GNUNET_DISK_internal_file_handle_ (
+        GNUNET_DISK_pipe_handle (pipe_stderr, GNUNET_DISK_PIPE_END_WRITE),
+        &fd_stderr_write,
+        sizeof (int)));
   }
   lscp = NULL;
   ls = 0;
@@ -819,7 +813,7 @@ start_process (int pipe_control,
   int argcount = 0;
   struct GNUNET_OS_Process *gnunet_proc;
   char path[MAX_PATH + 1];
-  char *our_env[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+  char *our_env[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
   char *env_block = NULL;
   char *pathbuf;
   DWORD pathbuf_len;
@@ -849,7 +843,8 @@ start_process (int pipe_control,
   DWORD error_code;
   DWORD create_no_window;
 
-  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL))
+  if (GNUNET_SYSERR ==
+      GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL))
     return NULL; /* not executable */
 
   /* Search in prefix dir (hopefully - the directory from which
@@ -861,9 +856,8 @@ start_process (int pipe_control,
 
   pathbuf_len = GetEnvironmentVariableA ("PATH", (char *) &pathbuf, 0);
 
-  alloc_len =
-      pathbuf_len + 1 + strlen (self_prefix) + 1 + strlen (bindir) + 1 +
-      strlen (libdir);
+  alloc_len = pathbuf_len + 1 + strlen (self_prefix) + 1 + strlen (bindir) + 1 +
+              strlen (libdir);
 
   pathbuf = GNUNET_malloc (alloc_len * sizeof (char));
 
@@ -877,21 +871,23 @@ start_process (int pipe_control,
   if (alloc_len != pathbuf_len - 1)
   {
     GNUNET_free (pathbuf);
-    errno = ENOSYS;             /* PATH changed on the fly. What kind of error is that? */
+    errno = ENOSYS; /* PATH changed on the fly. What kind of error is that? */
     return NULL;
   }
 
   cmdlen = strlen (filename);
-  if ( (cmdlen < 5) || (0 != strcmp (&filename[cmdlen - 4], ".exe")) )
+  if ((cmdlen < 5) || (0 != strcmp (&filename[cmdlen - 4], ".exe")))
     GNUNET_asprintf (&non_const_filename, "%s.exe", filename);
   else
     GNUNET_asprintf (&non_const_filename, "%s", filename);
 
   /* It could be in POSIX form, convert it to a DOS path early on */
-  if (ERROR_SUCCESS != (lRet = plibc_conv_to_win_path (non_const_filename, win_path)))
+  if (ERROR_SUCCESS !=
+      (lRet = plibc_conv_to_win_path (non_const_filename, win_path)))
   {
     SetErrnoFromWinError (lRet);
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "plibc_conv_to_win_path",
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                       "plibc_conv_to_win_path",
                        non_const_filename);
     GNUNET_free (non_const_filename);
     GNUNET_free (pathbuf);
@@ -899,7 +895,7 @@ start_process (int pipe_control,
   }
   GNUNET_free (non_const_filename);
   non_const_filename = GNUNET_strdup (win_path);
-   /* Check that this is the full path. If it isn't, search. */
+  /* Check that this is the full path. If it isn't, search. */
   /* FIXME: convert it to wchar_t and use SearchPathW?
    * Remember: arguments to _start_process() are technically in UTF-8...
    */
@@ -907,22 +903,27 @@ start_process (int pipe_control,
   {
     snprintf (path, sizeof (path) / sizeof (char), "%s", non_const_filename);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Using path `%s' as-is. PATH is %s\n", path, ptr);
+         "Using path `%s' as-is. PATH is %s\n",
+         path,
+         ptr);
   }
-  else if (!SearchPathA
-           (pathbuf, non_const_filename, NULL, sizeof (path) / sizeof (char),
-            path, NULL))
+  else if (! SearchPathA (pathbuf,
+                          non_const_filename,
+                          NULL,
+                          sizeof (path) / sizeof (char),
+                          path,
+                          NULL))
   {
     SetErrnoFromWinError (GetLastError ());
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "SearchPath",
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                       "SearchPath",
                        non_const_filename);
     GNUNET_free (non_const_filename);
     GNUNET_free (pathbuf);
     return NULL;
   }
   else
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Found `%s' in PATH `%s'\n", path, pathbuf);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' in PATH `%s'\n", path, pathbuf);
   GNUNET_free (pathbuf);
   GNUNET_free (non_const_filename);
 
@@ -966,8 +967,11 @@ start_process (int pipe_control,
   while (*arg)
   {
     char arg_last_char = (*arg)[strlen (*arg) - 1];
-    idx += sprintf (idx, "\"%s%s\"%s", *arg,
-        arg_last_char == '\\' ? "\\" : "", *(arg + 1) ? " " : "");
+    idx += sprintf (idx,
+                    "\"%s%s\"%s",
+                    *arg,
+                    arg_last_char == '\\' ? "\\" : "",
+                    *(arg + 1) ? " " : "");
     arg++;
   }
 
@@ -984,9 +988,10 @@ start_process (int pipe_control,
   GetHandleInformation (stdih, &stdif);
   if (pipe_stdin != NULL)
   {
-    GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                       (pipe_stdin, GNUNET_DISK_PIPE_END_READ),
-                                       &stdin_handle, sizeof (HANDLE));
+    GNUNET_DISK_internal_file_handle_ (
+      GNUNET_DISK_pipe_handle (pipe_stdin, GNUNET_DISK_PIPE_END_READ),
+      &stdin_handle,
+      sizeof (HANDLE));
     start.hStdInput = stdin_handle;
   }
   else if (stdih)
@@ -1006,10 +1011,10 @@ start_process (int pipe_control,
   GetHandleInformation (stdoh, &stdof);
   if (NULL != pipe_stdout)
   {
-    GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                       (pipe_stdout,
-                                        GNUNET_DISK_PIPE_END_WRITE),
-                                       &stdout_handle, sizeof (HANDLE));
+    GNUNET_DISK_internal_file_handle_ (
+      GNUNET_DISK_pipe_handle (pipe_stdout, GNUNET_DISK_PIPE_END_WRITE),
+      &stdout_handle,
+      sizeof (HANDLE));
     start.hStdOutput = stdout_handle;
   }
   else if (stdoh)
@@ -1043,12 +1048,15 @@ start_process (int pipe_control,
     childpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_YES, GNUNET_NO);
     if (NULL == childpipe)
       return NULL;
-    childpipe_read = GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_READ);
-    childpipe_write = GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_WRITE);
+    childpipe_read =
+      GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_READ);
+    childpipe_write =
+      GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_WRITE);
     GNUNET_DISK_pipe_close (childpipe);
     if ((NULL == childpipe_read) || (NULL == childpipe_write) ||
         (GNUNET_OK != GNUNET_DISK_internal_file_handle_ (childpipe_read,
-        &childpipe_read_handle, sizeof (HANDLE))))
+                                                         &childpipe_read_handle,
+                                                         sizeof (HANDLE))))
     {
       if (childpipe_read)
         GNUNET_DISK_file_close (childpipe_read);
@@ -1070,7 +1078,8 @@ start_process (int pipe_control,
 
   if (lsocks != NULL && lsocks[0] != INVALID_SOCKET)
   {
-    lsocks_pipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
+    lsocks_pipe =
+      GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
 
     if (lsocks_pipe == NULL)
     {
@@ -1083,13 +1092,15 @@ start_process (int pipe_control,
       }
       return NULL;
     }
-    lsocks_write_fd = GNUNET_DISK_pipe_handle (lsocks_pipe,
-        GNUNET_DISK_PIPE_END_WRITE);
+    lsocks_write_fd =
+      GNUNET_DISK_pipe_handle (lsocks_pipe, GNUNET_DISK_PIPE_END_WRITE);
     GNUNET_DISK_internal_file_handle_ (lsocks_write_fd,
-                                       &lsocks_write, sizeof (HANDLE));
-    GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
-                                       (lsocks_pipe, GNUNET_DISK_PIPE_END_READ),
-                                       &lsocks_read, sizeof (HANDLE));
+                                       &lsocks_write,
+                                       sizeof (HANDLE));
+    GNUNET_DISK_internal_file_handle_ (
+      GNUNET_DISK_pipe_handle (lsocks_pipe, GNUNET_DISK_PIPE_END_READ),
+      &lsocks_read,
+      sizeof (HANDLE));
   }
   else
   {
@@ -1103,7 +1114,7 @@ start_process (int pipe_control,
     GNUNET_asprintf (&our_env[env_off++], "%s=", GNUNET_OS_CONTROL_PIPE);
     GNUNET_asprintf (&our_env[env_off++], "%p", childpipe_read_handle);
   }
-  if ( (lsocks != NULL) && (lsocks[0] != INVALID_SOCKET))
+  if ((lsocks != NULL) && (lsocks[0] != INVALID_SOCKET))
   {
     /*This will tell the child that we're going to send lsocks over the pipe*/
     GNUNET_asprintf (&our_env[env_off++], "%s=", "GNUNET_OS_READ_LSOCKS");
@@ -1115,10 +1126,14 @@ start_process (int pipe_control,
     GNUNET_free_non_null (our_env[--env_off]);
 
   wpath_len = 0;
-  if (NULL == (wpath = u8_to_u16 ((uint8_t *) path, 1 + strlen (path), NULL, &wpath_len)))
+  if (NULL ==
+      (wpath =
+         u8_to_u16 ((uint8_t *) path, 1 + strlen (path), NULL, &wpath_len)))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Failed to convert `%s' from UTF-8 to UTF-16: %d\n", path, errno);
+         "Failed to convert `%s' from UTF-8 to UTF-16: %d\n",
+         path,
+         errno);
     GNUNET_free (env_block);
     GNUNET_free (cmd);
     if (lsocks_pipe)
@@ -1132,7 +1147,8 @@ start_process (int pipe_control,
   }
 
   wcmd_len = 0;
-  if (NULL == (wcmd = u8_to_u16 ((uint8_t *) cmd, 1 + strlen (cmd), NULL, &wcmd_len)))
+  if (NULL ==
+      (wcmd = u8_to_u16 ((uint8_t *) cmd, 1 + strlen (cmd), NULL, &wcmd_len)))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Failed to convert `%s' from UTF-8 to UTF-16: %d\n",
@@ -1153,15 +1169,29 @@ start_process (int pipe_control,
 
   create_no_window = 0;
   {
-    HANDLE console_input = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+    HANDLE console_input = CreateFile ("CONIN$",
+                                       GENERIC_READ,
+                                       FILE_SHARE_READ | FILE_SHARE_WRITE,
+                                       NULL,
+                                       OPEN_EXISTING,
+                                       0,
+                                       NULL);
     if (INVALID_HANDLE_VALUE == console_input)
       create_no_window = CREATE_NO_WINDOW;
     else
       CloseHandle (console_input);
   }
 
-  bresult = CreateProcessW (wpath, wcmd, NULL, NULL, GNUNET_YES,
-       create_no_window | CREATE_SUSPENDED, env_block, NULL, &start, &proc);
+  bresult = CreateProcessW (wpath,
+                            wcmd,
+                            NULL,
+                            NULL,
+                            GNUNET_YES,
+                            create_no_window | CREATE_SUSPENDED,
+                            env_block,
+                            NULL,
+                            &start,
+                            &proc);
   error_code = GetLastError ();
 
   if ((NULL == pipe_stdin) && (stdih))
@@ -1174,7 +1204,7 @@ start_process (int pipe_control,
   if (stdeh)
     SetHandleInformation (stdeh, HANDLE_FLAG_INHERIT, stdef);
 
-  if (!bresult)
+  if (! bresult)
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "CreateProcess(%s, %s) failed: %lu\n",
          path,
@@ -1190,7 +1220,7 @@ start_process (int pipe_control,
     GNUNET_DISK_file_close (childpipe_read);
   }
 
-  if (!bresult)
+  if (! bresult)
   {
     if (GNUNET_YES == pipe_control)
     {
@@ -1212,7 +1242,7 @@ start_process (int pipe_control,
   ResumeThread (proc.hThread);
   CloseHandle (proc.hThread);
 
-  if ( (NULL == lsocks) || (INVALID_SOCKET == lsocks[0]) )
+  if ((NULL == lsocks) || (INVALID_SOCKET == lsocks[0]))
     return gnunet_proc;
 
   GNUNET_DISK_pipe_close_end (lsocks_pipe, GNUNET_DISK_PIPE_END_READ);
@@ -1227,25 +1257,29 @@ start_process (int pipe_control,
     unsigned int i;
 
     /* Tell the number of sockets */
-    for (count = 0; lsocks && lsocks[count] != INVALID_SOCKET; count++);
+    for (count = 0; lsocks && lsocks[count] != INVALID_SOCKET; count++)
+      ;
 
     wrote = GNUNET_DISK_file_write (lsocks_write_fd, &count, sizeof (count));
     if (sizeof (count) != wrote)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 "Failed to write %u count bytes to the child: %lu\n",
-                 sizeof (count), GetLastError ());
+                  "Failed to write %u count bytes to the child: %lu\n",
+                  sizeof (count),
+                  GetLastError ());
       break;
     }
     for (i = 0; lsocks && lsocks[i] != INVALID_SOCKET; i++)
     {
       WSAPROTOCOL_INFOA pi;
       /* Get a socket duplication info */
-      if (SOCKET_ERROR == WSADuplicateSocketA (lsocks[i], gnunet_proc->pid, &pi))
+      if (SOCKET_ERROR ==
+          WSADuplicateSocketA (lsocks[i], gnunet_proc->pid, &pi))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   "Failed to duplicate an socket[%u]: %lu\n", i,
-                   GetLastError ());
+                    "Failed to duplicate an socket[%u]: %lu\n",
+                    i,
+                    GetLastError ());
         break;
       }
       /* Synchronous I/O is not nice, but we can't schedule this:
@@ -1261,8 +1295,10 @@ start_process (int pipe_control,
       if (sizeof (size) != wrote)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   "Failed to write %u size[%u] bytes to the child: %lu\n",
-                   sizeof (size), i, GetLastError ());
+                    "Failed to write %u size[%u] bytes to the child: %lu\n",
+                    sizeof (size),
+                    i,
+                    GetLastError ());
         break;
       }
       /* Finally! Send the data */
@@ -1270,8 +1306,10 @@ start_process (int pipe_control,
       if (sizeof (pi) != wrote)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   "Failed to write %u socket[%u] bytes to the child: %lu\n",
-                   sizeof (pi), i, GetLastError ());
+                    "Failed to write %u socket[%u] bytes to the child: %lu\n",
+                    sizeof (pi),
+                    i,
+                    GetLastError ());
         break;
       }
     }
@@ -1282,8 +1320,7 @@ start_process (int pipe_control,
      */
     wrote = GNUNET_DISK_file_write (lsocks_write_fd, &count, sizeof (count));
     fail = 0;
-  }
-  while (fail);
+  } while (fail);
 
   GNUNET_DISK_file_sync (lsocks_write_fd);
   GNUNET_DISK_pipe_close (lsocks_pipe);
@@ -1320,20 +1357,20 @@ start_process (int pipe_control,
 struct GNUNET_OS_Process *
 GNUNET_OS_start_process_vap (int pipe_control,
                              enum GNUNET_OS_InheritStdioFlags std_inheritance,
-                            struct GNUNET_DISK_PipeHandle *pipe_stdin,
-                            struct GNUNET_DISK_PipeHandle *pipe_stdout,
+                             struct GNUNET_DISK_PipeHandle *pipe_stdin,
+                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                              struct GNUNET_DISK_PipeHandle *pipe_stderr,
-                            const char *filename,
-                            char *const argv[])
+                             const char *filename,
+                             char *const argv[])
 {
   return start_process (pipe_control,
                         std_inheritance,
-                       pipe_stdin,
-                       pipe_stdout,
+                        pipe_stdin,
+                        pipe_stdout,
                         pipe_stderr,
-                       NULL,
-                       filename,
-                       argv);
+                        NULL,
+                        filename,
+                        argv);
 }
 
 
@@ -1352,10 +1389,11 @@ GNUNET_OS_start_process_vap (int pipe_control,
 struct GNUNET_OS_Process *
 GNUNET_OS_start_process_va (int pipe_control,
                             enum GNUNET_OS_InheritStdioFlags std_inheritance,
-                           struct GNUNET_DISK_PipeHandle *pipe_stdin,
+                            struct GNUNET_DISK_PipeHandle *pipe_stdin,
                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                             struct GNUNET_DISK_PipeHandle *pipe_stderr,
-                            const char *filename, va_list va)
+                            const char *filename,
+                            va_list va)
 {
   struct GNUNET_OS_Process *ret;
   va_list ap;
@@ -1375,11 +1413,11 @@ GNUNET_OS_start_process_va (int pipe_control,
   va_end (ap);
   ret = GNUNET_OS_start_process_vap (pipe_control,
                                      std_inheritance,
-                                    pipe_stdin,
-                                    pipe_stdout,
+                                     pipe_stdin,
+                                     pipe_stdout,
                                      pipe_stderr,
-                                    filename,
-                                    argv);
+                                     filename,
+                                     argv);
   GNUNET_free (argv);
   return ret;
 }
@@ -1399,10 +1437,11 @@ GNUNET_OS_start_process_va (int pipe_control,
 struct GNUNET_OS_Process *
 GNUNET_OS_start_process (int pipe_control,
                          enum GNUNET_OS_InheritStdioFlags std_inheritance,
-                        struct GNUNET_DISK_PipeHandle *pipe_stdin,
+                         struct GNUNET_DISK_PipeHandle *pipe_stdin,
                          struct GNUNET_DISK_PipeHandle *pipe_stdout,
                          struct GNUNET_DISK_PipeHandle *pipe_stderr,
-                         const char *filename, ...)
+                         const char *filename,
+                         ...)
 {
   struct GNUNET_OS_Process *ret;
   va_list ap;
@@ -1411,7 +1450,7 @@ GNUNET_OS_start_process (int pipe_control,
   ret = GNUNET_OS_start_process_va (pipe_control,
                                     std_inheritance,
                                     pipe_stdin,
-                                   pipe_stdout,
+                                    pipe_stdout,
                                     pipe_stderr,
                                     filename,
                                     ap);
@@ -1437,18 +1476,18 @@ GNUNET_OS_start_process (int pipe_control,
 struct GNUNET_OS_Process *
 GNUNET_OS_start_process_v (int pipe_control,
                            enum GNUNET_OS_InheritStdioFlags std_inheritance,
-                          const SOCKTYPE *lsocks,
+                           const SOCKTYPE *lsocks,
                            const char *filename,
                            char *const argv[])
 {
   return start_process (pipe_control,
                         std_inheritance,
-                       NULL,
-                       NULL,
                         NULL,
-                       lsocks,
-                       filename,
-                       argv);
+                        NULL,
+                        NULL,
+                        lsocks,
+                        filename,
+                        argv);
 }
 
 
@@ -1473,8 +1512,9 @@ GNUNET_OS_start_process_v (int pipe_control,
 struct GNUNET_OS_Process *
 GNUNET_OS_start_process_s (int pipe_control,
                            unsigned int std_inheritance,
-                           const SOCKTYPE * lsocks,
-                           const char *filename, ...)
+                           const SOCKTYPE *lsocks,
+                           const char *filename,
+                           ...)
 {
   va_list ap;
   char **argv;
@@ -1502,29 +1542,28 @@ GNUNET_OS_start_process_s (int pipe_control,
     {
       if ('"' == *rpos)
       {
-       if (1 == quote_on)
-         quote_on = 0;
-       else
-         quote_on = 1;
+        if (1 == quote_on)
+          quote_on = 0;
+        else
+          quote_on = 1;
       }
-      if ( (' ' == *rpos) && (0 == quote_on) )
+      if ((' ' == *rpos) && (0 == quote_on))
       {
-       if (NULL != last)
-         argv_size++;
-       last = NULL;
-       rpos++;
-       while (' ' == *rpos)
-         rpos++;
+        if (NULL != last)
+          argv_size++;
+        last = NULL;
+        rpos++;
+        while (' ' == *rpos)
+          rpos++;
       }
-      if ( (NULL == last) && ('\0' != *rpos) ) // FIXME: == or !=?
-       last = rpos;
+      if ((NULL == last) && ('\0' != *rpos)) // FIXME: == or !=?
+        last = rpos;
       if ('\0' != *rpos)
-       rpos++;
+        rpos++;
     }
     if (NULL != last)
       argv_size++;
-  }
-  while (NULL != (arg = (va_arg (ap, const char*))));
+  } while (NULL != (arg = (va_arg (ap, const char *))));
   va_end (ap);
 
   argv = GNUNET_malloc (argv_size * sizeof (char *));
@@ -1541,47 +1580,49 @@ GNUNET_OS_start_process_s (int pipe_control,
     {
       if ('"' == *pos)
       {
-       if (1 == quote_on)
-         quote_on = 0;
-       else
-         quote_on = 1;
+        if (1 == quote_on)
+          quote_on = 0;
+        else
+          quote_on = 1;
       }
-      if ( (' ' == *pos) && (0 == quote_on) )
+      if ((' ' == *pos) && (0 == quote_on))
       {
-       *pos = '\0';
-       if (NULL != last)
-         argv[argv_size++] = GNUNET_strdup (last);
-       last = NULL;
-       pos++;
-       while (' ' == *pos)
-         pos++;
+        *pos = '\0';
+        if (NULL != last)
+          argv[argv_size++] = GNUNET_strdup (last);
+        last = NULL;
+        pos++;
+        while (' ' == *pos)
+          pos++;
       }
-      if ( (NULL == last) && ('\0' != *pos)) // FIXME: == or !=?
-       last = pos;
+      if ((NULL == last) && ('\0' != *pos)) // FIXME: == or !=?
+        last = pos;
       if ('\0' != *pos)
-       pos++;
+        pos++;
     }
     if (NULL != last)
       argv[argv_size++] = GNUNET_strdup (last);
     last = NULL;
     GNUNET_free (cp);
-  }
-  while (NULL != (arg = (va_arg (ap, const char*))));
+  } while (NULL != (arg = (va_arg (ap, const char *))));
   va_end (ap);
   argv[argv_size] = NULL;
 
-  for(i = 0; i < argv_size; i++)
+  for (i = 0; i < argv_size; i++)
   {
     len = strlen (argv[i]);
-    if ( (argv[i][0] == '"') && (argv[i][len-1] == '"'))
+    if ((argv[i][0] == '"') && (argv[i][len - 1] == '"'))
     {
       memmove (&argv[i][0], &argv[i][1], len - 2);
-      argv[i][len-2] = '\0';
+      argv[i][len - 2] = '\0';
     }
   }
   binary_path = argv[0];
-  proc = GNUNET_OS_start_process_v (pipe_control, std_inheritance, lsocks,
-                                   binary_path, argv);
+  proc = GNUNET_OS_start_process_v (pipe_control,
+                                    std_inheritance,
+                                    lsocks,
+                                    binary_path,
+                                    argv);
   while (argv_size > 0)
     GNUNET_free (argv[--argv_size]);
   GNUNET_free (argv);
@@ -1613,8 +1654,7 @@ process_status (struct GNUNET_OS_Process *proc,
   ret = waitpid (proc->pid, &status, options);
   if (ret < 0)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                  "waitpid");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid");
     return GNUNET_SYSERR;
   }
   if (0 == ret)
@@ -1657,7 +1697,7 @@ process_status (struct GNUNET_OS_Process *proc,
   }
 #else
 #ifndef WNOHANG
-#define WNOHANG  42 /* just a flag for W32, purely internal at this point */
+#define WNOHANG 42 /* just a flag for W32, purely internal at this point */
 #endif
 
   HANDLE h;
@@ -1669,7 +1709,8 @@ process_status (struct GNUNET_OS_Process *proc,
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Invalid process information {%d, %08X}\n",
-         ret, h);
+         ret,
+         h);
     return GNUNET_SYSERR;
   }
   if (h == NULL)
@@ -1720,10 +1761,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
                           enum GNUNET_OS_ProcessStatusType *type,
                           unsigned long *code)
 {
-  return process_status (proc,
-                         type,
-                         code,
-                         WNOHANG);
+  return process_status (proc, type, code, WNOHANG);
 }
 
 
@@ -1741,10 +1779,7 @@ GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc,
                                enum GNUNET_OS_ProcessStatusType *type,
                                unsigned long *code)
 {
-  return process_status (proc,
-                         type,
-                         code,
-                         0);
+  return process_status (proc, type, code, 0);
 }
 
 
@@ -1765,12 +1800,11 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc)
   pid_t pid = proc->pid;
   pid_t ret;
 
-  while ( (pid != (ret = waitpid (pid, NULL, 0))) &&
-         (EINTR == errno) ) ;
+  while ((pid != (ret = waitpid (pid, NULL, 0))) && (EINTR == errno))
+    ;
   if (pid != ret)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                  "waitpid");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid");
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -1782,7 +1816,8 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Invalid process information {%d, %08X}\n",
-         proc->pid, h);
+         proc->pid,
+         h);
     return GNUNET_SYSERR;
   }
   if (NULL == h)
@@ -1890,9 +1925,7 @@ cmd_read (void *cls)
 
   cmd->rtask = NULL;
   tc = GNUNET_SCHEDULER_get_task_context ();
-  if (GNUNET_YES !=
-      GNUNET_NETWORK_fdset_handle_isset (tc->read_ready,
-                                        cmd->r))
+  if (GNUNET_YES != GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, cmd->r))
   {
     /* timeout */
     proc = cmd->proc;
@@ -1901,8 +1934,8 @@ cmd_read (void *cls)
     return;
   }
   ret = GNUNET_DISK_file_read (cmd->r,
-                              &cmd->buf[cmd->off],
-                              sizeof (cmd->buf) - cmd->off);
+                               &cmd->buf[cmd->off],
+                               sizeof (cmd->buf) - cmd->off);
   if (ret <= 0)
   {
     if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf)))
@@ -1925,11 +1958,12 @@ cmd_read (void *cls)
     cmd->off -= (end + 1 - cmd->buf);
     end = memchr (cmd->buf, '\n', cmd->off);
   }
-  cmd->rtask
-    = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
-                                      (cmd->timeout),
-                                     cmd->r,
-                                     &cmd_read, cmd);
+  cmd->rtask =
+    GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining (
+                                      cmd->timeout),
+                                    cmd->r,
+                                    &cmd_read,
+                                    cmd);
 }
 
 
@@ -1956,15 +1990,13 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc,
   struct GNUNET_DISK_PipeHandle *opipe;
   va_list ap;
 
-  opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES,
-                           GNUNET_NO, GNUNET_YES);
+  opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
   if (NULL == opipe)
     return NULL;
   va_start (ap, binary);
   /* redirect stdout, don't inherit stderr/stdin */
-  eip = GNUNET_OS_start_process_va (GNUNET_NO, 0, NULL,
-                                   opipe, NULL, binary,
-                                   ap);
+  eip =
+    GNUNET_OS_start_process_va (GNUNET_NO, 0, NULL, opipe, NULL, binary, ap);
   va_end (ap);
   if (NULL == eip)
   {
@@ -1978,12 +2010,8 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc,
   cmd->opipe = opipe;
   cmd->proc = proc;
   cmd->proc_cls = proc_cls;
-  cmd->r = GNUNET_DISK_pipe_handle (opipe,
-                                   GNUNET_DISK_PIPE_END_READ);
-  cmd->rtask = GNUNET_SCHEDULER_add_read_file (timeout,
-                                              cmd->r,
-                                              &cmd_read,
-                                              cmd);
+  cmd->r = GNUNET_DISK_pipe_handle (opipe, GNUNET_DISK_PIPE_END_READ);
+  cmd->rtask = GNUNET_SCHEDULER_add_read_file (timeout, cmd->r, &cmd_read, cmd);
   return cmd;
 }
 
index a2cb3a6cef40aa7ea5a5565428e168ba61e9008b..f42706bda1f7a2774f4e851f4ad1e4b72c6484f5 100644 (file)
@@ -49,7 +49,7 @@ log_duration (const char *cryptosystem,
   sprintf (s, "%6s %15s", cryptosystem, description);
   t = GNUNET_TIME_absolute_get_duration (start);
   t = GNUNET_TIME_relative_divide (t, l);
-  FPRINTF (stdout,
+  fprintf (stdout,
            "%s: %10s\n",
            s,
            GNUNET_STRINGS_relative_time_to_string (t,
index 59fa08d3a473af865880f9958c63d889672ae482..2729241e2d74ebf4e077ed0900a9acb56c14d101 100644 (file)
@@ -130,7 +130,7 @@ main (int argc, char *argv[])
 
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _
              ("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
index 4b922340ddf75aec8d963e2dd59866da18204fc7..19169f0709231ff76d745bf07a906ad8e67e5ccb 100644 (file)
@@ -28,7 +28,7 @@
 #include <ltdl.h>
 #include "gnunet_util_lib.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-plugin", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-plugin", __VA_ARGS__)
 
 /**
  * Linked list of active plugins.
@@ -82,8 +82,8 @@ plugin_init ()
   err = lt_dlinit ();
   if (err > 0)
   {
-    FPRINTF (stderr,
-             _("Initialization of plugin mechanism failed: %s!\n"),
+    fprintf (stderr,
+             _ ("Initialization of plugin mechanism failed: %s!\n"),
              lt_dlerror ());
     return;
   }
@@ -133,24 +133,21 @@ plugin_fini ()
  * @return NULL if the symbol was not found
  */
 static GNUNET_PLUGIN_Callback
-resolve_function (struct PluginList *plug,
-                  const char *name)
+resolve_function (struct PluginList *plug, const char *name)
 {
   char *initName;
   void *mptr;
 
-  GNUNET_asprintf (&initName,
-                   "_%s_%s",
-                   plug->name,
-                   name);
+  GNUNET_asprintf (&initName, "_%s_%s", plug->name, name);
   mptr = lt_dlsym (plug->handle, &initName[1]);
   if (NULL == mptr)
     mptr = lt_dlsym (plug->handle, initName);
   if (NULL == mptr)
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("`%s' failed to resolve method '%s' with error: %s\n"),
+         _ ("`%s' failed to resolve method '%s' with error: %s\n"),
          "lt_dlsym",
-         &initName[1], lt_dlerror ());
+         &initName[1],
+         lt_dlerror ());
   GNUNET_free (initName);
   return mptr;
 }
@@ -214,7 +211,7 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg)
   GNUNET_PLUGIN_Callback init;
   void *ret;
 
-  if (!initialized)
+  if (! initialized)
   {
     initialized = GNUNET_YES;
     plugin_init ();
@@ -223,9 +220,10 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg)
   if (libhandle == NULL)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("`%s' failed for library `%s' with error: %s\n"),
+         _ ("`%s' failed for library `%s' with error: %s\n"),
          "lt_dlopenext",
-         library_name, lt_dlerror ());
+         library_name,
+         lt_dlerror ());
     return NULL;
   }
   plug = GNUNET_new (struct PluginList);
@@ -255,8 +253,7 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg)
  * @return whatever the shutdown function returned
  */
 void *
-GNUNET_PLUGIN_unload (const char *library_name,
-                      void *arg)
+GNUNET_PLUGIN_unload (const char *library_name, void *arg)
 {
   struct PluginList *pos;
   struct PluginList *prev;
@@ -345,9 +342,9 @@ find_libraries (void *cls, const char *filename)
     libname = slashpos + 1;
   n = strlen (libname);
   if (0 != strncmp (lac->basename, libname, strlen (lac->basename)))
-    return GNUNET_OK;           /* wrong name */
+    return GNUNET_OK; /* wrong name */
   if ((n > 3) && (0 == strcmp (&libname[n - 3], ".la")))
-    return GNUNET_OK;           /* .la file */
+    return GNUNET_OK; /* .la file */
   basename = GNUNET_strdup (libname);
   if (NULL != (dot = strstr (basename, ".")))
     *dot = '\0';
@@ -372,8 +369,10 @@ find_libraries (void *cls, const char *filename)
  * @param cb_cls closure for @a cb
  */
 void
-GNUNET_PLUGIN_load_all (const char *basename, void *arg,
-                        GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
+GNUNET_PLUGIN_load_all (const char *basename,
+                        void *arg,
+                        GNUNET_PLUGIN_LoaderCallback cb,
+                        void *cb_cls)
 {
   struct LoadAllContext lac;
   char *path;
@@ -382,7 +381,7 @@ GNUNET_PLUGIN_load_all (const char *basename, void *arg,
   if (NULL == path)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Could not determine plugin installation path.\n"));
+                _ ("Could not determine plugin installation path.\n"));
     return;
   }
   lac.basename = basename;
index 73beb8d57f80373fc3d99fe132eb34e9302af2ba..77f4ea3ae2e539fe4d81aec364e8e2b243324246 100644 (file)
@@ -201,18 +201,18 @@ GNUNET_PROGRAM_run2 (int argc,
   /* prepare */
 #if ENABLE_NLS
   if (NULL != pd->gettext_domain)
+  {
+    setlocale (LC_ALL, "");
+    path = (NULL == pd->gettext_path)
+             ? GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR)
+             : GNUNET_strdup (pd->gettext_path);
+    if (NULL != path)
     {
-      setlocale (LC_ALL, "");
-      path = (NULL == pd->gettext_path)
-       ? GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR)
-       : GNUNET_strdup (pd->gettext_path);
-      if (NULL != path)
-       {
-         BINDTEXTDOMAIN (pd->gettext_domain, path);
-         GNUNET_free (path);
-       }
-      textdomain (pd->gettext_domain);
+      bindtextdomain (pd->gettext_domain, path);
+      GNUNET_free (path);
     }
+    textdomain (pd->gettext_domain);
+  }
 #endif
   cnt = 0;
   while (NULL != options[cnt].name)
index 73a73cbeac3f1798848dd2ab083b85f605f6e896..fba5a2f20879bf562dd6cd2dec65f3af49479f10 100644 (file)
 #endif
 
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-service", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-service", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, \
-                                                             "util-service", \
-                                                             syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-service", syscall)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file ( \
-    kind, "util-service", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util-service", syscall, filename)
 
 
 /**
@@ -77,7 +76,6 @@ struct ServiceListenContext
    * Task scheduled to do the listening.
    */
   struct GNUNET_SCHEDULER_Task *listen_task;
-
 };
 
 
@@ -363,8 +361,7 @@ struct GNUNET_SERVICE_Client
 static int
 have_non_monitor_clients (struct GNUNET_SERVICE_Handle *sh)
 {
-  for (struct GNUNET_SERVICE_Client *client = sh->clients_head;
-       NULL != client;
+  for (struct GNUNET_SERVICE_Client *client = sh->clients_head; NULL != client;
        client = client->next)
   {
     if (client->is_monitor)
@@ -383,8 +380,7 @@ have_non_monitor_clients (struct GNUNET_SERVICE_Handle *sh)
  * @param sr reason for suspending accepting connections
  */
 static void
-do_suspend (struct GNUNET_SERVICE_Handle *sh,
-            enum SuspendReason sr)
+do_suspend (struct GNUNET_SERVICE_Handle *sh, enum SuspendReason sr)
 {
   struct ServiceListenContext *slc;
 
@@ -426,8 +422,7 @@ service_shutdown (void *cls)
     break;
   case GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN:
     if (0 == (sh->suspend_state & SUSPEND_STATE_SHUTDOWN))
-      do_suspend (sh,
-                  SUSPEND_STATE_SHUTDOWN);
+      do_suspend (sh, SUSPEND_STATE_SHUTDOWN);
     if (GNUNET_NO == have_non_monitor_clients (sh))
       GNUNET_SERVICE_shutdown (sh);
     break;
@@ -451,8 +446,7 @@ check_ipv4_listed (const struct GNUNET_STRINGS_IPv4NetworkPolicy *list,
   if (NULL == list)
     return GNUNET_NO;
   i = 0;
-  while ( (0 != list[i].network.s_addr) ||
-          (0 != list[i].netmask.s_addr) )
+  while ((0 != list[i].network.s_addr) || (0 != list[i].netmask.s_addr))
   {
     if ((add->s_addr & list[i].netmask.s_addr) ==
         (list[i].network.s_addr & list[i].netmask.s_addr))
@@ -480,7 +474,7 @@ check_ipv6_listed (const struct GNUNET_STRINGS_IPv6NetworkPolicy *list,
   if (NULL == list)
     return GNUNET_NO;
   i = 0;
-  NEXT:
+NEXT:
   while (0 != GNUNET_is_zero (&list[i].network))
   {
     for (j = 0; j < sizeof (struct in6_addr) / sizeof (int); j++)
@@ -518,22 +512,17 @@ do_send (void *cls)
   client->send_task = NULL;
   buf = (const char *) client->msg;
   left = ntohs (client->msg->size) - client->msg_pos;
-  ret = GNUNET_NETWORK_socket_send (client->sock,
-                                    &buf[client->msg_pos],
-                                    left);
+  ret = GNUNET_NETWORK_socket_send (client->sock, &buf[client->msg_pos], left);
   GNUNET_assert (ret <= (ssize_t) left);
   if (0 == ret)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "no data send");
-    GNUNET_MQ_inject_error (client->mq,
-                            GNUNET_MQ_ERROR_WRITE);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "no data send");
+    GNUNET_MQ_inject_error (client->mq, GNUNET_MQ_ERROR_WRITE);
     return;
   }
   if (-1 == ret)
   {
-    if ( (EAGAIN == errno) ||
-         (EINTR == errno) )
+    if ((EAGAIN == errno) || (EINTR == errno))
     {
       /* ignore */
       ret = 0;
@@ -541,13 +530,11 @@ do_send (void *cls)
     else
     {
       if (EPIPE != errno)
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                             "send");
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "socket send returned with error code %i",
            errno);
-      GNUNET_MQ_inject_error (client->mq,
-                              GNUNET_MQ_ERROR_WRITE);
+      GNUNET_MQ_inject_error (client->mq, GNUNET_MQ_ERROR_WRITE);
       return;
     }
   }
@@ -559,11 +546,11 @@ do_send (void *cls)
   if (left > (size_t) ret)
   {
     GNUNET_assert (NULL == client->drop_task);
-    client->send_task
-      GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                        client->sock,
-                                        &do_send,
-                                        client);
+    client->send_task =
+      GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                      client->sock,
+                                      &do_send,
+                                      client);
     return;
   }
   GNUNET_MQ_impl_send_continue (client->mq);
@@ -595,11 +582,11 @@ service_mq_send (struct GNUNET_MQ_Handle *mq,
        ntohs (msg->size));
   client->msg = msg;
   client->msg_pos = 0;
-  client->send_task
-    GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                      client->sock,
-                                      &do_send,
-                                      client);
+  client->send_task =
+    GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                    client->sock,
+                                    &do_send,
+                                    client);
 }
 
 
@@ -610,8 +597,7 @@ service_mq_send (struct GNUNET_MQ_Handle *mq,
  * @param impl_state state specific to the implementation
  */
 static void
-service_mq_cancel (struct GNUNET_MQ_Handle *mq,
-                   void *impl_state)
+service_mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state)
 {
   struct GNUNET_SERVICE_Client *client = impl_state;
 
@@ -633,14 +619,12 @@ service_mq_cancel (struct GNUNET_MQ_Handle *mq,
  * @param error error code
  */
 static void
-service_mq_error_handler (void *cls,
-                          enum GNUNET_MQ_Error error)
+service_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_SERVICE_Handle *sh = client->sh;
 
-  if ( (GNUNET_MQ_ERROR_NO_MATCH == error) &&
-       (GNUNET_NO == sh->require_found) )
+  if ((GNUNET_MQ_ERROR_NO_MATCH == error) && (GNUNET_NO == sh->require_found))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "No handler for message of type %u found\n",
@@ -662,18 +646,20 @@ warn_no_client_continue (void *cls)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
-  GNUNET_break (0 != client->warn_type); /* type should never be 0 here, as we don't use 0 */
-  client->warn_task
-    = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
-                                    &warn_no_client_continue,
-                                    client);
-  LOG (GNUNET_ERROR_TYPE_WARNING,
-       _ (
-         "Processing code for message of type %u did not call `GNUNET_SERVICE_client_continue' after %s\n"),
-       (unsigned int) client->warn_type,
-       GNUNET_STRINGS_relative_time_to_string (
-         GNUNET_TIME_absolute_get_duration (client->warn_start),
-         GNUNET_YES));
+  GNUNET_break (
+    0 !=
+    client->warn_type); /* type should never be 0 here, as we don't use 0 */
+  client->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                                    &warn_no_client_continue,
+                                                    client);
+  LOG (
+    GNUNET_ERROR_TYPE_WARNING,
+    _ (
+      "Processing code for message of type %u did not call `GNUNET_SERVICE_client_continue' after %s\n"),
+    (unsigned int) client->warn_type,
+    GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (
+                                              client->warn_start),
+                                            GNUNET_YES));
 }
 
 
@@ -689,8 +675,7 @@ warn_no_client_continue (void *cls)
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if the client was dropped
  */
 static int
-service_client_mst_cb (void *cls,
-                       const struct GNUNET_MessageHeader *message)
+service_client_mst_cb (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
@@ -703,12 +688,10 @@ service_client_mst_cb (void *cls,
   client->warn_type = ntohs (message->type);
   client->warn_start = GNUNET_TIME_absolute_get ();
   GNUNET_assert (NULL == client->warn_task);
-  client->warn_task
-    = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
-                                    &warn_no_client_continue,
-                                    client);
-  GNUNET_MQ_inject_message (client->mq,
-                            message);
+  client->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                                    &warn_no_client_continue,
+                                                    client);
+  GNUNET_MQ_inject_message (client->mq, message);
   if (NULL != client->drop_task)
     return GNUNET_SYSERR;
   return GNUNET_OK;
@@ -728,10 +711,7 @@ service_client_recv (void *cls)
   int ret;
 
   client->recv_task = NULL;
-  ret = GNUNET_MST_read (client->mst,
-                         client->sock,
-                         GNUNET_NO,
-                         GNUNET_YES);
+  ret = GNUNET_MST_read (client->mst, client->sock, GNUNET_NO, GNUNET_YES);
   if (GNUNET_SYSERR == ret)
   {
     /* client closed connection (or IO error) */
@@ -751,11 +731,11 @@ service_client_recv (void *cls)
   if (NULL != client->recv_task)
     return;
   /* MST needs more data, re-schedule read job */
-  client->recv_task
-    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     client->sock,
-                                     &service_client_recv,
-                                     client);
+  client->recv_task =
+    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                   client->sock,
+                                   &service_client_recv,
+                                   client);
 }
 
 
@@ -773,9 +753,7 @@ start_client (struct GNUNET_SERVICE_Handle *sh,
   struct GNUNET_SERVICE_Client *client;
 
   client = GNUNET_new (struct GNUNET_SERVICE_Client);
-  GNUNET_CONTAINER_DLL_insert (sh->clients_head,
-                               sh->clients_tail,
-                               client);
+  GNUNET_CONTAINER_DLL_insert (sh->clients_head, sh->clients_tail, client);
   client->sh = sh;
   client->sock = csock;
   client->mq = GNUNET_MQ_queue_for_callbacks (&service_mq_send,
@@ -785,19 +763,15 @@ start_client (struct GNUNET_SERVICE_Handle *sh,
                                               sh->handlers,
                                               &service_mq_error_handler,
                                               client);
-  client->mst = GNUNET_MST_create (&service_client_mst_cb,
-                                   client);
+  client->mst = GNUNET_MST_create (&service_client_mst_cb, client);
   if (NULL != sh->connect_cb)
-    client->user_context = sh->connect_cb (sh->cb_cls,
-                                           client,
-                                           client->mq);
-  GNUNET_MQ_set_handlers_closure (client->mq,
-                                  client->user_context);
-  client->recv_task
-    = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     client->sock,
-                                     &service_client_recv,
-                                     client);
+    client->user_context = sh->connect_cb (sh->cb_cls, client, client->mq);
+  GNUNET_MQ_set_handlers_closure (client->mq, client->user_context);
+  client->recv_task =
+    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                   client->sock,
+                                   &service_client_recv,
+                                   client);
 }
 
 
@@ -830,11 +804,9 @@ accept_client (void *cls)
     if (NULL == sock)
     {
       if (EMFILE == errno)
-        do_suspend (sh,
-                    SUSPEND_STATE_EMFILE);
+        do_suspend (sh, SUSPEND_STATE_EMFILE);
       else if (EAGAIN != errno)
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
-                             "accept");
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "accept");
       break;
     }
     switch (sa.ss_family)
@@ -842,26 +814,22 @@ accept_client (void *cls)
     case AF_INET:
       GNUNET_assert (addrlen == sizeof (struct sockaddr_in));
       v4 = (const struct sockaddr_in *) &sa;
-      ok = ( ( (NULL == sh->v4_allowed) ||
-               (check_ipv4_listed (sh->v4_allowed,
-                                   &v4->sin_addr))) &&
-             ( (NULL == sh->v4_denied) ||
-               (! check_ipv4_listed (sh->v4_denied,
-                                     &v4->sin_addr)) ) );
+      ok = (((NULL == sh->v4_allowed) ||
+             (check_ipv4_listed (sh->v4_allowed, &v4->sin_addr))) &&
+            ((NULL == sh->v4_denied) ||
+             (! check_ipv4_listed (sh->v4_denied, &v4->sin_addr))));
       break;
     case AF_INET6:
       GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
       v6 = (const struct sockaddr_in6 *) &sa;
-      ok = ( ( (NULL == sh->v6_allowed) ||
-               (check_ipv6_listed (sh->v6_allowed,
-                                   &v6->sin6_addr))) &&
-             ( (NULL == sh->v6_denied) ||
-               (! check_ipv6_listed (sh->v6_denied,
-                                     &v6->sin6_addr)) ) );
+      ok = (((NULL == sh->v6_allowed) ||
+             (check_ipv6_listed (sh->v6_allowed, &v6->sin6_addr))) &&
+            ((NULL == sh->v6_denied) ||
+             (! check_ipv6_listed (sh->v6_denied, &v6->sin6_addr))));
       break;
 #ifndef WINDOWS
     case AF_UNIX:
-      ok = GNUNET_OK;            /* controlled using file-system ACL now */
+      ok = GNUNET_OK; /* controlled using file-system ACL now */
       break;
 #endif
     default:
@@ -874,26 +842,22 @@ accept_client (void *cls)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Service rejected incoming connection from %s due to policy.\n",
-           GNUNET_a2s ((const struct sockaddr *) &sa,
-                       addrlen));
-      GNUNET_break (GNUNET_OK ==
-                    GNUNET_NETWORK_socket_close (sock));
+           GNUNET_a2s ((const struct sockaddr *) &sa, addrlen));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
       continue;
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Service accepted incoming connection from %s.\n",
-         GNUNET_a2s ((const struct sockaddr *) &sa,
-                     addrlen));
-    start_client (slc->sh,
-                  sock);
+         GNUNET_a2s ((const struct sockaddr *) &sa, addrlen));
+    start_client (slc->sh, sock);
   }
   if (0 != sh->suspend_state)
     return;
-  slc->listen_task
-    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     slc->listen_socket,
-                                     &accept_client,
-                                     slc);
+  slc->listen_task =
+    GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                   slc->listen_socket,
+                                   &accept_client,
+                                   slc);
 }
 
 
@@ -905,24 +869,22 @@ accept_client (void *cls)
  *           or #SUSPEND_STATE_NONE on first startup
  */
 static void
-do_resume (struct GNUNET_SERVICE_Handle *sh,
-           enum SuspendReason sr)
+do_resume (struct GNUNET_SERVICE_Handle *sh, enum SuspendReason sr)
 {
   struct ServiceListenContext *slc;
 
-  GNUNET_assert ( (SUSPEND_STATE_NONE == sr) ||
-                  (0 != (sh->suspend_state & sr)) );
+  GNUNET_assert ((SUSPEND_STATE_NONE == sr) || (0 != (sh->suspend_state & sr)));
   sh->suspend_state -= sr;
   if (SUSPEND_STATE_NONE != sh->suspend_state)
     return;
   for (slc = sh->slc_head; NULL != slc; slc = slc->next)
   {
     GNUNET_assert (NULL == slc->listen_task);
-    slc->listen_task
-      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                       slc->listen_socket,
-                                       &accept_client,
-                                       slc);
+    slc->listen_task =
+      GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                     slc->listen_socket,
+                                     &accept_client,
+                                     slc);
   }
 }
 
@@ -940,22 +902,18 @@ service_main (void *cls)
   struct GNUNET_SERVICE_Handle *sh = cls;
 
   if (GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN != sh->options)
-    GNUNET_SCHEDULER_add_shutdown (&service_shutdown,
-                                   sh);
-  do_resume (sh,
-             SUSPEND_STATE_NONE);
+    GNUNET_SCHEDULER_add_shutdown (&service_shutdown, sh);
+  do_resume (sh, SUSPEND_STATE_NONE);
 
   if (-1 != sh->ready_confirm_fd)
   {
-    GNUNET_break (1 == WRITE (sh->ready_confirm_fd, ".", 1));
-    GNUNET_break (0 == CLOSE (sh->ready_confirm_fd));
+    GNUNET_break (1 == write (sh->ready_confirm_fd, ".", 1));
+    GNUNET_break (0 == close (sh->ready_confirm_fd));
     sh->ready_confirm_fd = -1;
   }
 
   if (NULL != sh->service_init_cb)
-    sh->service_init_cb (sh->cb_cls,
-                         sh->cfg,
-                         sh);
+    sh->service_init_cb (sh->cb_cls, sh->cfg, sh);
 }
 
 
@@ -975,9 +933,7 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
 {
   char *opt;
 
-  if (! GNUNET_CONFIGURATION_have_value (sh->cfg,
-                                         sh->service_name,
-                                         option))
+  if (! GNUNET_CONFIGURATION_have_value (sh->cfg, sh->service_name, option))
   {
     *ret = NULL;
     return GNUNET_OK;
@@ -1018,9 +974,7 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
 {
   char *opt;
 
-  if (! GNUNET_CONFIGURATION_have_value (sh->cfg,
-                                         sh->service_name,
-                                         option))
+  if (! GNUNET_CONFIGURATION_have_value (sh->cfg, sh->service_name, option))
   {
     *ret = NULL;
     return GNUNET_OK;
@@ -1066,9 +1020,7 @@ add_unixpath (struct sockaddr **saddrs,
 
   un = GNUNET_new (struct sockaddr_un);
   un->sun_family = AF_UNIX;
-  GNUNET_strlcpy (un->sun_path,
-                  unixpath,
-                  sizeof (un->sun_path));
+  GNUNET_strlcpy (un->sun_path, unixpath, sizeof (un->sun_path));
 #ifdef LINUX
   if (GNUNET_YES == abstract)
     un->sun_path[0] = '\0';
@@ -1132,24 +1084,18 @@ get_server_addresses (const char *service_name,
   *addr_lens = NULL;
   desc = NULL;
   disablev6 = GNUNET_NO;
-  if ( (GNUNET_NO ==
-        GNUNET_NETWORK_test_pf (PF_INET6)) ||
-       (GNUNET_YES ==
-        GNUNET_CONFIGURATION_get_value_yesno (cfg,
-                                              service_name,
-                                              "DISABLEV6") ) )
+  if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) ||
+      (GNUNET_YES ==
+       GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
     disablev6 = GNUNET_YES;
 
   port = 0;
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                       service_name,
-                                       "PORT"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
   {
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_number (cfg,
-                                               service_name,
-                                               "PORT",
-                                               &port))
+    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                            service_name,
+                                                            "PORT",
+                                                            &port))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
            _ ("Require valid port number for service `%s' in configuration!\n"),
@@ -1164,9 +1110,7 @@ get_server_addresses (const char *service_name,
     }
   }
 
-  if (GNUNET_CONFIGURATION_have_value (cfg,
-                                       service_name,
-                                       "BINDTO"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
                   GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -1181,14 +1125,11 @@ get_server_addresses (const char *service_name,
   abstract = GNUNET_NO;
 #ifdef AF_UNIX
   if ((GNUNET_YES ==
-       GNUNET_CONFIGURATION_have_value (cfg,
-                                        service_name,
-                                        "UNIXPATH")) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                service_name,
-                                                "UNIXPATH",
-                                                &unixpath)) &&
+       GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                             service_name,
+                                                             "UNIXPATH",
+                                                             &unixpath)) &&
       (0 < strlen (unixpath)))
   {
     /* probe UNIX support */
@@ -1201,9 +1142,7 @@ get_server_addresses (const char *service_name,
            unixpath,
            (unsigned long long) sizeof (s_un.sun_path));
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
-      LOG (GNUNET_ERROR_TYPE_INFO,
-           _ ("Using `%s' instead\n"),
-           unixpath);
+      LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
     }
 #ifdef LINUX
     abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -1212,27 +1151,19 @@ get_server_addresses (const char *service_name,
     if (GNUNET_SYSERR == abstract)
       abstract = GNUNET_NO;
 #endif
-    if ( (GNUNET_YES != abstract) &&
-         (GNUNET_OK !=
-          GNUNET_DISK_directory_create_for_file (unixpath)) )
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
-                                "mkdir",
-                                unixpath);
+    if ((GNUNET_YES != abstract) &&
+        (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
   }
   if (NULL != unixpath)
   {
-    desc = GNUNET_NETWORK_socket_create (AF_UNIX,
-                                         SOCK_STREAM,
-                                         0);
+    desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
     if (NULL == desc)
     {
-      if ((ENOBUFS == errno) ||
-          (ENOMEM == errno) ||
-          (ENFILE == errno) ||
+      if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
           (EACCES == errno))
       {
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                      "socket");
+        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
         GNUNET_free_non_null (hostname);
         GNUNET_free (unixpath);
         return GNUNET_SYSERR;
@@ -1241,14 +1172,13 @@ get_server_addresses (const char *service_name,
            _ (
              "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
            service_name,
-           STRERROR (errno));
+           strerror (errno));
       GNUNET_free (unixpath);
       unixpath = NULL;
     }
     else
     {
-      GNUNET_break (GNUNET_OK ==
-                    GNUNET_NETWORK_socket_close (desc));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc));
       desc = NULL;
     }
   }
@@ -1265,14 +1195,9 @@ get_server_addresses (const char *service_name,
   }
   if (0 == port)
   {
-    saddrs = GNUNET_new_array (2,
-                               struct sockaddr *);
-    saddrlens = GNUNET_new_array (2,
-                                  socklen_t);
-    add_unixpath (saddrs,
-                  saddrlens,
-                  unixpath,
-                  abstract);
+    saddrs = GNUNET_new_array (2, struct sockaddr *);
+    saddrlens = GNUNET_new_array (2, socklen_t);
+    add_unixpath (saddrs, saddrlens, unixpath, abstract);
     GNUNET_free_non_null (unixpath);
     GNUNET_free_non_null (hostname);
     *addrs = saddrs;
@@ -1286,16 +1211,11 @@ get_server_addresses (const char *service_name,
          "Resolving `%s' since that is where `%s' will bind to.\n",
          hostname,
          service_name);
-    memset (&hints,
-            0,
-            sizeof (struct addrinfo));
+    memset (&hints, 0, sizeof (struct addrinfo));
     if (disablev6)
       hints.ai_family = AF_INET;
     hints.ai_protocol = IPPROTO_TCP;
-    if ((0 != (ret = getaddrinfo (hostname,
-                                  NULL,
-                                  &hints,
-                                  &res))) ||
+    if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
         (NULL == res))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -1311,8 +1231,7 @@ get_server_addresses (const char *service_name,
     while (NULL != (pos = next))
     {
       next = pos->ai_next;
-      if ( (disablev6) &&
-           (pos->ai_family == AF_INET6) )
+      if ((disablev6) && (pos->ai_family == AF_INET6))
         continue;
       i++;
     }
@@ -1330,45 +1249,34 @@ get_server_addresses (const char *service_name,
     resi = i;
     if (NULL != unixpath)
       resi++;
-    saddrs = GNUNET_new_array (resi + 1,
-                               struct sockaddr *);
-    saddrlens = GNUNET_new_array (resi + 1,
-                                  socklen_t);
+    saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+    saddrlens = GNUNET_new_array (resi + 1, socklen_t);
     i = 0;
     if (NULL != unixpath)
     {
-      add_unixpath (saddrs,
-                    saddrlens,
-                    unixpath,
-                    abstract);
+      add_unixpath (saddrs, saddrlens, unixpath, abstract);
       i++;
     }
     next = res;
     while (NULL != (pos = next))
     {
       next = pos->ai_next;
-      if ( (disablev6) &&
-           (AF_INET6 == pos->ai_family) )
+      if ((disablev6) && (AF_INET6 == pos->ai_family))
         continue;
-      if ( (IPPROTO_TCP != pos->ai_protocol) &&
-           (0 != pos->ai_protocol) )
-        continue;               /* not TCP */
-      if ( (SOCK_STREAM != pos->ai_socktype) &&
-           (0 != pos->ai_socktype) )
-        continue;               /* huh? */
+      if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
+        continue; /* not TCP */
+      if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
+        continue; /* huh? */
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Service `%s' will bind to `%s'\n",
            service_name,
-           GNUNET_a2s (pos->ai_addr,
-                       pos->ai_addrlen));
+           GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
       if (AF_INET == pos->ai_family)
       {
         GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
         saddrlens[i] = pos->ai_addrlen;
         saddrs[i] = GNUNET_malloc (saddrlens[i]);
-        GNUNET_memcpy (saddrs[i],
-                       pos->ai_addr,
-                       saddrlens[i]);
+        GNUNET_memcpy (saddrs[i], pos->ai_addr, saddrlens[i]);
         ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port);
       }
       else
@@ -1377,9 +1285,7 @@ get_server_addresses (const char *service_name,
         GNUNET_assert (sizeof (struct sockaddr_in6) == pos->ai_addrlen);
         saddrlens[i] = pos->ai_addrlen;
         saddrs[i] = GNUNET_malloc (saddrlens[i]);
-        GNUNET_memcpy (saddrs[i],
-                       pos->ai_addr,
-                       saddrlens[i]);
+        GNUNET_memcpy (saddrs[i], pos->ai_addr, saddrlens[i]);
         ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port);
       }
       i++;
@@ -1398,16 +1304,11 @@ get_server_addresses (const char *service_name,
       if (NULL != unixpath)
         resi++;
       i = 0;
-      saddrs = GNUNET_new_array (resi + 1,
-                                 struct sockaddr *);
-      saddrlens = GNUNET_new_array (resi + 1,
-                                    socklen_t);
+      saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1, socklen_t);
       if (NULL != unixpath)
       {
-        add_unixpath (saddrs,
-                      saddrlens,
-                      unixpath,
-                      abstract);
+        add_unixpath (saddrs, saddrlens, unixpath, abstract);
         i++;
       }
       saddrlens[i] = sizeof (struct sockaddr_in);
@@ -1424,17 +1325,12 @@ get_server_addresses (const char *service_name,
       resi = 2;
       if (NULL != unixpath)
         resi++;
-      saddrs = GNUNET_new_array (resi + 1,
-                                 struct sockaddr *);
-      saddrlens = GNUNET_new_array (resi + 1,
-                                    socklen_t);
+      saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1, socklen_t);
       i = 0;
       if (NULL != unixpath)
       {
-        add_unixpath (saddrs,
-                      saddrlens,
-                      unixpath,
-                      abstract);
+        add_unixpath (saddrs, saddrlens, unixpath, abstract);
         i++;
       }
       saddrlens[i] = sizeof (struct sockaddr_in6);
@@ -1480,18 +1376,14 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
   HANDLE lsocks_pipe;
 
   env_buf = getenv ("GNUNET_OS_READ_LSOCKS");
-  if ( (NULL == env_buf) ||
-       (strlen (env_buf) <= 0) )
+  if ((NULL == env_buf) || (strlen (env_buf) <= 0))
     return NULL;
   /* Using W32 API directly here, because this pipe will
    * never be used outside of this function, and it's just too much of a bother
    * to create a GNUnet API that boxes a HANDLE (the way it is done with socks)
    */
-  lsocks_pipe = (HANDLE) strtoul (env_buf,
-                                  NULL,
-                                  10);
-  if ( (0 == lsocks_pipe) ||
-       (INVALID_HANDLE_VALUE == lsocks_pipe))
+  lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10);
+  if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
     return NULL;
   fail = 1;
   do
@@ -1500,17 +1392,10 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
     int fail2;
     DWORD rd;
 
-    ret = ReadFile (lsocks_pipe,
-                    &count,
-                    sizeof (count),
-                    &rd,
-                    NULL);
-    if ( (0 == ret) ||
-         (sizeof (count) != rd) ||
-         (0 == count) )
+    ret = ReadFile (lsocks_pipe, &count, sizeof (count), &rd, NULL);
+    if ((0 == ret) || (sizeof (count) != rd) || (0 == count))
       break;
-    lsocks = GNUNET_new_array (count + 1,
-                               struct GNUNET_NETWORK_Handle *);
+    lsocks = GNUNET_new_array (count + 1, struct GNUNET_NETWORK_Handle *);
 
     fail2 = 1;
     for (i = 0; i < count; i++)
@@ -1519,22 +1404,11 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
       uint64_t size;
       SOCKET s;
 
-      ret = ReadFile (lsocks_pipe,
-                      &size,
-                      sizeof (size),
-                      &rd,
-                      NULL);
-      if ( (0 == ret) ||
-           (sizeof (size) != rd) ||
-           (sizeof (pi) != size) )
+      ret = ReadFile (lsocks_pipe, &size, sizeof (size), &rd, NULL);
+      if ((0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size))
         break;
-      ret = ReadFile (lsocks_pipe,
-                      &pi,
-                      sizeof (pi),
-                      &rd,
-                      NULL);
-      if ( (0 == ret) ||
-           (sizeof (pi) != rd))
+      ret = ReadFile (lsocks_pipe, &pi, sizeof (pi), &rd, NULL);
+      if ((0 == ret) || (sizeof (pi) != rd))
         break;
       s = WSASocketA (pi.iAddressFamily,
                       pi.iSocketType,
@@ -1552,8 +1426,7 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
       break;
     lsocks[count] = NULL;
     fail = 0;
-  }
-  while (fail);
+  } while (fail);
   CloseHandle (lsocks_pipe);
 
   if (fail)
@@ -1561,8 +1434,7 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
     LOG (GNUNET_ERROR_TYPE_ERROR,
          _ ("Could not access a pre-bound socket, will try to bind myself\n"));
     for (i = 0; (i < count) && (NULL != lsocks[i]); i++)
-      GNUNET_break (GNUNET_OK ==
-                    GNUNET_NETWORK_socket_close (lsocks[i]));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (lsocks[i]));
     GNUNET_free (lsocks);
     return NULL;
   }
@@ -1579,8 +1451,7 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
  * @return NULL on error, otherwise the listen socket
  */
 static struct GNUNET_NETWORK_Handle *
-open_listen_socket (const struct sockaddr *server_addr,
-                    socklen_t socklen)
+open_listen_socket (const struct sockaddr *server_addr, socklen_t socklen)
 {
   struct GNUNET_NETWORK_Handle *sock;
   uint16_t port;
@@ -1602,20 +1473,15 @@ open_listen_socket (const struct sockaddr *server_addr,
     port = 0;
     break;
   }
-  sock = GNUNET_NETWORK_socket_create (server_addr->sa_family,
-                                       SOCK_STREAM,
-                                       0);
+  sock = GNUNET_NETWORK_socket_create (server_addr->sa_family, SOCK_STREAM, 0);
   if (NULL == sock)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "socket");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
     errno = 0;
     return NULL;
   }
   /* bind the socket */
-  if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock,
-                                               server_addr,
-                                               socklen))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, server_addr, socklen))
   {
     eno = errno;
     if (EADDRINUSE != errno)
@@ -1631,8 +1497,7 @@ open_listen_socket (const struct sockaddr *server_addr,
              port,
              (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6");
       else
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                      "bind");
+        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "bind");
       eno = 0;
     }
     else
@@ -1640,7 +1505,8 @@ open_listen_socket (const struct sockaddr *server_addr,
       if (0 != port)
         LOG (GNUNET_ERROR_TYPE_WARNING,
              _ ("`%s' failed for port %d (%s): address already in use\n"),
-             "bind", port,
+             "bind",
+             port,
              (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6");
       else if (AF_UNIX == server_addr->sa_family)
       {
@@ -1650,18 +1516,14 @@ open_listen_socket (const struct sockaddr *server_addr,
              GNUNET_a2s (server_addr, socklen));
       }
     }
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (sock));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
     errno = eno;
     return NULL;
   }
-  if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock,
-                                                 5))
+  if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock, 5))
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "listen");
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (sock));
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "listen");
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
     errno = 0;
     return NULL;
   }
@@ -1701,16 +1563,12 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
   char dummy[2];
 #endif
 
-  if (GNUNET_CONFIGURATION_have_value
-        (sh->cfg,
-        sh->service_name,
-        "TOLERANT"))
+  if (GNUNET_CONFIGURATION_have_value (sh->cfg, sh->service_name, "TOLERANT"))
   {
     if (GNUNET_SYSERR ==
-        (tolerant =
-           GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
-                                                 sh->service_name,
-                                                 "TOLERANT")))
+        (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
+                                                          sh->service_name,
+                                                          "TOLERANT")))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
            _ ("Specified value for `%s' of service `%s' is invalid\n"),
@@ -1725,25 +1583,16 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
   lsocks = NULL;
 #ifndef MINGW
   errno = 0;
-  if ( (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
-       (1 == SSCANF (nfds,
-                     "%u%1s",
-                     &cnt,
-                     dummy)) &&
-       (cnt > 0) &&
-       (cnt < FD_SETSIZE) &&
-       (cnt + 4 < FD_SETSIZE) )
+  if ((NULL != (nfds = getenv ("LISTEN_FDS"))) &&
+      (1 == sscanf (nfds, "%u%1s", &cnt, dummy)) && (cnt > 0) &&
+      (cnt < FD_SETSIZE) && (cnt + 4 < FD_SETSIZE))
   {
-    lsocks = GNUNET_new_array (cnt + 1,
-                               struct GNUNET_NETWORK_Handle *);
+    lsocks = GNUNET_new_array (cnt + 1, struct GNUNET_NETWORK_Handle *);
     while (0 < cnt--)
     {
-      flags = fcntl (3 + cnt,
-                     F_GETFD);
-      if ( (flags < 0) ||
-           (0 != (flags & FD_CLOEXEC)) ||
-           (NULL ==
-            (lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt))))
+      flags = fcntl (3 + cnt, F_GETFD);
+      if ((flags < 0) || (0 != (flags & FD_CLOEXEC)) ||
+          (NULL == (lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt))))
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
              _ (
@@ -1780,9 +1629,7 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
       slc = GNUNET_new (struct ServiceListenContext);
       slc->sh = sh;
       slc->listen_socket = *ls;
-      GNUNET_CONTAINER_DLL_insert (sh->slc_head,
-                                   sh->slc_tail,
-                                   slc);
+      GNUNET_CONTAINER_DLL_insert (sh->slc_head, sh->slc_tail, slc);
     }
     GNUNET_free (lsocks);
   }
@@ -1792,10 +1639,7 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
     socklen_t *addrlens;
     int num;
 
-    num = get_server_addresses (sh->service_name,
-                                sh->cfg,
-                                &addrs,
-                                &addrlens);
+    num = get_server_addresses (sh->service_name, sh->cfg, &addrs, &addrlens);
     if (GNUNET_SYSERR == num)
       return GNUNET_SYSERR;
 
@@ -1805,54 +1649,40 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
 
       slc = GNUNET_new (struct ServiceListenContext);
       slc->sh = sh;
-      slc->listen_socket = open_listen_socket (addrs[i],
-                                               addrlens[i]);
+      slc->listen_socket = open_listen_socket (addrs[i], addrlens[i]);
       GNUNET_free (addrs[i]);
       if (NULL == slc->listen_socket)
       {
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                             "bind");
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
         GNUNET_free (slc);
         continue;
       }
-      GNUNET_CONTAINER_DLL_insert (sh->slc_head,
-                                   sh->slc_tail,
-                                   slc);
+      GNUNET_CONTAINER_DLL_insert (sh->slc_head, sh->slc_tail, slc);
     }
     GNUNET_free_non_null (addrlens);
     GNUNET_free_non_null (addrs);
-    if ( (0 != num) &&
-         (NULL == sh->slc_head) )
+    if ((0 != num) && (NULL == sh->slc_head))
     {
       /* All attempts to bind failed, hard failure */
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _ (
-                    "Could not bind to any of the ports I was supposed to, refusing to run!\n"));
+      GNUNET_log (
+        GNUNET_ERROR_TYPE_ERROR,
+        _ (
+          "Could not bind to any of the ports I was supposed to, refusing to run!\n"));
       return GNUNET_SYSERR;
     }
   }
 
   sh->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
-  sh->match_uid
-    = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
-                                            sh->service_name,
-                                            "UNIX_MATCH_UID");
-  sh->match_gid
-    = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
-                                            sh->service_name,
-                                            "UNIX_MATCH_GID");
-  process_acl4 (&sh->v4_denied,
-                sh,
-                "REJECT_FROM");
-  process_acl4 (&sh->v4_allowed,
-                sh,
-                "ACCEPT_FROM");
-  process_acl6 (&sh->v6_denied,
-                sh,
-                "REJECT_FROM6");
-  process_acl6 (&sh->v6_allowed,
-                sh,
-                "ACCEPT_FROM6");
+  sh->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
+                                                        sh->service_name,
+                                                        "UNIX_MATCH_UID");
+  sh->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg,
+                                                        sh->service_name,
+                                                        "UNIX_MATCH_GID");
+  process_acl4 (&sh->v4_denied, sh, "REJECT_FROM");
+  process_acl4 (&sh->v4_allowed, sh, "ACCEPT_FROM");
+  process_acl6 (&sh->v6_denied, sh, "REJECT_FROM6");
+  process_acl6 (&sh->v6_allowed, sh, "ACCEPT_FROM6");
   return GNUNET_OK;
 }
 
@@ -1869,11 +1699,10 @@ get_user_name (struct GNUNET_SERVICE_Handle *sh)
 {
   char *un;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (sh->cfg,
-                                               sh->service_name,
-                                               "USERNAME",
-                                               &un))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sh->cfg,
+                                                            sh->service_name,
+                                                            "USERNAME",
+                                                            &un))
     return NULL;
   return un;
 }
@@ -1891,7 +1720,7 @@ set_user_id (struct GNUNET_SERVICE_Handle *sh)
   char *user;
 
   if (NULL == (user = get_user_name (sh)))
-    return GNUNET_OK;           /* keep */
+    return GNUNET_OK; /* keep */
 #ifndef MINGW
   struct passwd *pws;
 
@@ -1902,28 +1731,23 @@ set_user_id (struct GNUNET_SERVICE_Handle *sh)
     LOG (GNUNET_ERROR_TYPE_ERROR,
          _ ("Cannot obtain information about user `%s': %s\n"),
          user,
-         errno == 0 ? _ ("No such user") : STRERROR (errno));
+         errno == 0 ? _ ("No such user") : strerror (errno));
     GNUNET_free (user);
     return GNUNET_SYSERR;
   }
-  if ( (0 != setgid (pws->pw_gid)) ||
-       (0 != setegid (pws->pw_gid)) ||
+  if ((0 != setgid (pws->pw_gid)) || (0 != setegid (pws->pw_gid)) ||
 #if HAVE_INITGROUPS
-       (0 != initgroups (user,
-                         pws->pw_gid)) ||
+      (0 != initgroups (user, pws->pw_gid)) ||
 #endif
-       (0 != setuid (pws->pw_uid)) ||
-       (0 != seteuid (pws->pw_uid)))
+      (0 != setuid (pws->pw_uid)) || (0 != seteuid (pws->pw_uid)))
   {
-    if ((0 != setregid (pws->pw_gid,
-                        pws->pw_gid)) ||
-        (0 != setreuid (pws->pw_uid,
-                        pws->pw_uid)))
+    if ((0 != setregid (pws->pw_gid, pws->pw_gid)) ||
+        (0 != setreuid (pws->pw_uid, pws->pw_uid)))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
            _ ("Cannot change user/group to `%s': %s\n"),
            user,
-           STRERROR (errno));
+           strerror (errno));
       GNUNET_free (user);
       return GNUNET_SYSERR;
     }
@@ -1946,11 +1770,10 @@ get_pid_file_name (struct GNUNET_SERVICE_Handle *sh)
 {
   char *pif;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (sh->cfg,
-                                               sh->service_name,
-                                               "PIDFILE",
-                                               &pif))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sh->cfg,
+                                                            sh->service_name,
+                                                            "PIDFILE",
+                                                            &pif))
     return NULL;
   return pif;
 }
@@ -1967,11 +1790,9 @@ pid_file_delete (struct GNUNET_SERVICE_Handle *sh)
   char *pif = get_pid_file_name (sh);
 
   if (NULL == pif)
-    return;                     /* no PID file */
-  if (0 != UNLINK (pif))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
-                       "unlink",
-                       pif);
+    return; /* no PID file */
+  if (0 != unlink (pif))
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", pif);
   GNUNET_free (pif);
 }
 
@@ -1990,17 +1811,15 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh)
   int nullfd;
   int filedes[2];
 
-  if (0 != PIPE (filedes))
+  if (0 != pipe (filedes))
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "pipe");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe");
     return GNUNET_SYSERR;
   }
   pid = fork ();
   if (pid < 0)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "fork");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
     return GNUNET_SYSERR;
   }
   if (0 != pid)
@@ -2008,13 +1827,10 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh)
     /* Parent */
     char c;
 
-    GNUNET_break (0 == CLOSE (filedes[1]));
+    GNUNET_break (0 == close (filedes[1]));
     c = 'X';
-    if (1 != READ (filedes[0],
-                   &c,
-                   sizeof (char)))
-      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                    "read");
+    if (1 != read (filedes[0], &c, sizeof (char)))
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "read");
     fflush (stdout);
     switch (c)
     {
@@ -2033,30 +1849,26 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh)
            _ ("Service process failed to report status\n"));
       break;
     }
-    exit (1);                   /* child reported error */
+    exit (1); /* child reported error */
   }
-  GNUNET_break (0 == CLOSE (0));
-  GNUNET_break (0 == CLOSE (1));
-  GNUNET_break (0 == CLOSE (filedes[0]));
-  nullfd = OPEN ("/dev/null",
-                 O_RDWR | O_APPEND);
+  GNUNET_break (0 == close (0));
+  GNUNET_break (0 == close (1));
+  GNUNET_break (0 == close (filedes[0]));
+  nullfd = open ("/dev/null", O_RDWR | O_APPEND);
   if (nullfd < 0)
     return GNUNET_SYSERR;
   /* set stdin/stdout to /dev/null */
-  if ( (dup2 (nullfd, 0) < 0) ||
-       (dup2 (nullfd, 1) < 0) )
+  if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0))
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "dup2");
-    (void) CLOSE (nullfd);
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2");
+    (void) close (nullfd);
     return GNUNET_SYSERR;
   }
-  (void) CLOSE (nullfd);
+  (void) close (nullfd);
   /* Detach from controlling terminal */
   pid = setsid ();
   if (-1 == pid)
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                  "setsid");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "setsid");
   sh->ready_confirm_fd = filedes[1];
 #else
   /* FIXME: we probably need to do something else
@@ -2084,9 +1896,7 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh)
   GNUNET_free_non_null (sh->v6_allowed);
   while (NULL != (slc = sh->slc_head))
   {
-    GNUNET_CONTAINER_DLL_remove (sh->slc_head,
-                                 sh->slc_tail,
-                                 slc);
+    GNUNET_CONTAINER_DLL_remove (sh->slc_head, sh->slc_tail, slc);
     if (NULL != slc->listen_task)
       GNUNET_SCHEDULER_cancel (slc->listen_task);
     GNUNET_break (GNUNET_OK ==
@@ -2103,8 +1913,7 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh)
  * @param msg AGPL request
  */
 static void
-return_agpl (void *cls,
-             const struct GNUNET_MessageHeader *msg)
+return_agpl (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct GNUNET_SERVICE_Client *client = cls;
   struct GNUNET_MQ_Handle *mq;
@@ -2114,15 +1923,10 @@ return_agpl (void *cls,
 
   (void) msg;
   slen = strlen (GNUNET_AGPL_URL) + 1;
-  env = GNUNET_MQ_msg_extra (res,
-                             GNUNET_MESSAGE_TYPE_RESPONSE_AGPL,
-                             slen);
-  memcpy (&res[1],
-          GNUNET_AGPL_URL,
-          slen);
+  env = GNUNET_MQ_msg_extra (res, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, slen);
+  memcpy (&res[1], GNUNET_AGPL_URL, slen);
   mq = GNUNET_SERVICE_client_get_mq (client);
-  GNUNET_MQ_send (mq,
-                  env);
+  GNUNET_MQ_send (mq, env);
   GNUNET_SERVICE_client_continue (client);
 }
 
@@ -2179,17 +1983,14 @@ GNUNET_SERVICE_start (const char *service_name,
   sh->connect_cb = connect_cb;
   sh->disconnect_cb = disconnect_cb;
   sh->cb_cls = cls;
-  sh->handlers = GNUNET_MQ_copy_handlers2 (handlers,
-                                           &return_agpl,
-                                           NULL);
+  sh->handlers = GNUNET_MQ_copy_handlers2 (handlers, &return_agpl, NULL);
   if (GNUNET_OK != setup_service (sh))
   {
     GNUNET_free_non_null (sh->handlers);
     GNUNET_free (sh);
     return NULL;
   }
-  do_resume (sh,
-             SUSPEND_STATE_NONE);
+  do_resume (sh, SUSPEND_STATE_NONE);
   return sh;
 }
 
@@ -2279,24 +2080,21 @@ GNUNET_SERVICE_run_ (int argc,
   int ret;
   int err;
 
-  struct GNUNET_GETOPT_CommandLineOption service_options[] = {
-    GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
-    GNUNET_GETOPT_option_flag ('d',
-                               "daemonize",
-                               gettext_noop (
-                                 "do daemonize (detach from terminal)"),
-                               &do_daemonize),
-    GNUNET_GETOPT_option_help (NULL),
-    GNUNET_GETOPT_option_loglevel (&loglev),
-    GNUNET_GETOPT_option_logfile (&logfile),
-    GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption service_options[] =
+    {GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
+     GNUNET_GETOPT_option_flag ('d',
+                                "daemonize",
+                                gettext_noop (
+                                  "do daemonize (detach from terminal)"),
+                                &do_daemonize),
+     GNUNET_GETOPT_option_help (NULL),
+     GNUNET_GETOPT_option_loglevel (&loglev),
+     GNUNET_GETOPT_option_logfile (&logfile),
+     GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
+     GNUNET_GETOPT_OPTION_END};
 
   err = 1;
-  memset (&sh,
-          0,
-          sizeof (sh));
+  memset (&sh, 0, sizeof (sh));
   xdg = getenv ("XDG_CONFIG_HOME");
   if (NULL != xdg)
     GNUNET_asprintf (&cfg_filename,
@@ -2305,8 +2103,8 @@ GNUNET_SERVICE_run_ (int argc,
                      DIR_SEPARATOR_STR,
                      GNUNET_OS_project_data_get ()->config_file);
   else
-    cfg_filename = GNUNET_strdup (
-      GNUNET_OS_project_data_get ()->user_config_file);
+    cfg_filename =
+      GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
   sh.ready_confirm_fd = -1;
   sh.options = options;
   sh.cfg = cfg = GNUNET_CONFIGURATION_create ();
@@ -2322,10 +2120,7 @@ GNUNET_SERVICE_run_ (int argc,
   logfile = NULL;
   opt_cfg_filename = NULL;
   do_daemonize = 0;
-  ret = GNUNET_GETOPT_run (service_name,
-                           service_options,
-                           argc,
-                           argv);
+  ret = GNUNET_GETOPT_run (service_name, service_options, argc, argv);
   if (GNUNET_SYSERR == ret)
     goto shutdown;
   if (GNUNET_NO == ret)
@@ -2333,20 +2128,15 @@ GNUNET_SERVICE_run_ (int argc,
     err = 0;
     goto shutdown;
   }
-  if (GNUNET_OK != GNUNET_log_setup (service_name,
-                                     loglev,
-                                     logfile))
+  if (GNUNET_OK != GNUNET_log_setup (service_name, loglev, logfile))
   {
     GNUNET_break (0);
     goto shutdown;
   }
   if (NULL != opt_cfg_filename)
   {
-    if ( (GNUNET_YES !=
-          GNUNET_DISK_file_test (opt_cfg_filename)) ||
-         (GNUNET_SYSERR ==
-          GNUNET_CONFIGURATION_load (cfg,
-                                     opt_cfg_filename)) )
+    if ((GNUNET_YES != GNUNET_DISK_file_test (opt_cfg_filename)) ||
+        (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_filename)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _ ("Malformed configuration file `%s', exit ...\n"),
@@ -2356,12 +2146,9 @@ GNUNET_SERVICE_run_ (int argc,
   }
   else
   {
-    if (GNUNET_YES ==
-        GNUNET_DISK_file_test (cfg_filename))
+    if (GNUNET_YES == GNUNET_DISK_file_test (cfg_filename))
     {
-      if (GNUNET_SYSERR ==
-          GNUNET_CONFIGURATION_load (cfg,
-                                     cfg_filename))
+      if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_filename))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                     _ ("Malformed configuration file `%s', exit ...\n"),
@@ -2371,9 +2158,7 @@ GNUNET_SERVICE_run_ (int argc,
     }
     else
     {
-      if (GNUNET_SYSERR ==
-          GNUNET_CONFIGURATION_load (cfg,
-                                     NULL))
+      if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                     _ ("Malformed configuration, exit ...\n"));
@@ -2383,8 +2168,7 @@ GNUNET_SERVICE_run_ (int argc,
   }
   if (GNUNET_OK != setup_service (&sh))
     goto shutdown;
-  if ( (1 == do_daemonize) &&
-       (GNUNET_OK != detach_terminal (&sh)) )
+  if ((1 == do_daemonize) && (GNUNET_OK != detach_terminal (&sh)))
   {
     GNUNET_break (0);
     goto shutdown;
@@ -2395,64 +2179,51 @@ GNUNET_SERVICE_run_ (int argc,
        "Service `%s' runs with configuration from `%s'\n",
        service_name,
        (NULL != opt_cfg_filename) ? opt_cfg_filename : cfg_filename);
-  if ((GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_number (sh.cfg,
-                                              "TESTING",
-                                              "SKEW_OFFSET",
-                                              &skew_offset)) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_number (sh.cfg,
-                                              "TESTING",
-                                              "SKEW_VARIANCE",
-                                              &skew_variance)))
+  if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sh.cfg,
+                                                           "TESTING",
+                                                           "SKEW_OFFSET",
+                                                           &skew_offset)) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sh.cfg,
+                                                           "TESTING",
+                                                           "SKEW_VARIANCE",
+                                                           &skew_variance)))
   {
     clock_offset = skew_offset - skew_variance;
     GNUNET_TIME_set_offset (clock_offset);
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Skewing clock by %dll ms\n",
-         clock_offset);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Skewing clock by %dll ms\n", clock_offset);
   }
   GNUNET_RESOLVER_connect (sh.cfg);
 
   /* actually run service */
   err = 0;
-  GNUNET_SCHEDULER_run (&service_main,
-                        &sh);
+  GNUNET_SCHEDULER_run (&service_main, &sh);
   /* shutdown */
   if (1 == do_daemonize)
     pid_file_delete (&sh);
 
-  shutdown:
+shutdown:
   if (-1 != sh.ready_confirm_fd)
   {
-    if (1 != WRITE (sh.ready_confirm_fd,
-                    err ? "I" : "S",
-                    1))
-      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                    "write");
-    GNUNET_break (0 == CLOSE (sh.ready_confirm_fd));
+    if (1 != write (sh.ready_confirm_fd, err ? "I" : "S", 1))
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write");
+    GNUNET_break (0 == close (sh.ready_confirm_fd));
   }
 #if HAVE_MALLINFO
   {
     char *counter;
 
-    if ( (GNUNET_YES ==
-          GNUNET_CONFIGURATION_have_value (sh.cfg,
-                                           service_name,
-                                           "GAUGER_HEAP")) &&
-         (GNUNET_OK ==
-          GNUNET_CONFIGURATION_get_value_string (sh.cfg,
-                                                 service_name,
-                                                 "GAUGER_HEAP",
-                                                 &counter)) )
+    if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sh.cfg,
+                                                        service_name,
+                                                        "GAUGER_HEAP")) &&
+        (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sh.cfg,
+                                                             service_name,
+                                                             "GAUGER_HEAP",
+                                                             &counter)))
     {
       struct mallinfo mi;
 
       mi = mallinfo ();
-      GAUGER (service_name,
-              counter,
-              mi.usmblks,
-              "blocks");
+      GAUGER (service_name, counter, mi.usmblks, "blocks");
       GNUNET_free (counter);
     }
   }
@@ -2479,8 +2250,7 @@ GNUNET_SERVICE_run_ (int argc,
 void
 GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh)
 {
-  do_suspend (sh,
-              SUSPEND_STATE_APP);
+  do_suspend (sh, SUSPEND_STATE_APP);
 }
 
 
@@ -2492,8 +2262,7 @@ GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh)
 void
 GNUNET_SERVICE_resume (struct GNUNET_SERVICE_Handle *sh)
 {
-  do_resume (sh,
-             SUSPEND_STATE_APP);
+  do_resume (sh, SUSPEND_STATE_APP);
 }
 
 
@@ -2511,8 +2280,7 @@ resume_client_receive (void *cls)
 
   c->recv_task = NULL;
   /* first, check if there is still something in the buffer */
-  ret = GNUNET_MST_next (c->mst,
-                         GNUNET_YES);
+  ret = GNUNET_MST_next (c->mst, GNUNET_YES);
   if (GNUNET_SYSERR == ret)
   {
     if (NULL == c->drop_task)
@@ -2527,11 +2295,10 @@ resume_client_receive (void *cls)
   /* need to receive more data from the network first */
   if (NULL != c->recv_task)
     return;
-  c->recv_task
-    = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
-                                     c->sock,
-                                     &service_client_recv,
-                                     c);
+  c->recv_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
+                                                c->sock,
+                                                &service_client_recv,
+                                                c);
 }
 
 
@@ -2553,9 +2320,7 @@ GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c)
     GNUNET_SCHEDULER_cancel (c->warn_task);
     c->warn_task = NULL;
   }
-  c->recv_task
-    = GNUNET_SCHEDULER_add_now (&resume_client_receive,
-                                c);
+  c->recv_task = GNUNET_SCHEDULER_add_now (&resume_client_receive, c);
 }
 
 
@@ -2598,20 +2363,18 @@ finish_client_drop (void *cls)
   GNUNET_MQ_destroy (c->mq);
   if (GNUNET_NO == c->persist)
   {
-    GNUNET_break (GNUNET_OK ==
-                  GNUNET_NETWORK_socket_close (c->sock));
-    if ( (0 != (SUSPEND_STATE_EMFILE & sh->suspend_state)) &&
-         (0 == (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)) )
-      do_resume (sh,
-                 SUSPEND_STATE_EMFILE);
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (c->sock));
+    if ((0 != (SUSPEND_STATE_EMFILE & sh->suspend_state)) &&
+        (0 == (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)))
+      do_resume (sh, SUSPEND_STATE_EMFILE);
   }
   else
   {
     GNUNET_NETWORK_socket_free_memory_only_ (c->sock);
   }
   GNUNET_free (c);
-  if ( (0 != (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)) &&
-       (GNUNET_NO == have_non_monitor_clients (sh)) )
+  if ((0 != (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)) &&
+      (GNUNET_NO == have_non_monitor_clients (sh)))
     GNUNET_SERVICE_shutdown (sh);
 }
 
@@ -2640,8 +2403,7 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c)
     void *backtrace_array[MAX_TRACE_DEPTH];
     int num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH);
     char **backtrace_strings =
-      backtrace_symbols (backtrace_array,
-                         t->num_backtrace_strings);
+      backtrace_symbols (backtrace_array, t->num_backtrace_strings);
     for (unsigned int i = 0; i < num_backtrace_strings; i++)
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "client drop trace %u: %s\n",
@@ -2655,13 +2417,9 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c)
     GNUNET_assert (0);
     return;
   }
-  GNUNET_CONTAINER_DLL_remove (sh->clients_head,
-                               sh->clients_tail,
-                               c);
+  GNUNET_CONTAINER_DLL_remove (sh->clients_head, sh->clients_tail, c);
   if (NULL != sh->disconnect_cb)
-    sh->disconnect_cb (sh->cb_cls,
-                       c,
-                       c->user_context);
+    sh->disconnect_cb (sh->cb_cls, c, c->user_context);
   if (NULL != c->warn_task)
   {
     GNUNET_SCHEDULER_cancel (c->warn_task);
@@ -2677,8 +2435,7 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c)
     GNUNET_SCHEDULER_cancel (c->send_task);
     c->send_task = NULL;
   }
-  c->drop_task = GNUNET_SCHEDULER_add_now (&finish_client_drop,
-                                           c);
+  c->drop_task = GNUNET_SCHEDULER_add_now (&finish_client_drop, c);
 }
 
 
@@ -2693,8 +2450,7 @@ GNUNET_SERVICE_shutdown (struct GNUNET_SERVICE_Handle *sh)
   struct GNUNET_SERVICE_Client *client;
 
   if (0 == (sh->suspend_state & SUSPEND_STATE_SHUTDOWN))
-    do_suspend (sh,
-                SUSPEND_STATE_SHUTDOWN);
+    do_suspend (sh, SUSPEND_STATE_SHUTDOWN);
   while (NULL != (client = sh->clients_head))
     GNUNET_SERVICE_client_drop (client);
 }
@@ -2716,8 +2472,8 @@ void
 GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c)
 {
   c->is_monitor = GNUNET_YES;
-  if ( ((0 != (SUSPEND_STATE_SHUTDOWN & c->sh->suspend_state))&&
-        (GNUNET_NO == have_non_monitor_clients (c->sh)) ) )
+  if (((0 != (SUSPEND_STATE_SHUTDOWN & c->sh->suspend_state)) &&
+       (GNUNET_NO == have_non_monitor_clients (c->sh))))
     GNUNET_SERVICE_shutdown (c->sh);
 }
 
index 8cd591288963dc977578231006bfc5286fd4bff3..ef9fdd6934071db48602a15ecd50e1dfcbc24a96 100644 (file)
 #include <unistr.h>
 #include <uniconv.h>
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-strings", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-strings", __VA_ARGS__)
 
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-strings", syscall)
+#define LOG_STRERROR(kind, syscall) \
+  GNUNET_log_from_strerror (kind, "util-strings", syscall)
 
 
 /**
@@ -105,15 +106,13 @@ GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
 
   off = 0;
   buf = GNUNET_malloc (plen);
-  for (unsigned int i = 0;
-       i < num_pids;
-       i++)
+  for (unsigned int i = 0; i < num_pids; i++)
   {
     off += GNUNET_snprintf (&buf[off],
                             plen - off,
                             "%s%s",
                             GNUNET_i2s (&pids[i]),
-                            (i == num_pids -1) ? "" : "-");
+                            (i == num_pids - 1) ? "" : "-");
   }
   return buf;
 }
@@ -133,8 +132,10 @@ GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
  *         in the buffer, or 0 on error.
  */
 unsigned int
-GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size,
-                                unsigned int count, ...)
+GNUNET_STRINGS_buffer_tokenize (const char *buffer,
+                                size_t size,
+                                unsigned int count,
+                                ...)
 {
   unsigned int start;
   unsigned int needed;
@@ -153,10 +154,10 @@ GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size,
     if (needed == size)
     {
       va_end (ap);
-      return 0;                 /* error */
+      return 0; /* error */
     }
     *r = &buffer[start];
-    needed++;                   /* skip 0-termination */
+    needed++; /* skip 0-termination */
     count--;
   }
   va_end (ap);
@@ -173,7 +174,7 @@ GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size,
 char *
 GNUNET_STRINGS_byte_size_fancy (unsigned long long size)
 {
-  const char *unit = _/* size unit */ "b");
+  const char *unit = _ (/* size unit */ "b");
   char *ret;
 
   if (size > 5 * 1024)
@@ -215,7 +216,7 @@ GNUNET_STRINGS_byte_size_fancy (unsigned long long size)
  *        null byte
  */
 size_t
-GNUNET_strlcpy(char *dst, const char *src, size_t n)
+GNUNET_strlcpy (char *dst, const char *src, size_t n)
 {
   size_t slen;
 
@@ -257,8 +258,8 @@ struct ConversionTable
  */
 static int
 convert_with_table (const char *input,
-                   const struct ConversionTable *table,
-                   unsigned long long *output)
+                    const struct ConversionTable *table,
+                    unsigned long long *output)
 {
   unsigned long long ret;
   char *in;
@@ -290,7 +291,7 @@ convert_with_table (const char *input,
         if ((0 != errno) || (endptr == tok))
         {
           GNUNET_free (in);
-          return GNUNET_SYSERR;   /* expected number */
+          return GNUNET_SYSERR; /* expected number */
         }
         if ('\0' == endptr[0])
           break; /* next tok */
@@ -318,26 +319,22 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
                                     unsigned long long *size)
 {
   static const struct ConversionTable table[] =
-  {
-    { "B", 1},
-    { "KiB", 1024},
-    { "kB", 1000},
-    { "MiB", 1024 * 1024},
-    { "MB", 1000 * 1000},
-    { "GiB", 1024 * 1024 * 1024},
-    { "GB", 1000 * 1000 * 1000},
-    { "TiB", 1024LL * 1024LL * 1024LL * 1024LL},
-    { "TB", 1000LL * 1000LL * 1000LL * 1024LL},
-    { "PiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL},
-    { "PB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL},
-    { "EiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL},
-    { "EB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL * 1000LL},
-    { NULL, 0}
-  };
-
-  return convert_with_table (fancy_size,
-                            table,
-                            size);
+    {{"B", 1},
+     {"KiB", 1024},
+     {"kB", 1000},
+     {"MiB", 1024 * 1024},
+     {"MB", 1000 * 1000},
+     {"GiB", 1024 * 1024 * 1024},
+     {"GB", 1000 * 1000 * 1000},
+     {"TiB", 1024LL * 1024LL * 1024LL * 1024LL},
+     {"TB", 1000LL * 1000LL * 1000LL * 1024LL},
+     {"PiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL},
+     {"PB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL},
+     {"EiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL},
+     {"EB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL * 1000LL},
+     {NULL, 0}};
+
+  return convert_with_table (fancy_size, table, size);
 }
 
 
@@ -354,31 +351,29 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
                                        struct GNUNET_TIME_Relative *rtime)
 {
   static const struct ConversionTable table[] =
-  {
-    { "us", 1},
-    { "ms", 1000 },
-    { "s", 1000 * 1000LL },
-    { "second", 1000 * 1000LL },
-    { "seconds", 1000 * 1000LL },
-    { "\"", 1000  * 1000LL },
-    { "m", 60 * 1000  * 1000LL},
-    { "min", 60 * 1000  * 1000LL},
-    { "minute", 60 * 1000  * 1000LL},
-    { "minutes", 60 * 1000  * 1000LL},
-    { "'", 60 * 1000  * 1000LL},
-    { "h", 60 * 60 * 1000  * 1000LL},
-    { "hour", 60 * 60 * 1000  * 1000LL},
-    { "hours", 60 * 60 * 1000  * 1000LL},
-    { "d", 24 * 60 * 60 * 1000LL * 1000LL},
-    { "day", 24 * 60 * 60 * 1000LL * 1000LL},
-    { "days", 24 * 60 * 60 * 1000LL * 1000LL},
-    { "week", 7 * 24 * 60 * 60 * 1000LL * 1000LL},
-    { "weeks", 7 * 24 * 60 * 60 * 1000LL * 1000LL},
-    { "year", 31536000000000LL /* year */ },
-    { "years", 31536000000000LL /* year */ },
-    { "a", 31536000000000LL /* year */ },
-    { NULL, 0}
-  };
+    {{"us", 1},
+     {"ms", 1000},
+     {"s", 1000 * 1000LL},
+     {"second", 1000 * 1000LL},
+     {"seconds", 1000 * 1000LL},
+     {"\"", 1000 * 1000LL},
+     {"m", 60 * 1000 * 1000LL},
+     {"min", 60 * 1000 * 1000LL},
+     {"minute", 60 * 1000 * 1000LL},
+     {"minutes", 60 * 1000 * 1000LL},
+     {"'", 60 * 1000 * 1000LL},
+     {"h", 60 * 60 * 1000 * 1000LL},
+     {"hour", 60 * 60 * 1000 * 1000LL},
+     {"hours", 60 * 60 * 1000 * 1000LL},
+     {"d", 24 * 60 * 60 * 1000LL * 1000LL},
+     {"day", 24 * 60 * 60 * 1000LL * 1000LL},
+     {"days", 24 * 60 * 60 * 1000LL * 1000LL},
+     {"week", 7 * 24 * 60 * 60 * 1000LL * 1000LL},
+     {"weeks", 7 * 24 * 60 * 60 * 1000LL * 1000LL},
+     {"year", 31536000000000LL /* year */},
+     {"years", 31536000000000LL /* year */},
+     {"a", 31536000000000LL /* year */},
+     {NULL, 0}};
   int ret;
   unsigned long long val;
 
@@ -387,9 +382,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
     *rtime = GNUNET_TIME_UNIT_FOREVER_REL;
     return GNUNET_OK;
   }
-  ret = convert_with_table (fancy_time,
-                           table,
-                           &val);
+  ret = convert_with_table (fancy_time, table, &val);
   rtime->rel_value_us = (uint64_t) val;
   return ret;
 }
@@ -412,24 +405,23 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
   time_t t;
   const char *eos;
 
-  if (0 == strcasecmp ("end of time",
-                       fancy_time))
+  if (0 == strcasecmp ("end of time", fancy_time))
   {
     *atime = GNUNET_TIME_UNIT_FOREVER_ABS;
     return GNUNET_OK;
   }
   eos = &fancy_time[strlen (fancy_time)];
   memset (&tv, 0, sizeof (tv));
-  if ( (eos != strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) &&
-       (eos != strptime (fancy_time, "%c", &tv)) &&
-       (eos != strptime (fancy_time, "%Ec", &tv)) &&
-       (eos != strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) &&
-       (eos != strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) &&
-       (eos != strptime (fancy_time, "%x", &tv)) &&
-       (eos != strptime (fancy_time, "%Ex", &tv)) &&
-       (eos != strptime (fancy_time, "%Y-%m-%d", &tv)) &&
-       (eos != strptime (fancy_time, "%Y-%m", &tv)) &&
-       (eos != strptime (fancy_time, "%Y", &tv)) )
+  if ((eos != strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) &&
+      (eos != strptime (fancy_time, "%c", &tv)) &&
+      (eos != strptime (fancy_time, "%Ec", &tv)) &&
+      (eos != strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) &&
+      (eos != strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) &&
+      (eos != strptime (fancy_time, "%x", &tv)) &&
+      (eos != strptime (fancy_time, "%Ex", &tv)) &&
+      (eos != strptime (fancy_time, "%Y-%m-%d", &tv)) &&
+      (eos != strptime (fancy_time, "%Y-%m", &tv)) &&
+      (eos != strptime (fancy_time, "%Y", &tv)))
     return GNUNET_SYSERR;
   t = mktime (&tv);
   atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
@@ -452,9 +444,9 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
  */
 char *
 GNUNET_STRINGS_conv (const char *input,
-                    size_t len,
-                    const char *input_charset,
-                    const char *output_charset)
+                     size_t len,
+                     const char *input_charset,
+                     const char *output_charset)
 {
   char *ret;
   uint8_t *u8_string;
@@ -463,10 +455,12 @@ GNUNET_STRINGS_conv (const char *input,
   size_t encoded_string_length;
 
   u8_string = u8_conv_from_encoding (input_charset,
-                                    iconveh_error,
-                                    input, len,
-                                    NULL, NULL,
-                                    &u8_string_length);
+                                     iconveh_error,
+                                     input,
+                                     len,
+                                     NULL,
+                                     NULL,
+                                     &u8_string_length);
   if (NULL == u8_string)
   {
     LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "u8_conv_from_encoding");
@@ -480,10 +474,13 @@ GNUNET_STRINGS_conv (const char *input,
     free (u8_string);
     return ret;
   }
-  encoded_string = u8_conv_to_encoding (output_charset, iconveh_error,
-                                       u8_string, u8_string_length,
-                                       NULL, NULL,
-                                       &encoded_string_length);
+  encoded_string = u8_conv_to_encoding (output_charset,
+                                        iconveh_error,
+                                        u8_string,
+                                        u8_string_length,
+                                        NULL,
+                                        NULL,
+                                        &encoded_string_length);
   free (u8_string);
   if (NULL == encoded_string)
   {
@@ -495,10 +492,11 @@ GNUNET_STRINGS_conv (const char *input,
   ret[encoded_string_length] = '\0';
   free (encoded_string);
   return ret;
- fail:
+fail:
   LOG (GNUNET_ERROR_TYPE_WARNING,
-       _("Character sets requested were `%s'->`%s'\n"),
-       "UTF-8", output_charset);
+       _ ("Character sets requested were `%s'->`%s'\n"),
+       "UTF-8",
+       output_charset);
   ret = GNUNET_malloc (len + 1);
   GNUNET_memcpy (ret, input, len);
   ret[len] = '\0';
@@ -519,9 +517,7 @@ GNUNET_STRINGS_conv (const char *input,
  *  string is returned.
  */
 char *
-GNUNET_STRINGS_to_utf8 (const char *input,
-                        size_t len,
-                        const char *charset)
+GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset)
 {
   return GNUNET_STRINGS_conv (input, len, charset, "UTF-8");
 }
@@ -539,9 +535,7 @@ GNUNET_STRINGS_to_utf8 (const char *input,
  *  string is returned.
  */
 char *
-GNUNET_STRINGS_from_utf8 (const char *input,
-                          size_t len,
-                          const char *charset)
+GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset)
 {
   return GNUNET_STRINGS_conv (input, len, "UTF-8", charset);
 }
@@ -555,17 +549,20 @@ GNUNET_STRINGS_from_utf8 (const char *input,
  * @param output output buffer
  */
 void
-GNUNET_STRINGS_utf8_tolower (const char *input,
-                             char *output)
+GNUNET_STRINGS_utf8_tolower (const char *input, char *output)
 {
   uint8_t *tmp_in;
   size_t len;
 
-  tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input),
-                       NULL, UNINORM_NFD, NULL, &len);
-  GNUNET_memcpy(output, tmp_in, len);
+  tmp_in = u8_tolower ((uint8_t *) input,
+                       strlen ((char *) input),
+                       NULL,
+                       UNINORM_NFD,
+                       NULL,
+                       &len);
+  GNUNET_memcpy (output, tmp_in, len);
   output[len] = '\0';
-  free(tmp_in);
+  free (tmp_in);
 }
 
 
@@ -577,14 +574,17 @@ GNUNET_STRINGS_utf8_tolower (const char *input,
  * @param output output buffer
  */
 void
-GNUNET_STRINGS_utf8_toupper(const char *input,
-                            char *output)
+GNUNET_STRINGS_utf8_toupper (const char *input, char *output)
 {
   uint8_t *tmp_in;
   size_t len;
 
-  tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input),
-                       NULL, UNINORM_NFD, NULL, &len);
+  tmp_in = u8_toupper ((uint8_t *) input,
+                       strlen ((char *) input),
+                       NULL,
+                       UNINORM_NFD,
+                       NULL,
+                       &len);
   GNUNET_memcpy (output, tmp_in, len);
   output[len] = '\0';
   free (tmp_in);
@@ -624,7 +624,7 @@ GNUNET_STRINGS_filename_expand (const char *fil)
     if (fm == NULL)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("Failed to expand `$HOME': environment variable `HOME' not set"));
+           _ ("Failed to expand `$HOME': environment variable `HOME' not set"));
       return NULL;
     }
     fm = GNUNET_strdup (fm);
@@ -660,20 +660,20 @@ GNUNET_STRINGS_filename_expand (const char *fil)
     }
     if (fm == NULL)
     {
-      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                    "getcwd");
-      buffer = getenv ("PWD");  /* alternative */
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "getcwd");
+      buffer = getenv ("PWD"); /* alternative */
       if (buffer != NULL)
         fm = GNUNET_strdup (buffer);
     }
     if (fm == NULL)
-      fm = GNUNET_strdup ("./");        /* give up */
+      fm = GNUNET_strdup ("./"); /* give up */
   }
   GNUNET_asprintf (&buffer,
                    "%s%s%s",
                    fm,
-                   (fm[strlen (fm) - 1] ==
-                    DIR_SEPARATOR) ? "" : DIR_SEPARATOR_STR, fil_ptr);
+                   (fm[strlen (fm) - 1] == DIR_SEPARATOR) ? ""
+                                                          : DIR_SEPARATOR_STR,
+                   fil_ptr);
   GNUNET_free (fm);
   return buffer;
 #else
@@ -682,29 +682,22 @@ GNUNET_STRINGS_filename_expand (const char *fil)
   if ((lRet = plibc_conv_to_win_path (fil, fn)) != ERROR_SUCCESS)
   {
     SetErrnoFromWinError (lRet);
-    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                  "plibc_conv_to_win_path");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "plibc_conv_to_win_path");
     return NULL;
   }
   /* is the path relative? */
-  if ( (0 != strncmp (fn + 1, ":\\", 2)) &&
-       (0 != strncmp (fn, "\\\\", 2)) )
+  if ((0 != strncmp (fn + 1, ":\\", 2)) && (0 != strncmp (fn, "\\\\", 2)))
   {
     char szCurDir[MAX_PATH + 1];
 
-    lRet = GetCurrentDirectory (MAX_PATH + 1,
-                                szCurDir);
+    lRet = GetCurrentDirectory (MAX_PATH + 1, szCurDir);
     if (lRet + strlen (fn) + 1 > (MAX_PATH + 1))
     {
       SetErrnoFromWinError (ERROR_BUFFER_OVERFLOW);
-      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
-                    "GetCurrentDirectory");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "GetCurrentDirectory");
       return NULL;
     }
-    GNUNET_asprintf (&buffer,
-                     "%s\\%s",
-                     szCurDir,
-                     fn);
+    GNUNET_asprintf (&buffer, "%s\\%s", szCurDir, fn);
     GNUNET_free (fn);
     fn = buffer;
   }
@@ -725,56 +718,46 @@ GNUNET_STRINGS_filename_expand (const char *fil)
  */
 const char *
 GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
-                                       int do_round)
+                                        int do_round)
 {
   static char buf[128];
-  const char *unit = _/* time unit */ "µs");
+  const char *unit = _ (/* time unit */ "µs");
   uint64_t dval = delta.rel_value_us;
 
   if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us)
-    return _("forever");
+    return _ ("forever");
   if (0 == delta.rel_value_us)
-    return _("0 ms");
-  if ( ( (GNUNET_YES == do_round) &&
-        (dval > 5 * 1000) ) ||
-       (0 == (dval % 1000) ))
+    return _ ("0 ms");
+  if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
   {
     dval = dval / 1000;
-    unit = _( /* time unit */ "ms");
-    if ( ( (GNUNET_YES == do_round) &&
-          (dval > 5 * 1000) ) ||
-        (0 == (dval % 1000) ))
+    unit = _ (/* time unit */ "ms");
+    if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
     {
       dval = dval / 1000;
-      unit = _( /* time unit */ "s");
-      if ( ( (GNUNET_YES == do_round) &&
-            (dval > 5 * 60) ) ||
-          (0 == (dval % 60) ) )
+      unit = _ (/* time unit */ "s");
+      if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
       {
-       dval = dval / 60;
-       unit = _( /* time unit */ "m");
-       if ( ( (GNUNET_YES == do_round) &&
-              (dval > 5 * 60) ) ||
-            (0 == (dval % 60) ))
-       {
-         dval = dval / 60;
-         unit = _( /* time unit */ "h");
-         if ( ( (GNUNET_YES == do_round) &&
-                (dval > 5 * 24) ) ||
-              (0 == (dval % 24)) )
-         {
-           dval = dval / 24;
-           if (1 == dval)
-             unit = _( /* time unit */ "day");
-           else
-             unit = _( /* time unit */ "days");
-         }
-       }
+        dval = dval / 60;
+        unit = _ (/* time unit */ "m");
+        if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
+        {
+          dval = dval / 60;
+          unit = _ (/* time unit */ "h");
+          if (((GNUNET_YES == do_round) && (dval > 5 * 24)) ||
+              (0 == (dval % 24)))
+          {
+            dval = dval / 24;
+            if (1 == dval)
+              unit = _ (/* time unit */ "day");
+            else
+              unit = _ (/* time unit */ "days");
+          }
+        }
       }
     }
   }
-  GNUNET_snprintf (buf, sizeof (buf),
-                  "%llu %s", dval, unit);
+  GNUNET_snprintf (buf, sizeof (buf), "%llu %s", dval, unit);
   return buf;
 }
 
@@ -796,7 +779,7 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
   struct tm *tp;
 
   if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
-    return _("end of time");
+    return _ ("end of time");
   tt = t.abs_value_us / 1000LL / 1000LL;
   tp = localtime (&tt);
   /* This is hacky, but i don't know a way to detect libc character encoding.
@@ -813,12 +796,16 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
     uint8_t *conved;
     size_t ssize;
 
-    wcsftime (wbuf, sizeof (wbuf) / sizeof (wchar_t),
-        L"%a %b %d %H:%M:%S %Y", tp);
+    wcsftime (wbuf,
+              sizeof (wbuf) / sizeof (wchar_t),
+              L"%a %b %d %H:%M:%S %Y",
+              tp);
 
     ssize = sizeof (buf);
-    conved = u16_to_u8 (wbuf, sizeof (wbuf) / sizeof (wchar_t),
-        (uint8_t *) buf, &ssize);
+    conved = u16_to_u8 (wbuf,
+                        sizeof (wbuf) / sizeof (wchar_t),
+                        (uint8_t *) buf,
+                        &ssize);
     if (conved != (uint8_t *) buf)
     {
       GNUNET_strlcpy (buf, (char *) conved, sizeof (buf));
@@ -847,8 +834,7 @@ GNUNET_STRINGS_get_short_name (const char *filename)
   const char *short_fn = filename;
   const char *ss;
 
-  while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))
-      && (ss[1] != '\0'))
+  while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)) && (ss[1] != '\0'))
     short_fn = 1 + ss;
   return short_fn;
 }
@@ -890,7 +876,7 @@ getValue__ (unsigned char a)
     return a - '0';
   if ((a >= 'a') && (a <= 'z'))
     a = toupper (a);
-    /* return (a - 'a' + 10); */
+  /* return (a - 'a' + 10); */
   dec = 0;
   if ((a >= 'A') && (a <= 'Z'))
   {
@@ -950,12 +936,12 @@ GNUNET_STRINGS_data_to_string (const void *data,
   {
     if ((rpos < size) && (vbit < 5))
     {
-      bits = (bits << 8) | udata[rpos++];   /* eat 8 more bits */
+      bits = (bits << 8) | udata[rpos++]; /* eat 8 more bits */
       vbit += 8;
     }
     if (vbit < 5)
     {
-      bits <<= (5 - vbit);      /* zero-padding */
+      bits <<= (5 - vbit); /* zero-padding */
       GNUNET_assert (vbit == ((size * 8) % 5));
       vbit = 5;
     }
@@ -985,8 +971,7 @@ GNUNET_STRINGS_data_to_string (const void *data,
  * @return freshly allocated, null-terminated string
  */
 char *
-GNUNET_STRINGS_data_to_string_alloc (const void *buf,
-                                     size_t size)
+GNUNET_STRINGS_data_to_string_alloc (const void *buf, size_t size)
 {
   char *str_buf;
   size_t len = size * 8;
@@ -1018,8 +1003,10 @@ GNUNET_STRINGS_data_to_string_alloc (const void *buf,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding
  */
 int
-GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen,
-                              void *out, size_t out_size)
+GNUNET_STRINGS_string_to_data (const char *enc,
+                               size_t enclen,
+                               void *out,
+                               size_t out_size)
 {
   unsigned int rpos;
   unsigned int wpos;
@@ -1073,8 +1060,7 @@ GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen,
       vbit -= 8;
     }
   }
-  if ( (0 != rpos) ||
-       (0 != vbit) )
+  if ((0 != rpos) || (0 != vbit))
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
@@ -1098,8 +1084,8 @@ GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen,
  */
 int
 GNUNET_STRINGS_parse_uri (const char *path,
-                         char **scheme_part,
-                         const char **path_part)
+                          char **scheme_part,
+                          const char **path_part)
 {
   size_t len;
   size_t i;
@@ -1107,19 +1093,20 @@ GNUNET_STRINGS_parse_uri (const char *path,
   int pp_state = 0;
   const char *post_scheme_part = NULL;
   len = strlen (path);
-  for (end = 0, i = 0; !end && i < len; i++)
+  for (end = 0, i = 0; ! end && i < len; i++)
   {
     switch (pp_state)
     {
     case 0:
-      if ( (path[i] == ':') && (i > 0) )
+      if ((path[i] == ':') && (i > 0))
       {
         pp_state += 1;
         continue;
       }
-      if (!((path[i] >= 'A' && path[i] <= 'Z') || (path[i] >= 'a' && path[i] <= 'z')
-          || (path[i] >= '0' && path[i] <= '9') || path[i] == '+' || path[i] == '-'
-          || (path[i] == '.')))
+      if (! ((path[i] >= 'A' && path[i] <= 'Z') ||
+             (path[i] >= 'a' && path[i] <= 'z') ||
+             (path[i] >= '0' && path[i] <= '9') || path[i] == '+' ||
+             path[i] == '-' || (path[i] == '.')))
         end = 1;
       break;
     case 1:
@@ -1178,7 +1165,7 @@ GNUNET_STRINGS_path_is_absolute (const char *filename,
 #endif
   const char *post_scheme_path;
   int is_uri;
-  char * uri;
+  char *uri;
   /* consider POSIX paths to be absolute too, even on W32,
    * as plibc expansion will fix them for us.
    */
@@ -1196,14 +1183,17 @@ GNUNET_STRINGS_path_is_absolute (const char *filename,
       else
         GNUNET_free_non_null (uri);
 #if WINDOWS
-      len = strlen(post_scheme_path);
+      len = strlen (post_scheme_path);
       /* Special check for file:///c:/blah
        * We want to parse 'c:/', not '/c:/'
        */
       if (post_scheme_path[0] == '/' && len >= 3 && post_scheme_path[2] == ':')
         post_scheme_path = &post_scheme_path[1];
 #endif
-      return GNUNET_STRINGS_path_is_absolute (post_scheme_path, GNUNET_NO, NULL, NULL);
+      return GNUNET_STRINGS_path_is_absolute (post_scheme_path,
+                                              GNUNET_NO,
+                                              NULL,
+                                              NULL);
     }
   }
   else
@@ -1214,18 +1204,18 @@ GNUNET_STRINGS_path_is_absolute (const char *filename,
 #if WINDOWS
   len = strlen (filename);
   if (len >= 3 &&
-      ((filename[0] >= 'A' && filename[0] <= 'Z')
-      || (filename[0] >= 'a' && filename[0] <= 'z'))
-      && filename[1] == ':' && (filename[2] == '/' || filename[2] == '\\'))
+      ((filename[0] >= 'A' && filename[0] <= 'Z') ||
+       (filename[0] >= 'a' && filename[0] <= 'z')) &&
+      filename[1] == ':' && (filename[2] == '/' || filename[2] == '\\'))
     return GNUNET_YES;
 #endif
   return GNUNET_NO;
 }
 
 #if MINGW
-#define        _IFMT           0170000 /* type of file */
-#define        _IFLNK          0120000 /* symbolic link */
-#define  S_ISLNK(m)    (((m)&_IFMT) == _IFLNK)
+#define _IFMT 0170000 /* type of file */
+#define _IFLNK 0120000 /* symbolic link */
+#define S_ISLNK(m) (((m) &_IFMT) == _IFLNK)
 #endif
 
 
@@ -1239,19 +1229,19 @@ GNUNET_STRINGS_path_is_absolute (const char *filename,
  */
 int
 GNUNET_STRINGS_check_filename (const char *filename,
-                              enum GNUNET_STRINGS_FilenameCheck checks)
+                               enum GNUNET_STRINGS_FilenameCheck checks)
 {
   struct stat st;
-  if ( (NULL == filename) || (filename[0] == '\0') )
+  if ((NULL == filename) || (filename[0] == '\0'))
     return GNUNET_SYSERR;
   if (0 != (checks & GNUNET_STRINGS_CHECK_IS_ABSOLUTE))
-    if (!GNUNET_STRINGS_path_is_absolute (filename, GNUNET_NO, NULL, NULL))
+    if (! GNUNET_STRINGS_path_is_absolute (filename, GNUNET_NO, NULL, NULL))
       return GNUNET_NO;
-  if (0 != (checks & (GNUNET_STRINGS_CHECK_EXISTS
-                     | GNUNET_STRINGS_CHECK_IS_DIRECTORY
-                     | GNUNET_STRINGS_CHECK_IS_LINK)))
+  if (0 != (checks &
+            (GNUNET_STRINGS_CHECK_EXISTS | GNUNET_STRINGS_CHECK_IS_DIRECTORY |
+             GNUNET_STRINGS_CHECK_IS_LINK)))
   {
-    if (0 != STAT (filename, &st))
+    if (0 != stat (filename, &st))
     {
       if (0 != (checks & GNUNET_STRINGS_CHECK_EXISTS))
         return GNUNET_NO;
@@ -1260,10 +1250,10 @@ GNUNET_STRINGS_check_filename (const char *filename,
     }
   }
   if (0 != (checks & GNUNET_STRINGS_CHECK_IS_DIRECTORY))
-    if (!S_ISDIR (st.st_mode))
+    if (! S_ISDIR (st.st_mode))
       return GNUNET_NO;
   if (0 != (checks & GNUNET_STRINGS_CHECK_IS_LINK))
-    if (!S_ISLNK (st.st_mode))
+    if (! S_ISLNK (st.st_mode))
       return GNUNET_NO;
   return GNUNET_YES;
 }
@@ -1283,8 +1273,8 @@ GNUNET_STRINGS_check_filename (const char *filename,
  */
 int
 GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
-                               uint16_t addrlen,
-                               struct sockaddr_in6 *r_buf)
+                                uint16_t addrlen,
+                                struct sockaddr_in6 *r_buf)
 {
   char zbuf[addrlen + 1];
   int ret;
@@ -1298,7 +1288,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
   if ('[' != zbuf[0])
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("IPv6 address did not start with `['\n"));
+                _ ("IPv6 address did not start with `['\n"));
     return GNUNET_SYSERR;
   }
   zbuf[addrlen] = '\0';
@@ -1306,34 +1296,33 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
   if (NULL == port_colon)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("IPv6 address did contain ':' to separate port number\n"));
+                _ ("IPv6 address did contain ':' to separate port number\n"));
     return GNUNET_SYSERR;
   }
   if (']' != *(port_colon - 1))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("IPv6 address did contain ']' before ':' to separate port number\n"));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ ("IPv6 address did contain ']' before ':' to separate port number\n"));
     return GNUNET_SYSERR;
   }
-  ret = SSCANF (port_colon,
-               ":%u%1s",
-               &port,
-               dummy);
-  if ( (1 != ret) || (port > 65535) )
+  ret = sscanf (port_colon, ":%u%1s", &port, dummy);
+  if ((1 != ret) || (port > 65535))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("IPv6 address did contain a valid port number after the last ':'\n"));
+    GNUNET_log (
+      GNUNET_ERROR_TYPE_WARNING,
+      _ ("IPv6 address did contain a valid port number after the last ':'\n"));
     return GNUNET_SYSERR;
   }
-  *(port_colon-1) = '\0';
+  *(port_colon - 1) = '\0';
   memset (r_buf, 0, sizeof (struct sockaddr_in6));
   ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
   if (ret <= 0)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Invalid IPv6 address `%s': %s\n"),
-               &zbuf[1],
-               STRERROR (errno));
+                _ ("Invalid IPv6 address `%s': %s\n"),
+                &zbuf[1],
+                strerror (errno));
     return GNUNET_SYSERR;
   }
   r_buf->sin6_port = htons (port);
@@ -1358,8 +1347,8 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
  */
 int
 GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
-                               uint16_t addrlen,
-                               struct sockaddr_in *r_buf)
+                                uint16_t addrlen,
+                                struct sockaddr_in *r_buf)
 {
   unsigned int temps[4];
   unsigned int port;
@@ -1368,14 +1357,14 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
 
   if (addrlen < 9)
     return GNUNET_SYSERR;
-  cnt = SSCANF (zt_addr,
-               "%u.%u.%u.%u:%u%1s",
-               &temps[0],
-               &temps[1],
-               &temps[2],
-               &temps[3],
-               &port,
-               dummy);
+  cnt = sscanf (zt_addr,
+                "%u.%u.%u.%u:%u%1s",
+                &temps[0],
+                &temps[1],
+                &temps[2],
+                &temps[3],
+                &port,
+                dummy);
   if (5 != cnt)
     return GNUNET_SYSERR;
   for (cnt = 0; cnt < 4; cnt++)
@@ -1385,8 +1374,8 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
     return GNUNET_SYSERR;
   r_buf->sin_family = AF_INET;
   r_buf->sin_port = htons (port);
-  r_buf->sin_addr.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) +
-                                 (temps[2] << 8) + temps[3]);
+  r_buf->sin_addr.s_addr =
+    htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]);
 #if HAVE_SOCKADDR_IN_SIN_LEN
   r_buf->sin_len = (u_char) sizeof (struct sockaddr_in);
 #endif
@@ -1407,8 +1396,8 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
  */
 int
 GNUNET_STRINGS_to_address_ip (const char *addr,
-                             uint16_t addrlen,
-                             struct sockaddr_storage *r_buf)
+                              uint16_t addrlen,
+                              struct sockaddr_storage *r_buf)
 {
   if (addr[0] == '[')
     return GNUNET_STRINGS_to_address_ipv6 (addr,
@@ -1431,8 +1420,8 @@ GNUNET_STRINGS_to_address_ip (const char *addr,
  */
 size_t
 GNUNET_STRINGS_parse_socket_addr (const char *addr,
-                                 uint8_t *af,
-                                 struct sockaddr **sa)
+                                  uint8_t *af,
+                                  struct sockaddr **sa)
 {
   char *cp = GNUNET_strdup (addr);
 
@@ -1442,9 +1431,9 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
     /* IPv6 */
     *sa = GNUNET_malloc (sizeof (struct sockaddr_in6));
     if (GNUNET_OK !=
-       GNUNET_STRINGS_to_address_ipv6 (cp,
-                                       strlen (cp),
-                                       (struct sockaddr_in6 *) *sa))
+        GNUNET_STRINGS_to_address_ipv6 (cp,
+                                        strlen (cp),
+                                        (struct sockaddr_in6 *) *sa))
     {
       GNUNET_free (*sa);
       *sa = NULL;
@@ -1460,9 +1449,9 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
     /* IPv4 */
     *sa = GNUNET_malloc (sizeof (struct sockaddr_in));
     if (GNUNET_OK !=
-       GNUNET_STRINGS_to_address_ipv4 (cp,
-                                       strlen (cp),
-                                       (struct sockaddr_in *) *sa))
+        GNUNET_STRINGS_to_address_ipv4 (cp,
+                                        strlen (cp),
+                                        (struct sockaddr_in *) *sa))
     {
       GNUNET_free (*sa);
       *sa = NULL;
@@ -1481,8 +1470,7 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
  * freed with a single call to GNUNET_free();
  */
 static char *const *
-_make_continuous_arg_copy (int argc,
-                           char *const *argv)
+_make_continuous_arg_copy (int argc, char *const *argv)
 {
   size_t argvsize = 0;
   int i;
@@ -1519,9 +1507,9 @@ _make_continuous_arg_copy (int argc,
  */
 int
 GNUNET_STRINGS_get_utf8_args (int argc,
-                             char *const *argv,
-                             int *u8argc,
-                             char *const **u8argv)
+                              char *const *argv,
+                              int *u8argc,
+                              char *const **u8argv)
 {
 #if WINDOWS
   wchar_t *wcmd;
@@ -1543,7 +1531,8 @@ GNUNET_STRINGS_get_utf8_args (int argc,
   {
     size_t strl;
     /* Hopefully it will allocate us NUL-terminated strings... */
-    split_u8argv[i] = (char *) u16_to_u8 (wargv[i], wcslen (wargv[i]) + 1, NULL, &strl);
+    split_u8argv[i] =
+      (char *) u16_to_u8 (wargv[i], wcslen (wargv[i]) + 1, NULL, &strl);
     if (NULL == split_u8argv[i])
     {
       int j;
@@ -1563,7 +1552,8 @@ GNUNET_STRINGS_get_utf8_args (int argc,
   free (split_u8argv);
   return GNUNET_OK;
 #else
-  char *const *new_argv = (char *const *) _make_continuous_arg_copy (argc, argv);
+  char *const *new_argv =
+    (char *const *) _make_continuous_arg_copy (argc, argv);
   *u8argv = new_argv;
   *u8argc = argc;
   return GNUNET_OK;
@@ -1595,35 +1585,22 @@ parse_port_policy (const char *port_policy,
     pp->negate_portrange = GNUNET_YES;
     pos++;
   }
-  if (2 == sscanf (pos,
-                   "%u-%u%1s",
-                   &s,
-                  &e,
-                  eol))
+  if (2 == sscanf (pos, "%u-%u%1s", &s, &e, eol))
   {
-    if ( (0 == s) ||
-         (s > 0xFFFF) ||
-         (e < s) ||
-         (e > 0xFFFF) )
+    if ((0 == s) || (s > 0xFFFF) || (e < s) || (e > 0xFFFF))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _("Port not in range\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Port not in range\n"));
       return GNUNET_SYSERR;
     }
     pp->start_port = (uint16_t) s;
     pp->end_port = (uint16_t) e;
     return GNUNET_OK;
   }
-  if (1 == sscanf (pos,
-                   "%u%1s",
-                   &s,
-                   eol))
+  if (1 == sscanf (pos, "%u%1s", &s, eol))
   {
-    if ( (0 == s) ||
-         (s > 0xFFFF) )
+    if ((0 == s) || (s > 0xFFFF))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _("Port not in range\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Port not in range\n"));
       return GNUNET_SYSERR;
     }
 
@@ -1632,7 +1609,7 @@ parse_port_policy (const char *port_policy,
     return GNUNET_OK;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              _("Malformed port policy `%s'\n"),
+              _ ("Malformed port policy `%s'\n"),
               port_policy);
   return GNUNET_SYSERR;
 }
@@ -1666,7 +1643,7 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
   int end;
   char *routeList;
   char dummy[2];
-  
+
   if (NULL == routeListX)
     return NULL;
   len = strlen (routeListX);
@@ -1677,14 +1654,14 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
   for (i = 0; i < len; i++)
     if (routeList[i] == ';')
       count++;
-  result = GNUNET_malloc (sizeof (struct GNUNET_STRINGS_IPv4NetworkPolicy) * (count + 1));
+  result = GNUNET_malloc (sizeof (struct GNUNET_STRINGS_IPv4NetworkPolicy) *
+                          (count + 1));
   i = 0;
   pos = 0;
   while (i < count)
   {
     for (colon = pos; ':' != routeList[colon]; colon++)
-      if ( (';' == routeList[colon]) ||
-           ('\0' == routeList[colon]) )
+      if ((';' == routeList[colon]) || ('\0' == routeList[colon]))
         break;
     for (end = colon; ';' != routeList[end]; end++)
       if ('\0' == routeList[end])
@@ -1695,76 +1672,70 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
     if (':' == routeList[colon])
     {
       routeList[colon] = '\0';
-      if (GNUNET_OK != parse_port_policy (&routeList[colon + 1],
-                                          &result[i].pp))
+      if (GNUNET_OK != parse_port_policy (&routeList[colon + 1], &result[i].pp))
         break;
     }
-    cnt =
-        SSCANF (&routeList[pos],
-                "%u.%u.%u.%u/%u.%u.%u.%u%1s",
-                &temps[0],
-                &temps[1],
-                &temps[2],
-                &temps[3],
-                &temps[4],
-                &temps[5],
-                &temps[6],
-                &temps[7],
-               dummy);
+    cnt = sscanf (&routeList[pos],
+                  "%u.%u.%u.%u/%u.%u.%u.%u%1s",
+                  &temps[0],
+                  &temps[1],
+                  &temps[2],
+                  &temps[3],
+                  &temps[4],
+                  &temps[5],
+                  &temps[6],
+                  &temps[7],
+                  dummy);
     if (8 == cnt)
     {
       for (j = 0; j < 8; j++)
         if (temps[j] > 0xFF)
         {
           LOG (GNUNET_ERROR_TYPE_WARNING,
-               _("Invalid format for IP: `%s'\n"),
+               _ ("Invalid format for IP: `%s'\n"),
                &routeList[pos]);
           GNUNET_free (result);
           GNUNET_free (routeList);
           return NULL;
         }
-      result[i].network.s_addr =
-          htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
-                 temps[3]);
-      result[i].netmask.s_addr =
-          htonl ((temps[4] << 24) + (temps[5] << 16) + (temps[6] << 8) +
-                 temps[7]);
+      result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) +
+                                        (temps[2] << 8) + temps[3]);
+      result[i].netmask.s_addr = htonl ((temps[4] << 24) + (temps[5] << 16) +
+                                        (temps[6] << 8) + temps[7]);
       pos = end + 1;
       i++;
       continue;
     }
     /* try second notation */
-    cnt =
-        SSCANF (&routeList[pos],
-                "%u.%u.%u.%u/%u%1s",
-                &temps[0],
-                &temps[1],
-                &temps[2],
-                &temps[3],
-                &slash,
-               dummy);
+    cnt = sscanf (&routeList[pos],
+                  "%u.%u.%u.%u/%u%1s",
+                  &temps[0],
+                  &temps[1],
+                  &temps[2],
+                  &temps[3],
+                  &slash,
+                  dummy);
     if (5 == cnt)
     {
       for (j = 0; j < 4; j++)
         if (temps[j] > 0xFF)
         {
           LOG (GNUNET_ERROR_TYPE_WARNING,
-               _("Invalid format for IP: `%s'\n"),
+               _ ("Invalid format for IP: `%s'\n"),
                &routeList[pos]);
           GNUNET_free (result);
           GNUNET_free (routeList);
           return NULL;
         }
-      result[i].network.s_addr =
-          htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
-                 temps[3]);
+      result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) +
+                                        (temps[2] << 8) + temps[3]);
       if ((slash <= 32) && (slash >= 0))
       {
         result[i].netmask.s_addr = 0;
         while (slash > 0)
         {
           result[i].netmask.s_addr =
-              (result[i].netmask.s_addr >> 1) + 0x80000000;
+            (result[i].netmask.s_addr >> 1) + 0x80000000;
           slash--;
         }
         result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
@@ -1775,38 +1746,36 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
       else
       {
         LOG (GNUNET_ERROR_TYPE_WARNING,
-             _("Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
+             _ ("Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
              slash);
         GNUNET_free (result);
-          GNUNET_free (routeList);
-        return NULL;            /* error */
+        GNUNET_free (routeList);
+        return NULL; /* error */
       }
     }
     /* try third notation */
     slash = 32;
-    cnt =
-        SSCANF (&routeList[pos],
-                "%u.%u.%u.%u%1s",
-                &temps[0],
-                &temps[1],
-                &temps[2],
-                &temps[3],
-               dummy);
+    cnt = sscanf (&routeList[pos],
+                  "%u.%u.%u.%u%1s",
+                  &temps[0],
+                  &temps[1],
+                  &temps[2],
+                  &temps[3],
+                  dummy);
     if (4 == cnt)
     {
       for (j = 0; j < 4; j++)
         if (temps[j] > 0xFF)
         {
           LOG (GNUNET_ERROR_TYPE_WARNING,
-               _("Invalid format for IP: `%s'\n"),
+               _ ("Invalid format for IP: `%s'\n"),
                &routeList[pos]);
           GNUNET_free (result);
           GNUNET_free (routeList);
           return NULL;
         }
-      result[i].network.s_addr =
-          htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
-                 temps[3]);
+      result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) +
+                                        (temps[2] << 8) + temps[3]);
       result[i].netmask.s_addr = 0;
       while (slash > 0)
       {
@@ -1819,23 +1788,23 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
       continue;
     }
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Invalid format for IP: `%s'\n"),
+         _ ("Invalid format for IP: `%s'\n"),
          &routeList[pos]);
     GNUNET_free (result);
     GNUNET_free (routeList);
-    return NULL;                /* error */
+    return NULL; /* error */
   }
   if (pos < strlen (routeList))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Invalid format: `%s'\n"),
+         _ ("Invalid format: `%s'\n"),
          &routeListX[pos]);
     GNUNET_free (result);
     GNUNET_free (routeList);
-    return NULL;                /* oops */
+    return NULL; /* oops */
   }
   GNUNET_free (routeList);
-  return result;                /* ok */
+  return result; /* ok */
 }
 
 
@@ -1867,7 +1836,7 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
   int save;
   int colon;
   char dummy[2];
-  
+
   if (NULL == routeListX)
     return NULL;
   len = strlen (routeListX);
@@ -1881,13 +1850,14 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
   if (';' != routeList[len - 1])
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _("Invalid network notation (does not end with ';': `%s')\n"),
+         _ ("Invalid network notation (does not end with ';': `%s')\n"),
          routeList);
     GNUNET_free (routeList);
     return NULL;
   }
 
-  result = GNUNET_malloc (sizeof (struct GNUNET_STRINGS_IPv6NetworkPolicy) * (count + 1));
+  result = GNUNET_malloc (sizeof (struct GNUNET_STRINGS_IPv6NetworkPolicy) *
+                          (count + 1));
   i = 0;
   pos = 0;
   while (i < count)
@@ -1901,9 +1871,7 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
 
     if (slash < start)
     {
-      memset (&result[i].netmask,
-              0xFF,
-              sizeof (struct in6_addr));
+      memset (&result[i].netmask, 0xFF, sizeof (struct in6_addr));
       slash = pos;
     }
     else
@@ -1915,8 +1883,8 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
       if (':' == routeList[colon])
       {
         routeList[colon] = '\0';
-        if (GNUNET_OK != parse_port_policy (&routeList[colon + 1],
-                                            &result[i].pp))
+        if (GNUNET_OK !=
+            parse_port_policy (&routeList[colon + 1], &result[i].pp))
         {
           GNUNET_free (result);
           GNUNET_free (routeList);
@@ -1927,15 +1895,12 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
       if (ret <= 0)
       {
         save = errno;
-        if ( (1 != SSCANF (&routeList[slash + 1],
-                          "%u%1s",
-                          &bits,
-                          dummy)) ||
-            (bits > 128) )
+        if ((1 != sscanf (&routeList[slash + 1], "%u%1s", &bits, dummy)) ||
+            (bits > 128))
         {
           if (0 == ret)
             LOG (GNUNET_ERROR_TYPE_WARNING,
-                 _("Wrong format `%s' for netmask\n"),
+                 _ ("Wrong format `%s' for netmask\n"),
                  &routeList[slash + 1]);
           else
           {
@@ -1955,7 +1920,7 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
         while (bits > 0)
         {
           result[i].netmask.s6_addr[off] =
-              (result[i].netmask.s6_addr[off] >> 1) + 0x80;
+            (result[i].netmask.s6_addr[off] >> 1) + 0x80;
           bits--;
         }
       }
@@ -1966,11 +1931,10 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
     {
       if (0 == ret)
         LOG (GNUNET_ERROR_TYPE_WARNING,
-             _("Wrong format `%s' for network\n"),
+             _ ("Wrong format `%s' for network\n"),
              &routeList[slash + 1]);
       else
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
-                      "inet_pton");
+        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "inet_pton");
       GNUNET_free (result);
       GNUNET_free (routeList);
       return NULL;
@@ -1983,12 +1947,12 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
 }
 
 
-
 /** ******************** Base64 encoding ***********/
 
 #define FILLCHAR '='
-static char *cvt =
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/";
+static char *cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                   "abcdefghijklmnopqrstuvwxyz"
+                   "0123456789+/";
 
 
 /**
@@ -2001,9 +1965,7 @@ static char *cvt =
  * @return the size of the output
  */
 size_t
-GNUNET_STRINGS_base64_encode (const void *in,
-                              size_t len,
-                              char **output)
+GNUNET_STRINGS_base64_encode (const void *in, size_t len, char **output)
 {
   const char *data = in;
   size_t ret;
@@ -2047,11 +2009,14 @@ GNUNET_STRINGS_base64_encode (const void *in,
   return ret;
 }
 
-#define cvtfind(a)( (((a) >= 'A')&&((a) <= 'Z'))? (a)-'A'\
-                   :(((a)>='a')&&((a)<='z')) ? (a)-'a'+26\
-                   :(((a)>='0')&&((a)<='9')) ? (a)-'0'+52\
-          :((a) == '+') ? 62\
-          :((a) == '/') ? 63 : -1)
+#define cvtfind(a)                        \
+  ((((a) >= 'A') && ((a) <= 'Z'))         \
+     ? (a) - 'A'                          \
+     : (((a) >= 'a') && ((a) <= 'z'))     \
+         ? (a) - 'a' + 26                 \
+         : (((a) >= '0') && ((a) <= '9')) \
+             ? (a) - '0' + 52             \
+             : ((a) == '+') ? 62 : ((a) == '/') ? 63 : -1)
 
 
 /**
@@ -2064,18 +2029,20 @@ GNUNET_STRINGS_base64_encode (const void *in,
  * @return the size of the output
  */
 size_t
-GNUNET_STRINGS_base64_decode (const char *data,
-                              size_t len,
-                              void **out)
+GNUNET_STRINGS_base64_decode (const char *data, size_t len, void **out)
 {
   char *output;
   size_t ret = 0;
 
-#define CHECK_CRLF  while (data[i] == '\r' || data[i] == '\n') {\
-                       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, "ignoring CR/LF\n"); \
-                       i++; \
-                       if (i >= len) goto END;  \
-               }
+#define CHECK_CRLF                                                \
+  while (data[i] == '\r' || data[i] == '\n')                      \
+  {                                                               \
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, \
+                "ignoring CR/LF\n");                              \
+    i++;                                                          \
+    if (i >= len)                                                 \
+      goto END;                                                   \
+  }
 
   output = GNUNET_malloc ((len * 3 / 4) + 8);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
index 476934b3ff0efcb8224b3269f098338a2a3d7d64..fcc453d6b866e2375255a5a490cc3723ebbb11f4 100644 (file)
@@ -144,7 +144,7 @@ main (int argc, char *argv[])
                     NULL);
   ret = check ();
   if (ret != 0)
-    FPRINTF (stderr,
+    fprintf (stderr,
              "ERROR %d.\n",
              ret);
   return ret;
index 396bf3966c7046b6876dd727a14253c1c0655522..6ae50b36ba7060289323d10f98e9673c259721dd 100644 (file)
@@ -44,7 +44,7 @@ main (int argc, char *argv[])
   unsigned int logs = 0;
 
   if (0 != putenv ("GNUNET_FORCE_LOG="))
-    FPRINTF (stderr, "Failed to putenv: %s\n", strerror (errno));
+    fprintf (stderr, "Failed to putenv: %s\n", strerror (errno));
   GNUNET_log_setup ("test-common-logging", "DEBUG", "/dev/null");
   GNUNET_logger_add (&my_log, &logs);
   GNUNET_logger_add (&my_log, &logs);
@@ -60,7 +60,7 @@ main (int argc, char *argv[])
   GNUNET_logger_remove (&my_log, &logs);
   if (logs != 4)
   {
-    FPRINTF (stdout, "Expected 4 log calls, got %u\n", logs);
+    fprintf (stdout, "Expected 4 log calls, got %u\n", logs);
     failureCount++;
   }
   GNUNET_break (0 ==
@@ -84,13 +84,13 @@ main (int argc, char *argv[])
   GNUNET_logger_remove (&my_log, &logs);
   if (logs != 1)
   {
-    FPRINTF (stdout, "Expected 1 log call, got %u\n", logs);
+    fprintf (stdout, "Expected 1 log call, got %u\n", logs);
     failureCount++;
   }
 
   if (failureCount != 0)
   {
-    FPRINTF (stdout, "%u TESTS FAILED!\n", failureCount);
+    fprintf (stdout, "%u TESTS FAILED!\n", failureCount);
     return -1;
   }
   return 0;
index 5c3709206182147b88f7f9373f16c7c0adf8efa7..d3c6e3452e07ff2448a548d3a53a2fc104d3156b 100644 (file)
@@ -51,7 +51,7 @@ my_log (void *ctx,
   (void) date;
   if (strncmp ("test-common-logging-dummy", component, 25) != 0)
     return;
-  FPRINTF (stdout, "%s", msg);
+  fprintf (stdout, "%s", msg);
   fflush (stdout);
 }
 
index 7c72acf7dc399896bf8cf02e0bb1c66abd135d57..8da808760c6d263d16b30d717392dde44b66e2c8 100644 (file)
@@ -237,7 +237,7 @@ read_call (void *cls)
     buf_ptr += rd;
     bytes += rd;
 #if VERBOSE
-    FPRINTF (stderr, "got %d bytes, reading more\n", rd);
+    fprintf (stderr, "got %d bytes, reading more\n", rd);
 #endif
     read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                                stdout_read_handle,
@@ -247,7 +247,7 @@ read_call (void *cls)
   }
 
 #if VERBOSE
-  FPRINTF (stderr, "bytes is %d:%s\n", bytes, buf);
+  fprintf (stderr, "bytes is %d:%s\n", bytes, buf);
 #endif
 
   /* +------CHILD OUTPUT--
@@ -334,7 +334,7 @@ read_call (void *cls)
                           &bytes, &delays[7], level)))
   {
     if (bytes == LOG_BUFFER_SIZE)
-      FPRINTF (stderr, "%s",  "Ran out of buffer space!\n");
+      fprintf (stderr, "%s",  "Ran out of buffer space!\n");
     GNUNET_break (0);
     ok = 2;
     GNUNET_SCHEDULER_cancel (die_task);
index 96f13eefe37569ef876625948472f81550f439df..67e532f40b46f3ad2fc6954e8ac548586008517c 100644 (file)
@@ -236,14 +236,14 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfg_default, int option)
   GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData);
   if (1 == (ret = cbData.status))
   {
-    FPRINTF (stderr, "%s",
+    fprintf (stderr, "%s",
              "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n");
     goto housekeeping;
   }
   cbData.cfgDiffs = cfg;
   GNUNET_CONFIGURATION_iterate (cfgDiffs, diffsCallBack, &cbData);
   if ((ret = cbData.status) == 1)
-    FPRINTF (stderr, "%s",
+    fprintf (stderr, "%s",
              "Incorrect Configuration Diffs: Data may be missing in diffs\n");
 
 housekeeping:
@@ -273,7 +273,7 @@ testConfig ()
     return 1;
   if (0 != strcmp ("b", c))
   {
-    FPRINTF (stderr, "Got `%s'\n", c);
+    fprintf (stderr, "Got `%s'\n", c);
     GNUNET_free (c);
     return 2;
   }
@@ -466,7 +466,7 @@ main (int argc, char *argv[])
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf"))
   {
-    FPRINTF (stderr, "%s",  "Failed to parse configuration file\n");
+    fprintf (stderr, "%s",  "Failed to parse configuration file\n");
     GNUNET_CONFIGURATION_destroy (cfg);
     return 1;
   }
@@ -480,12 +480,12 @@ main (int argc, char *argv[])
 
   if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf"))
   {
-    FPRINTF (stderr, "%s",  "Failed to write configuration file\n");
+    fprintf (stderr, "%s",  "Failed to write configuration file\n");
     GNUNET_CONFIGURATION_destroy (cfg);
     return 1;
   }
   GNUNET_CONFIGURATION_destroy (cfg);
-  GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf"));
+  GNUNET_assert (0 == unlink ("/tmp/gnunet-test.conf"));
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
@@ -542,7 +542,7 @@ main (int argc, char *argv[])
 error:
   if (failureCount != 0)
   {
-    FPRINTF (stderr, "Test failed: %u\n", failureCount);
+    fprintf (stderr, "Test failed: %u\n", failureCount);
     return 1;
   }
   return 0;
index 42849af97114007c9c7f287ca5ad4e74e9b96282..043eacafd8170df3ddad1c202418820d701e91a5 100644 (file)
  * Generate a random hashcode.
  */
 static void
-nextHC (struct GNUNET_HashCode * hc)
+nextHC (struct GNUNET_HashCode *hc)
 {
   GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, hc);
 }
 
 static int
-add_iterator (void *cls, struct GNUNET_HashCode * next)
+add_iterator (void *cls, struct GNUNET_HashCode *next)
 {
   int *ret = cls;
   struct GNUNET_HashCode pos;
@@ -68,8 +68,8 @@ main (int argc, char *argv[])
 
   GNUNET_log_setup ("test-container-bloomfilter", "WARNING", NULL);
   GNUNET_CRYPTO_seed_weak_random (1);
-  if (0 == STAT (TESTFILE, &sbuf))
-    if (0 != UNLINK (TESTFILE))
+  if (0 == stat (TESTFILE, &sbuf))
+    if (0 != unlink (TESTFILE))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", TESTFILE);
   bf = GNUNET_CONTAINER_bloomfilter_load (TESTFILE, SIZE, K);
 
@@ -88,7 +88,9 @@ main (int argc, char *argv[])
   }
   if (ok1 != 200)
   {
-    printf ("Got %d elements out of" "200 expected after insertion.\n", ok1);
+    printf ("Got %d elements out of"
+            "200 expected after insertion.\n",
+            ok1);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     return -1;
   }
@@ -118,7 +120,9 @@ main (int argc, char *argv[])
   }
   if (ok1 != 200)
   {
-    printf ("Got %d elements out of 200 " "expected after reloading.\n", ok1);
+    printf ("Got %d elements out of 200 "
+            "expected after reloading.\n",
+            ok1);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     GNUNET_CONTAINER_bloomfilter_free (bfi);
     return -1;
@@ -126,7 +130,8 @@ main (int argc, char *argv[])
 
   if (ok2 != 200)
   {
-    printf ("Got %d elements out of 200 " "expected after initialization.\n",
+    printf ("Got %d elements out of 200 "
+            "expected after initialization.\n",
             ok2);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     GNUNET_CONTAINER_bloomfilter_free (bfi);
@@ -157,7 +162,8 @@ main (int argc, char *argv[])
   if (ok1 != 100)
   {
     printf ("Expected 100 elements in loaded filter"
-            " after adding 200 and deleting 100, got %d\n", ok1);
+            " after adding 200 and deleting 100, got %d\n",
+            ok1);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     GNUNET_CONTAINER_bloomfilter_free (bfi);
     return -1;
@@ -220,7 +226,8 @@ main (int argc, char *argv[])
   if (ok1 != 20)
   {
     printf ("Expected 20 elements in resized file-backed filter"
-            " after adding 20, got %d\n", ok1);
+            " after adding 20, got %d\n",
+            ok1);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     GNUNET_CONTAINER_bloomfilter_free (bfi);
     return -1;
@@ -228,7 +235,8 @@ main (int argc, char *argv[])
   if (ok2 != 20)
   {
     printf ("Expected 20 elements in resized filter"
-            " after adding 20, got %d\n", ok2);
+            " after adding 20, got %d\n",
+            ok2);
     GNUNET_CONTAINER_bloomfilter_free (bf);
     GNUNET_CONTAINER_bloomfilter_free (bfi);
     return -1;
@@ -238,6 +246,6 @@ main (int argc, char *argv[])
   GNUNET_CONTAINER_bloomfilter_free (bf);
   GNUNET_CONTAINER_bloomfilter_free (bfi);
 
-  GNUNET_break (0 == UNLINK (TESTFILE));
+  GNUNET_break (0 == unlink (TESTFILE));
   return 0;
 }
index 0b0b8d57cbfbf37d773f29240ed6e5785b24912f..c0828c35493cf6c18425477d1d0c0b8eafc27cdd 100644 (file)
@@ -172,7 +172,7 @@ main (int argc, char *argv[])
 
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _
              ("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
index 721f831d0af22d78af36f1d4362990ea426bba4f..00f85033e6a741ba9ee9eca3baae8651e3295726 100644 (file)
@@ -74,7 +74,7 @@ main (int argc, char *argv[])
 {
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
     return 0;
index c4392ca5afdbf1890bfa96699ba4fdf19f3a4d9b..71fe9b570a95da3b2e25b154ace0fff84b7e9cef 100644 (file)
@@ -40,7 +40,7 @@ main (int argc, char *argv[])
 
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _
              ("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
index 8fa5eb48632dc1c864037df698042e8dc57c5ae9..00cc72af44c608d9045e9c309ea1245df7c5aa00 100644 (file)
@@ -46,7 +46,7 @@ testSignVerify ()
   struct GNUNET_TIME_Absolute start;
   int ok = GNUNET_OK;
 
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   GNUNET_CRYPTO_ecdsa_key_get_public (key, &pkey);
   start = GNUNET_TIME_absolute_get ();
   purp.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
@@ -54,10 +54,10 @@ testSignVerify ()
 
   for (i = 0; i < ITER; i++)
   {
-    FPRINTF (stderr, "%s",  "."); fflush (stderr);
+    fprintf (stderr, "%s",  "."); fflush (stderr);
     if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
     {
-      FPRINTF (stderr,
+      fprintf (stderr,
                "%s",
                "GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
       ok = GNUNET_SYSERR;
@@ -103,7 +103,7 @@ testDeriveSignVerify ()
 
   if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (dpriv, &purp, &sig))
   {
-    FPRINTF (stderr, "%s",  "GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
+    fprintf (stderr, "%s",  "GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
     GNUNET_free (dpriv);
     return GNUNET_SYSERR;
   }
@@ -151,15 +151,15 @@ testSignPerformance ()
 
   purp.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
   purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   GNUNET_CRYPTO_ecdsa_key_get_public (key, &pkey);
   start = GNUNET_TIME_absolute_get ();
   for (i = 0; i < ITER; i++)
   {
-    FPRINTF (stderr, "%s",  "."); fflush (stderr);
+    fprintf (stderr, "%s",  "."); fflush (stderr);
     if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
     {
-      FPRINTF (stderr, "%s",
+      fprintf (stderr, "%s",
                "GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
       ok = GNUNET_SYSERR;
       continue;
@@ -180,7 +180,7 @@ perf_keygen ()
   struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
   int i;
 
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   start = GNUNET_TIME_absolute_get ();
   for (i=0;i<10;i++)
   {
@@ -203,7 +203,7 @@ main (int argc, char *argv[])
 
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _
              ("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
index e738f7e6cc8aee6dca0ae43860288fdbdf802729..acb5fbdf50c16ed020fa6784262dbd83bbc164b1 100644 (file)
@@ -48,7 +48,7 @@ testSignVerify ()
   struct GNUNET_TIME_Absolute start;
   int ok = GNUNET_OK;
 
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   GNUNET_CRYPTO_eddsa_key_get_public (key, &pkey);
   start = GNUNET_TIME_absolute_get ();
   purp.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
@@ -56,10 +56,10 @@ testSignVerify ()
 
   for (i = 0; i < ITER; i++)
   {
-    FPRINTF (stderr, "%s",  "."); fflush (stderr);
+    fprintf (stderr, "%s",  "."); fflush (stderr);
     if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
     {
-      FPRINTF (stderr, "%s",  "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
+      fprintf (stderr, "%s",  "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
       ok = GNUNET_SYSERR;
       continue;
     }
@@ -99,15 +99,15 @@ testSignPerformance ()
 
   purp.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose));
   purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   GNUNET_CRYPTO_eddsa_key_get_public (key, &pkey);
   start = GNUNET_TIME_absolute_get ();
   for (i = 0; i < ITER; i++)
   {
-    FPRINTF (stderr, "%s",  "."); fflush (stderr);
+    fprintf (stderr, "%s",  "."); fflush (stderr);
     if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
     {
-      FPRINTF (stderr, "%s",  "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
+      fprintf (stderr, "%s",  "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
       ok = GNUNET_SYSERR;
       continue;
     }
@@ -135,7 +135,7 @@ testCreateFromFile ()
   GNUNET_CRYPTO_eddsa_key_get_public (key, &p2);
   GNUNET_assert (0 == memcmp (&p1, &p2, sizeof (p1)));
   GNUNET_free (key);
-  GNUNET_assert (0 == UNLINK (KEYFILE));
+  GNUNET_assert (0 == unlink (KEYFILE));
   key = GNUNET_CRYPTO_eddsa_key_create_from_file (KEYFILE);
   GNUNET_assert (NULL != key);
   GNUNET_CRYPTO_eddsa_key_get_public (key, &p2);
@@ -152,7 +152,7 @@ perf_keygen ()
   struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
   int i;
 
-  FPRINTF (stderr, "%s",  "W");
+  fprintf (stderr, "%s",  "W");
   start = GNUNET_TIME_absolute_get ();
   for (i=0;i<10;i++)
   {
@@ -175,7 +175,7 @@ main (int argc, char *argv[])
 
   if (! gcry_check_version ("1.6.0"))
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
              _("libgcrypt has not the expected version (version %s is required).\n"),
              "1.6.0");
     return 0;
@@ -193,7 +193,7 @@ main (int argc, char *argv[])
   GNUNET_free (key);
   if (GNUNET_OK != testCreateFromFile ())
     failure_count++;
-  GNUNET_assert (0 == UNLINK (KEYFILE));
+  GNUNET_assert (0 == unlink (KEYFILE));
   perf_keygen ();
 
   if (0 != failure_count)
index 52e24718d7a250827e233b19c4e4b4d2a85eb5da..e08348e53841da19a0d5add6e064bb26a55ebfac 100644 (file)
@@ -130,12 +130,12 @@ testFileHash ()
 
   memset (block, 42, sizeof (block) / 2);
   memset (&block[sizeof (block) / 2], 43, sizeof (block) / 2);
-  GNUNET_assert (NULL != (f = FOPEN (FILENAME, "w+")));
+  GNUNET_assert (NULL != (f = fopen (FILENAME, "w+")));
   GNUNET_break (sizeof (block) == fwrite (block, 1, sizeof (block), f));
-  GNUNET_break (0 == FCLOSE (f));
+  GNUNET_break (0 == fclose (f));
   ret = 1;
   GNUNET_SCHEDULER_run (&file_hasher, &ret);
-  GNUNET_break (0 == UNLINK (FILENAME));
+  GNUNET_break (0 == unlink (FILENAME));
   return ret;
 }
 
index dec58086a4b79aaa25efd2cf12adf1fe7db6a623..6386c79db08d593aa056871b951ea297f033d1c9 100644 (file)
@@ -42,7 +42,7 @@ test (enum GNUNET_CRYPTO_Quality mode)
     b2 = GNUNET_CRYPTO_random_permute (mode, 1024);
     if (0 == memcmp (b2, buf, sizeof (buf)))
     {
-      FPRINTF (stderr, "%s",  "!");
+      fprintf (stderr, "%s",  "!");
       GNUNET_free (b2);
       continue;
     }
index 267d4d4f9300ebab4d2c7604117c4d5db5f28881..5746aa96e30b62671f8983379765fb96edf4104a 100644 (file)
@@ -45,13 +45,13 @@ testReadWrite ()
   ret = GNUNET_DISK_fn_read (".testfile", tmp, sizeof (tmp) - 1);
   if (ret < 0)
   {
-    FPRINTF (stderr, "Error reading file `%s' in testReadWrite\n", ".testfile");
+    fprintf (stderr, "Error reading file `%s' in testReadWrite\n", ".testfile");
     return 1;
   }
   tmp[ret] = '\0';
   if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
   {
-    FPRINTF (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
+    fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
              TESTSTRING, ".testfile");
     return 1;
   }
@@ -60,20 +60,20 @@ testReadWrite ()
   ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1);
   if (ret < 0)
   {
-    FPRINTF (stderr, "Error reading file `%s' in testReadWrite\n",
+    fprintf (stderr, "Error reading file `%s' in testReadWrite\n",
              ".testfile2");
     return 1;
   }
   tmp[ret] = '\0';
   if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
   {
-    FPRINTF (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
+    fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
              TESTSTRING, ".testfile2");
     return 1;
   }
 
-  GNUNET_break (0 == UNLINK (".testfile"));
-  GNUNET_break (0 == UNLINK (".testfile2"));
+  GNUNET_break (0 == unlink (".testfile"));
+  GNUNET_break (0 == unlink (".testfile2"));
   if (GNUNET_NO != GNUNET_DISK_file_test (".testfile"))
     return 1;
 
@@ -99,7 +99,7 @@ testOpenClose ()
                 GNUNET_DISK_file_size (".testfile", &size, GNUNET_NO, GNUNET_YES));
   if (size != 5)
     return 1;
-  GNUNET_break (0 == UNLINK (".testfile"));
+  GNUNET_break (0 == unlink (".testfile"));
 
   return 0;
 }
@@ -281,7 +281,7 @@ main (int argc, char *argv[])
   failureCount += testDirMani ();
   if (0 != failureCount)
   {
-    FPRINTF (stderr,
+    fprintf (stderr,
             "\n%u TESTS FAILED!\n",
             failureCount);
     return -1;
index 4294117a66a6ada698c5b304c15d18dea2bc6d71..d9dd7121ff6975d61718714e49f3e4fabe41bafa 100644 (file)
 static int
 testMinimal ()
 {
-  char *const emptyargv[] = {
-    "test",
-    NULL
-  };
+  char *const emptyargv[] = {"test", NULL};
   const struct GNUNET_GETOPT_CommandLineOption emptyoptionlist[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
+    GNUNET_GETOPT_OPTION_END};
 
   if (1 != GNUNET_GETOPT_run ("test", emptyoptionlist, 1, emptyargv))
     return 1;
@@ -46,19 +42,11 @@ testMinimal ()
 static int
 testVerbose ()
 {
-  char *const myargv[] = {
-    "test",
-    "-V",
-    "-V",
-    "more",
-    NULL
-  };
+  char *const myargv[] = {"test", "-V", "-V", "more", NULL};
   unsigned int vflags = 0;
 
-  const struct GNUNET_GETOPT_CommandLineOption verboseoptionlist[] = {
-    GNUNET_GETOPT_option_verbose (&vflags),
-    GNUNET_GETOPT_OPTION_END
-  };
+  const struct GNUNET_GETOPT_CommandLineOption verboseoptionlist[] =
+    {GNUNET_GETOPT_option_verbose (&vflags), GNUNET_GETOPT_OPTION_END};
 
   if (3 != GNUNET_GETOPT_run ("test", verboseoptionlist, 4, myargv))
   {
@@ -77,15 +65,10 @@ testVerbose ()
 static int
 testVersion ()
 {
-  char *const myargv[] = {
-    "test_getopt",
-    "-v",
-    NULL
-  };
-  const struct GNUNET_GETOPT_CommandLineOption versionoptionlist[] = {
-    GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
-    GNUNET_GETOPT_OPTION_END
-  };
+  char *const myargv[] = {"test_getopt", "-v", NULL};
+  const struct GNUNET_GETOPT_CommandLineOption versionoptionlist[] =
+    {GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
+     GNUNET_GETOPT_OPTION_END};
 
   if (0 != GNUNET_GETOPT_run ("test_getopt", versionoptionlist, 2, myargv))
   {
@@ -99,15 +82,9 @@ testVersion ()
 static int
 testAbout ()
 {
-  char *const myargv[] = {
-    "test_getopt",
-    "-h",
-    NULL
-  };
-  const struct GNUNET_GETOPT_CommandLineOption aboutoptionlist[] = {
-    GNUNET_GETOPT_option_help ("Testing"),
-    GNUNET_GETOPT_OPTION_END
-  };
+  char *const myargv[] = {"test_getopt", "-h", NULL};
+  const struct GNUNET_GETOPT_CommandLineOption aboutoptionlist[] =
+    {GNUNET_GETOPT_option_help ("Testing"), GNUNET_GETOPT_OPTION_END};
 
   if (0 != GNUNET_GETOPT_run ("test_getopt", aboutoptionlist, 2, myargv))
   {
@@ -121,31 +98,23 @@ testAbout ()
 static int
 testLogOpts ()
 {
-  char *const myargv[] = {
-    "test_getopt",
-    "-l", "filename",
-    "-L", "WARNING",
-    NULL
-  };
+  char *const myargv[] =
+    {"test_getopt", "-l", "filename", "-L", "WARNING", NULL};
   char *level = GNUNET_strdup ("stuff");
   char *fn = NULL;
 
-  const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = {
-    GNUNET_GETOPT_option_logfile (&fn),
-    GNUNET_GETOPT_option_loglevel (&level),
-    GNUNET_GETOPT_OPTION_END
-  };
+  const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] =
+    {GNUNET_GETOPT_option_logfile (&fn),
+     GNUNET_GETOPT_option_loglevel (&level),
+     GNUNET_GETOPT_OPTION_END};
 
-  if (5 != GNUNET_GETOPT_run ("test_getopt",
-                              logoptionlist,
-                              5, myargv))
+  if (5 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 5, myargv))
   {
     GNUNET_break (0);
     return 1;
   }
   GNUNET_assert (NULL != fn);
-  if ( (0 != strcmp (level, "WARNING")) ||
-       (NULL == strstr (fn, "/filename")) )
+  if ((0 != strcmp (level, "WARNING")) || (NULL == strstr (fn, "/filename")))
   {
     GNUNET_break (0);
     GNUNET_free (level);
@@ -161,47 +130,23 @@ testLogOpts ()
 static int
 testFlagNum ()
 {
-  char *const myargv[] = {
-    "test_getopt",
-    "-f",
-    "-n", "42",
-    "-N", "42",
-    NULL
-  };
+  char *const myargv[] = {"test_getopt", "-f", "-n", "42", "-N", "42", NULL};
   int flag = 0;
   unsigned int num = 0;
   unsigned long long lnum = 0;
 
-  const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = {
-    GNUNET_GETOPT_option_flag ('f',
-                                  "--flag",
-                                  "helptext",
-                                  &flag),
-    GNUNET_GETOPT_option_uint ('n',
-                                   "--num",
-                                   "ARG",
-                                   "helptext",
-                                   &num),
-    GNUNET_GETOPT_option_ulong ('N',
-                                    "--lnum",
-                                    "ARG",
-                                    "helptext",
-                                    &lnum),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (6 !=
-      GNUNET_GETOPT_run ("test_getopt",
-                         logoptionlist,
-                         6,
-                         myargv))
+  const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] =
+    {GNUNET_GETOPT_option_flag ('f', "--flag", "helptext", &flag),
+     GNUNET_GETOPT_option_uint ('n', "--num", "ARG", "helptext", &num),
+     GNUNET_GETOPT_option_ulong ('N', "--lnum", "ARG", "helptext", &lnum),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (6 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 6, myargv))
   {
     GNUNET_break (0);
     return 1;
   }
-  if ( (1 != flag) ||
-       (42 != num) ||
-       (42 != lnum))
+  if ((1 != flag) || (42 != num) || (42 != lnum))
   {
     GNUNET_break (0);
     return 1;
@@ -215,12 +160,10 @@ main (int argc, char *argv[])
 {
   int errCnt = 0;
 
-  GNUNET_log_setup ("test_getopt",
-                    "WARNING",
-                    NULL);
+  GNUNET_log_setup ("test_getopt", "WARNING", NULL);
   /* suppress output from -h, -v options */
 #ifndef MINGW
-  GNUNET_break (0 == CLOSE (1));
+  GNUNET_break (0 == close (1));
 #endif
   if (0 != testMinimal ())
     errCnt++;
index 248836b4c842f1706fceafb931b5ff6b770062e7..b059f2cf3a299e3b164546c853988418cccc6860 100644 (file)
@@ -65,7 +65,7 @@ check ()
     pid = GNUNET_PEER_intern (&pidArr[i]);
     if (pid != (i + 1))
     {
-      FPRINTF (stderr, "%s",  "Unexpected Peer ID returned by intern function\n");
+      fprintf (stderr, "%s",  "Unexpected Peer ID returned by intern function\n");
       return 1;
     }
   }
@@ -76,7 +76,7 @@ check ()
     pid = GNUNET_PEER_intern (&pidArr[i]);
     if (pid != (i + 1))
     {
-      FPRINTF (stderr, "%s",  "Unexpected Peer ID returned by intern function\n");
+      fprintf (stderr, "%s",  "Unexpected Peer ID returned by intern function\n");
       return 1;
     }
   }
index 686301694129f49f86747884bddb29aaac3ddd09..f4184aa84e31bfcfe9894fb4b3a18815741b1f18 100644 (file)
@@ -229,7 +229,7 @@ run (void *cls, char *const *args, const char *cfgfile,
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 _("gethostbyname() could not lookup IP address: %s\n"),
                 hstrerror (h_errno));
-    FPRINTF (stderr,
+    fprintf (stderr,
              "%s",
              "System seems to be off-line, will not run all DNS tests\n");
     *ok = 0;                    /* mark test as passing anyway */
@@ -373,7 +373,7 @@ main (int argc, char *argv[])
   GNUNET_OS_process_destroy (proc);
   proc = NULL;
   if (0 != ok)
-    FPRINTF (stderr, "Missed some resolutions: %u\n", ok);
+    fprintf (stderr, "Missed some resolutions: %u\n", ok);
   return ok;
 }
 
index c38af8a0a71b03d1240db8558dfee19627a4af0e..234a2aae11a2c6d4f00ae782a70d7d3c413437ca 100644 (file)
@@ -224,7 +224,7 @@ taskSig (void *cls)
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
                                  &taskNeverRun,
                                  NULL);
-  GNUNET_break (0 == PLIBC_KILL (getpid (),
+  GNUNET_break (0 == kill (getpid (),
                                 GNUNET_TERM_SIG));
 }
 
index 6c25531f21d57666e8b01d63ed86d7fa8ed54041..1ec86c6475efe1d9f6756a9bc8e710b3501434db 100644 (file)
@@ -55,10 +55,10 @@ test_task (void *cls)
   target =
       GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
                                         (GNUNET_TIME_UNIT_MICROSECONDS, i));
-  FPRINTF (stderr, "%s",  ".");
+  fprintf (stderr, "%s",  ".");
   if (i > MAXV)
   {
-    FPRINTF (stderr, "%s",  "\n");
+    fprintf (stderr, "%s",  "\n");
     return;
   }
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
@@ -77,17 +77,17 @@ main (int argc, char *argv[])
                    NULL);
   target = GNUNET_TIME_absolute_get ();
   GNUNET_SCHEDULER_run (&test_task, NULL);
-  FPRINTF (stdout,
+  fprintf (stdout,
           "Sleep precision: %llu microseconds (average delta). ",
            cumDelta / (MAXV / INCR));
   if (cumDelta <= 500 * MAXV / INCR)
-    FPRINTF (stdout, "%s",  "Timer precision is excellent.\n");
+    fprintf (stdout, "%s",  "Timer precision is excellent.\n");
   else if (cumDelta <= 5000 * MAXV / INCR)        /* 5 ms average deviation */
-    FPRINTF (stdout, "%s",  "Timer precision is good.\n");
+    fprintf (stdout, "%s",  "Timer precision is good.\n");
   else if (cumDelta > 25000 * MAXV / INCR)
-    FPRINTF (stdout, "%s",  "Timer precision is awful.\n");
+    fprintf (stdout, "%s",  "Timer precision is awful.\n");
   else
-    FPRINTF (stdout, "%s",  "Timer precision is acceptable.\n");
+    fprintf (stdout, "%s",  "Timer precision is acceptable.\n");
   return 0;
 }
 
index 72bd1f3713b075701f2a74e9934353fb29453cb0..dc8bc59c1fe2ccb6a2de3a0fead9041737735108 100644 (file)
@@ -222,7 +222,7 @@ main (int argc,
                           "socket");
       return 1;
     }
-    FPRINTF (stderr,
+    fprintf (stderr,
              "IPv6 support seems to not be available (%s), not testing it!\n",
              strerror (errno));
   }
index 652c3be232f2172c09ae9c61e93ee50a242ba429..9e4e808ef56ba2f828700078c53edc548be4b511 100644 (file)
@@ -93,7 +93,7 @@ main (int argc, char *argv[])
    * however, the "0:05 19" should always be there; hence: */
   if (NULL == strstr (bc, "0:05 19"))
   {
-    FPRINTF (stderr, "Got %s\n", bc);
+    fprintf (stderr, "Got %s\n", bc);
     GNUNET_break (0);
     return 1;
   }
index 758921718abffedb7af3fb204810cd1b18f67d52..85a781aff41a29a6af1171a62bd16f16edd0beba 100644 (file)
@@ -37,7 +37,7 @@
 #endif
 #endif
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-time", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-time", __VA_ARGS__)
 
 /**
  * Variable used to simulate clock skew.  Used for testing, never in production.
@@ -120,10 +120,10 @@ GNUNET_TIME_absolute_get ()
   struct GNUNET_TIME_Absolute ret;
   struct timeval tv;
 
-  GETTIMEOFDAY (&tv, NULL);
-  ret.abs_value_us =
-      (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL) +
-                  ((uint64_t) tv.tv_usec)) + timestamp_offset;
+  gettimeofday (&tv, NULL);
+  ret.abs_value_us = (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL) +
+                                 ((uint64_t) tv.tv_usec)) +
+                     timestamp_offset;
   return ret;
 }
 
@@ -158,7 +158,7 @@ GNUNET_TIME_absolute_get_zero_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_unit_ ()
 {
-  static struct GNUNET_TIME_Relative one = { 1 };
+  static struct GNUNET_TIME_Relative one = {1};
 
   return one;
 }
@@ -170,7 +170,7 @@ GNUNET_TIME_relative_get_unit_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_millisecond_ ()
 {
-  static struct GNUNET_TIME_Relative one = { 1000 };
+  static struct GNUNET_TIME_Relative one = {1000};
 
   return one;
 }
@@ -182,7 +182,7 @@ GNUNET_TIME_relative_get_millisecond_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_second_ ()
 {
-  static struct GNUNET_TIME_Relative one = { 1000 * 1000LL };
+  static struct GNUNET_TIME_Relative one = {1000 * 1000LL};
 
   return one;
 }
@@ -194,7 +194,7 @@ GNUNET_TIME_relative_get_second_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_minute_ ()
 {
-  static struct GNUNET_TIME_Relative one = { 60 * 1000 * 1000LL };
+  static struct GNUNET_TIME_Relative one = {60 * 1000 * 1000LL};
 
   return one;
 }
@@ -206,7 +206,7 @@ GNUNET_TIME_relative_get_minute_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_hour_ ()
 {
-  static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 * 1000LL };
+  static struct GNUNET_TIME_Relative one = {60 * 60 * 1000 * 1000LL};
 
   return one;
 }
@@ -218,7 +218,7 @@ GNUNET_TIME_relative_get_hour_ ()
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_forever_ ()
 {
-  static struct GNUNET_TIME_Relative forever = { UINT64_MAX };
+  static struct GNUNET_TIME_Relative forever = {UINT64_MAX};
 
   return forever;
 }
@@ -230,7 +230,7 @@ GNUNET_TIME_relative_get_forever_ ()
 struct GNUNET_TIME_Absolute
 GNUNET_TIME_absolute_get_forever_ ()
 {
-  static struct GNUNET_TIME_Absolute forever = { UINT64_MAX };
+  static struct GNUNET_TIME_Absolute forever = {UINT64_MAX};
   return forever;
 }
 
@@ -252,7 +252,7 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
 
   if (rel.rel_value_us + now.abs_value_us < rel.rel_value_us)
   {
-    GNUNET_break (0);           /* overflow... */
+    GNUNET_break (0); /* overflow... */
     return GNUNET_TIME_UNIT_FOREVER_ABS;
   }
   ret.abs_value_us = rel.rel_value_us + now.abs_value_us;
@@ -290,7 +290,6 @@ GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1,
 }
 
 
-
 /**
  * Return the minimum of two relative time values.
  *
@@ -395,7 +394,8 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start,
 {
   struct GNUNET_TIME_Absolute ret;
 
-  if ((start.abs_value_us == UINT64_MAX) || (duration.rel_value_us == UINT64_MAX))
+  if ((start.abs_value_us == UINT64_MAX) ||
+      (duration.rel_value_us == UINT64_MAX))
     return GNUNET_TIME_UNIT_FOREVER_ABS;
   if (start.abs_value_us + duration.rel_value_us < start.abs_value_us)
   {
@@ -462,8 +462,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
  * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor
  */
 struct GNUNET_TIME_Relative
-relative_multiply_double (struct GNUNET_TIME_Relative rel,
-                          double factor)
+relative_multiply_double (struct GNUNET_TIME_Relative rel, double factor)
 {
   struct GNUNET_TIME_Relative out;
   double m;
@@ -546,7 +545,8 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
  *        assuming it continues at the same speed
  */
 struct GNUNET_TIME_Relative
-GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished,
+GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start,
+                           uint64_t finished,
                            uint64_t total)
 {
   struct GNUNET_TIME_Relative dur;
@@ -673,7 +673,6 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
 
   ret.abs_value_us = GNUNET_ntohll (a.abs_value_us__);
   return ret;
-
 }
 
 
@@ -706,12 +705,11 @@ GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at)
   struct tm *t;
   time_t tp;
 
-  tp = at.abs_value_us / 1000LL / 1000LL;    /* microseconds to seconds */
+  tp = at.abs_value_us / 1000LL / 1000LL; /* microseconds to seconds */
   t = gmtime (&tp);
   if (t == NULL)
     return 0;
   return t->tm_year + 1900;
-
 }
 
 
@@ -740,8 +738,8 @@ GNUNET_TIME_year_to_time (unsigned int year)
   t.tm_wday = 1;
   t.tm_yday = 1;
   tp = mktime (&t);
-  GNUNET_break (tp != (time_t) - 1);
-  ret.abs_value_us = tp * 1000LL * 1000LL;  /* seconds to microseconds */
+  GNUNET_break (tp != (time_t) -1);
+  ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
   return ret;
 }
 
@@ -756,16 +754,16 @@ GNUNET_TIME_year_to_time (unsigned int year)
  * @return the next backoff time
  */
 struct GNUNET_TIME_Relative
-GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold)
+GNUNET_TIME_randomized_backoff (struct GNUNET_TIME_Relative rt,
+                                struct GNUNET_TIME_Relative threshold)
 {
-  double r = (rand() % 500) / 1000.0;
+  double r = (rand () % 500) / 1000.0;
   struct GNUNET_TIME_Relative t;
 
-  t = relative_multiply_double (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS,
-                                                          rt),
-                                2 + r);
-  return GNUNET_TIME_relative_min (threshold,
-                                   t);
+  t = relative_multiply_double (
+    GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, rt),
+    2 + r);
+  return GNUNET_TIME_relative_min (threshold, t);
 }
 
 
@@ -778,10 +776,9 @@ GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIM
 struct GNUNET_TIME_Relative
 GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r)
 {
-  double d = ((rand() % 1001) - 500) / 1000.0;
+  double d = ((rand () % 1001) - 500) / 1000.0;
 
-  return relative_multiply_double (r,
-                                   d);
+  return relative_multiply_double (r, d);
 }
 
 
@@ -804,7 +801,8 @@ GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r)
  * @return monotonically increasing time
  */
 struct GNUNET_TIME_Absolute
-GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cfg)
+GNUNET_TIME_absolute_get_monotonic (
+  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   static const struct GNUNET_CONFIGURATION_Handle *last_cfg;
   static struct GNUNET_TIME_Absolute last_time;
@@ -825,23 +823,26 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
     map = NULL;
 
     last_cfg = cfg;
-    if ( (NULL != cfg) &&
-        (GNUNET_OK ==
-         GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                  "util",
-                                                  "MONOTONIC_TIME_FILENAME",
-                                                  &filename)) )
+    if ((NULL != cfg) &&
+        (GNUNET_OK ==
+         GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                                  "util",
+                                                  "MONOTONIC_TIME_FILENAME",
+                                                  &filename)))
     {
       struct GNUNET_DISK_FileHandle *fh;
 
       fh = GNUNET_DISK_file_open (filename,
-                                  GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE,
-                                  GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_WRITE |
-                                  GNUNET_DISK_PERM_USER_READ  | GNUNET_DISK_PERM_GROUP_READ);
+                                  GNUNET_DISK_OPEN_READWRITE |
+                                    GNUNET_DISK_OPEN_CREATE,
+                                  GNUNET_DISK_PERM_USER_WRITE |
+                                    GNUNET_DISK_PERM_GROUP_WRITE |
+                                    GNUNET_DISK_PERM_USER_READ |
+                                    GNUNET_DISK_PERM_GROUP_READ);
       if (NULL == fh)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                    _("Failed to map `%s', cannot assure monotonic time!\n"),
+                    _ ("Failed to map `%s', cannot assure monotonic time!\n"),
                     filename);
       }
       else
@@ -849,18 +850,13 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
         off_t size;
 
         size = 0;
-        GNUNET_break (GNUNET_OK ==
-                      GNUNET_DISK_file_handle_size (fh,
-                                                    &size));
+        GNUNET_break (GNUNET_OK == GNUNET_DISK_file_handle_size (fh, &size));
         if (size < (off_t) sizeof (*map))
         {
           struct GNUNET_TIME_AbsoluteNBO o;
-          
+
           o = GNUNET_TIME_absolute_hton (now);
-          if (sizeof (o) !=
-              GNUNET_DISK_file_write (fh,
-                                      &o,
-                                      sizeof (o)))
+          if (sizeof (o) != GNUNET_DISK_file_write (fh, &o, sizeof (o)))
             size = 0;
           else
             size = sizeof (o);
@@ -873,14 +869,17 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
                                       sizeof (*map));
           if (NULL == map)
             GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                        _("Failed to map `%s', cannot assure monotonic time!\n"),
+                        _ (
+                          "Failed to map `%s', cannot assure monotonic time!\n"),
                         filename);
         }
         else
         {
-          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                      _("Failed to setup monotonic time file `%s', cannot assure monotonic time!\n"),
-                      filename);
+          GNUNET_log (
+            GNUNET_ERROR_TYPE_WARNING,
+            _ (
+              "Failed to setup monotonic time file `%s', cannot assure monotonic time!\n"),
+            filename);
         }
       }
       GNUNET_DISK_file_close (fh);
@@ -900,11 +899,11 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
 #else
     mt.abs_value_us__ = atomic_load (map);
 #endif
-    last_time = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_ntoh (mt),
-                                         last_time);
+    last_time =
+      GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_ntoh (mt), last_time);
   }
   if (now.abs_value_us <= last_time.abs_value_us)
-    now.abs_value_us = last_time.abs_value_us+1;
+    now.abs_value_us = last_time.abs_value_us + 1;
   last_time = now;
   if (NULL != map)
   {
@@ -913,11 +912,10 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
 #if __GNUC__
     (void) __sync_lock_test_and_set (map, val);
 #else
-    *map = val;  /* godspeed, pray this is atomic */
+    *map = val; /* godspeed, pray this is atomic */
 #endif
 #else
-    atomic_store (map,
-                 val);
+    atomic_store (map, val);
 #endif
   }
   return now;
@@ -927,8 +925,7 @@ GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cf
 /**
  * Destructor
  */
-void __attribute__ ((destructor))
-GNUNET_util_time_fini ()
+void __attribute__ ((destructor)) GNUNET_util_time_fini ()
 {
   (void) GNUNET_TIME_absolute_get_monotonic (NULL);
 }
index 38ead202332b2153f81ece271ffa4ec454cf08e7..1651767f4d5f4f76ad64fe77f4014364c344e38c 100644 (file)
@@ -88,7 +88,7 @@ static int ret;
 /**
  * Option '-d': duration of the mapping
  */
-static struct GNUNET_TIME_Relative duration = { 5 * 60 * 1000} ;
+static struct GNUNET_TIME_Relative duration = {5 * 60 * 1000};
 
 
 /**
@@ -127,9 +127,7 @@ do_disconnect (void *cls)
  *                specified target peer; NULL on error
  */
 static void
-allocation_cb (void *cls,
-              int af,
-              const void *address)
+allocation_cb (void *cls, int af, const void *address)
 {
   char buf[INET6_ADDRSTRLEN];
 
@@ -138,13 +136,10 @@ allocation_cb (void *cls,
   {
   case AF_INET6:
   case AF_INET:
-    FPRINTF (stdout,
-            "%s\n",
-            inet_ntop (af, address, buf, sizeof (buf)));
+    fprintf (stdout, "%s\n", inet_ntop (af, address, buf, sizeof (buf)));
     break;
   case AF_UNSPEC:
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Error creating tunnel\n"));
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Error creating tunnel\n"));
     ret = 1;
     break;
   default:
@@ -188,8 +183,10 @@ run (void *cls,
   {
     if (ipv6)
     {
-      FPRINTF (stderr, _("Option `%s' makes no sense with option `%s'.\n"),
-               "-4", "-6");
+      fprintf (stderr,
+               _ ("Option `%s' makes no sense with option `%s'.\n"),
+               "-4",
+               "-6");
       goto error;
     }
     req_af = AF_INET;
@@ -201,26 +198,32 @@ run (void *cls,
   {
     if (NULL == service_name)
     {
-      FPRINTF (stderr, _("Option `%s' or `%s' is required.\n"),
-               "-i", "-s");
+      fprintf (stderr, _ ("Option `%s' or `%s' is required.\n"), "-i", "-s");
       goto error;
     }
     if (NULL == peer_id)
     {
-      FPRINTF (stderr, _("Option `%s' is required when using option `%s'.\n"),
-               "-p", "-s");
+      fprintf (stderr,
+               _ ("Option `%s' is required when using option `%s'.\n"),
+               "-p",
+               "-s");
       goto error;
     }
-    if (! (tcp | udp) )
+    if (! (tcp | udp))
     {
-      FPRINTF (stderr, _("Option `%s' or `%s' is required when using option `%s'.\n"),
-               "-t", "-u", "-s");
+      fprintf (stderr,
+               _ ("Option `%s' or `%s' is required when using option `%s'.\n"),
+               "-t",
+               "-u",
+               "-s");
       goto error;
     }
     if (tcp & udp)
     {
-      FPRINTF (stderr, _("Option `%s' makes no sense with option `%s'.\n"),
-               "-t", "-u");
+      fprintf (stderr,
+               _ ("Option `%s' makes no sense with option `%s'.\n"),
+               "-t",
+               "-u");
       goto error;
     }
     if (tcp)
@@ -228,24 +231,22 @@ run (void *cls,
     if (udp)
       protocol = IPPROTO_UDP;
     if (GNUNET_OK !=
-       GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
+        GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
                                                     strlen (peer_id),
                                                     &peer.public_key))
     {
-      FPRINTF (stderr,
-               _("`%s' is not a valid peer identifier.\n"),
-               peer_id);
+      fprintf (stderr, _ ("`%s' is not a valid peer identifier.\n"), peer_id);
       goto error;
     }
-    GNUNET_TUN_service_name_to_hash (service_name,
-                                     &sd);
+    GNUNET_TUN_service_name_to_hash (service_name, &sd);
     request = GNUNET_VPN_redirect_to_peer (handle,
-                                          req_af,
-                                          protocol,
-                                          &peer,
-                                          &sd,
-                                          etime,
-                                          &allocation_cb, NULL);
+                                           req_af,
+                                           protocol,
+                                           &peer,
+                                           &sd,
+                                           etime,
+                                           &allocation_cb,
+                                           NULL);
   }
   else
   {
@@ -253,14 +254,13 @@ run (void *cls,
     {
       if (1 != inet_pton (AF_INET, target_ip, &v4))
       {
-       FPRINTF (stderr, _("`%s' is not a valid IP address.\n"),
-                target_ip);
-       goto error;
+        fprintf (stderr, _ ("`%s' is not a valid IP address.\n"), target_ip);
+        goto error;
       }
       else
       {
-       dst_af = AF_INET;
-       addr = &v4;
+        dst_af = AF_INET;
+        addr = &v4;
       }
     }
     else
@@ -269,15 +269,16 @@ run (void *cls,
       addr = &v6;
     }
     request = GNUNET_VPN_redirect_to_ip (handle,
-                                        req_af,
-                                        dst_af,
-                                        addr,
-                                        etime,
-                                        &allocation_cb, NULL);
+                                         req_af,
+                                         dst_af,
+                                         addr,
+                                         etime,
+                                         &allocation_cb,
+                                         NULL);
   }
   return;
 
- error:
+error:
   GNUNET_SCHEDULER_shutdown ();
   ret = 1;
 }
@@ -286,63 +287,73 @@ run (void *cls,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('4',
-                                  "ipv4",
-                                  gettext_noop ("request that result should be an IPv4 address"),
-                                  &ipv4),
-
-    GNUNET_GETOPT_option_flag ('6',
-                                  "ipv6",
-                                  gettext_noop ("request that result should be an IPv6 address"),
-                                  &ipv6),
-
-    GNUNET_GETOPT_option_relative_time ('d',
-                                            "duration",
-                                            "TIME",
-                                            gettext_noop ("how long should the mapping be valid for new tunnels?"),
-                                            &duration),
-
-    GNUNET_GETOPT_option_string ('i',
-                                 "ip",
-                                 "IP",
-                                 gettext_noop ("destination IP for the tunnel"),
-                                 &target_ip),
-
-    GNUNET_GETOPT_option_string ('p',
-                                 "peer",
-                                 "PEERID",
-                                 gettext_noop ("peer offering the service we would like to access"),
-                                 &peer_id),
-
-    GNUNET_GETOPT_option_string ('s', 
-                                 "service",
-                                 "NAME",
-                                 gettext_noop ("name of the service we would like to access"),
-                                 &service_name),
-
-    GNUNET_GETOPT_option_flag ('t',
-                                  "tcp",
-                                  gettext_noop ("service is offered via TCP"),
-                                  &tcp),
-
-    GNUNET_GETOPT_option_flag ('u',
-                                  "udp",
-                                  gettext_noop ("service is offered via UDP"),
-                                  &udp),
-
-    GNUNET_GETOPT_option_verbose (&verbosity),
-
-    GNUNET_GETOPT_OPTION_END
-  };
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('4',
+                                "ipv4",
+                                gettext_noop (
+                                  "request that result should be an IPv4 address"),
+                                &ipv4),
+
+     GNUNET_GETOPT_option_flag ('6',
+                                "ipv6",
+                                gettext_noop (
+                                  "request that result should be an IPv6 address"),
+                                &ipv6),
+
+     GNUNET_GETOPT_option_relative_time (
+       'd',
+       "duration",
+       "TIME",
+       gettext_noop ("how long should the mapping be valid for new tunnels?"),
+       &duration),
+
+     GNUNET_GETOPT_option_string ('i',
+                                  "ip",
+                                  "IP",
+                                  gettext_noop (
+                                    "destination IP for the tunnel"),
+                                  &target_ip),
+
+     GNUNET_GETOPT_option_string (
+       'p',
+       "peer",
+       "PEERID",
+       gettext_noop ("peer offering the service we would like to access"),
+       &peer_id),
+
+     GNUNET_GETOPT_option_string ('s',
+                                  "service",
+                                  "NAME",
+                                  gettext_noop (
+                                    "name of the service we would like to access"),
+                                  &service_name),
+
+     GNUNET_GETOPT_option_flag ('t',
+                                "tcp",
+                                gettext_noop ("service is offered via TCP"),
+                                &tcp),
+
+     GNUNET_GETOPT_option_flag ('u',
+                                "udp",
+                                gettext_noop ("service is offered via UDP"),
+                                &udp),
+
+     GNUNET_GETOPT_option_verbose (&verbosity),
+
+     GNUNET_GETOPT_OPTION_END};
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
 
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-vpn",
-                            gettext_noop
-                            ("Setup tunnels via VPN."), options,
-                              &run, NULL)) ? ret : 1;
+  ret =
+    (GNUNET_OK == GNUNET_PROGRAM_run (argc,
+                                      argv,
+                                      "gnunet-vpn",
+                                      gettext_noop ("Setup tunnels via VPN."),
+                                      options,
+                                      &run,
+                                      NULL))
+      ? ret
+      : 1;
   GNUNET_free ((void *) argv);
   return ret;
 }