]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - lib/File/KDBX/Constants.pm
Fix documentation typos
[chaz/p5-File-KDBX] / lib / File / KDBX / Constants.pm
index ea4e02636d56900fee53f42e299f9fc964ea8db5..e5f5f1d0c7b7670c1338072619c0ef0850cc5906 100644 (file)
@@ -6,10 +6,12 @@ package File::KDBX::Constants;
 #  2. List it in the pod at the bottom of this file in the section corresponding to its tag.
 #  3. There is no step three.
 
+use 5.010;
 use warnings;
 use strict;
 
 use Exporter qw(import);
+use File::KDBX::Util qw(int64);
 use Scalar::Util qw(dualvar);
 use namespace::clean -except => 'import';
 
@@ -126,8 +128,14 @@ BEGIN {
         },
         history     => {
             __prefix            => 'HISTORY',
+            DEFAULT_MAX_AGE     => 365,
             DEFAULT_MAX_ITEMS   => 10,
-            DEFAULT_MAX_SIZE    => 6_291_456, # 6 M
+            DEFAULT_MAX_SIZE    => 6_291_456, # 6 MiB
+        },
+        iteration   => {
+            ITERATION_BFS   => dualvar(1, 'bfs'),
+            ITERATION_DFS   => dualvar(2, 'dfs'),
+            ITERATION_IDS   => dualvar(3, 'ids'),
         },
         icon        => {
             __prefix            => 'ICON',
@@ -207,7 +215,7 @@ BEGIN {
         },
         time        => {
             __prefix                    => 'TIME',
-            SECONDS_AD1_TO_UNIX_EPOCH   => 62_135_596_800,
+            SECONDS_AD1_TO_UNIX_EPOCH   => int64('62135596800'),
         },
         yubikey     => {
             YUBICO_VID              => dualvar( 0x1050, 'Yubico'),
@@ -274,9 +282,10 @@ BEGIN {
 }
 
 our %EXPORT_TAGS;
-push @{$EXPORT_TAGS{header}}, 'KDBX_HEADER';
-push @{$EXPORT_TAGS{inner_header}}, 'KDBX_INNER_HEADER';
-push @{$EXPORT_TAGS{icon}}, 'icon';
+push @{$EXPORT_TAGS{header}},       'to_header_constant';
+push @{$EXPORT_TAGS{compression}},  'to_compression_constant';
+push @{$EXPORT_TAGS{inner_header}}, 'to_inner_header_constant';
+push @{$EXPORT_TAGS{icon}},         'to_icon_constant';
 
 $EXPORT_TAGS{all} = [map { @$_ } values %EXPORT_TAGS];
 our @EXPORT_OK = sort @{$EXPORT_TAGS{all}};
@@ -290,8 +299,13 @@ for my $header (
 ) {
     $HEADER{$header} = $HEADER{0+$header} = $header;
 }
-sub KDBX_HEADER { $HEADER{$_[0]} }
+sub to_header_constant { $HEADER{$_[0] // ''} }
 
+my %COMPRESSION;
+for my $compression (COMPRESSION_NONE, COMPRESSION_GZIP) {
+    $COMPRESSION{$compression} = $COMPRESSION{0+$compression} = $compression;
+}
+sub to_compression_constant { $COMPRESSION{$_[0] // ''} }
 
 my %INNER_HEADER;
 for my $inner_header (
@@ -300,7 +314,7 @@ for my $inner_header (
 ) {
     $INNER_HEADER{$inner_header} = $INNER_HEADER{0+$inner_header} = $inner_header;
 }
-sub KDBX_INNER_HEADER { $INNER_HEADER{$_[0]} }
+sub to_inner_header_constant { $INNER_HEADER{$_[0] // ''} }
 
 my %ICON;
 for my $icon (
@@ -318,7 +332,7 @@ for my $icon (
 ) {
     $ICON{$icon} = $ICON{0+$icon} = $icon;
 }
-sub icon { $ICON{$_[0] // ''} // ICON_PASSWORD }
+sub to_icon_constant { $ICON{$_[0] // ''} // ICON_PASSWORD }
 
 1;
 __END__
@@ -399,7 +413,13 @@ Constants related to parsing and generating KDBX file headers:
 = C<HEADER_INNER_RANDOM_STREAM_ID>
 = C<HEADER_KDF_PARAMETERS>
 = C<HEADER_PUBLIC_CUSTOM_DATA>
-= C<KDBX_HEADER>
+
+=func to_header_constant
+
+    $constant = to_header_constant($number);
+    $constant = to_header_constant($string);
+
+Get a header constant from an integer or string value.
 
 =head2 :compression
 
@@ -409,9 +429,16 @@ Constants related to identifying the compression state of a file:
 = C<COMPRESSION_NONE>
 = C<COMPRESSION_GZIP>
 
+=func to_compression_constant
+
+    $constant = to_compression_constant($number);
+    $constant = to_compression_constant($string);
+
+Get a compression constant from an integer or string value.
+
 =head2 :cipher
 
-Constants related ciphers:
+Constants related to ciphers:
 
 =for :list
 = C<CIPHER_UUID_AES128>
@@ -484,7 +511,13 @@ Constants related to parsing and generating KDBX4 inner headers:
 = C<INNER_HEADER_INNER_RANDOM_STREAM_KEY>
 = C<INNER_HEADER_BINARY>
 = C<INNER_HEADER_BINARY_FLAG_PROTECT>
-= C<KDBX_INNER_HEADER>
+
+=func to_inner_header_constant
+
+    $constant = to_inner_header_constant($number);
+    $constant = to_inner_header_constant($string);
+
+Get an inner header constant from an integer or string value.
 
 =head2 :key_file
 
@@ -501,9 +534,19 @@ Constants related to identifying key file types:
 Constants for history-related default values:
 
 =for :list
+= C<HISTORY_DEFAULT_MAX_AGE>
 = C<HISTORY_DEFAULT_MAX_ITEMS>
 = C<HISTORY_DEFAULT_MAX_SIZE>
 
+=head2 :iteration
+
+Constants for searching algorithms.
+
+=for :list
+= C<ITERATION_IDS> - Iterative deepening search
+= C<ITERATION_BFS> - Breadth-first search
+= C<ITERATION_DFS> - Depth-first search
+
 =head2 :icon
 
 Constants for default icons used by KeePass password safe implementations:
@@ -579,6 +622,13 @@ Constants for default icons used by KeePass password safe implementations:
 = C<ICON_CERTIFICATE>
 = C<ICON_SMARTPHONE>
 
+=func to_icon_constant
+
+    $constant = to_icon_constant($number);
+    $constant = to_icon_constant($string);
+
+Get an icon constant from an integer or string value.
+
 =head2 :bool
 
 Boolean values:
This page took 0.026532 seconds and 4 git commands to generate.