aboutsummaryrefslogtreecommitdiff
path: root/src/identity/gnunet-identity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/gnunet-identity.c')
-rw-r--r--src/identity/gnunet-identity.c86
1 files changed, 9 insertions, 77 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index 97dc2ce7e..6f09113d8 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -106,11 +106,6 @@ static char *pubkey_msg;
106static char *set_ego; 106static char *set_ego;
107 107
108/** 108/**
109 * -S option.
110 */
111static char *set_subsystem;
112
113/**
114 * Operation handle for set operation. 109 * Operation handle for set operation.
115 */ 110 */
116static struct GNUNET_IDENTITY_Operation *set_op; 111static struct GNUNET_IDENTITY_Operation *set_op;
@@ -178,7 +173,6 @@ test_finished (void)
178 if ( (NULL == create_op) && 173 if ( (NULL == create_op) &&
179 (NULL == delete_op) && 174 (NULL == delete_op) &&
180 (NULL == set_op) && 175 (NULL == set_op) &&
181 (NULL == set_subsystem) &&
182 (NULL == write_msg) && 176 (NULL == write_msg) &&
183 (NULL == read_msg) && 177 (NULL == read_msg) &&
184 (! list) && 178 (! list) &&
@@ -195,17 +189,17 @@ test_finished (void)
195 * Deletion operation finished. 189 * Deletion operation finished.
196 * 190 *
197 * @param cls pointer to operation handle 191 * @param cls pointer to operation handle
198 * @param emsg NULL on success, otherwise an error message 192 * @param ec the error code
199 */ 193 */
200static void 194static void
201delete_finished (void *cls, 195delete_finished (void *cls,
202 const char *emsg) 196 enum GNUNET_ErrorCode ec)
203{ 197{
204 struct GNUNET_IDENTITY_Operation **op = cls; 198 struct GNUNET_IDENTITY_Operation **op = cls;
205 199
206 *op = NULL; 200 *op = NULL;
207 if (NULL != emsg) 201 if (GNUNET_EC_NONE != ec)
208 fprintf (stderr, "%s\n", gettext (emsg)); 202 fprintf (stderr, "%s\n", GNUNET_ErrorCode_get_hint (ec));
209 test_finished (); 203 test_finished ();
210} 204}
211 205
@@ -215,12 +209,12 @@ delete_finished (void *cls,
215 * 209 *
216 * @param cls pointer to operation handle 210 * @param cls pointer to operation handle
217 * @param pk private key of the ego, or NULL on error 211 * @param pk private key of the ego, or NULL on error
218 * @param emsg error message, NULL on success 212 * @param ec the error code
219 */ 213 */
220static void 214static void
221create_finished (void *cls, 215create_finished (void *cls,
222 const struct GNUNET_IDENTITY_PrivateKey *pk, 216 const struct GNUNET_IDENTITY_PrivateKey *pk,
223 const char *emsg) 217 enum GNUNET_ErrorCode ec)
224{ 218{
225 struct GNUNET_IDENTITY_Operation **op = cls; 219 struct GNUNET_IDENTITY_Operation **op = cls;
226 220
@@ -229,7 +223,7 @@ create_finished (void *cls,
229 { 223 {
230 fprintf (stderr, 224 fprintf (stderr,
231 _ ("Failed to create ego: %s\n"), 225 _ ("Failed to create ego: %s\n"),
232 emsg); 226 GNUNET_ErrorCode_get_hint (ec));
233 global_ret = 1; 227 global_ret = 1;
234 } 228 }
235 else if (verbose) 229 else if (verbose)
@@ -258,25 +252,6 @@ create_finished (void *cls,
258 252
259 253
260/** 254/**
261 * Function called by #GNUNET_IDENTITY_set up on completion.
262 *
263 * @param cls NULL
264 * @param emsg error message (NULL on success)
265 */
266static void
267set_done (void *cls, const char *emsg)
268{
269 set_op = NULL;
270 if (NULL != emsg)
271 {
272 fprintf (stderr, _ ("Failed to set default ego: %s\n"), emsg);
273 global_ret = 1;
274 }
275 test_finished ();
276}
277
278
279/**
280 * Encrypt a message given with -W, encrypted using public key of 255 * Encrypt a message given with -W, encrypted using public key of
281 * an identity given with -k. 256 * an identity given with -k.
282 */ 257 */
@@ -447,35 +422,6 @@ print_ego (void *cls,
447 char *s; 422 char *s;
448 char *privs; 423 char *privs;
449 424
450 if ( (NULL != set_ego) &&
451 (NULL != set_subsystem) &&
452 (NULL != ego) &&
453 (NULL != identifier) &&
454 (0 == strcmp (identifier, set_ego)))
455 {
456 set_op = GNUNET_IDENTITY_set (sh,
457 set_subsystem,
458 ego,
459 &set_done,
460 NULL);
461 GNUNET_free (set_subsystem);
462 set_subsystem = NULL;
463 GNUNET_free (set_ego);
464 set_ego = NULL;
465 }
466 if ( (NULL == ego) &&
467 (NULL != set_ego) &&
468 (NULL != set_subsystem) )
469 {
470 fprintf (stderr,
471 "Could not set ego to `%s' for subsystem `%s', ego not known\n",
472 set_ego,
473 set_subsystem);
474 GNUNET_free (set_subsystem);
475 set_subsystem = NULL;
476 GNUNET_free (set_ego);
477 set_ego = NULL;
478 }
479 if ( (NULL == ego) && 425 if ( (NULL == ego) &&
480 (NULL != set_ego) && 426 (NULL != set_ego) &&
481 (NULL != read_msg) ) 427 (NULL != read_msg) )
@@ -557,12 +503,6 @@ run (void *cls,
557 const char *cfgfile, 503 const char *cfgfile,
558 const struct GNUNET_CONFIGURATION_Handle *cfg) 504 const struct GNUNET_CONFIGURATION_Handle *cfg)
559{ 505{
560 if ((NULL != set_subsystem) && (NULL == set_ego))
561 {
562 fprintf (stderr, "Option -s requires option -e to be specified as well.\n");
563 return;
564 }
565
566 if ((NULL != read_msg) && (NULL == set_ego)) 506 if ((NULL != read_msg) && (NULL == set_ego))
567 { 507 {
568 fprintf (stderr, 508 fprintf (stderr,
@@ -577,8 +517,7 @@ run (void *cls,
577 } 517 }
578 sh = GNUNET_IDENTITY_connect (cfg, 518 sh = GNUNET_IDENTITY_connect (cfg,
579 (monitor | list) || 519 (monitor | list) ||
580 (NULL != set_ego) || 520 (NULL != set_ego)
581 (NULL != set_subsystem)
582 ? &print_ego 521 ? &print_ego
583 : NULL, 522 : NULL,
584 NULL); 523 NULL);
@@ -686,7 +625,7 @@ main (int argc, char *const *argv)
686 "ego", 625 "ego",
687 "NAME", 626 "NAME",
688 gettext_noop ( 627 gettext_noop (
689 "set default identity to NAME for a subsystem SUBSYSTEM (use together with -s), restrict results to NAME (use together with -d) or read and decrypt a message for NAME (use together with -R)"), 628 "restrict results to NAME (use together with -d) or read and decrypt a message for NAME (use together with -R)"),
690 &set_ego), 629 &set_ego),
691 GNUNET_GETOPT_option_string ('k', 630 GNUNET_GETOPT_option_string ('k',
692 "key", 631 "key",
@@ -702,13 +641,6 @@ main (int argc, char *const *argv)
702 "private-keys", 641 "private-keys",
703 gettext_noop ("display private keys as well"), 642 gettext_noop ("display private keys as well"),
704 &private_keys), 643 &private_keys),
705 GNUNET_GETOPT_option_string (
706 's',
707 "set",
708 "SUBSYSTEM",
709 gettext_noop (
710 "set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
711 &set_subsystem),
712 GNUNET_GETOPT_option_verbose (&verbose), 644 GNUNET_GETOPT_option_verbose (&verbose),
713 GNUNET_GETOPT_OPTION_END 645 GNUNET_GETOPT_OPTION_END
714 }; 646 };