aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-23 15:58:23 +0000
committerChristian Grothoff <christian@grothoff.org>2016-10-23 15:58:23 +0000
commit3ecbb9b47c2f8c1ed5e9dbed4803999420dbd6ac (patch)
treef6266a7b908593cb99992fb6da539f7f6e6c8220 /src/namestore/gnunet-namestore.c
parent1358762d69a894017d1be7d3d55367e492deb111 (diff)
downloadgnunet-3ecbb9b47c2f8c1ed5e9dbed4803999420dbd6ac.tar.gz
gnunet-3ecbb9b47c2f8c1ed5e9dbed4803999420dbd6ac.zip
simplify gnunet-namestore / namestore_rest_plugin to avoid deprecated CLIENT_service_test
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r--src/namestore/gnunet-namestore.c117
1 files changed, 36 insertions, 81 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 8f0c14fa0..457e77022 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -753,27 +753,37 @@ del_monitor (void *cls,
753 753
754 754
755/** 755/**
756 * Function called with the result from the check if the namestore 756 * Callback invoked from identity service with ego information.
757 * service is actually running. If it is, we start the actual 757 * An @a ego of NULL means the ego was not found.
758 * operation.
759 * 758 *
760 * @param cls closure with our configuration 759 * @param cls closure with the configuration
761 * @param result #GNUNET_YES if the namestore service is running 760 * @param ego an ego known to identity service, or NULL
762 */ 761 */
763static void 762static void
764testservice_task (void *cls, 763identity_cb (void *cls,
765 int result) 764 const struct GNUNET_IDENTITY_Ego *ego)
766{ 765{
767 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 766 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
768 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 767 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
769 struct GNUNET_GNSRECORD_Data rd; 768 struct GNUNET_GNSRECORD_Data rd;
770 769
771 if (GNUNET_YES != result) 770 el = NULL;
771 if (NULL == ego)
772 { 772 {
773 FPRINTF (stderr, _("Service `%s' is not running\n"), 773 if (NULL != ego_name)
774 "namestore"); 774 {
775 fprintf (stderr,
776 _("Ego `%s' not known to identity service\n"),
777 ego_name);
778 }
779 GNUNET_SCHEDULER_shutdown ();
780 ret = -1;
775 return; 781 return;
776 } 782 }
783 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
784 GNUNET_free_non_null (ego_name);
785 ego_name = NULL;
786
777 if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) ) 787 if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) )
778 { 788 {
779 /* nothing more to be done */ 789 /* nothing more to be done */
@@ -1028,42 +1038,6 @@ testservice_task (void *cls,
1028} 1038}
1029 1039
1030 1040
1031/**
1032 * Callback invoked from identity service with ego information.
1033 * An @a ego of NULL means the ego was not found.
1034 *
1035 * @param cls closure with the configuration
1036 * @param ego an ego known to identity service, or NULL
1037 */
1038static void
1039identity_cb (void *cls,
1040 const struct GNUNET_IDENTITY_Ego *ego)
1041{
1042 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1043
1044 el = NULL;
1045 if (NULL == ego)
1046 {
1047 if (NULL != ego_name)
1048 {
1049 fprintf (stderr,
1050 _("Ego `%s' not known to identity service\n"),
1051 ego_name);
1052 }
1053 GNUNET_SCHEDULER_shutdown ();
1054 ret = -1;
1055 return;
1056 }
1057 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
1058 GNUNET_free_non_null (ego_name);
1059 ego_name = NULL;
1060 GNUNET_CLIENT_service_test ("namestore", cfg,
1061 GNUNET_TIME_UNIT_SECONDS,
1062 &testservice_task,
1063 (void *) cfg);
1064}
1065
1066
1067static void 1041static void
1068default_ego_cb (void *cls, 1042default_ego_cb (void *cls,
1069 struct GNUNET_IDENTITY_Ego *ego, 1043 struct GNUNET_IDENTITY_Ego *ego,
@@ -1104,19 +1078,23 @@ id_connect_cb (void *cls,
1104} 1078}
1105 1079
1106 1080
1081/**
1082 * Main function that will be run.
1083 *
1084 * @param cls closure
1085 * @param args remaining command-line arguments
1086 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
1087 * @param cfg configuration
1088 */
1107static void 1089static void
1108testservice_id_task (void *cls, int result) 1090run (void *cls,
1091 char *const *args,
1092 const char *cfgfile,
1093 const struct GNUNET_CONFIGURATION_Handle *cfg)
1109{ 1094{
1110 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 1095 if ( (NULL != args[0]) && (NULL == uri) )
1096 uri = GNUNET_strdup (args[0]);
1111 1097
1112 if (result != GNUNET_YES)
1113 {
1114 fprintf (stderr,
1115 _("Identity service is not running\n"));
1116 GNUNET_SCHEDULER_shutdown ();
1117 ret = -1;
1118 return;
1119 }
1120 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 1098 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
1121 (void *) cfg); 1099 (void *) cfg);
1122 1100
@@ -1126,7 +1104,8 @@ testservice_id_task (void *cls, int result)
1126 &id_connect_cb, 1104 &id_connect_cb,
1127 (void *) cfg); 1105 (void *) cfg);
1128 if (NULL == idh) 1106 if (NULL == idh)
1129 fprintf (stderr, _("Cannot connect to identity service\n")); 1107 fprintf (stderr,
1108 _("Cannot connect to identity service\n"));
1130 ret = -1; 1109 ret = -1;
1131 return; 1110 return;
1132 } 1111 }
@@ -1138,30 +1117,6 @@ testservice_id_task (void *cls, int result)
1138 1117
1139 1118
1140/** 1119/**
1141 * Main function that will be run.
1142 *
1143 * @param cls closure
1144 * @param args remaining command-line arguments
1145 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
1146 * @param cfg configuration
1147 */
1148static void
1149run (void *cls,
1150 char *const *args,
1151 const char *cfgfile,
1152 const struct GNUNET_CONFIGURATION_Handle *cfg)
1153{
1154 if ( (NULL != args[0]) && (NULL == uri) )
1155 uri = GNUNET_strdup (args[0]);
1156
1157 GNUNET_CLIENT_service_test ("identity", cfg,
1158 GNUNET_TIME_UNIT_SECONDS,
1159 &testservice_id_task,
1160 (void *) cfg);
1161}
1162
1163
1164/**
1165 * The main function for gnunet-namestore. 1120 * The main function for gnunet-namestore.
1166 * 1121 *
1167 * @param argc number of arguments from the command line 1122 * @param argc number of arguments from the command line