aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/gnunet-scalarproduct.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-23 13:43:02 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-23 13:43:02 +0000
commit5a0e57891c7f33f03bb25a3ab6b83d0f0b26a05e (patch)
treefe9e0c8c1ffbe9867b0c03839df6c1fab288e292 /src/scalarproduct/gnunet-scalarproduct.c
parent33b89b07e0ea833955f64d07b7e54e64aab500e9 (diff)
downloadgnunet-5a0e57891c7f33f03bb25a3ab6b83d0f0b26a05e.tar.gz
gnunet-5a0e57891c7f33f03bb25a3ab6b83d0f0b26a05e.zip
-more vector -> scalar renaming
Diffstat (limited to 'src/scalarproduct/gnunet-scalarproduct.c')
-rw-r--r--src/scalarproduct/gnunet-scalarproduct.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c
index 449085593..16c0e173a 100644
--- a/src/scalarproduct/gnunet-scalarproduct.c
+++ b/src/scalarproduct/gnunet-scalarproduct.c
@@ -19,8 +19,8 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file vectorproduct/gnunet-vectorproduct.c 22 * @file scalarproduct/gnunet-scalarproduct.c
23 * @brief vectorproduct client 23 * @brief scalarproduct client
24 * @author Christian M. Fuchs 24 * @author Christian M. Fuchs
25 */ 25 */
26#define GCRYPT_NO_DEPRECATED 26#define GCRYPT_NO_DEPRECATED
@@ -29,10 +29,10 @@
29 29
30#include "platform.h" 30#include "platform.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_vectorproduct_service.h" 32#include "gnunet_scalarproduct_service.h"
33#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
34 34
35#define LOG(kind,...) GNUNET_log_from (kind, "gnunet-vectorproduct",__VA_ARGS__) 35#define LOG(kind,...) GNUNET_log_from (kind, "gnunet-scalarproduct",__VA_ARGS__)
36/** 36/**
37 * Option -p: destination peer identity for checking message-ids with 37 * Option -p: destination peer identity for checking message-ids with
38 */ 38 */
@@ -44,12 +44,12 @@ static char *input_peer_id = NULL;
44static char *input_key = NULL; 44static char *input_key = NULL;
45 45
46/** 46/**
47 * Option -e: vector to calculate a vectorproduct with 47 * Option -e: vector to calculate a scalarproduct with
48 */ 48 */
49static char *input_elements = NULL; 49static char *input_elements = NULL;
50 50
51/** 51/**
52 * Option -m: message-ids to calculate a vectorproduct with 52 * Option -m: message-ids to calculate a scalarproduct with
53 */ 53 */
54static char *input_mask = NULL; 54static char *input_mask = NULL;
55 55
@@ -89,21 +89,21 @@ struct GNUNET_PeerIdentity peer;
89struct GNUNET_HashCode key; 89struct GNUNET_HashCode key;
90 90
91/** 91/**
92 * Pointer to the GNUNET_VECTORPRODUCT_Handle 92 * Pointer to the GNUNET_SCALARPRODUCT_Handle
93 */ 93 */
94struct GNUNET_VECTORPRODUCT_Handle *handle; 94struct GNUNET_SCALARPRODUCT_Handle *handle;
95 95
96/** 96/**
97 * Global return value 97 * Global return value
98 */ 98 */
99static int ret; 99static int ret;
100 100
101struct GNUNET_VECTORPRODUCT_TestCls 101struct GNUNET_SCALARPRODUCT_TestCls
102{ 102{
103 struct GNUNET_VECTORPRODUCT_Handle * h; 103 struct GNUNET_SCALARPRODUCT_Handle * h;
104}; 104};
105 105
106struct GNUNET_VECTORPRODUCT_TestCls test_cls; 106struct GNUNET_SCALARPRODUCT_TestCls test_cls;
107 107
108 108
109/** 109/**
@@ -115,32 +115,32 @@ struct GNUNET_VECTORPRODUCT_TestCls test_cls;
115static void 115static void
116responder_callback (void *cls, 116responder_callback (void *cls,
117 const struct GNUNET_HashCode * key, 117 const struct GNUNET_HashCode * key,
118 enum GNUNET_VECTORPRODUCT_ResponseStatus status) 118 enum GNUNET_SCALARPRODUCT_ResponseStatus status)
119{ 119{
120 ret = -1; 120 ret = -1;
121 121
122 switch (status) 122 switch (status)
123 { 123 {
124 case GNUNET_VECTORPRODUCT_Status_Success: 124 case GNUNET_SCALARPRODUCT_Status_Success:
125 ret = 0; 125 ret = 0;
126 LOG (GNUNET_ERROR_TYPE_INFO, "Session %s concluded.\n", GNUNET_h2s (key)); 126 LOG (GNUNET_ERROR_TYPE_INFO, "Session %s concluded.\n", GNUNET_h2s (key));
127 break; 127 break;
128 case GNUNET_VECTORPRODUCT_Status_InvalidResponse: 128 case GNUNET_SCALARPRODUCT_Status_InvalidResponse:
129 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: invalid response\n", GNUNET_h2s (key)); 129 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: invalid response\n", GNUNET_h2s (key));
130 break; 130 break;
131 case GNUNET_VECTORPRODUCT_Status_Timeout: 131 case GNUNET_SCALARPRODUCT_Status_Timeout:
132 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: timeout\n", GNUNET_h2s (key)); 132 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: timeout\n", GNUNET_h2s (key));
133 break; 133 break;
134 case GNUNET_VECTORPRODUCT_Status_Failure: 134 case GNUNET_SCALARPRODUCT_Status_Failure:
135 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service failure\n", GNUNET_h2s (key)); 135 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service failure\n", GNUNET_h2s (key));
136 case GNUNET_VECTORPRODUCT_Status_ServiceDisconnected: 136 case GNUNET_SCALARPRODUCT_Status_ServiceDisconnected:
137 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service disconnect!!\n", GNUNET_h2s (key)); 137 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service disconnect!!\n", GNUNET_h2s (key));
138 break; 138 break;
139 default: 139 default:
140 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: return code %d\n", GNUNET_h2s (key), (int) status); 140 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: return code %d\n", GNUNET_h2s (key), (int) status);
141 } 141 }
142 142
143 GNUNET_VECTORPRODUCT_disconnect (handle); 143 GNUNET_SCALARPRODUCT_disconnect (handle);
144 GNUNET_SCHEDULER_shutdown (); 144 GNUNET_SCHEDULER_shutdown ();
145} 145}
146 146
@@ -160,15 +160,15 @@ static void
160requester_callback (void *cls, 160requester_callback (void *cls,
161 const struct GNUNET_HashCode * key, 161 const struct GNUNET_HashCode * key,
162 const struct GNUNET_PeerIdentity * peer, 162 const struct GNUNET_PeerIdentity * peer,
163 enum GNUNET_VECTORPRODUCT_ResponseStatus status, 163 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
164 const struct GNUNET_VECTORPRODUCT_client_response *msg) 164 const struct GNUNET_SCALARPRODUCT_client_response *msg)
165{ 165{
166 uint32_t product_len; 166 uint32_t product_len;
167 ret = -1; 167 ret = -1;
168 168
169 switch (status) 169 switch (status)
170 { 170 {
171 case GNUNET_VECTORPRODUCT_Status_Success: 171 case GNUNET_SCALARPRODUCT_Status_Success:
172 product_len = ntohl (msg->product_length); 172 product_len = ntohl (msg->product_length);
173 173
174 LOG (GNUNET_ERROR_TYPE_INFO, "Session %s concluded.\n", GNUNET_h2s (key)); 174 LOG (GNUNET_ERROR_TYPE_INFO, "Session %s concluded.\n", GNUNET_h2s (key));
@@ -194,21 +194,21 @@ requester_callback (void *cls,
194 LOG (GNUNET_ERROR_TYPE_ERROR, "Service-side error in session %s, return code: %d\n", GNUNET_h2s (key), product_len); 194 LOG (GNUNET_ERROR_TYPE_ERROR, "Service-side error in session %s, return code: %d\n", GNUNET_h2s (key), product_len);
195 } 195 }
196 break; 196 break;
197 case GNUNET_VECTORPRODUCT_Status_InvalidResponse: 197 case GNUNET_SCALARPRODUCT_Status_InvalidResponse:
198 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: invalid response\n", GNUNET_h2s (key)); 198 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: invalid response\n", GNUNET_h2s (key));
199 break; 199 break;
200 case GNUNET_VECTORPRODUCT_Status_Timeout: 200 case GNUNET_SCALARPRODUCT_Status_Timeout:
201 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: timeout\n", GNUNET_h2s (key)); 201 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: timeout\n", GNUNET_h2s (key));
202 break; 202 break;
203 case GNUNET_VECTORPRODUCT_Status_Failure: 203 case GNUNET_SCALARPRODUCT_Status_Failure:
204 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service failure\n", GNUNET_h2s (key)); 204 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service failure\n", GNUNET_h2s (key));
205 case GNUNET_VECTORPRODUCT_Status_ServiceDisconnected: 205 case GNUNET_SCALARPRODUCT_Status_ServiceDisconnected:
206 LOG (GNUNET_ERROR_TYPE_ERROR, "Disconnected from service.\n", GNUNET_h2s (key)); 206 LOG (GNUNET_ERROR_TYPE_ERROR, "Disconnected from service.\n", GNUNET_h2s (key));
207 break; 207 break;
208 default: 208 default:
209 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: return code %d\n", GNUNET_h2s (key), (int) status); 209 LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: return code %d\n", GNUNET_h2s (key), (int) status);
210 } 210 }
211 GNUNET_VECTORPRODUCT_disconnect (handle); 211 GNUNET_SCALARPRODUCT_disconnect (handle);
212 GNUNET_SCHEDULER_shutdown (); 212 GNUNET_SCHEDULER_shutdown ();
213} 213}
214 214
@@ -342,7 +342,7 @@ run (void *cls,
342 mask[i] = UCHAR_MAX; // all 1's 342 mask[i] = UCHAR_MAX; // all 1's
343 } 343 }
344 344
345 handle = GNUNET_VECTORPRODUCT_connect (cfg); 345 handle = GNUNET_SCALARPRODUCT_connect (cfg);
346 if (handle == NULL) 346 if (handle == NULL)
347 { 347 {
348 FPRINTF (stderr, _ ("Could not connect to the GNUNET Vector Product Service\n")); 348 FPRINTF (stderr, _ ("Could not connect to the GNUNET Vector Product Service\n"));
@@ -351,7 +351,7 @@ run (void *cls,
351 351
352 test_cls.h = handle; 352 test_cls.h = handle;
353 353
354 if (input_peer_id && !GNUNET_VECTORPRODUCT_request (handle, 354 if (input_peer_id && !GNUNET_SCALARPRODUCT_request (handle,
355 &key, 355 &key,
356 &peer, 356 &peer,
357 element_count, 357 element_count,
@@ -361,7 +361,7 @@ run (void *cls,
361 &requester_callback, 361 &requester_callback,
362 (void *) &test_cls)) 362 (void *) &test_cls))
363 return; 363 return;
364 if ( !input_peer_id && !GNUNET_VECTORPRODUCT_prepare_response (handle, 364 if ( !input_peer_id && !GNUNET_SCALARPRODUCT_prepare_response (handle,
365 &key, 365 &key,
366 element_count, 366 element_count,
367 elements, 367 elements,
@@ -375,7 +375,7 @@ run (void *cls,
375 375
376 376
377/** 377/**
378 * The main function to the vectorproduct client. 378 * The main function to the scalarproduct client.
379 * 379 *
380 * @param argc number of arguments from the command line 380 * @param argc number of arguments from the command line
381 * @param argv command line arguments 381 * @param argv command line arguments
@@ -392,7 +392,7 @@ main (int argc, char *const *argv)
392 gettext_noop ("A comma separated mask to select which elements should actually be compared."), 392 gettext_noop ("A comma separated mask to select which elements should actually be compared."),
393 1, &GNUNET_GETOPT_set_string, &input_mask}, 393 1, &GNUNET_GETOPT_set_string, &input_mask},
394 {'p', "peer", "PEERID", 394 {'p', "peer", "PEERID",
395 gettext_noop ("[Optional] peer to calculate our vectorproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."), 395 gettext_noop ("[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."),
396 1, &GNUNET_GETOPT_set_string, &input_peer_id}, 396 1, &GNUNET_GETOPT_set_string, &input_peer_id},
397 {'k', "key", "TRANSACTION_ID", 397 {'k', "key", "TRANSACTION_ID",
398 gettext_noop ("Transaction ID shared with peer."), 398 gettext_noop ("Transaction ID shared with peer."),
@@ -403,7 +403,7 @@ main (int argc, char *const *argv)
403 return (GNUNET_OK == 403 return (GNUNET_OK ==
404 GNUNET_PROGRAM_run (argc, 404 GNUNET_PROGRAM_run (argc,
405 argv, 405 argv,
406 "gnunet-vectorproduct", 406 "gnunet-scalarproduct",
407 gettext_noop ("Calculate the Vectorproduct with a GNUnet peer."), 407 gettext_noop ("Calculate the Vectorproduct with a GNUnet peer."),
408 options, &run, NULL)) ? ret : 1; 408 options, &run, NULL)) ? ret : 1;
409} 409}