X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FConstants.pm;h=6f88b252cb35092be24d1b59d1dc744776336f34;hb=0f9150d48f698cf468d3d814e52ee9f15572809b;hp=ea4e02636d56900fee53f42e299f9fc964ea8db5;hpb=05e0bcef1c2165c556b910314312866dc4a667b7;p=chaz%2Fp5-File-KDBX diff --git a/lib/File/KDBX/Constants.pm b/lib/File/KDBX/Constants.pm index ea4e026..6f88b25 100644 --- a/lib/File/KDBX/Constants.pm +++ b/lib/File/KDBX/Constants.pm @@ -274,9 +274,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 +291,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 +306,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 +324,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 +405,13 @@ Constants related to parsing and generating KDBX file headers: = C = C = C -= C + +=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,6 +421,13 @@ Constants related to identifying the compression state of a file: = C = C +=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: @@ -484,7 +503,13 @@ Constants related to parsing and generating KDBX4 inner headers: = C = C = C -= C + +=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 @@ -579,6 +604,13 @@ Constants for default icons used by KeePass password safe implementations: = C = C +=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: