summaryrefslogtreecommitdiff
path: root/libarchive/test/test_read_format_cab_filename.c
diff options
context:
space:
mode:
authorKonrad Kleine <konrad.wilhelm.kleine@gmail.com>2013-10-09 13:53:15 +0200
committerKonrad Kleine <konrad.wilhelm.kleine@gmail.com>2013-10-09 13:53:15 +0200
commit2de568ca5b0ccdbababf6e3857e2e05eea9eb0a6 (patch)
tree1a8e5ab4c68d4953b08f799543f211fae7d7b407 /libarchive/test/test_read_format_cab_filename.c
parentfec2ae3cd3b16ae97a8bf3ff2c8b878697e9852e (diff)
downloadlibarchive-2de568ca5b0ccdbababf6e3857e2e05eea9eb0a6.tar.gz
Better archive_read_has_encrypted_entries function
These are the possible return values: ===================================== ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED (-2): ------------------------------------------------ This is the default return value for reader that don't support encrpytion detection at all. When this value is returned you can be sure that it will always be returned even on later calls to archive_read_has_encrypted_entries. ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW (-1): ---------------------------------------------- This is the default return value for readers that support encryption. It means that the reader is not yet ready (e.g. not enough data was read so far) to say that there are encrypted entries in the archive. Over time as more data was consumed by a reader this value might change to 0 or 1. 0: -- No encrypted entries were found yet (maybe there will be one when reading the next header). When 0 is returned, it might be that on a later call 1 will be returned. 1: -- At least one encrypted entry was found. Once 1 is returned. It will always be returned even if the another entry is not encrypted. NOTE: ===== If the metadata/header of an archive is also encrypted, you cannot rely on the number of encrypted entries. That is why this function does not return the number of encrypted entries but just 1 to show that there are some. Also, two distinct readers might detect the number of entries and their encryption status at different times. If one reader can say how many files are encrypted after reading the first header another reader might need more data. In the end the number of encrypted entries might be the same in two archives while the appropriate readers output different results at different points in time. This is more confusing than helpful.
Diffstat (limited to 'libarchive/test/test_read_format_cab_filename.c')
-rw-r--r--libarchive/test/test_read_format_cab_filename.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libarchive/test/test_read_format_cab_filename.c b/libarchive/test/test_read_format_cab_filename.c
index 885f750a..2f46a7e6 100644
--- a/libarchive/test/test_read_format_cab_filename.c
+++ b/libarchive/test/test_read_format_cab_filename.c
@@ -59,7 +59,7 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname)
archive_entry_pathname(ae));
assertEqualInt(5, archive_entry_size(ae));
assertEqualInt(archive_entry_is_encrypted(ae), 0);
- assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
/* Verify regular file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -68,7 +68,7 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname)
archive_entry_pathname(ae));
assertEqualInt(5, archive_entry_size(ae));
assertEqualInt(archive_entry_is_encrypted(ae), 0);
- assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
/* End of archive. */
@@ -127,7 +127,7 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname)
assertEqualInt(5, archive_entry_size(ae));
#endif
assertEqualInt(archive_entry_is_encrypted(ae), 0);
- assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
/* Verify regular file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -146,7 +146,7 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname)
#endif
assertEqualInt(5, archive_entry_size(ae));
assertEqualInt(archive_entry_is_encrypted(ae), 0);
- assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
/* End of archive. */