diff options
Diffstat (limited to 'src/rps/gnunet-rps.c')
-rw-r--r-- | src/rps/gnunet-rps.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c index 8de588568..b3785a733 100644 --- a/src/rps/gnunet-rps.c +++ b/src/rps/gnunet-rps.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) | 3 | Copyright (C) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -152,12 +150,21 @@ run (void *cls, | |||
152 | static struct GNUNET_PeerIdentity zero_pid; | 150 | static struct GNUNET_PeerIdentity zero_pid; |
153 | 151 | ||
154 | rps_handle = GNUNET_RPS_connect (cfg); | 152 | rps_handle = GNUNET_RPS_connect (cfg); |
153 | if (NULL == rps_handle) | ||
154 | { | ||
155 | FPRINTF (stderr, "Failed to connect to the rps service\n"); | ||
156 | return; | ||
157 | } | ||
155 | 158 | ||
156 | if ((0 == memcmp (&zero_pid, &peer_id, sizeof (peer_id))) && | 159 | if ((0 == memcmp (&zero_pid, &peer_id, sizeof (peer_id))) && |
157 | (!view_update)) | 160 | (!view_update)) |
158 | { /* Request n PeerIDs */ | 161 | { /* Request n PeerIDs */ |
159 | /* If number was specified use it, else request single peer. */ | 162 | /* If number was specified use it, else request single peer. */ |
160 | num_peers = (NULL == args[0]) ? 1 : atoi (args[0]); | 163 | if (NULL == args[0] || |
164 | 0 == sscanf (args[0], "%lu", &num_peers)) | ||
165 | { | ||
166 | num_peers = 1; | ||
167 | } | ||
161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
162 | "Requesting %" PRIu64 " PeerIDs\n", num_peers); | 169 | "Requesting %" PRIu64 " PeerIDs\n", num_peers); |
163 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); | 170 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); |
@@ -165,7 +172,11 @@ run (void *cls, | |||
165 | } else if (view_update) | 172 | } else if (view_update) |
166 | { | 173 | { |
167 | /* Get updates of view */ | 174 | /* Get updates of view */ |
168 | num_view_updates = (NULL == args[0]) ? 0 : atoi (args[0]); | 175 | if (NULL == args[0] || |
176 | 0 == sscanf (args[0], "%lu", &num_view_updates)) | ||
177 | { | ||
178 | num_view_updates = 0; | ||
179 | } | ||
169 | GNUNET_RPS_view_request (rps_handle, num_view_updates, view_update_handle, NULL); | 180 | GNUNET_RPS_view_request (rps_handle, num_view_updates, view_update_handle, NULL); |
170 | if (0 != num_view_updates) | 181 | if (0 != num_view_updates) |
171 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |