aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/client.c4
-rw-r--r--src/util/common_allocation.c8
-rw-r--r--src/util/configuration.c178
-rw-r--r--src/util/connection.c24
-rw-r--r--src/util/container_slist.c4
-rw-r--r--src/util/network.c4
-rw-r--r--src/util/service.c3
-rw-r--r--src/util/test_bio.c24
-rw-r--r--src/util/test_configuration.c35
-rw-r--r--src/util/test_peer.c84
10 files changed, 197 insertions, 171 deletions
diff --git a/src/util/client.c b/src/util/client.c
index 4d158ab2f..80ea6d644 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -362,8 +362,8 @@ check_complete (struct GNUNET_CLIENT_Connection *conn)
362{ 362{
363 if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) && 363 if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) &&
364 (conn->received_pos >= 364 (conn->received_pos >=
365 ntohs (((const struct GNUNET_MessageHeader *) conn-> 365 ntohs (((const struct GNUNET_MessageHeader *) conn->received_buf)->
366 received_buf)->size))) 366 size)))
367 conn->msg_complete = GNUNET_YES; 367 conn->msg_complete = GNUNET_YES;
368} 368}
369 369
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index 1e546b962..5be7caaa7 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -32,11 +32,11 @@
32#endif 32#endif
33 33
34#if 0 34#if 0
35 #define W32_MEM_LIMIT 200000000 35#define W32_MEM_LIMIT 200000000
36#endif 36#endif
37 37
38#ifdef W32_MEM_LIMIT 38#ifdef W32_MEM_LIMIT
39 static LONG mem_used = 0; 39static LONG mem_used = 0;
40#endif 40#endif
41 41
42/** 42/**
@@ -66,7 +66,7 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber)
66 void *result; 66 void *result;
67 67
68#ifdef W32_MEM_LIMIT 68#ifdef W32_MEM_LIMIT
69 size += sizeof(size_t); 69 size += sizeof (size_t);
70 if (mem_used + size > W32_MEM_LIMIT) 70 if (mem_used + size > W32_MEM_LIMIT)
71 return NULL; 71 return NULL;
72#endif 72#endif
@@ -109,7 +109,7 @@ GNUNET_xrealloc_ (void *ptr,
109 const char *filename, int linenumber) 109 const char *filename, int linenumber)
110{ 110{
111#ifdef W32_MEM_LIMIT 111#ifdef W32_MEM_LIMIT
112 n += sizeof(size_t); 112 n += sizeof (size_t);
113 ptr = &((size_t *) ptr)[-1]; 113 ptr = &((size_t *) ptr)[-1];
114 mem_used = mem_used - *((size_t *) ptr) + n; 114 mem_used = mem_used - *((size_t *) ptr) + n;
115#endif 115#endif
diff --git a/src/util/configuration.c b/src/util/configuration.c
index d64ca8e83..250f9d3d5 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -102,9 +102,10 @@ struct GNUNET_CONFIGURATION_Handle
102 * Used for diffing a configuration object against 102 * Used for diffing a configuration object against
103 * the default one 103 * the default one
104 */ 104 */
105struct GNUNNET_CONFIGURATION_Diff_Handle{ 105struct GNUNNET_CONFIGURATION_Diff_Handle
106 struct GNUNET_CONFIGURATION_Handle* cfgNew; 106{
107 struct GNUNET_CONFIGURATION_Handle* cfgDiff; 107 struct GNUNET_CONFIGURATION_Handle *cfgNew;
108 struct GNUNET_CONFIGURATION_Handle *cfgDiff;
108}; 109};
109 110
110 111
@@ -479,71 +480,81 @@ findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg,
479 * @param option option name of the value (of the default conf.) 480 * @param option option name of the value (of the default conf.)
480 * @param value value to copy (of the default conf.) 481 * @param value value to copy (of the default conf.)
481 */ 482 */
482void 483void
483compareEntries( 484compareEntries (void *cls,
484 void *cls, 485 const char *section, const char *option, const char *value)
485 const char *section,
486 const char *option,
487 const char *value)
488{ 486{
489 struct ConfigSection *secNew; 487 struct ConfigSection *secNew;
490 struct ConfigEntry *entNew; 488 struct ConfigEntry *entNew;
491 struct GNUNNET_CONFIGURATION_Diff_Handle* cfgDiff = (struct GNUNNET_CONFIGURATION_Diff_Handle*)cls; 489 struct GNUNNET_CONFIGURATION_Diff_Handle *cfgDiff =
492 490 (struct GNUNNET_CONFIGURATION_Diff_Handle *) cls;
493 secNew = findSection(cfgDiff->cfgNew, section); 491
494 entNew = findEntry(cfgDiff->cfgNew, section, option); 492 secNew = findSection (cfgDiff->cfgNew, section);
495 if (secNew && strcmp(entNew->val, value) != 0) { 493 entNew = findEntry (cfgDiff->cfgNew, section, option);
496 /* Value in the new configuration has been changed */ 494 if (secNew && strcmp (entNew->val, value) != 0)
497 /* Add the changed value to the diff configuration object */ 495 {
498 struct ConfigEntry *diffEntry = NULL; 496 /* Value in the new configuration has been changed */
499 struct ConfigSection *diffSection = NULL; 497 /* Add the changed value to the diff configuration object */
500 498 struct ConfigEntry *diffEntry = NULL;
501 diffSection = cfgDiff->cfgDiff->sections; 499 struct ConfigSection *diffSection = NULL;
502 if (diffSection == NULL) { 500
503 /* First section */ 501 diffSection = cfgDiff->cfgDiff->sections;
504 diffSection = GNUNET_malloc(sizeof(struct ConfigSection)); 502 if (diffSection == NULL)
505 memcpy(diffSection, secNew, sizeof(struct ConfigSection)); 503 {
506 cfgDiff->cfgDiff->sections = diffSection; 504 /* First section */
507 diffSection->entries = NULL; 505 diffSection = GNUNET_malloc (sizeof (struct ConfigSection));
508 diffSection->next = NULL; 506 memcpy (diffSection, secNew, sizeof (struct ConfigSection));
509 } 507 cfgDiff->cfgDiff->sections = diffSection;
510 else { 508 diffSection->entries = NULL;
511 while ((strcmp(diffSection->name, secNew->name) != 0) && (diffSection->next != NULL)) { 509 diffSection->next = NULL;
512 diffSection = diffSection->next; 510 }
513 } 511 else
514 if (strcmp(diffSection->name, secNew->name) != 0) { 512 {
515 /* Section not found in diffs configuration */ 513 while ((strcmp (diffSection->name, secNew->name) != 0)
516 diffSection->next = GNUNET_malloc(sizeof(struct ConfigSection)); 514 && (diffSection->next != NULL))
517 memcpy(diffSection->next, secNew, sizeof(struct ConfigSection)); 515 {
518 diffSection->next->entries = NULL; 516 diffSection = diffSection->next;
519 diffSection->next->next = NULL; 517 }
520 } 518 if (strcmp (diffSection->name, secNew->name) != 0)
521 else { 519 {
522 diffEntry = diffSection->entries; 520 /* Section not found in diffs configuration */
523 } 521 diffSection->next =
524 } 522 GNUNET_malloc (sizeof (struct ConfigSection));
525 523 memcpy (diffSection->next, secNew,
526 if (diffEntry == NULL) { 524 sizeof (struct ConfigSection));
527 /* First Entry */ 525 diffSection->next->entries = NULL;
528 diffEntry = GNUNET_malloc(sizeof(struct ConfigEntry)); 526 diffSection->next->next = NULL;
529 memcpy(diffEntry, entNew, sizeof(struct ConfigEntry)); 527 }
530 if (diffSection->next == NULL) 528 else
531 /* The first Entry of the first Section */ 529 {
532 diffSection->entries = diffEntry; 530 diffEntry = diffSection->entries;
533 else 531 }
534 /* The first entry of the non-first Section */ 532 }
535 diffSection->next->entries = diffEntry; 533
536 diffEntry->next = NULL; 534 if (diffEntry == NULL)
537 } 535 {
538 else { 536 /* First Entry */
539 while (diffEntry->next != NULL) { 537 diffEntry = GNUNET_malloc (sizeof (struct ConfigEntry));
540 diffEntry = diffEntry->next; 538 memcpy (diffEntry, entNew, sizeof (struct ConfigEntry));
541 } 539 if (diffSection->next == NULL)
542 diffEntry->next = GNUNET_malloc(sizeof(struct ConfigEntry)); 540 /* The first Entry of the first Section */
543 memcpy(diffEntry->next, entNew, sizeof(struct ConfigEntry)); 541 diffSection->entries = diffEntry;
544 diffEntry->next->next = NULL; 542 else
545 } 543 /* The first entry of the non-first Section */
546 } 544 diffSection->next->entries = diffEntry;
545 diffEntry->next = NULL;
546 }
547 else
548 {
549 while (diffEntry->next != NULL)
550 {
551 diffEntry = diffEntry->next;
552 }
553 diffEntry->next = GNUNET_malloc (sizeof (struct ConfigEntry));
554 memcpy (diffEntry->next, entNew, sizeof (struct ConfigEntry));
555 diffEntry->next->next = NULL;
556 }
557 }
547} 558}
548 559
549 560
@@ -555,24 +566,23 @@ compareEntries(
555 * @return GNUNET_OK on success, GNUNET_SYSERR on error 566 * @return GNUNET_OK on success, GNUNET_SYSERR on error
556 */ 567 */
557int 568int
558GNUNET_CONFIGURATION_write_diffs( 569GNUNET_CONFIGURATION_write_diffs (struct GNUNET_CONFIGURATION_Handle
559 struct GNUNET_CONFIGURATION_Handle *cfgDefault, 570 *cfgDefault,
560 struct GNUNET_CONFIGURATION_Handle *cfgNew, 571 struct GNUNET_CONFIGURATION_Handle *cfgNew,
561 const char* filename 572 const char *filename)
562 )
563{ 573{
564 int ret; 574 int ret;
565 struct GNUNNET_CONFIGURATION_Diff_Handle diffHandle; 575 struct GNUNNET_CONFIGURATION_Diff_Handle diffHandle;
566 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create(); 576 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
567 diffHandle.cfgDiff->sections = NULL; 577 diffHandle.cfgDiff->sections = NULL;
568 diffHandle.cfgNew = cfgNew; 578 diffHandle.cfgNew = cfgNew;
569 GNUNET_CONFIGURATION_iterate(cfgDefault, compareEntries, &diffHandle); 579 GNUNET_CONFIGURATION_iterate (cfgDefault, compareEntries, &diffHandle);
570 580
571 ret = GNUNET_CONFIGURATION_write(diffHandle.cfgDiff, filename); 581 ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
572 582
573 /* Housekeeping */ 583 /* Housekeeping */
574 GNUNET_CONFIGURATION_destroy(diffHandle.cfgDiff); 584 GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
575 return ret; 585 return ret;
576} 586}
577 587
578 588
diff --git a/src/util/connection.c b/src/util/connection.c
index 886ae140c..e09c0cd9e 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -817,12 +817,11 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched,
817 ret->port = port; 817 ret->port = port;
818 ret->hostname = GNUNET_strdup (hostname); 818 ret->hostname = GNUNET_strdup (hostname);
819 ret->dns_active = GNUNET_RESOLVER_ip_get (sched, 819 ret->dns_active = GNUNET_RESOLVER_ip_get (sched,
820 cfg, 820 cfg,
821 ret->hostname, 821 ret->hostname,
822 AF_UNSPEC, 822 AF_UNSPEC,
823 GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, 823 GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
824 &try_connect_using_address, 824 &try_connect_using_address, ret);
825 ret);
826 return ret; 825 return ret;
827} 826}
828 827
@@ -971,9 +970,8 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
972 "Receive from `%s' encounters error: time out by %llums... (%p)\n", 971 "Receive from `%s' encounters error: time out by %llums... (%p)\n",
973 GNUNET_a2s (sh->addr, sh->addrlen), 972 GNUNET_a2s (sh->addr, sh->addrlen),
974 GNUNET_TIME_absolute_get_duration (sh-> 973 GNUNET_TIME_absolute_get_duration (sh->receive_timeout).
975 receive_timeout).value, 974 value, sh);
976 sh);
977#endif 975#endif
978 signal_timeout (sh); 976 signal_timeout (sh);
979 return; 977 return;
@@ -1320,8 +1318,8 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1320 GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size); 1318 GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size);
1321RETRY: 1319RETRY:
1322 ret = GNUNET_NETWORK_socket_send (sock->sock, 1320 ret = GNUNET_NETWORK_socket_send (sock->sock,
1323 &sock-> 1321 &sock->write_buffer[sock->
1324 write_buffer[sock->write_buffer_pos], 1322 write_buffer_pos],
1325 have); 1323 have);
1326 if (ret == -1) 1324 if (ret == -1)
1327 { 1325 {
@@ -1418,8 +1416,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1418#endif 1416#endif
1419 sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched, 1417 sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched,
1420 GNUNET_TIME_absolute_get_remaining 1418 GNUNET_TIME_absolute_get_remaining
1421 (sock-> 1419 (sock->nth.
1422 nth.transmit_timeout), 1420 transmit_timeout),
1423 sock->sock, 1421 sock->sock,
1424 &transmit_ready, 1422 &transmit_ready,
1425 sock); 1423 sock);
diff --git a/src/util/container_slist.c b/src/util/container_slist.c
index 715dcee32..ab547f313 100644
--- a/src/util/container_slist.c
+++ b/src/util/container_slist.c
@@ -336,7 +336,9 @@ GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
336 * Release an iterator 336 * Release an iterator
337 * @param i iterator 337 * @param i iterator
338 */ 338 */
339void GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i) 339void
340GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator
341 *i)
340{ 342{
341 GNUNET_free (i); 343 GNUNET_free (i);
342} 344}
diff --git a/src/util/network.c b/src/util/network.c
index 2707e9432..5d7370003 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -976,7 +976,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
976 on_next = GNUNET_YES; 976 on_next = GNUNET_YES;
977 } 977 }
978 } 978 }
979 GNUNET_CONTAINER_slist_iter_destroy (i); 979 GNUNET_CONTAINER_slist_iter_destroy (i);
980 } 980 }
981 981
982 /* Poll for faulty pipes */ 982 /* Poll for faulty pipes */
@@ -1043,7 +1043,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1043 } 1043 }
1044 select_loop_end: 1044 select_loop_end:
1045 if (retcode == 0 && nfds == 0) 1045 if (retcode == 0 && nfds == 0)
1046 Sleep(GNUNET_MIN(100, limit - GetTickCount())); 1046 Sleep (GNUNET_MIN (100, limit - GetTickCount ()));
1047 } 1047 }
1048 while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit)); 1048 while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit));
1049 if (retcode != -1) 1049 if (retcode != -1)
diff --git a/src/util/service.c b/src/util/service.c
index 2c84e91f4..75161f71f 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -799,7 +799,8 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
799 { 799 {
800 if (GNUNET_SYSERR == 800 if (GNUNET_SYSERR ==
801 (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, 801 (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
802 sctx->serviceName, 802 sctx->
803 serviceName,
803 "DISABLEV6"))) 804 "DISABLEV6")))
804 return GNUNET_SYSERR; 805 return GNUNET_SYSERR;
805 } 806 }
diff --git a/src/util/test_bio.c b/src/util/test_bio.c
index b005cb057..1eda86a6f 100644
--- a/src/util/test_bio.c
+++ b/src/util/test_bio.c
@@ -49,8 +49,7 @@ test_normal_rw ()
49 GNUNET_assert (NULL != fileW); 49 GNUNET_assert (NULL != fileW);
50 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_string (fileW, TESTSTRING)); 50 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_string (fileW, TESTSTRING));
51 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_meta_data (fileW, metaDataW)); 51 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_meta_data (fileW, metaDataW));
52 GNUNET_assert (GNUNET_OK == 52 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int64 (fileW, TESTNUMBER64));
53 GNUNET_BIO_write_int64 (fileW, TESTNUMBER64));
54 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (fileW)); 53 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (fileW));
55 54
56 fileR = GNUNET_BIO_read_open (fileName); 55 fileR = GNUNET_BIO_read_open (fileName);
@@ -199,14 +198,16 @@ test_bigmeta_rw ()
199} 198}
200 199
201static int 200static int
202test_directory_r(){ 201test_directory_r ()
202{
203 char *msg; 203 char *msg;
204 char readResult[200]; 204 char readResult[200];
205 struct GNUNET_BIO_ReadHandle *fileR; 205 struct GNUNET_BIO_ReadHandle *fileR;
206 206
207 fileR = GNUNET_BIO_read_open ("/dev"); 207 fileR = GNUNET_BIO_read_open ("/dev");
208 GNUNET_assert (NULL != fileR); 208 GNUNET_assert (NULL != fileR);
209 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read (fileR, "Read error", readResult, 65537)); 209 GNUNET_assert (GNUNET_SYSERR ==
210 GNUNET_BIO_read (fileR, "Read error", readResult, 65537));
210 msg = NULL; 211 msg = NULL;
211 GNUNET_BIO_read_close (fileR, &msg); 212 GNUNET_BIO_read_close (fileR, &msg);
212 GNUNET_free (msg); 213 GNUNET_free (msg);
@@ -240,7 +241,7 @@ test_nullfile_rw ()
240 fileW = GNUNET_BIO_write_open ("/dev/full"); 241 fileW = GNUNET_BIO_write_open ("/dev/full");
241 GNUNET_assert (NULL != fileW); 242 GNUNET_assert (NULL != fileW);
242 GNUNET_assert (GNUNET_SYSERR == 243 GNUNET_assert (GNUNET_SYSERR ==
243 GNUNET_BIO_write (fileW, fileNameNO, sizeof(fileNameNO))); 244 GNUNET_BIO_write (fileW, fileNameNO, sizeof (fileNameNO)));
244 GNUNET_assert (GNUNET_SYSERR == 245 GNUNET_assert (GNUNET_SYSERR ==
245 GNUNET_BIO_write_string (fileW, TESTSTRING)); 246 GNUNET_BIO_write_string (fileW, TESTSTRING));
246 GNUNET_assert (GNUNET_SYSERR == 247 GNUNET_assert (GNUNET_SYSERR ==
@@ -384,14 +385,15 @@ check_file_rw ()
384{ 385{
385 GNUNET_assert (0 == test_normal_rw ()); 386 GNUNET_assert (0 == test_normal_rw ());
386 GNUNET_assert (0 == test_nullfile_rw ()); 387 GNUNET_assert (0 == test_nullfile_rw ());
387 GNUNET_assert (0 == test_directory_r()); 388 GNUNET_assert (0 == test_directory_r ());
388 return 0; 389 return 0;
389} 390}
390 391
391int 392int
392main (int argc, char *argv[]){ 393main (int argc, char *argv[])
393 GNUNET_assert (0 == check_file_rw()); 394{
394 GNUNET_assert (0 == check_metadata_rw()); 395 GNUNET_assert (0 == check_file_rw ());
395 GNUNET_assert (0 == check_string_rw()); 396 GNUNET_assert (0 == check_metadata_rw ());
396 return 0; 397 GNUNET_assert (0 == check_string_rw ());
398 return 0;
397} /* end of main */ 399} /* end of main */
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c
index 150b8d6b4..3cd076f0f 100644
--- a/src/util/test_configuration.c
+++ b/src/util/test_configuration.c
@@ -231,23 +231,26 @@ main (int argc, char *argv[])
231// return 1; 231// return 1;
232// } 232// }
233// 233//
234 struct GNUNET_CONFIGURATION_Handle* cfgDefault = GNUNET_CONFIGURATION_create (); 234 struct GNUNET_CONFIGURATION_Handle *cfgDefault =
235 struct GNUNET_CONFIGURATION_Handle* cfgNew = GNUNET_CONFIGURATION_create(); 235 GNUNET_CONFIGURATION_create ();
236 struct GNUNET_CONFIGURATION_Handle *cfgNew = GNUNET_CONFIGURATION_create ();
236 if (GNUNET_OK != 237 if (GNUNET_OK !=
237 GNUNET_CONFIGURATION_parse (cfgDefault, "src/util/test_configuration_data.conf")) 238 GNUNET_CONFIGURATION_parse (cfgDefault,
238 { 239 "src/util/test_configuration_data.conf"))
239 fprintf (stderr, "Failed to parse configuration file\n"); 240 {
240 GNUNET_CONFIGURATION_destroy (cfgDefault); 241 fprintf (stderr, "Failed to parse configuration file\n");
241 return 1; 242 GNUNET_CONFIGURATION_destroy (cfgDefault);
242 } 243 return 1;
244 }
243 if (GNUNET_OK != 245 if (GNUNET_OK !=
244 GNUNET_CONFIGURATION_parse (cfgNew, "/Users/soufi/Desktop/test_configuration_data.conf")) 246 GNUNET_CONFIGURATION_parse (cfgNew,
245 { 247 "/Users/soufi/Desktop/test_configuration_data.conf"))
246 fprintf (stderr, "Failed to parse configuration file\n"); 248 {
247 GNUNET_CONFIGURATION_destroy (cfgNew); 249 fprintf (stderr, "Failed to parse configuration file\n");
248 return 1; 250 GNUNET_CONFIGURATION_destroy (cfgNew);
249 } 251 return 1;
250 252 }
251 GNUNET_CONFIGURATION_write_diffs(cfgDefault, cfgNew, "/tmp/safey.conf"); 253
254 GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfgNew, "/tmp/safey.conf");
252 return 0; 255 return 0;
253} 256}
diff --git a/src/util/test_peer.c b/src/util/test_peer.c
index 0f4a227d3..e2fd100fd 100644
--- a/src/util/test_peer.c
+++ b/src/util/test_peer.c
@@ -36,70 +36,80 @@
36static struct GNUNET_PeerIdentity pidArr[NUMBER_OF_PEERS]; 36static struct GNUNET_PeerIdentity pidArr[NUMBER_OF_PEERS];
37 37
38 38
39static void generatePeerIdList() 39static void
40generatePeerIdList ()
40{ 41{
41 int i; 42 int i;
42 43
43 for (i = 0; i < NUMBER_OF_PEERS; i++ ) { 44 for (i = 0; i < NUMBER_OF_PEERS; i++)
44 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &pidArr[i].hashPubKey); 45 {
46 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
47 &pidArr[i].hashPubKey);
45#ifdef DEBUG 48#ifdef DEBUG
46 printf ("Peer %d: %s\n", 49 printf ("Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i]));
47 i,
48 GNUNET_i2s (&pidArr[i]));
49#endif 50#endif
50 } 51 }
51} 52}
52 53
53 54
54static int check() 55static int
56check ()
55{ 57{
56 int i; 58 int i;
57 GNUNET_PEER_Id pid; 59 GNUNET_PEER_Id pid;
58 60
59 /* Insert Peers into PeerEntry table and hashmap */ 61 /* Insert Peers into PeerEntry table and hashmap */
60 for (i=0; i < NUMBER_OF_PEERS; i++) { 62 for (i = 0; i < NUMBER_OF_PEERS; i++)
61 pid = GNUNET_PEER_intern(&pidArr[i]); 63 {
62 if ( pid != (i + 1)) { 64 pid = GNUNET_PEER_intern (&pidArr[i]);
63 fprintf(stderr, "Unexpected Peer ID returned by intern function \n"); 65 if (pid != (i + 1))
64 return 1; 66 {
67 fprintf (stderr,
68 "Unexpected Peer ID returned by intern function \n");
69 return 1;
70 }
65 } 71 }
66 } 72
67
68 /* Referencing the first 3 peers once again */ 73 /* Referencing the first 3 peers once again */
69 for (i = 0; i < 3; i++) { 74 for (i = 0; i < 3; i++)
70 pid = GNUNET_PEER_intern(&pidArr[i]); 75 {
71 if (pid != (i + 1)) { 76 pid = GNUNET_PEER_intern (&pidArr[i]);
72 fprintf(stderr, "Unexpcted Peer ID returned by intern function \n"); 77 if (pid != (i + 1))
73 return 1; 78 {
79 fprintf (stderr,
80 "Unexpcted Peer ID returned by intern function \n");
81 return 1;
82 }
74 } 83 }
75 } 84
76
77 /* Dereferencing the first 3 peers once [decrementing their reference count] */ 85 /* Dereferencing the first 3 peers once [decrementing their reference count] */
78 { 86 {
79 GNUNET_PEER_Id ids[] = {1, 2, 3}; 87 GNUNET_PEER_Id ids[] = { 1, 2, 3 };
80 GNUNET_PEER_decrement_rcs(ids, 3); 88 GNUNET_PEER_decrement_rcs (ids, 3);
81 } 89 }
82 90
83 /* re-referencing the first 3 peers using the change_rc function */ 91 /* re-referencing the first 3 peers using the change_rc function */
84 for (i = 0; i < 3; i++) { 92 for (i = 0; i < 3; i++)
85 GNUNET_PEER_change_rc(i, 1); 93 {
86 } 94 GNUNET_PEER_change_rc (i, 1);
87 95 }
96
88 /* Removing the second Peer from the PeerEntry hash map */ 97 /* Removing the second Peer from the PeerEntry hash map */
89 GNUNET_PEER_change_rc(2, -2); 98 GNUNET_PEER_change_rc (2, -2);
90 99
91 /* convert the pid of the first PeerEntry into that of the third */ 100 /* convert the pid of the first PeerEntry into that of the third */
92 GNUNET_PEER_resolve(1, &pidArr[3]); 101 GNUNET_PEER_resolve (1, &pidArr[3]);
93 102
94 return 0; 103 return 0;
95} 104}
96 105
97 106
98int main() 107int
108main ()
99{ 109{
100 GNUNET_log_setup ("test-peer", "ERROR", NULL); 110 GNUNET_log_setup ("test-peer", "ERROR", NULL);
101 generatePeerIdList(); 111 generatePeerIdList ();
102 return check(); 112 return check ();
103} 113}
104 114
105/* end of test_peer.c */ 115/* end of test_peer.c */