summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
committerng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
commit6e599264ad13e8fc105493d74d7c11d46f8739ed (patch)
tree169bef1ecbade5a659831fb169f3ae6943af127f /src
parent4f13bc15113021ebf71d5d81e99bc29f8a07fc9c (diff)
first step to remove plibc
Diffstat (limited to 'src')
-rw-r--r--src/arm/Kyuafile9
-rw-r--r--src/arm/gnunet-arm.c30
-rw-r--r--src/arm/gnunet-service-arm.c1071
-rw-r--r--src/arm/test_exponential_backoff.c2
-rw-r--r--src/arm/test_gnunet_service_arm.c8
-rw-r--r--src/ats-tool/gnunet-ats.c427
-rw-r--r--src/cadet/gnunet-cadet-profiler.c2
-rw-r--r--src/cadet/gnunet-cadet.c348
-rw-r--r--src/cadet/test_cadet.c10
-rw-r--r--src/cadet/test_cadet_flow.c10
-rw-r--r--src/conversation/gnunet-conversation.c487
-rw-r--r--src/core/gnunet-core.c8
-rw-r--r--src/core/test_core_api_reliability.c4
-rw-r--r--src/core/test_core_api_start_only.c2
-rw-r--r--src/core/test_core_quota_compliance.c4
-rw-r--r--src/datacache/datacache.c126
-rw-r--r--src/datacache/perf_datacache.c16
-rw-r--r--src/datacache/plugin_datacache_sqlite.c504
-rw-r--r--src/datacache/test_datacache.c4
-rw-r--r--src/datacache/test_datacache_quota.c12
-rw-r--r--src/datastore/gnunet-datastore.c120
-rw-r--r--src/datastore/gnunet-service-datastore.c622
-rw-r--r--src/datastore/perf_datastore_api.c10
-rw-r--r--src/datastore/perf_plugin_datastore.c8
-rw-r--r--src/datastore/plugin_datastore_sqlite.c893
-rw-r--r--src/datastore/test_datastore_api.c10
-rw-r--r--src/datastore/test_datastore_api_management.c4
-rw-r--r--src/datastore/test_plugin_datastore.c8
-rw-r--r--src/dht/gnunet-dht-get.c149
-rw-r--r--src/dht/gnunet-dht-monitor.c110
-rw-r--r--src/dht/gnunet-dht-put.c118
-rw-r--r--src/dht/test_dht_api.c2
-rw-r--r--src/dht/test_dht_topo.c2
-rw-r--r--src/fragmentation/test_fragmentation.c24
-rw-r--r--src/fragmentation/test_fragmentation_parallel.c18
-rw-r--r--src/fs/fs_api.c842
-rw-r--r--src/fs/fs_dirmetascan.c217
-rw-r--r--src/fs/fs_download.c736
-rw-r--r--src/fs/fs_file_information.c181
-rw-r--r--src/fs/fs_namespace.c188
-rw-r--r--src/fs/fs_uri.c400
-rw-r--r--src/fs/gnunet-auto-share.c2
-rw-r--r--src/fs/gnunet-directory.c70
-rw-r--r--src/fs/gnunet-download.c277
-rw-r--r--src/fs/gnunet-fs.c42
-rw-r--r--src/fs/gnunet-helper-fs-publish.c194
-rw-r--r--src/fs/gnunet-publish.c530
-rw-r--r--src/fs/gnunet-search.c173
-rw-r--r--src/fs/gnunet-service-fs_indexing.c248
-rw-r--r--src/fs/gnunet-unindex.c58
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c4
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_respect.c4
-rw-r--r--src/fs/test_fs.c4
-rw-r--r--src/fs/test_fs_directory.c4
-rw-r--r--src/fs/test_fs_download.c6
-rw-r--r--src/fs/test_fs_download_persistence.c4
-rw-r--r--src/fs/test_fs_getopt.c2
-rw-r--r--src/fs/test_fs_list_indexed.c2
-rw-r--r--src/fs/test_fs_namespace.c18
-rw-r--r--src/fs/test_fs_publish.c4
-rw-r--r--src/fs/test_fs_publish_persistence.c2
-rw-r--r--src/fs/test_fs_search.c6
-rw-r--r--src/fs/test_fs_search_persistence.c6
-rw-r--r--src/fs/test_fs_search_probes.c6
-rw-r--r--src/fs/test_fs_search_with_and.c6
-rw-r--r--src/fs/test_fs_unindex.c4
-rw-r--r--src/fs/test_fs_unindex_persistence.c2
-rw-r--r--src/fs/test_fs_uri.c4
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c2
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c2
-rw-r--r--src/fs/test_plugin_block_fs.c2
-rw-r--r--src/gns/gnunet-bcd.c12
-rw-r--r--src/gns/gnutls_ca.cfg25
-rw-r--r--src/gns/plugin_gnsrecord_gns.c438
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c14
-rw-r--r--src/hello/gnunet-hello.c124
-rw-r--r--src/hostlist/hostlists_learn_peer2.filebin71 -> 72 bytes
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c4
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c4
-rw-r--r--src/identity/gnunet-service-identity.c394
-rw-r--r--src/include/Makefile.am2
-rw-r--r--src/include/gnunet_common.h8
-rw-r--r--src/include/platform.h20
-rw-r--r--src/include/plibc.h980
-rw-r--r--src/json/json.c2
-rw-r--r--src/namecache/gnunet-namecache.c126
-rw-r--r--src/namecache/test_plugin_namecache.c6
-rw-r--r--src/namestore/gnunet-namestore.c24
-rw-r--r--src/namestore/test_plugin_namestore.c6
-rw-r--r--src/nat-auto/gnunet-nat-auto.c149
-rw-r--r--src/nat-auto/nat_auto_api_test.c226
-rw-r--r--src/nat/gnunet-nat.c223
-rw-r--r--src/nat/gnunet-service-nat_helper.c211
-rw-r--r--src/nat/gnunet-service-nat_mini.c263
-rw-r--r--src/nse/gnunet-nse-profiler.c380
-rw-r--r--src/nse/gnunet-nse.c2
-rw-r--r--src/nse/test_nse_api.c2
-rw-r--r--src/nse/test_nse_multipeer.c2
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c309
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c620
-rw-r--r--src/peerinfo/perf_peerinfo_api.c2
-rw-r--r--src/peerstore/test_plugin_peerstore.c6
-rw-r--r--src/reclaim/oidc_helper.c3
-rw-r--r--src/regex/gnunet-regex-simulation-profiler.c8
-rw-r--r--src/regex/test_regex_api.c2
-rw-r--r--src/regex/test_regex_integration.c2
-rw-r--r--src/revocation/gnunet-revocation.c274
-rw-r--r--src/rps/gnunet-rps.c14
-rw-r--r--src/statistics/gnunet-service-statistics.c418
-rw-r--r--src/statistics/gnunet-statistics.c42
-rw-r--r--src/testbed/generate-underlay-topology.c210
-rw-r--r--src/testbed/gnunet-helper-testbed.c2
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c4
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c135
-rw-r--r--src/testbed/testbed_api_hosts.c332
-rw-r--r--src/testing/gnunet-testing.c212
-rw-r--r--src/testing/list-keys.c43
-rw-r--r--src/testing/testing.c450
-rw-r--r--src/topology/test_gnunet_daemon_topology.c2
-rw-r--r--src/transport/gnunet-communicator-tcp.c8
-rw-r--r--src/transport/gnunet-communicator-udp.c4
-rw-r--r--src/transport/gnunet-communicator-unix.c2
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c36
-rw-r--r--src/transport/gnunet-transport-profiler.c42
-rw-r--r--src/transport/gnunet-transport.c50
-rw-r--r--src/transport/plugin_transport_smtp.c4
-rw-r--r--src/transport/plugin_transport_tcp.c1281
-rw-r--r--src/transport/plugin_transport_udp.c1187
-rw-r--r--src/transport/plugin_transport_unix.c453
-rw-r--r--src/transport/tcp_connection_legacy.c421
-rw-r--r--src/transport/tcp_service_legacy.c458
-rw-r--r--src/transport/test_plugin_hostkeybin914 -> 915 bytes
-rw-r--r--src/transport/test_quota_compliance.c6
-rw-r--r--src/transport/test_transport_address_switch.c18
-rw-r--r--src/transport/test_transport_api_reliability.c4
-rw-r--r--src/transport/test_transport_api_timeout.c4
-rw-r--r--src/transport/test_transport_blacklisting.c2
-rw-r--r--src/util/bio.c133
-rw-r--r--src/util/common_allocation.c199
-rw-r--r--src/util/common_logging.c21
-rw-r--r--src/util/configuration.c451
-rw-r--r--src/util/container_bloomfilter.c205
-rw-r--r--src/util/crypto_ecc_setup.c247
-rw-r--r--src/util/crypto_random.c10
-rw-r--r--src/util/disk.c589
-rw-r--r--src/util/dnsstub.c168
-rw-r--r--src/util/getopt.c32
-rw-r--r--src/util/getopt_helpers.c22
-rw-r--r--src/util/gnunet-ecc.c208
-rw-r--r--src/util/gnunet-resolver.c4
-rw-r--r--src/util/gnunet-scrypt.c4
-rw-r--r--src/util/helper.c221
-rw-r--r--src/util/os_installation.c64
-rw-r--r--src/util/os_priority.c604
-rw-r--r--src/util/perf_crypto_asymmetric.c2
-rw-r--r--src/util/perf_crypto_ecc_dlog.c2
-rw-r--r--src/util/plugin.c41
-rw-r--r--src/util/program.c20
-rw-r--r--src/util/service.c856
-rw-r--r--src/util/strings.c693
-rw-r--r--src/util/test_common_allocation.c2
-rw-r--r--src/util/test_common_logging.c8
-rw-r--r--src/util/test_common_logging_dummy.c2
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c6
-rw-r--r--src/util/test_configuration.c14
-rw-r--r--src/util/test_container_bloomfilter.c30
-rw-r--r--src/util/test_crypto_ecc_dlog.c2
-rw-r--r--src/util/test_crypto_ecdh_eddsa.c2
-rw-r--r--src/util/test_crypto_ecdhe.c2
-rw-r--r--src/util/test_crypto_ecdsa.c18
-rw-r--r--src/util/test_crypto_eddsa.c20
-rw-r--r--src/util/test_crypto_hash.c6
-rw-r--r--src/util/test_crypto_random.c2
-rw-r--r--src/util/test_disk.c16
-rw-r--r--src/util/test_getopt.c119
-rw-r--r--src/util/test_peer.c4
-rw-r--r--src/util/test_resolver_api.c4
-rw-r--r--src/util/test_scheduler.c2
-rw-r--r--src/util/test_scheduler_delay.c14
-rw-r--r--src/util/test_service.c2
-rw-r--r--src/util/test_strings.c2
-rw-r--r--src/util/time.c125
-rw-r--r--src/vpn/gnunet-vpn.c205
183 files changed, 11336 insertions, 14218 deletions
diff --git a/src/arm/Kyuafile b/src/arm/Kyuafile
new file mode 100644
index 000000000..f97f05e18
--- /dev/null
+++ b/src/arm/Kyuafile
@@ -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'}
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 7d705733a..f96076231 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -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);
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 4b7cbec20..a05257563 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -29,9 +29,10 @@
#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)
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index e3c2a399a..43984f9bf 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -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,
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 55903c499..9508581de 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -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
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 88c3c41e9..519f77af8 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -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;
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c
index 2de17dc9e..34ea53a57 100644
--- a/src/cadet/gnunet-cadet-profiler.c
+++ b/src/cadet/gnunet-cadet-profiler.c
@@ -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]);
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 262cdf64d..4e81d52f2 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -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);
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index 80a6e8227..5a28b439e 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -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);
}
diff --git a/src/cadet/test_cadet_flow.c b/src/cadet/test_cadet_flow.c
index 552d0fdb3..87e7b9a03 100644
--- a/src/cadet/test_cadet_flow.c
+++ b/src/cadet/test_cadet_flow.c
@@ -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;
}
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c
index 6c3db2184..4c5407cd7 100644
--- a/src/conversation/gnunet-conversation.c
+++ b/src/conversation/gnunet-conversation.c
@@ -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)
{
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 674da705a..aeb3ba61f 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -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);
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index a2f7c0cf0..7bd4bfea0 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -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)
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index 03edffe8e..92574e3d4 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -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)
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index c661ff3e5..908d90ac3 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -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);
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 7dcd54fcf..57e0b0bb7 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -29,9 +29,10 @@
#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);
}
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 4381171c5..1dfb46cf1 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -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;
}
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 07a72957a..0cf77d6e6 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -29,16 +29,17 @@
#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 */
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index d62a31c27..572a775df 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -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;
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c
index 7c4e56ea5..0201df3b3 100644
--- a/src/datacache/test_datacache_quota.c
+++ b/src/datacache/test_datacache_quota.c
@@ -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;
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c
index cd089071c..4cf318777 100644
--- a/src/datastore/gnunet-datastore.c
+++ b/src/datastore/gnunet-datastore.c
@@ -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;
}
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 70a946ca5..4596f6131 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -45,13 +45,15 @@
* 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 */
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 2c261b155..96ec9e924 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -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;
}
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index f68d1f389..564f8f37b 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -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;
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index d548935ea..4bd2b39cb 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -1,4 +1,4 @@
- /*
+/*
* This file is part of GNUnet
* Copyright (C) 2009, 2011, 2017 GNUnet e.V.
*
@@ -55,7 +55,17 @@
* 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)
/**
@@ -63,8 +73,23 @@
* 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;
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index daf6cccb3..ee78a8cfc 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -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;
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index d91fe748b..fc4c03885 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -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;
}
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c
index c37b8ddb9..2b7bf9ae4 100644
--- a/src/datastore/test_plugin_datastore.c
+++ b/src/datastore/test_plugin_datastore.c
@@ -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;
}
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index b42326fc5..af667584b 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -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 */
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c
index 52a57473b..3787b7cfa 100644
--- a/src/dht/gnunet-dht-monitor.c
+++ b/src/dht/gnunet-dht-monitor.c
@@ -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 */
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 4c26f98a5..0432dc4a0 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -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 */
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index 38adbc219..7ec6758b7 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -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 ();
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c
index 2ff0e7a59..a0d80e52c 100644
--- a/src/dht/test_dht_topo.c
+++ b/src/dht/test_dht_topo.c
@@ -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,
diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c
index 0bf3b2ab1..a49f6d71a 100644
--- a/src/fragmentation/test_fragmentation.c
+++ b/src/fragmentation/test_fragmentation.c
@@ -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,
diff --git a/src/fragmentation/test_fragmentation_parallel.c b/src/fragmentation/test_fragmentation_parallel.c
index 5cde75c0b..d8e598484 100644
--- a/src/fragmentation/test_fragmentation_parallel.c
+++ b/src/fragmentation/test_fragmentation_parallel.c
@@ -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;
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c
index aec5ff340..f7b64a5c9 100644
--- a/src/fs/fs_api.c
+++ b/src/fs/fs_api.c
@@ -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;
}
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c
index 115f99391..dd207e2c9 100644
--- a/src/fs/fs_dirmetascan.c
+++ b/src/fs/fs_dirmetascan.c
@@ -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;
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 2d64bba11..59821f8a5 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -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);
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index 49cfc1a68..fbf3181ef 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -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);
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 675253b90..11a137a09 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -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);
}
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 9097d9884..5a67afbc0 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -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.
@@ -102,7 +101,7 @@
*/
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;
}
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c
index ba28c5c23..8b04e474d 100644
--- a/src/fs/gnunet-auto-share.c
+++ b/src/fs/gnunet-auto-share.c
@@ -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;
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index 097dd4406..4cce69d72 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -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;
}
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 31e62c603..00e8336a2 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -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;
}
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 26970c06a..ad2a8d6c5 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -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;
}
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index fefb33e14..dcb4b47cd 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -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. */