diff options
Diffstat (limited to 'src/fs/fs_api.c')
-rw-r--r-- | src/fs/fs_api.c | 448 |
1 files changed, 285 insertions, 163 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index e04a93f9c..3d2ba3e99 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -676,7 +676,7 @@ get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | |||
676 | fn = get_serialization_file_name (h, ext, ent); | 676 | fn = get_serialization_file_name (h, ext, ent); |
677 | if (NULL == fn) | 677 | if (NULL == fn) |
678 | return NULL; | 678 | return NULL; |
679 | ret = GNUNET_BIO_read_open (fn); | 679 | ret = GNUNET_BIO_read_open_file (fn); |
680 | GNUNET_free (fn); | 680 | GNUNET_free (fn); |
681 | return ret; | 681 | return ret; |
682 | } | 682 | } |
@@ -699,7 +699,7 @@ get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | |||
699 | fn = get_serialization_file_name (h, ext, ent); | 699 | fn = get_serialization_file_name (h, ext, ent); |
700 | if (NULL == fn) | 700 | if (NULL == fn) |
701 | return NULL; | 701 | return NULL; |
702 | ret = GNUNET_BIO_write_open (fn); | 702 | ret = GNUNET_BIO_write_open_file (fn); |
703 | GNUNET_break (NULL != ret); | 703 | GNUNET_break (NULL != ret); |
704 | GNUNET_free (fn); | 704 | GNUNET_free (fn); |
705 | return ret; | 705 | return ret; |
@@ -727,7 +727,7 @@ get_write_handle_in_dir (struct GNUNET_FS_Handle *h, | |||
727 | fn = get_serialization_file_name_in_dir (h, ext, uni, ent); | 727 | fn = get_serialization_file_name_in_dir (h, ext, uni, ent); |
728 | if (NULL == fn) | 728 | if (NULL == fn) |
729 | return NULL; | 729 | return NULL; |
730 | ret = GNUNET_BIO_write_open (fn); | 730 | ret = GNUNET_BIO_write_open_file (fn); |
731 | GNUNET_free (fn); | 731 | GNUNET_free (fn); |
732 | return ret; | 732 | return ret; |
733 | } | 733 | } |
@@ -839,7 +839,7 @@ write_start_time (struct GNUNET_BIO_WriteHandle *wh, | |||
839 | struct GNUNET_TIME_Relative dur; | 839 | struct GNUNET_TIME_Relative dur; |
840 | 840 | ||
841 | dur = GNUNET_TIME_absolute_get_duration (timestamp); | 841 | dur = GNUNET_TIME_absolute_get_duration (timestamp); |
842 | return GNUNET_BIO_write_int64 (wh, dur.rel_value_us); | 842 | return GNUNET_BIO_write_int64 (wh, "start time", dur.rel_value_us); |
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
@@ -863,7 +863,8 @@ read_start_time (struct GNUNET_BIO_ReadHandle *rh, | |||
863 | { | 863 | { |
864 | struct GNUNET_TIME_Relative dur; | 864 | struct GNUNET_TIME_Relative dur; |
865 | 865 | ||
866 | if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dur.rel_value_us)) | 866 | if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, "start time", |
867 | (int64_t *) &dur.rel_value_us)) | ||
867 | return GNUNET_SYSERR; | 868 | return GNUNET_SYSERR; |
868 | *timestamp = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), dur); | 869 | *timestamp = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), dur); |
869 | return GNUNET_OK; | 870 | return GNUNET_OK; |
@@ -937,10 +938,22 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
937 | (GNUNET_OK != | 938 | (GNUNET_OK != |
938 | GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) || | 939 | GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) || |
939 | (GNUNET_OK != | 940 | (GNUNET_OK != |
940 | GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value_us)) || | 941 | GNUNET_BIO_read_int64 ( |
941 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) || | 942 | rh, |
942 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) || | 943 | "expiration time", |
943 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level))) | 944 | (int64_t *) &ret->bo.expiration_time.abs_value_us)) || |
945 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
946 | rh, | ||
947 | "anonymity level", | ||
948 | (int32_t *) &ret->bo.anonymity_level)) || | ||
949 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
950 | rh, | ||
951 | "content priority", | ||
952 | (int32_t *) &ret->bo.content_priority)) || | ||
953 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
954 | rh, | ||
955 | "replication level", | ||
956 | (int32_t *) &ret->bo.replication_level))) | ||
944 | { | 957 | { |
945 | GNUNET_break (0); | 958 | GNUNET_break (0); |
946 | goto cleanup; | 959 | goto cleanup; |
@@ -948,7 +961,10 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
948 | switch (b) | 961 | switch (b) |
949 | { | 962 | { |
950 | case 0: /* file-insert */ | 963 | case 0: /* file-insert */ |
951 | if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) | 964 | if (GNUNET_OK != GNUNET_BIO_read_int64 ( |
965 | rh, | ||
966 | "file size", | ||
967 | (int64_t *) &ret->data.file.file_size)) | ||
952 | { | 968 | { |
953 | GNUNET_break (0); | 969 | GNUNET_break (0); |
954 | goto cleanup; | 970 | goto cleanup; |
@@ -990,7 +1006,10 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
990 | GNUNET_break (0); | 1006 | GNUNET_break (0); |
991 | goto cleanup; | 1007 | goto cleanup; |
992 | } | 1008 | } |
993 | if (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) | 1009 | if (GNUNET_OK != GNUNET_BIO_read_int64 ( |
1010 | rh, | ||
1011 | "file size", | ||
1012 | (int64_t *) &ret->data.file.file_size)) | ||
994 | { | 1013 | { |
995 | GNUNET_break (0); | 1014 | GNUNET_break (0); |
996 | goto cleanup; | 1015 | goto cleanup; |
@@ -1010,7 +1029,10 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
1010 | GNUNET_break (0); | 1029 | GNUNET_break (0); |
1011 | goto cleanup; | 1030 | goto cleanup; |
1012 | } | 1031 | } |
1013 | if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || | 1032 | if ((GNUNET_OK != GNUNET_BIO_read_int64 ( |
1033 | rh, | ||
1034 | "file size", | ||
1035 | (int64_t *) &ret->data.file.file_size)) || | ||
1014 | (GNUNET_OK != GNUNET_BIO_read (rh, | 1036 | (GNUNET_OK != GNUNET_BIO_read (rh, |
1015 | "fileid", | 1037 | "fileid", |
1016 | &ret->data.file.file_id, | 1038 | &ret->data.file.file_id, |
@@ -1034,7 +1056,10 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
1034 | GNUNET_break (0); | 1056 | GNUNET_break (0); |
1035 | goto cleanup; | 1057 | goto cleanup; |
1036 | } | 1058 | } |
1037 | if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || | 1059 | if ((GNUNET_OK != GNUNET_BIO_read_int64 ( |
1060 | rh, | ||
1061 | "file size", | ||
1062 | (int64_t *) &ret->data.file.file_size)) || | ||
1038 | (GNUNET_OK != GNUNET_BIO_read (rh, | 1063 | (GNUNET_OK != GNUNET_BIO_read (rh, |
1039 | "fileid", | 1064 | "fileid", |
1040 | &ret->data.file.file_id, | 1065 | &ret->data.file.file_id, |
@@ -1054,11 +1079,18 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, | |||
1054 | 1079 | ||
1055 | case 4: /* directory */ | 1080 | case 4: /* directory */ |
1056 | ret->is_directory = GNUNET_YES; | 1081 | ret->is_directory = GNUNET_YES; |
1057 | if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dsize)) || | 1082 | if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, "dsize", |
1083 | (int32_t *) &dsize)) || | ||
1058 | (GNUNET_OK != | 1084 | (GNUNET_OK != |
1059 | GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_completed)) || | 1085 | GNUNET_BIO_read_int64 ( |
1086 | rh, | ||
1087 | "contents completed", | ||
1088 | (int64_t *) &ret->data.dir.contents_completed)) || | ||
1060 | (GNUNET_OK != | 1089 | (GNUNET_OK != |
1061 | GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_size)) || | 1090 | GNUNET_BIO_read_int64 ( |
1091 | rh, | ||
1092 | "contents size", | ||
1093 | (int64_t *) &ret->data.dir.contents_size)) || | ||
1062 | (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) || | 1094 | (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) || |
1063 | (GNUNET_OK != | 1095 | (GNUNET_OK != |
1064 | GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) || | 1096 | GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) || |
@@ -1294,7 +1326,7 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh, | |||
1294 | GNUNET_free (emsg); | 1326 | GNUNET_free (emsg); |
1295 | return GNUNET_SYSERR; | 1327 | return GNUNET_SYSERR; |
1296 | } | 1328 | } |
1297 | if (GNUNET_OK != GNUNET_BIO_write (wh, buf, ret)) | 1329 | if (GNUNET_OK != GNUNET_BIO_write (wh, "copied from reader", buf, ret)) |
1298 | return GNUNET_SYSERR; | 1330 | return GNUNET_SYSERR; |
1299 | off += ret; | 1331 | off += ret; |
1300 | } | 1332 | } |
@@ -1353,19 +1385,34 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1353 | skss = GNUNET_FS_uri_to_string (fi->sks_uri); | 1385 | skss = GNUNET_FS_uri_to_string (fi->sks_uri); |
1354 | else | 1386 | else |
1355 | skss = NULL; | 1387 | skss = NULL; |
1356 | if ((GNUNET_OK != GNUNET_BIO_write (wh, &b, sizeof(b))) || | 1388 | struct GNUNET_BIO_WriteSpec ws1[] = { |
1357 | (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, fi->meta)) || | 1389 | GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)), |
1358 | (GNUNET_OK != GNUNET_BIO_write_string (wh, ksks)) || | 1390 | GNUNET_BIO_write_spec_meta_data ("meta", fi->meta), |
1359 | (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) || | 1391 | GNUNET_BIO_write_spec_string ("ksks", ksks), |
1360 | (GNUNET_OK != GNUNET_BIO_write_string (wh, skss)) || | 1392 | GNUNET_BIO_write_spec_string ("chks", chks), |
1393 | GNUNET_BIO_write_spec_string ("skss", skss), | ||
1394 | GNUNET_BIO_write_spec_end (), | ||
1395 | }; | ||
1396 | struct GNUNET_BIO_WriteSpec ws2[] = { | ||
1397 | GNUNET_BIO_write_spec_string ("emsg", fi->emsg), | ||
1398 | GNUNET_BIO_write_spec_string ("filename", fi->filename), | ||
1399 | GNUNET_BIO_write_spec_int64 ( | ||
1400 | "expiration time", | ||
1401 | (int64_t *) &fi->bo.expiration_time.abs_value_us), | ||
1402 | GNUNET_BIO_write_spec_int32 ( | ||
1403 | "anonymity level", | ||
1404 | (int32_t *) &fi->bo.anonymity_level), | ||
1405 | GNUNET_BIO_write_spec_int32 ( | ||
1406 | "content priority", | ||
1407 | (int32_t *) &fi->bo.content_priority), | ||
1408 | GNUNET_BIO_write_spec_int32 ( | ||
1409 | "replication level", | ||
1410 | (int32_t *) &fi->bo.replication_level), | ||
1411 | GNUNET_BIO_write_spec_end (), | ||
1412 | }; | ||
1413 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) || | ||
1361 | (GNUNET_OK != write_start_time (wh, fi->start_time)) || | 1414 | (GNUNET_OK != write_start_time (wh, fi->start_time)) || |
1362 | (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) || | 1415 | (GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws2))) |
1363 | (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) || | ||
1364 | (GNUNET_OK != | ||
1365 | GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value_us)) || | ||
1366 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) || | ||
1367 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) || | ||
1368 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.replication_level))) | ||
1369 | { | 1416 | { |
1370 | GNUNET_break (0); | 1417 | GNUNET_break (0); |
1371 | goto cleanup; | 1418 | goto cleanup; |
@@ -1380,7 +1427,8 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1380 | switch (b) | 1427 | switch (b) |
1381 | { | 1428 | { |
1382 | case 0: /* file-insert */ | 1429 | case 0: /* file-insert */ |
1383 | if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) | 1430 | if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size", |
1431 | fi->data.file.file_size)) | ||
1384 | { | 1432 | { |
1385 | GNUNET_break (0); | 1433 | GNUNET_break (0); |
1386 | goto cleanup; | 1434 | goto cleanup; |
@@ -1399,7 +1447,8 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1399 | GNUNET_break (0); | 1447 | GNUNET_break (0); |
1400 | goto cleanup; | 1448 | goto cleanup; |
1401 | } | 1449 | } |
1402 | if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) | 1450 | if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size", |
1451 | fi->data.file.file_size)) | ||
1403 | { | 1452 | { |
1404 | GNUNET_break (0); | 1453 | GNUNET_break (0); |
1405 | goto cleanup; | 1454 | goto cleanup; |
@@ -1413,8 +1462,10 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1413 | GNUNET_break (0); | 1462 | GNUNET_break (0); |
1414 | goto cleanup; | 1463 | goto cleanup; |
1415 | } | 1464 | } |
1416 | if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) || | 1465 | if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size", |
1466 | fi->data.file.file_size)) || | ||
1417 | (GNUNET_OK != GNUNET_BIO_write (wh, | 1467 | (GNUNET_OK != GNUNET_BIO_write (wh, |
1468 | "file id", | ||
1418 | &fi->data.file.file_id, | 1469 | &fi->data.file.file_id, |
1419 | sizeof(struct GNUNET_HashCode)))) | 1470 | sizeof(struct GNUNET_HashCode)))) |
1420 | { | 1471 | { |
@@ -1427,19 +1478,24 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1427 | if ((NULL != fi->data.dir.entries) && | 1478 | if ((NULL != fi->data.dir.entries) && |
1428 | (NULL == fi->data.dir.entries->serialization)) | 1479 | (NULL == fi->data.dir.entries->serialization)) |
1429 | GNUNET_FS_file_information_sync_ (fi->data.dir.entries); | 1480 | GNUNET_FS_file_information_sync_ (fi->data.dir.entries); |
1430 | if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) || | 1481 | struct GNUNET_BIO_WriteSpec ws[] = { |
1431 | (GNUNET_OK != | 1482 | GNUNET_BIO_write_spec_int32 ("dir size", |
1432 | GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_completed)) || | 1483 | (int32_t *) &fi->data.dir.dir_size), |
1433 | (GNUNET_OK != | 1484 | GNUNET_BIO_write_spec_int64 ( |
1434 | GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_size)) || | 1485 | "contents completed", |
1435 | (GNUNET_OK != GNUNET_BIO_write (wh, | 1486 | (int64_t *) &fi->data.dir.contents_completed), |
1436 | fi->data.dir.dir_data, | 1487 | GNUNET_BIO_write_spec_int64 ("contents size", |
1437 | (uint32_t) fi->data.dir.dir_size)) || | 1488 | (int64_t *) &fi->data.dir.contents_size), |
1438 | (GNUNET_OK != | 1489 | GNUNET_BIO_write_spec_object ("dir data", |
1439 | GNUNET_BIO_write_string (wh, | 1490 | fi->data.dir.dir_data, |
1440 | (fi->data.dir.entries == NULL) | 1491 | (uint32_t) fi->data.dir.dir_size), |
1441 | ? NULL | 1492 | GNUNET_BIO_write_spec_string ("dir entries", |
1442 | : fi->data.dir.entries->serialization))) | 1493 | (fi->data.dir.entries == NULL) |
1494 | ? NULL | ||
1495 | : fi->data.dir.entries->serialization), | ||
1496 | GNUNET_BIO_write_spec_end (), | ||
1497 | }; | ||
1498 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws))) | ||
1443 | { | 1499 | { |
1444 | GNUNET_break (0); | 1500 | GNUNET_break (0); |
1445 | goto cleanup; | 1501 | goto cleanup; |
@@ -1453,6 +1509,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1453 | if ((NULL != fi->next) && (NULL == fi->next->serialization)) | 1509 | if ((NULL != fi->next) && (NULL == fi->next->serialization)) |
1454 | GNUNET_FS_file_information_sync_ (fi->next); | 1510 | GNUNET_FS_file_information_sync_ (fi->next); |
1455 | if (GNUNET_OK != GNUNET_BIO_write_string (wh, | 1511 | if (GNUNET_OK != GNUNET_BIO_write_string (wh, |
1512 | "serialization", | ||
1456 | (fi->next != NULL) | 1513 | (fi->next != NULL) |
1457 | ? fi->next->serialization | 1514 | ? fi->next->serialization |
1458 | : NULL)) | 1515 | : NULL)) |
@@ -1460,7 +1517,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1460 | GNUNET_break (0); | 1517 | GNUNET_break (0); |
1461 | goto cleanup; | 1518 | goto cleanup; |
1462 | } | 1519 | } |
1463 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 1520 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
1464 | { | 1521 | { |
1465 | wh = NULL; | 1522 | wh = NULL; |
1466 | GNUNET_break (0); | 1523 | GNUNET_break (0); |
@@ -1469,7 +1526,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1469 | return; /* done! */ | 1526 | return; /* done! */ |
1470 | cleanup: | 1527 | cleanup: |
1471 | if (NULL != wh) | 1528 | if (NULL != wh) |
1472 | (void) GNUNET_BIO_write_close (wh); | 1529 | (void) GNUNET_BIO_write_close (wh, NULL); |
1473 | GNUNET_free_non_null (chks); | 1530 | GNUNET_free_non_null (chks); |
1474 | GNUNET_free_non_null (ksks); | 1531 | GNUNET_free_non_null (ksks); |
1475 | GNUNET_free_non_null (skss); | 1532 | GNUNET_free_non_null (skss); |
@@ -1586,23 +1643,23 @@ deserialize_publish_file (void *cls, const char *filename) | |||
1586 | pc->serialization = get_serialization_short_name (filename); | 1643 | pc->serialization = get_serialization_short_name (filename); |
1587 | fi_root = NULL; | 1644 | fi_root = NULL; |
1588 | fi_pos = NULL; | 1645 | fi_pos = NULL; |
1589 | rh = GNUNET_BIO_read_open (filename); | 1646 | rh = GNUNET_BIO_read_open_file (filename); |
1590 | if (NULL == rh) | 1647 | if (NULL == rh) |
1591 | { | 1648 | { |
1592 | GNUNET_break (0); | 1649 | GNUNET_break (0); |
1593 | goto cleanup; | 1650 | goto cleanup; |
1594 | } | 1651 | } |
1595 | if ((GNUNET_OK != | 1652 | struct GNUNET_BIO_ReadSpec rs[] = { |
1596 | GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) || | 1653 | GNUNET_BIO_read_spec_string ("publish-nid", &pc->nid, 1024), |
1597 | (GNUNET_OK != | 1654 | GNUNET_BIO_read_spec_string ("publish-nuid", &pc->nuid, 1024), |
1598 | GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) || | 1655 | GNUNET_BIO_read_spec_int32 ("options", &options), |
1599 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) || | 1656 | GNUNET_BIO_read_spec_int32 ("all done", &all_done), |
1600 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &all_done)) || | 1657 | GNUNET_BIO_read_spec_int32 ("have ns", &have_ns), |
1601 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &have_ns)) || | 1658 | GNUNET_BIO_read_spec_string ("publish-firoot", &fi_root, 128), |
1602 | (GNUNET_OK != | 1659 | GNUNET_BIO_read_spec_string ("publish-fipos", &fi_pos, 128), |
1603 | GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) || | 1660 | GNUNET_BIO_read_spec_end (), |
1604 | (GNUNET_OK != | 1661 | }; |
1605 | GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) || | 1662 | if ((GNUNET_OK != GNUNET_BIO_read_spec_commit (rh, rs)) || |
1606 | ((GNUNET_YES == have_ns) && | 1663 | ((GNUNET_YES == have_ns) && |
1607 | (GNUNET_OK != GNUNET_BIO_read (rh, "publish-ns", &ns, sizeof(ns))))) | 1664 | (GNUNET_OK != GNUNET_BIO_read (rh, "publish-ns", &ns, sizeof(ns))))) |
1608 | { | 1665 | { |
@@ -1729,26 +1786,30 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) | |||
1729 | goto cleanup; | 1786 | goto cleanup; |
1730 | } | 1787 | } |
1731 | have_ns = (NULL != pc->ns) ? GNUNET_YES : GNUNET_NO; | 1788 | have_ns = (NULL != pc->ns) ? GNUNET_YES : GNUNET_NO; |
1732 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nid)) || | 1789 | struct GNUNET_BIO_WriteSpec ws[] = { |
1733 | (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nuid)) || | 1790 | GNUNET_BIO_write_spec_string ("nid", pc->nid), |
1734 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->options)) || | 1791 | GNUNET_BIO_write_spec_string ("nuid", pc->nuid), |
1735 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->all_done)) || | 1792 | GNUNET_BIO_write_spec_int32 ("options", (int32_t *) &pc->options), |
1736 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, have_ns)) || | 1793 | GNUNET_BIO_write_spec_int32 ("all done", &pc->all_done), |
1737 | (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) || | 1794 | GNUNET_BIO_write_spec_int32 ("have ns", &have_ns), |
1738 | (GNUNET_OK != GNUNET_BIO_write_string (wh, | 1795 | GNUNET_BIO_write_spec_string ("serialization", pc->fi->serialization), |
1739 | (NULL == pc->fi_pos) | 1796 | GNUNET_BIO_write_spec_string ("pos serialization", (NULL == pc->fi_pos) |
1740 | ? NULL | 1797 | ? NULL |
1741 | : pc->fi_pos->serialization)) || | 1798 | : pc->fi_pos->serialization), |
1799 | GNUNET_BIO_read_spec_end () | ||
1800 | }; | ||
1801 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws)) || | ||
1742 | ((NULL != pc->ns) && | 1802 | ((NULL != pc->ns) && |
1743 | (GNUNET_OK != | 1803 | (GNUNET_OK != |
1744 | GNUNET_BIO_write (wh, | 1804 | GNUNET_BIO_write (wh, |
1805 | "ns", | ||
1745 | pc->ns, | 1806 | pc->ns, |
1746 | sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey))))) | 1807 | sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey))))) |
1747 | { | 1808 | { |
1748 | GNUNET_break (0); | 1809 | GNUNET_break (0); |
1749 | goto cleanup; | 1810 | goto cleanup; |
1750 | } | 1811 | } |
1751 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 1812 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
1752 | { | 1813 | { |
1753 | wh = NULL; | 1814 | wh = NULL; |
1754 | GNUNET_break (0); | 1815 | GNUNET_break (0); |
@@ -1757,7 +1818,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) | |||
1757 | return; | 1818 | return; |
1758 | cleanup: | 1819 | cleanup: |
1759 | if (NULL != wh) | 1820 | if (NULL != wh) |
1760 | (void) GNUNET_BIO_write_close (wh); | 1821 | (void) GNUNET_BIO_write_close (wh, NULL); |
1761 | GNUNET_FS_remove_sync_file_ (pc->h, | 1822 | GNUNET_FS_remove_sync_file_ (pc->h, |
1762 | GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, | 1823 | GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, |
1763 | pc->serialization); | 1824 | pc->serialization); |
@@ -1797,25 +1858,34 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) | |||
1797 | uris = GNUNET_FS_uri_to_string (uc->ksk_uri); | 1858 | uris = GNUNET_FS_uri_to_string (uc->ksk_uri); |
1798 | else | 1859 | else |
1799 | uris = NULL; | 1860 | uris = NULL; |
1800 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uc->filename)) || | 1861 | struct GNUNET_BIO_WriteSpec ws1[] = { |
1801 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, uc->file_size)) || | 1862 | GNUNET_BIO_write_spec_string ("filename", uc->filename), |
1863 | GNUNET_BIO_write_spec_int64 ("file size", (int64_t *) &uc->file_size), | ||
1864 | GNUNET_BIO_write_spec_end (), | ||
1865 | }; | ||
1866 | struct GNUNET_BIO_WriteSpec ws2[] = { | ||
1867 | GNUNET_BIO_write_spec_int32 ("state", (int32_t *) &uc->state), | ||
1868 | GNUNET_BIO_write_spec_object ("hashkey", &uc->chk, | ||
1869 | sizeof (struct ContentHashKey)), | ||
1870 | GNUNET_BIO_write_spec_string ("uris", uris), | ||
1871 | GNUNET_BIO_write_spec_int32 ("ksk offset", (int32_t *) &uc->ksk_offset), | ||
1872 | GNUNET_BIO_write_spec_end (), | ||
1873 | }; | ||
1874 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) || | ||
1802 | (GNUNET_OK != write_start_time (wh, uc->start_time)) || | 1875 | (GNUNET_OK != write_start_time (wh, uc->start_time)) || |
1803 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) || | 1876 | (GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws2)) || |
1804 | (GNUNET_OK != | ||
1805 | GNUNET_BIO_write (wh, &uc->chk, sizeof(struct ContentHashKey))) || | ||
1806 | (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || | ||
1807 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->ksk_offset)) || | ||
1808 | ((uc->state == UNINDEX_STATE_FS_NOTIFY) && | 1877 | ((uc->state == UNINDEX_STATE_FS_NOTIFY) && |
1809 | (GNUNET_OK != GNUNET_BIO_write (wh, | 1878 | (GNUNET_OK != GNUNET_BIO_write (wh, |
1879 | "file id", | ||
1810 | &uc->file_id, | 1880 | &uc->file_id, |
1811 | sizeof(struct GNUNET_HashCode)))) || | 1881 | sizeof(struct GNUNET_HashCode)))) || |
1812 | ((uc->state == UNINDEX_STATE_ERROR) && | 1882 | ((uc->state == UNINDEX_STATE_ERROR) && |
1813 | (GNUNET_OK != GNUNET_BIO_write_string (wh, uc->emsg)))) | 1883 | (GNUNET_OK != GNUNET_BIO_write_string (wh, "emsg", uc->emsg)))) |
1814 | { | 1884 | { |
1815 | GNUNET_break (0); | 1885 | GNUNET_break (0); |
1816 | goto cleanup; | 1886 | goto cleanup; |
1817 | } | 1887 | } |
1818 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 1888 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
1819 | { | 1889 | { |
1820 | wh = NULL; | 1890 | wh = NULL; |
1821 | GNUNET_break (0); | 1891 | GNUNET_break (0); |
@@ -1824,7 +1894,7 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) | |||
1824 | return; | 1894 | return; |
1825 | cleanup: | 1895 | cleanup: |
1826 | if (NULL != wh) | 1896 | if (NULL != wh) |
1827 | (void) GNUNET_BIO_write_close (wh); | 1897 | (void) GNUNET_BIO_write_close (wh, NULL); |
1828 | GNUNET_FS_remove_sync_file_ (uc->h, | 1898 | GNUNET_FS_remove_sync_file_ (uc->h, |
1829 | GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, | 1899 | GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, |
1830 | uc->serialization); | 1900 | uc->serialization); |
@@ -1845,15 +1915,20 @@ write_download_request (struct GNUNET_BIO_WriteHandle *wh, | |||
1845 | struct DownloadRequest *dr) | 1915 | struct DownloadRequest *dr) |
1846 | { | 1916 | { |
1847 | unsigned int i; | 1917 | unsigned int i; |
1848 | 1918 | struct GNUNET_BIO_WriteSpec ws[] = { | |
1849 | if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->state)) || | 1919 | GNUNET_BIO_write_spec_int32 ("state", (int32_t *) &dr->state), |
1850 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dr->offset)) || | 1920 | GNUNET_BIO_write_spec_int64 ("offset", (int64_t *) &dr->offset), |
1851 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->num_children)) || | 1921 | GNUNET_BIO_write_spec_int32 ("num children", (int32_t *) &dr->num_children), |
1852 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth))) | 1922 | GNUNET_BIO_write_spec_int32 ("depth", (int32_t *) &dr->depth), |
1923 | GNUNET_BIO_write_spec_end (), | ||
1924 | }; | ||
1925 | |||
1926 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws))) | ||
1853 | return GNUNET_NO; | 1927 | return GNUNET_NO; |
1854 | if ((BRS_CHK_SET == dr->state) && | 1928 | if ((BRS_CHK_SET == dr->state) && |
1855 | (GNUNET_OK != | 1929 | (GNUNET_OK != |
1856 | GNUNET_BIO_write (wh, &dr->chk, sizeof(struct ContentHashKey)))) | 1930 | GNUNET_BIO_write (wh, "hashkey", |
1931 | &dr->chk, sizeof(struct ContentHashKey)))) | ||
1857 | return GNUNET_NO; | 1932 | return GNUNET_NO; |
1858 | for (i = 0; i < dr->num_children; i++) | 1933 | for (i = 0; i < dr->num_children; i++) |
1859 | if (GNUNET_NO == write_download_request (wh, dr->children[i])) | 1934 | if (GNUNET_NO == write_download_request (wh, dr->children[i])) |
@@ -1875,11 +1950,16 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) | |||
1875 | unsigned int i; | 1950 | unsigned int i; |
1876 | 1951 | ||
1877 | dr = GNUNET_new (struct DownloadRequest); | 1952 | dr = GNUNET_new (struct DownloadRequest); |
1878 | if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) || | 1953 | struct GNUNET_BIO_ReadSpec rs[] = { |
1879 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || | 1954 | GNUNET_BIO_read_spec_int32 ("state", (int32_t *) &dr->state), |
1880 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || | 1955 | GNUNET_BIO_read_spec_int64 ("offset", (int64_t *) &dr->offset), |
1956 | GNUNET_BIO_read_spec_int32 ("num children", (int32_t *) &dr->num_children), | ||
1957 | GNUNET_BIO_read_spec_end (), | ||
1958 | }; | ||
1959 | if ((GNUNET_OK != GNUNET_BIO_read_spec_commit (rh, rs)) || | ||
1881 | (dr->num_children > CHK_PER_INODE) || | 1960 | (dr->num_children > CHK_PER_INODE) || |
1882 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || | 1961 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "depth", |
1962 | (int32_t *) &dr->depth)) || | ||
1883 | ((0 == dr->depth) && (dr->num_children > 0)) || | 1963 | ((0 == dr->depth) && (dr->num_children > 0)) || |
1884 | ((dr->depth > 0) && (0 == dr->num_children))) | 1964 | ((dr->depth > 0) && (0 == dr->num_children))) |
1885 | { | 1965 | { |
@@ -2005,7 +2085,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
2005 | return; | 2085 | return; |
2006 | } | 2086 | } |
2007 | } | 2087 | } |
2008 | wh = GNUNET_BIO_write_open (fn); | 2088 | wh = GNUNET_BIO_write_open_file (fn); |
2009 | if (NULL == wh) | 2089 | if (NULL == wh) |
2010 | { | 2090 | { |
2011 | GNUNET_free (dc->serialization); | 2091 | GNUNET_free (dc->serialization); |
@@ -2016,19 +2096,28 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
2016 | GNUNET_assert ((GNUNET_YES == GNUNET_FS_uri_test_chk (dc->uri)) || | 2096 | GNUNET_assert ((GNUNET_YES == GNUNET_FS_uri_test_chk (dc->uri)) || |
2017 | (GNUNET_YES == GNUNET_FS_uri_test_loc (dc->uri))); | 2097 | (GNUNET_YES == GNUNET_FS_uri_test_loc (dc->uri))); |
2018 | uris = GNUNET_FS_uri_to_string (dc->uri); | 2098 | uris = GNUNET_FS_uri_to_string (dc->uri); |
2019 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || | 2099 | struct GNUNET_BIO_WriteSpec ws1[] = { |
2020 | (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, dc->meta)) || | 2100 | GNUNET_BIO_write_spec_string ("uris", uris), |
2021 | (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->emsg)) || | 2101 | GNUNET_BIO_write_spec_meta_data ("metadata", dc->meta), |
2022 | (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->filename)) || | 2102 | GNUNET_BIO_write_spec_string ("emsg", dc->emsg), |
2023 | (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->temp_filename)) || | 2103 | GNUNET_BIO_write_spec_string ("filename", dc->filename), |
2024 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->old_file_size)) || | 2104 | GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename), |
2025 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->offset)) || | 2105 | GNUNET_BIO_write_spec_int64 ("old file size", |
2026 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->length)) || | 2106 | (int64_t *) &dc->old_file_size), |
2027 | (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->completed)) || | 2107 | GNUNET_BIO_write_spec_int64 ("offset", (int64_t *) &dc->offset), |
2108 | GNUNET_BIO_write_spec_int64 ("length", (int64_t *) &dc->length), | ||
2109 | GNUNET_BIO_write_spec_int64 ("completed", (int64_t *) &dc->completed), | ||
2110 | GNUNET_BIO_write_spec_end (), | ||
2111 | }; | ||
2112 | struct GNUNET_BIO_WriteSpec ws2[] = { | ||
2113 | GNUNET_BIO_write_spec_int32 ("anonymity", (int32_t *) &dc->anonymity), | ||
2114 | GNUNET_BIO_write_spec_int32 ("options", (int32_t *) &dc->options), | ||
2115 | GNUNET_BIO_write_spec_int32 ("has finished", (int32_t *) &dc->has_finished), | ||
2116 | GNUNET_BIO_write_spec_end (), | ||
2117 | }; | ||
2118 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) || | ||
2028 | (GNUNET_OK != write_start_time (wh, dc->start_time)) || | 2119 | (GNUNET_OK != write_start_time (wh, dc->start_time)) || |
2029 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dc->anonymity)) || | 2120 | (GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws2))) |
2030 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) || | ||
2031 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->has_finished))) | ||
2032 | { | 2121 | { |
2033 | GNUNET_break (0); | 2122 | GNUNET_break (0); |
2034 | goto cleanup; | 2123 | goto cleanup; |
@@ -2044,7 +2133,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
2044 | } | 2133 | } |
2045 | GNUNET_free_non_null (uris); | 2134 | GNUNET_free_non_null (uris); |
2046 | uris = NULL; | 2135 | uris = NULL; |
2047 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 2136 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
2048 | { | 2137 | { |
2049 | wh = NULL; | 2138 | wh = NULL; |
2050 | GNUNET_break (0); | 2139 | GNUNET_break (0); |
@@ -2054,7 +2143,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
2054 | return; | 2143 | return; |
2055 | cleanup: | 2144 | cleanup: |
2056 | if (NULL != wh) | 2145 | if (NULL != wh) |
2057 | (void) GNUNET_BIO_write_close (wh); | 2146 | (void) GNUNET_BIO_write_close (wh, NULL); |
2058 | GNUNET_free_non_null (uris); | 2147 | GNUNET_free_non_null (uris); |
2059 | if (0 != unlink (fn)) | 2148 | if (0 != unlink (fn)) |
2060 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); | 2149 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
@@ -2102,23 +2191,30 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) | |||
2102 | goto cleanup; | 2191 | goto cleanup; |
2103 | } | 2192 | } |
2104 | uris = GNUNET_FS_uri_to_string (sr->uri); | 2193 | uris = GNUNET_FS_uri_to_string (sr->uri); |
2105 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || | 2194 | struct GNUNET_BIO_WriteSpec ws[] = { |
2106 | (GNUNET_OK != GNUNET_BIO_write_string (wh, | 2195 | GNUNET_BIO_write_spec_string ("uris", uris), |
2107 | (sr->download != NULL) | 2196 | GNUNET_BIO_write_spec_string ("download serialization", |
2108 | ? sr->download->serialization | 2197 | (sr->download != NULL) |
2109 | : NULL)) || | 2198 | ? sr->download->serialization |
2110 | (GNUNET_OK != | 2199 | : NULL), |
2111 | GNUNET_BIO_write_string (wh, | 2200 | GNUNET_BIO_write_spec_string ("update search serialization", |
2112 | (sr->update_search != NULL) | 2201 | (sr->update_search != NULL) |
2113 | ? sr->update_search->serialization | 2202 | ? sr->update_search->serialization |
2114 | : NULL)) || | 2203 | : NULL), |
2115 | (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, sr->meta)) || | 2204 | GNUNET_BIO_write_spec_meta_data ("metadata", sr->meta), |
2116 | (GNUNET_OK != | 2205 | GNUNET_BIO_write_spec_object ("key", &sr->key, |
2117 | GNUNET_BIO_write (wh, &sr->key, sizeof(struct GNUNET_HashCode))) || | 2206 | sizeof(struct GNUNET_HashCode)), |
2118 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->mandatory_missing)) || | 2207 | GNUNET_BIO_write_spec_int32 ("mandatory missing", |
2119 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->optional_support)) || | 2208 | (int32_t *) &sr->mandatory_missing), |
2120 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->availability_success)) || | 2209 | GNUNET_BIO_write_spec_int32 ("optional support", |
2121 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sr->availability_trials))) | 2210 | (int32_t *) &sr->optional_support), |
2211 | GNUNET_BIO_write_spec_int32 ("availability success", | ||
2212 | (int32_t *) &sr->availability_success), | ||
2213 | GNUNET_BIO_write_spec_int32 ("availability trials", | ||
2214 | (int32_t *) &sr->availability_trials), | ||
2215 | GNUNET_BIO_write_spec_end (), | ||
2216 | }; | ||
2217 | if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws))) | ||
2122 | { | 2218 | { |
2123 | GNUNET_break (0); | 2219 | GNUNET_break (0); |
2124 | goto cleanup; | 2220 | goto cleanup; |
@@ -2126,13 +2222,14 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) | |||
2126 | if ((NULL != sr->uri) && (GNUNET_FS_URI_KSK == sr->sc->uri->type) && | 2222 | if ((NULL != sr->uri) && (GNUNET_FS_URI_KSK == sr->sc->uri->type) && |
2127 | (GNUNET_OK != | 2223 | (GNUNET_OK != |
2128 | GNUNET_BIO_write (wh, | 2224 | GNUNET_BIO_write (wh, |
2225 | "keyword bitmap", | ||
2129 | sr->keyword_bitmap, | 2226 | sr->keyword_bitmap, |
2130 | (sr->sc->uri->data.ksk.keywordCount + 7) / 8))) | 2227 | (sr->sc->uri->data.ksk.keywordCount + 7) / 8))) |
2131 | { | 2228 | { |
2132 | GNUNET_break (0); | 2229 | GNUNET_break (0); |
2133 | goto cleanup; | 2230 | goto cleanup; |
2134 | } | 2231 | } |
2135 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 2232 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
2136 | { | 2233 | { |
2137 | wh = NULL; | 2234 | wh = NULL; |
2138 | GNUNET_break (0); | 2235 | GNUNET_break (0); |
@@ -2143,7 +2240,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) | |||
2143 | cleanup: | 2240 | cleanup: |
2144 | GNUNET_free_non_null (uris); | 2241 | GNUNET_free_non_null (uris); |
2145 | if (NULL != wh) | 2242 | if (NULL != wh) |
2146 | (void) GNUNET_BIO_write_close (wh); | 2243 | (void) GNUNET_BIO_write_close (wh, NULL); |
2147 | remove_sync_file_in_dir (sr->h, | 2244 | remove_sync_file_in_dir (sr->h, |
2148 | (NULL == sr->sc->psearch_result) | 2245 | (NULL == sr->sc->psearch_result) |
2149 | ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH | 2246 | ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH |
@@ -2188,19 +2285,21 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) | |||
2188 | (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri))); | 2285 | (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri))); |
2189 | uris = GNUNET_FS_uri_to_string (sc->uri); | 2286 | uris = GNUNET_FS_uri_to_string (sc->uri); |
2190 | in_pause = (sc->task != NULL) ? 'r' : '\0'; | 2287 | in_pause = (sc->task != NULL) ? 'r' : '\0'; |
2191 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || | 2288 | if ((GNUNET_OK != GNUNET_BIO_write_string (wh, "uris", uris)) || |
2192 | (GNUNET_OK != write_start_time (wh, sc->start_time)) || | 2289 | (GNUNET_OK != write_start_time (wh, sc->start_time)) || |
2193 | (GNUNET_OK != GNUNET_BIO_write_string (wh, sc->emsg)) || | 2290 | (GNUNET_OK != GNUNET_BIO_write_string (wh, "emsg", sc->emsg)) || |
2194 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) || | 2291 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, "options", |
2195 | (GNUNET_OK != GNUNET_BIO_write (wh, &in_pause, sizeof(in_pause))) || | 2292 | (uint32_t) sc->options)) || |
2196 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sc->anonymity))) | 2293 | (GNUNET_OK != GNUNET_BIO_write (wh, "in pause", |
2294 | &in_pause, sizeof(in_pause))) || | ||
2295 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, "anonymity", sc->anonymity))) | ||
2197 | { | 2296 | { |
2198 | GNUNET_break (0); | 2297 | GNUNET_break (0); |
2199 | goto cleanup; | 2298 | goto cleanup; |
2200 | } | 2299 | } |
2201 | GNUNET_free (uris); | 2300 | GNUNET_free (uris); |
2202 | uris = NULL; | 2301 | uris = NULL; |
2203 | if (GNUNET_OK != GNUNET_BIO_write_close (wh)) | 2302 | if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) |
2204 | { | 2303 | { |
2205 | wh = NULL; | 2304 | wh = NULL; |
2206 | GNUNET_break (0); | 2305 | GNUNET_break (0); |
@@ -2209,7 +2308,7 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) | |||
2209 | return; | 2308 | return; |
2210 | cleanup: | 2309 | cleanup: |
2211 | if (NULL != wh) | 2310 | if (NULL != wh) |
2212 | (void) GNUNET_BIO_write_close (wh); | 2311 | (void) GNUNET_BIO_write_close (wh, NULL); |
2213 | GNUNET_free_non_null (uris); | 2312 | GNUNET_free_non_null (uris); |
2214 | GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization); | 2313 | GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization); |
2215 | GNUNET_free (sc->serialization); | 2314 | GNUNET_free (sc->serialization); |
@@ -2239,7 +2338,7 @@ deserialize_unindex_file (void *cls, const char *filename) | |||
2239 | uc = GNUNET_new (struct GNUNET_FS_UnindexContext); | 2338 | uc = GNUNET_new (struct GNUNET_FS_UnindexContext); |
2240 | uc->h = h; | 2339 | uc->h = h; |
2241 | uc->serialization = get_serialization_short_name (filename); | 2340 | uc->serialization = get_serialization_short_name (filename); |
2242 | rh = GNUNET_BIO_read_open (filename); | 2341 | rh = GNUNET_BIO_read_open_file (filename); |
2243 | if (NULL == rh) | 2342 | if (NULL == rh) |
2244 | { | 2343 | { |
2245 | GNUNET_break (0); | 2344 | GNUNET_break (0); |
@@ -2248,14 +2347,17 @@ deserialize_unindex_file (void *cls, const char *filename) | |||
2248 | uris = NULL; | 2347 | uris = NULL; |
2249 | if ((GNUNET_OK != | 2348 | if ((GNUNET_OK != |
2250 | GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10 * 1024)) || | 2349 | GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10 * 1024)) || |
2251 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &uc->file_size)) || | 2350 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, "file size", |
2351 | (int64_t *) &uc->file_size)) || | ||
2252 | (GNUNET_OK != read_start_time (rh, &uc->start_time)) || | 2352 | (GNUNET_OK != read_start_time (rh, &uc->start_time)) || |
2253 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &state)) || | 2353 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "state", |
2354 | (int32_t *) &state)) || | ||
2254 | (GNUNET_OK != | 2355 | (GNUNET_OK != |
2255 | GNUNET_BIO_read (rh, "uri", &uc->chk, sizeof(struct ContentHashKey))) || | 2356 | GNUNET_BIO_read (rh, "uri", &uc->chk, sizeof(struct ContentHashKey))) || |
2256 | (GNUNET_OK != | 2357 | (GNUNET_OK != |
2257 | GNUNET_BIO_read_string (rh, "unindex-kskuri", &uris, 10 * 1024)) || | 2358 | GNUNET_BIO_read_string (rh, "unindex-kskuri", &uris, 10 * 1024)) || |
2258 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &uc->ksk_offset))) | 2359 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "ksk offset", |
2360 | (int32_t *) &uc->ksk_offset))) | ||
2259 | { | 2361 | { |
2260 | GNUNET_free_non_null (uris); | 2362 | GNUNET_free_non_null (uris); |
2261 | GNUNET_break (0); | 2363 | GNUNET_break (0); |
@@ -2443,7 +2545,7 @@ deserialize_search_result (void *cls, const char *filename) | |||
2443 | struct GNUNET_FS_SearchResult *sr; | 2545 | struct GNUNET_FS_SearchResult *sr; |
2444 | 2546 | ||
2445 | ser = get_serialization_short_name (filename); | 2547 | ser = get_serialization_short_name (filename); |
2446 | rh = GNUNET_BIO_read_open (filename); | 2548 | rh = GNUNET_BIO_read_open_file (filename); |
2447 | if (NULL == rh) | 2549 | if (NULL == rh) |
2448 | { | 2550 | { |
2449 | if (NULL != ser) | 2551 | if (NULL != ser) |
@@ -2478,10 +2580,22 @@ deserialize_search_result (void *cls, const char *filename) | |||
2478 | "result-key", | 2580 | "result-key", |
2479 | &sr->key, | 2581 | &sr->key, |
2480 | sizeof(struct GNUNET_HashCode))) || | 2582 | sizeof(struct GNUNET_HashCode))) || |
2481 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) || | 2583 | (GNUNET_OK != GNUNET_BIO_read_int32 ( |
2482 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->optional_support)) || | 2584 | rh, |
2483 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->availability_success)) || | 2585 | "mandatory missing", |
2484 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->availability_trials))) | 2586 | (int32_t *) &sr->mandatory_missing)) || |
2587 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
2588 | rh, | ||
2589 | "optional support", | ||
2590 | (int32_t *) &sr->optional_support)) || | ||
2591 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
2592 | rh, | ||
2593 | "availability success", | ||
2594 | (int32_t *) &sr->availability_success)) || | ||
2595 | (GNUNET_OK != GNUNET_BIO_read_int32 ( | ||
2596 | rh, | ||
2597 | "availability trials", | ||
2598 | (int32_t *) &sr->availability_trials))) | ||
2485 | { | 2599 | { |
2486 | GNUNET_break (0); | 2600 | GNUNET_break (0); |
2487 | goto cleanup; | 2601 | goto cleanup; |
@@ -2741,7 +2855,7 @@ deserialize_subdownload (void *cls, const char *filename) | |||
2741 | struct GNUNET_BIO_ReadHandle *rh; | 2855 | struct GNUNET_BIO_ReadHandle *rh; |
2742 | 2856 | ||
2743 | ser = get_serialization_short_name (filename); | 2857 | ser = get_serialization_short_name (filename); |
2744 | rh = GNUNET_BIO_read_open (filename); | 2858 | rh = GNUNET_BIO_read_open_file (filename); |
2745 | if (NULL == rh) | 2859 | if (NULL == rh) |
2746 | { | 2860 | { |
2747 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2861 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -2827,29 +2941,35 @@ deserialize_download (struct GNUNET_FS_Handle *h, | |||
2827 | dc->parent = parent; | 2941 | dc->parent = parent; |
2828 | dc->h = h; | 2942 | dc->h = h; |
2829 | dc->serialization = GNUNET_strdup (serialization); | 2943 | dc->serialization = GNUNET_strdup (serialization); |
2944 | struct GNUNET_BIO_ReadSpec rs[] = { | ||
2945 | GNUNET_BIO_read_spec_meta_data ("download-meta", &dc->meta), | ||
2946 | GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024), | ||
2947 | GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024), | ||
2948 | GNUNET_BIO_read_spec_string ("download-tfn", | ||
2949 | &dc->temp_filename, 10 * 1024), | ||
2950 | GNUNET_BIO_read_spec_int64 ("old file size", | ||
2951 | (int64_t *) &dc->old_file_size), | ||
2952 | GNUNET_BIO_read_spec_int64 ("offset", | ||
2953 | (int64_t *) &dc->offset), | ||
2954 | GNUNET_BIO_read_spec_int64 ("length", | ||
2955 | (int64_t *) &dc->length), | ||
2956 | GNUNET_BIO_read_spec_int64 ("completed", | ||
2957 | (int64_t *) &dc->completed), | ||
2958 | GNUNET_BIO_read_spec_end (), | ||
2959 | }; | ||
2830 | if ((GNUNET_OK != | 2960 | if ((GNUNET_OK != |
2831 | GNUNET_BIO_read_string (rh, "download-uri", &uris, 10 * 1024)) || | 2961 | GNUNET_BIO_read_string (rh, "download-uri", &uris, 10 * 1024)) || |
2832 | (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || | 2962 | (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || |
2833 | ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) && | 2963 | ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) && |
2834 | (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) || | 2964 | (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) || |
2835 | (GNUNET_OK != | 2965 | (GNUNET_OK != GNUNET_BIO_read_spec_commit (rh, rs)) || |
2836 | GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta)) || | ||
2837 | (GNUNET_OK != | ||
2838 | GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) || | ||
2839 | (GNUNET_OK != | ||
2840 | GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) || | ||
2841 | (GNUNET_OK != GNUNET_BIO_read_string (rh, | ||
2842 | "download-tfn", | ||
2843 | &dc->temp_filename, | ||
2844 | 10 * 1024)) || | ||
2845 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->old_file_size)) || | ||
2846 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->offset)) || | ||
2847 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->length)) || | ||
2848 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dc->completed)) || | ||
2849 | (GNUNET_OK != read_start_time (rh, &dc->start_time)) || | 2966 | (GNUNET_OK != read_start_time (rh, &dc->start_time)) || |
2850 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dc->anonymity)) || | 2967 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "anonymity", |
2851 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) || | 2968 | (int32_t *) &dc->anonymity)) || |
2852 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &status))) | 2969 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "options", |
2970 | (int32_t *) &options)) || | ||
2971 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "status", | ||
2972 | (int32_t *) &status))) | ||
2853 | { | 2973 | { |
2854 | GNUNET_break (0); | 2974 | GNUNET_break (0); |
2855 | goto cleanup; | 2975 | goto cleanup; |
@@ -2972,10 +3092,12 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2972 | (GNUNET_OK != read_start_time (rh, &sc->start_time)) || | 3092 | (GNUNET_OK != read_start_time (rh, &sc->start_time)) || |
2973 | (GNUNET_OK != | 3093 | (GNUNET_OK != |
2974 | GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10 * 1024)) || | 3094 | GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10 * 1024)) || |
2975 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) || | 3095 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "options", |
3096 | (int32_t *) &options)) || | ||
2976 | (GNUNET_OK != | 3097 | (GNUNET_OK != |
2977 | GNUNET_BIO_read (rh, "search-pause", &in_pause, sizeof(in_pause))) || | 3098 | GNUNET_BIO_read (rh, "search-pause", &in_pause, sizeof(in_pause))) || |
2978 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sc->anonymity))) | 3099 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "anonymity", |
3100 | (int32_t *) &sc->anonymity))) | ||
2979 | { | 3101 | { |
2980 | GNUNET_break (0); | 3102 | GNUNET_break (0); |
2981 | goto cleanup; | 3103 | goto cleanup; |
@@ -3038,7 +3160,7 @@ deserialize_search_file (void *cls, const char *filename) | |||
3038 | if (S_ISDIR (buf.st_mode)) | 3160 | if (S_ISDIR (buf.st_mode)) |
3039 | return GNUNET_OK; /* skip directories */ | 3161 | return GNUNET_OK; /* skip directories */ |
3040 | ser = get_serialization_short_name (filename); | 3162 | ser = get_serialization_short_name (filename); |
3041 | rh = GNUNET_BIO_read_open (filename); | 3163 | rh = GNUNET_BIO_read_open_file (filename); |
3042 | if (NULL == rh) | 3164 | if (NULL == rh) |
3043 | { | 3165 | { |
3044 | if (NULL != ser) | 3166 | if (NULL != ser) |
@@ -3081,7 +3203,7 @@ deserialize_download_file (void *cls, const char *filename) | |||
3081 | struct GNUNET_BIO_ReadHandle *rh; | 3203 | struct GNUNET_BIO_ReadHandle *rh; |
3082 | 3204 | ||
3083 | ser = get_serialization_short_name (filename); | 3205 | ser = get_serialization_short_name (filename); |
3084 | rh = GNUNET_BIO_read_open (filename); | 3206 | rh = GNUNET_BIO_read_open_file (filename); |
3085 | if (NULL == rh) | 3207 | if (NULL == rh) |
3086 | { | 3208 | { |
3087 | if (0 != unlink (filename)) | 3209 | if (0 != unlink (filename)) |