]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - lib/File/KDBX/Dumper/V4.pm
Add support for 32-bit perls
[chaz/p5-File-KDBX] / lib / File / KDBX / Dumper / V4.pm
index f2a8574e8b55413419c4b9c974340cc5e5d11549..8765e0211a9b4a8b105c57ef3e216cb337509d98 100644 (file)
@@ -11,7 +11,7 @@ use File::KDBX::Constants qw(:header :inner_header :compression :kdf :variant_ma
 use File::KDBX::Error;
 use File::KDBX::IO::Crypt;
 use File::KDBX::IO::HmacBlock;
-use File::KDBX::Util qw(:class :empty :load assert_64bit erase_scoped);
+use File::KDBX::Util qw(:class :empty :int :load erase_scoped);
 use IO::Handle;
 use Scalar::Util qw(looks_like_number);
 use boolean qw(:all);
@@ -61,7 +61,7 @@ sub _write_header {
     my $type = shift;
     my $val  = shift // '';
 
-    $type = kdbx_header($type);
+    $type = to_header_constant($type);
     if ($type == HEADER_END) {
         # nothing
     }
@@ -129,9 +129,8 @@ sub _intuit_variant_type {
         return VMAP_TYPE_BOOL;
     }
     elsif (looks_like_number($variant) && ($variant + 0) =~ /^\d+$/) {
-        assert_64bit;
         my $neg = $variant < 0;
-        my @b = unpack('L>2', pack('Q>', $variant));
+        my @b = unpack('L>2', scalar reverse pack_Ql($variant));
         return VMAP_TYPE_INT64  if $b[0] && $neg;
         return VMAP_TYPE_UINT64 if $b[0];
         return VMAP_TYPE_INT32  if $neg;
@@ -162,8 +161,7 @@ sub _write_variant_dictionary {
             $val = pack('L<', $val);
         }
         elsif ($type == VMAP_TYPE_UINT64) {
-            assert_64bit;
-            $val = pack('Q<', $val);
+            $val = pack_Ql($val);
         }
         elsif ($type == VMAP_TYPE_BOOL) {
             $val = pack('C', $val);
@@ -172,8 +170,7 @@ sub _write_variant_dictionary {
             $val = pack('l', $val);
         }
         elsif ($type == VMAP_TYPE_INT64) {
-            assert_64bit;
-            $val = pack('q<', $val);
+            $val = pack_ql($val);
         }
         elsif ($type == VMAP_TYPE_STRING) {
             $val = encode('UTF-8', $val);
@@ -289,8 +286,7 @@ sub _write_inner_header {
     my $buf = pack('C', $type);
     $fh->print($buf) or throw 'Failed to write inner header type';
 
-    $type = kdbx_inner_header($type);
-
+    $type = to_inner_header_constant($type);
     if ($type == INNER_HEADER_END) {
         # nothing
     }
@@ -318,8 +314,8 @@ sub _write_binaries {
     my $new_ref = 0;
     my $written = $self->_binaries_written;
 
-    my $entries = $kdbx->all_entries(history => true);
-    for my $entry (@$entries) {
+    my $entries = $kdbx->entries(history => 1);
+    while (my $entry = $entries->next) {
         for my $key (keys %{$entry->binaries}) {
             my $binary = $entry->binaries->{$key};
             if (defined $binary->{ref} && defined $kdbx->binaries->{$binary->{ref}}) {
This page took 0.024024 seconds and 4 git commands to generate.