/**
* Expiration time for the DNS record; relative or absolute depends
- * on 'flags', network byte order.
+ * on @e flags, network byte order.
*/
uint64_t expiration_time GNUNET_PACKED;
off = 0;
for (i=0;i<rd_count;i++)
{
-#if 0
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Serializing record %u with flags %d and expiration time %llu\n",
i,
rd[i].flags,
(unsigned long long) rd[i].expiration_time);
-#endif
rec.expiration_time = GNUNET_htonll (rd[i].expiration_time);
rec.data_size = htonl ((uint32_t) rd[i].data_size);
rec.record_type = htonl (rd[i].record_type);
rec.flags = htonl (rd[i].flags);
if (off + sizeof (rec) > dest_size)
return -1;
- GNUNET_memcpy (&dest[off], &rec, sizeof (rec));
+ GNUNET_memcpy (&dest[off],
+ &rec,
+ sizeof (rec));
off += sizeof (rec);
if (off + rd[i].data_size > dest_size)
return -1;
- GNUNET_memcpy (&dest[off], rd[i].data, rd[i].data_size);
+ GNUNET_memcpy (&dest[off],
+ rd[i].data,
+ rd[i].data_size);
off += rd[i].data_size;
}
return off;
return GNUNET_SYSERR;
dest[i].data = &src[off];
off += dest[i].data_size;
-#if 0
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Deserialized record %u with flags %d and expiration time %llu\n",
i,
dest[i].flags,
(unsigned long long) dest[i].expiration_time);
-#endif
}
return GNUNET_OK;
}
rd[i].data_size);
if (NULL == s)
{
- FPRINTF (stdout, _("\tCorrupt or unsupported record of type %u\n"),
+ FPRINTF (stdout,
+ _("\tCorrupt or unsupported record of type %u\n"),
(unsigned int) rd[i].record_type);
continue;
}
break;
}
memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
- GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
+ GNUNET_memcpy (&rdn[1],
+ rd,
+ rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
rde = &rdn[0];
rde->data = data;
rde->data_size = data_size;
{
fprintf (stderr,
_("Missing option `%s' for operation `%s'\n"),
- "-e", _("add"));
+ "-e",
+ _("add"));
GNUNET_SCHEDULER_shutdown ();
ret = 1;
return;
&etime_rel))
{
etime_is_rel = GNUNET_YES;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Storing record with relative expiration time of %s\n",
+ GNUNET_STRINGS_relative_time_to_string (etime_rel,
+ GNUNET_NO));
}
else if (GNUNET_OK ==
GNUNET_STRINGS_fancy_time_to_absolute (expirationstring,
&etime_abs))
{
etime_is_rel = GNUNET_NO;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Storing record with absolute expiration time of %s\n",
+ GNUNET_STRINGS_absolute_time_to_string (etime_abs));
}
else
{
ret = 1;
return;
}
- add_qe_uri = GNUNET_NAMESTORE_set_nick(ns, &zone_pkey, nickstring,
- &add_continuation, &add_qe_uri);
+ add_qe_uri = GNUNET_NAMESTORE_set_nick(ns,
+ &zone_pkey,
+ nickstring,
+ &add_continuation,
+ &add_qe_uri);
}
if (monitor)
{
{
get_default = GNUNET_IDENTITY_get (idh,
"namestore",
- &default_ego_cb, (void *) cfg);
+ &default_ego_cb,
+ (void *) cfg);
}
}
testservice_id_task (void *cls, int result)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
if (result != GNUNET_YES)
{
fprintf (stderr,
ret = -1;
return;
}
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ (void *) cfg);
if (NULL == ego_name)
{
- idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg);
+ idh = GNUNET_IDENTITY_connect (cfg,
+ &id_connect_cb,
+ (void *) cfg);
if (NULL == idh)
fprintf (stderr, _("Cannot connect to identity service\n"));
ret = -1;
* @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 ( (NULL != args[0]) && (NULL == uri) )
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
is_public = -1;
is_shadow = -1;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
- GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
+ GNUNET_log_setup ("gnunet-namestore",
+ "WARNING",
+ NULL);
if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv, "gnunet-namestore",
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-namestore",
_("GNUnet zone manipulation tool"),
options,
&run, NULL))
static void
-merge_with_nick_records ( const struct GNUNET_GNSRECORD_Data *nick_rd,
- unsigned int rdc2,
- const struct GNUNET_GNSRECORD_Data *rd2,
- unsigned int *rdc_res,
- struct GNUNET_GNSRECORD_Data **rd_res)
+merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
+ unsigned int rdc2,
+ const struct GNUNET_GNSRECORD_Data *rd2,
+ unsigned int *rdc_res,
+ struct GNUNET_GNSRECORD_Data **rd_res)
{
uint64_t latest_expiration;
- int c;
size_t req;
char *data;
int record_offset;
size_t data_offset;
- (*rdc_res) = 1 + rdc2;
+ (*rdc_res) = 1 + rdc2;
if (0 == 1 + rdc2)
{
(*rd_res) = NULL;
}
req = 0;
- for (c=0; c< 1; c++)
+ for (unsigned int c=0; c< 1; c++)
req += sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd[c].data_size;
- for (c=0; c< rdc2; c++)
+ for (unsigned int c=0; c< rdc2; c++)
req += sizeof (struct GNUNET_GNSRECORD_Data) + rd2[c].data_size;
(*rd_res) = GNUNET_malloc (req);
data = (char *) &(*rd_res)[1 + rdc2];
data_offset = 0;
latest_expiration = 0;
- for (c=0; c< rdc2; c++)
+ for (unsigned int c=0; c< rdc2; c++)
{
if (0 != (rd2[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
{
latest_expiration = rd2[c].expiration_time;
(*rd_res)[c] = rd2[c];
(*rd_res)[c].data = (void *) &data[data_offset];
- // WTF?
GNUNET_memcpy ((void *) (*rd_res)[c].data,
rd2[c].data,
rd2[c].data_size);
data_offset += (*rd_res)[c].data_size;
}
record_offset = rdc2;
- for (c=0; c< 1; c++)
+ for (unsigned int c=0; c< 1; c++)
{
(*rd_res)[c+record_offset] = nick_rd[c];
(*rd_res)[c+record_offset].expiration_time = latest_expiration;
(*rd_res)[c+record_offset].data = (void *) &data[data_offset];
- // WTF?
GNUNET_memcpy ((void *) (*rd_res)[c+record_offset].data,
nick_rd[c].data,
nick_rd[c].data_size);
if ((NULL != nick) && (0 != strcmp(name, GNUNET_GNS_MASTERZONE_STR)))
{
nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
- merge_with_nick_records (nick, rd_count, rd, &res_count, &res);
- //fprintf (stderr, "Merging %u records for `%s' with NICK records\n",rd_count, name);
+ merge_with_nick_records (nick,
+ rd_count,
+ rd,
+ &res_count,
+ &res);
GNUNET_free (nick);
}
else
{
res_count = rd_count;
res = (struct GNUNET_GNSRECORD_Data *) rd;
- //fprintf (stderr, "Not merging %u records for `%s' with NICK records\n",rd_count, name);
}
name_len = strlen (name) + 1;
rd_ser = &name_tmp[name_len];
GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message with %u records and size %zu\n",
- "RECORD_RESULT",
+ "Sending RECORD_RESULT message with %u records and size %zu\n",
res_count,
msg_size);
GNUNET_SERVER_notification_context_unicast (nc,
rlc->found = GNUNET_YES;
if (0 != rd_count)
{
- if ((NULL != rlc->nick) && (0 != strcmp(label, GNUNET_GNS_MASTERZONE_STR)))
+ if ( (NULL != rlc->nick) &&
+ (0 != strcmp (label,
+ GNUNET_GNS_MASTERZONE_STR)) )
{
/* Merge */
rd_res = NULL;
rd_count, rd,
&rdc_res, &rd_res);
- rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, rd_res);
+ rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res,
+ rd_res);
rlc->res_rd_count = rdc_res;
rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
- GNUNET_GNSRECORD_records_serialize (rdc_res, rd_res, rlc->rd_ser_len , rlc->res_rd);
+ GNUNET_GNSRECORD_records_serialize (rdc_res,
+ rd_res,
+ rlc->rd_ser_len,
+ rlc->res_rd);
GNUNET_free (rd_res);
GNUNET_free (rlc->nick);
}
else
{
- rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
+ rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count,
+ rd);
rlc->res_rd_count = rd_count;
rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
- GNUNET_GNSRECORD_records_serialize (rd_count, rd, rlc->rd_ser_len , rlc->res_rd);
+ GNUNET_GNSRECORD_records_serialize (rd_count,
+ rd,
+ rlc->rd_ser_len,
+ rlc->res_rd);
}
}
else
client,
&llr_msg->gns_header.header,
GNUNET_NO);
-
GNUNET_free_non_null (rlc.res_rd);
GNUNET_free (llr_msg);
}
{
/* create indices */
if ( (SQLITE_OK !=
- sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns097records (zone_private_key,pkey)",
+ sqlite3_exec (dbh,
+ "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns097records (zone_private_key,pkey)",
NULL, NULL, NULL)) ||
(SQLITE_OK !=
- sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns097records (zone_private_key,rvalue)",
+ sqlite3_exec (dbh,
+ "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns097records (zone_private_key,rvalue)",
NULL, NULL, NULL)) ||
(SQLITE_OK !=
- sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS it_iter ON ns097records (rvalue)",
+ sqlite3_exec (dbh,
+ "CREATE INDEX IF NOT EXISTS it_iter ON ns097records (rvalue)",
NULL, NULL, NULL)) )
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create indices: %s\n", sqlite3_errmsg (dbh));
+ "Failed to create indices: %s\n",
+ sqlite3_errmsg (dbh));
}
#endif
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, "namestore-sqlite",
- "FILENAME", &afsdir))
+ GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
+ "namestore-sqlite",
+ "FILENAME",
+ &afsdir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "namestore-sqlite", "FILENAME");
+ "namestore-sqlite",
+ "FILENAME");
return GNUNET_SYSERR;
}
- if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
+ 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);
return GNUNET_SYSERR;
}
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA temp_store=MEMORY", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA synchronous=NORMAL", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA synchronous=NORMAL", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA legacy_file_format=OFF", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA legacy_file_format=OFF", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL", NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA auto_vacuum=INCREMENTAL", NULL,
NULL, ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA encoding=\"UTF-8\"", NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA encoding=\"UTF-8\"", NULL,
NULL, ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL,
ENULL));
CHECK (SQLITE_OK ==
- sqlite3_exec (plugin->dbh, "PRAGMA page_size=4092", NULL, NULL,
+ sqlite3_exec (plugin->dbh,
+ "PRAGMA page_size=4092", NULL, NULL,
ENULL));
- CHECK (SQLITE_OK == sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS));
+ CHECK (SQLITE_OK ==
+ sqlite3_busy_timeout (plugin->dbh,
+ BUSY_TIMEOUT_MS));
/* Create table */
")",
NULL, NULL, NULL) != SQLITE_OK))
{
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
+ LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR,
+ "sqlite3_exec");
sqlite3_finalize (stmt);
return GNUNET_SYSERR;
}
for (i=0;i<rd_count;i++)
if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type)
{
- GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == rd[i].data_size);
+ GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) ==
+ rd[i].data_size);
GNUNET_memcpy (&pkey,
- rd[i].data,
- rd[i].data_size);
+ rd[i].data,
+ rd[i].data_size);
break;
}
- rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
- data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
+ rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX);
+ data_size = GNUNET_GNSRECORD_records_get_size (rd_count,
+ rd);
if (data_size > 64 * 65536)
{
GNUNET_break (0);
{
char data[data_size];
- if (data_size != GNUNET_GNSRECORD_records_serialize (rd_count, rd,
- data_size, data))
+ if (data_size !=
+ GNUNET_GNSRECORD_records_serialize (rd_count,
+ rd,
+ data_size,
+ data))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
/* First delete 'old' records */
- if ((SQLITE_OK != sqlite3_bind_blob (plugin->delete_records, 1,
- zone_key, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_text (plugin->delete_records, 2, label, -1, SQLITE_STATIC)))
+ if ((SQLITE_OK !=
+ sqlite3_bind_blob (plugin->delete_records,
+ 1,
+ zone_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
+ SQLITE_STATIC)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_text (plugin->delete_records,
+ 2,
+ label,
+ -1,
+ SQLITE_STATIC)))
{
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
if (0 != rd_count)
{
- if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1,
- zone_key, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2,
- &pkey, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) ||
- (SQLITE_OK != sqlite3_bind_int (plugin->store_records, 4, rd_count)) ||
- (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_text (plugin->store_records, 6, label, -1, SQLITE_STATIC)))
+ if ((SQLITE_OK !=
+ sqlite3_bind_blob (plugin->store_records,
+ 1,
+ zone_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
+ SQLITE_STATIC)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_blob (plugin->store_records,
+ 2,
+ &pkey,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
+ SQLITE_STATIC)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_int64 (plugin->store_records, 3, rvalue)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_int (plugin->store_records, 4, rd_count)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_blob (plugin->store_records, 5,
+ data, data_size,
+ SQLITE_STATIC)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_text (plugin->store_records, 6,
+ label, -1,
+ SQLITE_STATIC)))
{
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
struct tm tv;
time_t t;
- if (0 == strcasecmp ("end of time", fancy_time))
+ if (0 == strcasecmp ("end of time",
+ fancy_time))
{
*atime = GNUNET_TIME_UNIT_FOREVER_ABS;
return GNUNET_OK;
&v4,
&v6))
{
+ GNUNET_break (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
return;
/* failure, we're done */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to allocate IP address for new destination\n"));
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_SERVER_receive_done (client,
+ GNUNET_OK);
return;
}