#include <gnunet_dnsparser_lib.h>
#include <gnunet_identity_service.h>
#include <gnunet_gnsrecord_lib.h>
+#include <gnunet_gns_service.h>
#include <gnunet_namestore_service.h>
*/
static int add;
-/**
- * Iterator for the 'add' operation.
- */
-static struct GNUNET_NAMESTORE_ZoneIterator *add_zit;
-
/**
* Queue entry for the 'add-uri' operation.
*/
*/
static char *expirationstring;
+/**
+ * Desired nick name.
+ */
+static char *nickstring;
+
/**
* Global return value
*/
const char *emsg)
{
del_qe = NULL;
- if (success != GNUNET_YES)
+ if (GNUNET_NO == success)
+ {
+ fprintf (stderr,
+ _("Deleting record failed, record does not exist%s%s\n"),
+ (NULL != emsg) ? ": " : "",
+ (NULL != emsg) ? emsg : "");
+ }
+ if (GNUNET_SYSERR == success)
+ {
fprintf (stderr,
- _("Deleting record failed: %s\n"),
- emsg);
+ _("Deleting record failed%s%s\n"),
+ (NULL != emsg) ? ": " : "",
+ (NULL != emsg) ? emsg : "");
+ }
test_finished ();
}
ets = GNUNET_STRINGS_absolute_time_to_string (at);
}
FPRINTF (stdout,
- "\t%s: %s (%s)\n",
+ "\t%s: %s (%s)\t%s\t%s\t%s\n",
typestring,
s,
- ets);
+ ets,
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" : "PUBLIC",
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" : "",
+ (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) ? "PENDING" : "");
GNUNET_free (s);
}
FPRINTF (stdout, "%s", "\n");
struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
struct GNUNET_GNSRECORD_Data *rde;
+ add_qe = NULL;
if ( (NULL != zone_key) &&
(0 != strcmp (rec_name, name)) )
{
- GNUNET_NAMESTORE_zone_iterator_next (add_zit);
+ GNUNET_break (0);
return;
}
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u records for name `%s'\n",
+ rd_count, rec_name);
+
memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
memcpy (&rdn[1], rd, rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
/* FIXME: should add some logic to overwrite records if there
rde->data = data;
rde->data_size = data_size;
rde->record_type = type;
- if (1 != shadow)
+ if (1 == shadow)
rde->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
if (1 != public)
rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
rde,
&add_continuation,
&add_qe);
- /* only cancel if we were not told that this
- was the end of the iteration already */
- if (NULL != rec_name)
- GNUNET_NAMESTORE_zone_iteration_stop (add_zit);
- add_zit = NULL;
}
"namestore");
return;
}
- if (! (add|del|list|(NULL != uri)|(NULL != reverse_pkey)) )
+ if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) )
{
/* nothing more to be done */
fprintf (stderr,
ret = 1;
return;
}
- add_zit = GNUNET_NAMESTORE_zone_iteration_start (ns,
- &zone_pkey,
- &get_existing_record,
- NULL);
+ add_qe = GNUNET_NAMESTORE_records_lookup (ns, &zone_pkey, name,
+ &get_existing_record, NULL );
}
if (del)
{
rd.expiration_time = etime_abs.abs_value_us;
else
rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+
if (1 != shadow)
rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
add_qe_uri = GNUNET_NAMESTORE_records_store (ns,
&add_continuation,
&add_qe_uri);
}
+ if (NULL != nickstring)
+ {
+ if (0 == strlen(nickstring))
+ {
+ fprintf (stderr,
+ _("Invalid nick `%s'\n"),
+ nickstring);
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
+ add_qe_uri = GNUNET_NAMESTORE_set_nick(ns, &zone_pkey, nickstring,
+ &add_continuation, &add_qe_uri);
+ }
if (monitor)
{
zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
&zone_pkey,
+ GNUNET_YES,
&display_record,
&sync_cb,
NULL);
_("You must specify which zone should be accessed\n"));
return;
}
+
if ( (NULL != args[0]) && (NULL == uri) )
uri = GNUNET_strdup (args[0]);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
main (int argc, char *const *argv)
{
public = -1;
+ shadow = -1;
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "add", NULL,
{'e', "expiration", "TIME",
gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1,
&GNUNET_GETOPT_set_string, &expirationstring},
+ {'i', "nick", "NICKNAME",
+ gettext_noop ("set the desired nick name for the zone"), 1,
+ &GNUNET_GETOPT_set_string, &nickstring},
{'m', "monitor", NULL,
gettext_noop ("monitor changes in the namestore"), 0,
&GNUNET_GETOPT_set_one, &monitor},