diff options
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index a5ff9f9fa..c2e8f5d88 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -1404,7 +1404,7 @@ load_hostlist_file () | |||
1404 | return; | 1404 | return; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | rh = GNUNET_BIO_read_open (filename); | 1407 | rh = GNUNET_BIO_read_open_file (filename); |
1408 | if (NULL == rh) | 1408 | if (NULL == rh) |
1409 | { | 1409 | { |
1410 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1410 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -1417,13 +1417,17 @@ load_hostlist_file () | |||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | counter = 0; | 1419 | counter = 0; |
1420 | struct GNUNET_BIO_ReadSpec rs[] = { | ||
1421 | GNUNET_BIO_read_spec_int32 ("times used", (int32_t *)×_used), | ||
1422 | GNUNET_BIO_read_spec_int64 ("quality", (int64_t *) &quality), | ||
1423 | GNUNET_BIO_read_spec_int64 ("last used", (int64_t *) &last_used), | ||
1424 | GNUNET_BIO_read_spec_int64 ("created", (int64_t *) &created), | ||
1425 | GNUNET_BIO_read_spec_int32 ("hellos returned", (int32_t *) &hellos_returned), | ||
1426 | GNUNET_BIO_read_spec_end (), | ||
1427 | }; | ||
1420 | while ((GNUNET_OK == GNUNET_BIO_read_string (rh, "url", &uri, MAX_URL_LEN)) && | 1428 | while ((GNUNET_OK == GNUNET_BIO_read_string (rh, "url", &uri, MAX_URL_LEN)) && |
1421 | (NULL != uri) && | 1429 | (NULL != uri) && |
1422 | (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used)) && | 1430 | (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs))) |
1423 | (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) && | ||
1424 | (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &last_used)) && | ||
1425 | (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &created)) && | ||
1426 | (GNUNET_OK == GNUNET_BIO_read_int32 (rh, &hellos_returned))) | ||
1427 | { | 1431 | { |
1428 | hostlist = GNUNET_malloc (sizeof(struct Hostlist) + strlen (uri) + 1); | 1432 | hostlist = GNUNET_malloc (sizeof(struct Hostlist) + strlen (uri) + 1); |
1429 | hostlist->hello_count = hellos_returned; | 1433 | hostlist->hello_count = hellos_returned; |
@@ -1494,7 +1498,7 @@ save_hostlist_file (int shutdown) | |||
1494 | GNUNET_free (filename); | 1498 | GNUNET_free (filename); |
1495 | return; | 1499 | return; |
1496 | } | 1500 | } |
1497 | wh = GNUNET_BIO_write_open (filename); | 1501 | wh = GNUNET_BIO_write_open_file (filename); |
1498 | if (NULL == wh) | 1502 | if (NULL == wh) |
1499 | { | 1503 | { |
1500 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1504 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1521,14 +1525,21 @@ save_hostlist_file (int shutdown) | |||
1521 | } | 1525 | } |
1522 | if (GNUNET_YES == ok) | 1526 | if (GNUNET_YES == ok) |
1523 | { | 1527 | { |
1524 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pos->hostlist_uri)) || | 1528 | struct GNUNET_BIO_WriteSpec ws[] = { |
1525 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->times_used)) || | 1529 | GNUNET_BIO_write_spec_string ("hostlist uri", pos->hostlist_uri), |
1526 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) || | 1530 | GNUNET_BIO_write_spec_int32 ("times used", (int32_t *) &pos->times_used), |
1527 | (GNUNET_OK != | 1531 | GNUNET_BIO_write_spec_int64 ("quality", (int64_t *) &pos->quality), |
1528 | GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value_us)) || | 1532 | GNUNET_BIO_write_spec_int64 ( |
1529 | (GNUNET_OK != | 1533 | "last usage", |
1530 | GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value_us)) || | 1534 | (int64_t *) &pos->time_last_usage.abs_value_us), |
1531 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->hello_count))) | 1535 | GNUNET_BIO_write_spec_int64 ( |
1536 | "creation time", | ||
1537 | (int64_t *) &pos->time_creation.abs_value_us), | ||
1538 | GNUNET_BIO_write_spec_int32 ("hellos count", | ||
1539 | (int32_t *) &pos->hello_count), | ||
1540 | GNUNET_BIO_write_spec_end (), | ||
1541 | }; | ||
1542 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws))) | ||
1532 | { | 1543 | { |
1533 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1544 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1534 | _ ("Error writing hostlist URIs to file `%s'\n"), | 1545 | _ ("Error writing hostlist URIs to file `%s'\n"), |
@@ -1548,7 +1559,7 @@ save_hostlist_file (int shutdown) | |||
1548 | counter, | 1559 | counter, |
1549 | GNUNET_YES); | 1560 | GNUNET_YES); |
1550 | 1561 | ||
1551 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 1562 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
1552 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1563 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1553 | _ ("Error writing hostlist URIs to file `%s'\n"), | 1564 | _ ("Error writing hostlist URIs to file `%s'\n"), |
1554 | filename); | 1565 | filename); |