X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FConstants.pm;h=2bc6c8b6ab1ad7415ceb2fa78f41120fa7cf5fa4;hb=aa81281930c0a90b6c7d6b555f2688d418cf6abc;hp=51e7e4cac8d4be1897c096c298d4225ce809afcc;hpb=b4e8407685b3f9ce0193aedf05f6651ed588a448;p=chaz%2Fp5-File-KDBX diff --git a/lib/File/KDBX/Constants.pm b/lib/File/KDBX/Constants.pm index 51e7e4c..2bc6c8b 100644 --- a/lib/File/KDBX/Constants.pm +++ b/lib/File/KDBX/Constants.pm @@ -126,8 +126,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', @@ -274,8 +280,10 @@ BEGIN { } our %EXPORT_TAGS; -push @{$EXPORT_TAGS{header}}, 'KDBX_HEADER'; -push @{$EXPORT_TAGS{inner_header}}, 'KDBX_INNER_HEADER'; +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}}; @@ -289,8 +297,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 ( @@ -299,7 +312,25 @@ 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 ( + ICON_PASSWORD, ICON_PACKAGE_NETWORK, ICON_MESSAGEBOX_WARNING, ICON_SERVER, ICON_KLIPPER, + ICON_EDU_LANGUAGES, ICON_KCMDF, ICON_KATE, ICON_SOCKET, ICON_IDENTITY, ICON_KONTACT, ICON_CAMERA, + ICON_IRKICKFLASH, ICON_KGPG_KEY3, ICON_LAPTOP_POWER, ICON_SCANNER, ICON_MOZILLA_FIREBIRD, + ICON_CDROM_UNMOUNT, ICON_DISPLAY, ICON_MAIL_GENERIC, ICON_MISC, ICON_KORGANIZER, ICON_ASCII, ICON_ICONS, + ICON_CONNECT_ESTABLISHED, ICON_FOLDER_MAIL, ICON_FILESAVE, ICON_NFS_UNMOUNT, ICON_MESSAGE, ICON_KGPG_TERM, + ICON_KONSOLE, ICON_FILEPRINT, ICON_FSVIEW, ICON_RUN, ICON_CONFIGURE, ICON_KRFB, ICON_ARK, + ICON_KPERCENTAGE, ICON_SAMBA_UNMOUNT, ICON_HISTORY, ICON_MAIL_FIND, ICON_VECTORGFX, ICON_KCMMEMORY, + ICON_TRASHCAN_FULL, ICON_KNOTES, ICON_CANCEL, ICON_HELP, ICON_KPACKAGE, ICON_FOLDER, + ICON_FOLDER_BLUE_OPEN, ICON_FOLDER_TAR, ICON_DECRYPTED, ICON_ENCRYPTED, ICON_APPLY, ICON_SIGNATURE, + ICON_THUMBNAIL, ICON_KADDRESSBOOK, ICON_VIEW_TEXT, ICON_KGPG, ICON_PACKAGE_DEVELOPMENT, ICON_KFM_HOME, + ICON_SERVICES, ICON_TUX, ICON_FEATHER, ICON_APPLE, ICON_W, ICON_MONEY, ICON_CERTIFICATE, ICON_SMARTPHONE, +) { + $ICON{$icon} = $ICON{0+$icon} = $icon; +} +sub to_icon_constant { $ICON{$_[0] // ''} // ICON_PASSWORD } 1; __END__ @@ -380,7 +411,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 @@ -390,6 +427,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: @@ -465,7 +509,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 @@ -482,9 +532,19 @@ Constants related to identifying key file types: Constants for history-related default values: =for :list += C = C = C +=head2 :iteration + +Constants for searching algorithms. + +=for :list += C - Iterative deepening search += C - Breadth-first search += C - Depth-first search + =head2 :icon Constants for default icons used by KeePass password safe implementations: @@ -560,6 +620,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: