diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-03 20:14:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-03 20:14:05 +0000 |
commit | 03b62462b4db11dbbb3e121cb6992c8d0fb9152a (patch) | |
tree | b569899eec14316da743c442169e4cc7e3f69889 /src/hello/hello.c | |
parent | 5baf12a487a19225962d15e28ba52f10d1d1f7d4 (diff) | |
download | gnunet-03b62462b4db11dbbb3e121cb6992c8d0fb9152a.tar.gz gnunet-03b62462b4db11dbbb3e121cb6992c8d0fb9152a.zip |
-improving comments and coding style for libgnunethello library
Diffstat (limited to 'src/hello/hello.c')
-rw-r--r-- | src/hello/hello.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c index 1013fd5a3..4e43fafb5 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -1000,7 +1000,7 @@ add_address_to_uri (void *cls, | |||
1000 | time_t seconds; | 1000 | time_t seconds; |
1001 | 1001 | ||
1002 | papi = ctx->plugins_find (address->transport_name); | 1002 | papi = ctx->plugins_find (address->transport_name); |
1003 | if (papi == NULL) | 1003 | if (NULL == papi) |
1004 | { | 1004 | { |
1005 | /* Not an error - we might just not have the right plugin. */ | 1005 | /* Not an error - we might just not have the right plugin. */ |
1006 | return GNUNET_OK; | 1006 | return GNUNET_OK; |
@@ -1012,14 +1012,18 @@ add_address_to_uri (void *cls, | |||
1012 | address->transport_name); | 1012 | address->transport_name); |
1013 | return GNUNET_OK; | 1013 | return GNUNET_OK; |
1014 | } | 1014 | } |
1015 | addr = papi->address_to_string (papi->cls, address->address, address->address_length); | 1015 | addr = papi->address_to_string (papi->cls, |
1016 | 1016 | address->address, | |
1017 | if ( (addr == NULL) || (strlen(addr) == 0) ) | 1017 | address->address_length); |
1018 | if ( (NULL == addr) || | ||
1019 | (0 == strlen(addr)) ) | ||
1018 | return GNUNET_OK; | 1020 | return GNUNET_OK; |
1019 | 1021 | ||
1020 | addr_dup = GNUNET_strdup (addr); | 1022 | addr_dup = GNUNET_strdup (addr); |
1021 | if (NULL != (pos = strstr (addr_dup, "_server"))) | 1023 | if (NULL != (pos = strstr (addr_dup, "_server"))) |
1022 | memcpy (pos, client_str, strlen(client_str)); /* Replace all server addresses with client addresses */ | 1024 | memcpy (pos, |
1025 | client_str, | ||
1026 | strlen (client_str)); /* Replace all server addresses with client addresses */ | ||
1023 | 1027 | ||
1024 | seconds = expiration.abs_value_us / 1000LL / 1000LL; | 1028 | seconds = expiration.abs_value_us / 1000LL / 1000LL; |
1025 | t = gmtime (&seconds); | 1029 | t = gmtime (&seconds); |
@@ -1055,17 +1059,21 @@ GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | |||
1055 | GNUNET_HELLO_TransportPluginsFind plugins_find) | 1059 | GNUNET_HELLO_TransportPluginsFind plugins_find) |
1056 | { | 1060 | { |
1057 | struct GNUNET_HELLO_ComposeUriContext ctx; | 1061 | struct GNUNET_HELLO_ComposeUriContext ctx; |
1058 | ctx.plugins_find = plugins_find; | 1062 | char *pkey; |
1059 | |||
1060 | char *pkey = GNUNET_CRYPTO_eddsa_public_key_to_string (&(hello->publicKey)); | ||
1061 | 1063 | ||
1062 | GNUNET_asprintf (&(ctx.uri), | 1064 | ctx.plugins_find = plugins_find; |
1065 | pkey = GNUNET_CRYPTO_eddsa_public_key_to_string (&hello->publicKey); | ||
1066 | GNUNET_asprintf (&ctx.uri, | ||
1063 | "%s%s", | 1067 | "%s%s", |
1064 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? GNUNET_FRIEND_HELLO_URI_PREFIX : GNUNET_HELLO_URI_PREFIX, | 1068 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) |
1069 | ? GNUNET_FRIEND_HELLO_URI_PREFIX | ||
1070 | : GNUNET_HELLO_URI_PREFIX, | ||
1065 | pkey); | 1071 | pkey); |
1066 | GNUNET_free (pkey); | 1072 | GNUNET_free (pkey); |
1067 | 1073 | GNUNET_HELLO_iterate_addresses (hello, | |
1068 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &add_address_to_uri, &ctx); | 1074 | GNUNET_NO, |
1075 | &add_address_to_uri, | ||
1076 | &ctx); | ||
1069 | return ctx.uri; | 1077 | return ctx.uri; |
1070 | } | 1078 | } |
1071 | 1079 | ||
@@ -1153,7 +1161,8 @@ add_address_to_hello (void *cls, | |||
1153 | return GNUNET_SYSERR; | 1161 | return GNUNET_SYSERR; |
1154 | } | 1162 | } |
1155 | tname++; | 1163 | tname++; |
1156 | address = strchr (tname, (int) GNUNET_HELLO_URI_SEP); | 1164 | address = strchr (tname, |
1165 | (int) GNUNET_HELLO_URI_SEP); | ||
1157 | if (NULL == address) | 1166 | if (NULL == address) |
1158 | { | 1167 | { |
1159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1168 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1210,7 +1219,10 @@ add_address_to_hello (void *cls, | |||
1210 | haddr.address_length = addr_len; | 1219 | haddr.address_length = addr_len; |
1211 | haddr.address = addr; | 1220 | haddr.address = addr; |
1212 | haddr.transport_name = plugin_name; | 1221 | haddr.transport_name = plugin_name; |
1213 | ret = GNUNET_HELLO_add_address (&haddr, expire, buffer, max); | 1222 | ret = GNUNET_HELLO_add_address (&haddr, |
1223 | expire, | ||
1224 | buffer, | ||
1225 | max); | ||
1214 | ctx->counter_added ++; | 1226 | ctx->counter_added ++; |
1215 | GNUNET_free (addr); | 1227 | GNUNET_free (addr); |
1216 | GNUNET_free (plugin_name); | 1228 | GNUNET_free (plugin_name); |