/**
- * Function called with the result from the check if the namestore
- * service is actually running. If it is, we start the actual
- * operation.
+ * Callback invoked from identity service with ego information.
+ * An @a ego of NULL means the ego was not found.
*
- * @param cls closure with our configuration
- * @param result #GNUNET_YES if the namestore service is running
+ * @param cls closure with the configuration
+ * @param ego an ego known to identity service, or NULL
*/
static void
-testservice_task (void *cls,
- int result)
+identity_cb (void *cls,
+ const struct GNUNET_IDENTITY_Ego *ego)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct GNUNET_CRYPTO_EcdsaPublicKey pub;
struct GNUNET_GNSRECORD_Data rd;
- if (GNUNET_YES != result)
+ el = NULL;
+ if (NULL == ego)
{
- FPRINTF (stderr, _("Service `%s' is not running\n"),
- "namestore");
+ if (NULL != ego_name)
+ {
+ fprintf (stderr,
+ _("Ego `%s' not known to identity service\n"),
+ ego_name);
+ }
+ GNUNET_SCHEDULER_shutdown ();
+ ret = -1;
return;
}
+ zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
+ GNUNET_free_non_null (ego_name);
+ ego_name = NULL;
+
if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) )
{
/* nothing more to be done */
}
-/**
- * Callback invoked from identity service with ego information.
- * An @a ego of NULL means the ego was not found.
- *
- * @param cls closure with the configuration
- * @param ego an ego known to identity service, or NULL
- */
-static void
-identity_cb (void *cls,
- const struct GNUNET_IDENTITY_Ego *ego)
-{
- const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-
- el = NULL;
- if (NULL == ego)
- {
- if (NULL != ego_name)
- {
- fprintf (stderr,
- _("Ego `%s' not known to identity service\n"),
- ego_name);
- }
- GNUNET_SCHEDULER_shutdown ();
- ret = -1;
- return;
- }
- zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
- GNUNET_free_non_null (ego_name);
- ego_name = NULL;
- GNUNET_CLIENT_service_test ("namestore", cfg,
- GNUNET_TIME_UNIT_SECONDS,
- &testservice_task,
- (void *) cfg);
-}
-
-
static void
default_ego_cb (void *cls,
struct GNUNET_IDENTITY_Ego *ego,
}
+/**
+ * Main function that will be run.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param cfg configuration
+ */
static void
-testservice_id_task (void *cls, int result)
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ if ( (NULL != args[0]) && (NULL == uri) )
+ uri = GNUNET_strdup (args[0]);
- if (result != GNUNET_YES)
- {
- fprintf (stderr,
- _("Identity service is not running\n"));
- GNUNET_SCHEDULER_shutdown ();
- ret = -1;
- return;
- }
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
(void *) cfg);
&id_connect_cb,
(void *) cfg);
if (NULL == idh)
- fprintf (stderr, _("Cannot connect to identity service\n"));
+ fprintf (stderr,
+ _("Cannot connect to identity service\n"));
ret = -1;
return;
}
}
-/**
- * Main function that will be run.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg configuration
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- if ( (NULL != args[0]) && (NULL == uri) )
- uri = GNUNET_strdup (args[0]);
-
- GNUNET_CLIENT_service_test ("identity", cfg,
- GNUNET_TIME_UNIT_SECONDS,
- &testservice_id_task,
- (void *) cfg);
-}
-
-
/**
* The main function for gnunet-namestore.
*
is_public = -1;
is_shadow = -1;
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "add", NULL,
- gettext_noop ("add record"), 0,
- &GNUNET_GETOPT_set_one, &add},
- {'d', "delete", NULL,
- gettext_noop ("delete record"), 0,
- &GNUNET_GETOPT_set_one, &del},
- {'D', "display", NULL,
- gettext_noop ("display records"), 0,
- &GNUNET_GETOPT_set_one, &list},
- {'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},
- {'n', "name", "NAME",
- gettext_noop ("name of the record to add/delete/display"), 1,
- &GNUNET_GETOPT_set_string, &name},
- {'r', "reverse", "PKEY",
- gettext_noop ("determine our name for the given PKEY"), 1,
- &GNUNET_GETOPT_set_string, &reverse_pkey},
- {'t', "type", "TYPE",
- gettext_noop ("type of the record to add/delete/display"), 1,
- &GNUNET_GETOPT_set_string, &typestring},
- {'u', "uri", "URI",
- gettext_noop ("URI to import into our zone"), 1,
- &GNUNET_GETOPT_set_string, &uri},
- {'V', "value", "VALUE",
- gettext_noop ("value of the record to add/delete"), 1,
- &GNUNET_GETOPT_set_string, &value},
- {'p', "public", NULL,
- gettext_noop ("create or list public record"), 0,
- &GNUNET_GETOPT_set_one, &is_public},
- {'s', "shadow", NULL,
- gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), 0,
- &GNUNET_GETOPT_set_one, &is_shadow},
- {'z', "zone", "EGO",
- gettext_noop ("name of the ego controlling the zone"), 1,
- &GNUNET_GETOPT_set_string, &ego_name},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_option_flag ('a',
+ "add",
+ gettext_noop ("add record"),
+ &add),
+
+ GNUNET_GETOPT_option_flag ('d',
+ "delete",
+ gettext_noop ("delete record"),
+ &del),
+
+ GNUNET_GETOPT_option_flag ('D',
+ "display",
+ gettext_noop ("display records"),
+ &list),
+
+ GNUNET_GETOPT_option_string ('e',
+ "expiration",
+ "TIME",
+ gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"),
+ &expirationstring),
+
+ GNUNET_GETOPT_option_string ('i',
+ "nick",
+ "NICKNAME",
+ gettext_noop ("set the desired nick name for the zone"),
+ &nickstring),
+
+ GNUNET_GETOPT_option_flag ('m',
+ "monitor",
+ gettext_noop ("monitor changes in the namestore"),
+ &monitor),
+
+ GNUNET_GETOPT_option_string ('n',
+ "name",
+ "NAME",
+ gettext_noop ("name of the record to add/delete/display"),
+ &name),
+
+ GNUNET_GETOPT_option_string ('r',
+ "reverse",
+ "PKEY",
+ gettext_noop ("determine our name for the given PKEY"),
+ &reverse_pkey),
+
+
+
+ GNUNET_GETOPT_option_string ('t',
+ "type",
+ "TYPE",
+ gettext_noop ("type of the record to add/delete/display"),
+ &typestring),
+
+ GNUNET_GETOPT_option_string ('u',
+ "uri",
+ "URI",
+ gettext_noop ("URI to import into our zone"),
+ &uri),
+
+ GNUNET_GETOPT_option_string ('V',
+ "value",
+ "VALUE",
+ gettext_noop ("value of the record to add/delete"),
+ &value),
+
+ GNUNET_GETOPT_option_flag ('p',
+ "public",
+ gettext_noop ("create or list public record"),
+ &is_public),
+
+ GNUNET_GETOPT_option_flag ('s',
+ "shadow",
+ gettext_noop ("create shadow record (only valid if all other records of the same type have expired"),
+ &is_shadow),
+
+ GNUNET_GETOPT_option_string ('z',
+ "zone",
+ "EGO",
+ gettext_noop ("name of the ego controlling the zone"),
+ &ego_name),
+
GNUNET_GETOPT_OPTION_END
};