* TODO:
* - allow users to set record options (not just 'RF_AUTHORITY')
* - test
- * - parsing SOA, PTR and MX value specifications (and define format!)
* - add options to list/lookup individual records
*/
#include "platform.h"
#include <gnunet_dnsparser_lib.h>
#include <gnunet_namestore_service.h>
+
/**
* Handle to the namestore.
*/
{
if (NULL != ns)
{
- GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
+ GNUNET_NAMESTORE_disconnect (ns);
ns = NULL;
}
if (NULL != zone_pkey)
uint32_t type;
void *data = NULL;
size_t data_size = 0;
- struct GNUNET_TIME_Relative etime;
+ struct GNUNET_TIME_Relative etime_rel;
+ struct GNUNET_TIME_Absolute etime_abs;
+ int etime_is_rel = GNUNET_SYSERR;
struct GNUNET_NAMESTORE_RecordData rd;
if (NULL == keyfile)
}
if (NULL != expirationstring)
{
- if (GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_relative (expirationstring,
- &etime))
+ if (0 == strcmp (expirationstring, "never"))
+ {
+ etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS;
+ etime_is_rel = GNUNET_NO;
+ }
+ else if (GNUNET_OK ==
+ GNUNET_STRINGS_fancy_time_to_relative (expirationstring,
+ &etime_rel))
+ {
+ etime_is_rel = GNUNET_YES;
+ }
+ else if (GNUNET_OK ==
+ GNUNET_STRINGS_fancy_time_to_absolute (expirationstring,
+ &etime_abs))
+ {
+ etime_is_rel = GNUNET_NO;
+ }
+ else
{
fprintf (stderr,
_("Invalid time format `%s'\n"),
GNUNET_SCHEDULER_shutdown ();
return;
}
- } else if (add)
+ }
+ else if (add)
{
fprintf (stderr,
_("Missing option `%s' for operation `%s'\n"),
rd.data = data;
rd.data_size = data_size;
rd.record_type = type;
- rd.expiration = GNUNET_TIME_relative_to_absolute (etime);
+ if (GNUNET_YES == etime_is_rel)
+ {
+ rd.expiration_time = etime_rel.rel_value;
+ rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+ }
+ else if (GNUNET_NO == etime_is_rel)
+ rd.expiration_time = etime_abs.abs_value;
+ else
+ {
+ fprintf (stderr,
+ _("No valid expiration time for operation `%s'\n"),
+ _("add"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
if (1 != nonauthority)
rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
if (1 != public)
rd.data = data;
rd.data_size = data_size;
rd.record_type = type;
- rd.expiration.abs_value = 0;
+ rd.expiration_time = 0;
rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
del_qe = GNUNET_NAMESTORE_record_remove (ns,
zone_pkey,
gettext_noop ("display records"), 0,
&GNUNET_GETOPT_set_one, &list},
{'e', "expiration", "TIME",
- gettext_noop ("expiration time for record to use (for adding only)"), 1,
+ gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1,
&GNUNET_GETOPT_set_string, &expirationstring},
{'n', "name", "NAME",
gettext_noop ("name of the record to add/delete/display"), 1,
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
ret =
(GNUNET_OK ==