28 |
## Initialize of this class -- called by constructors |
## Initialize of this class -- called by constructors |
29 |
%DEFAULT = ( |
%DEFAULT = ( |
30 |
-_ARRAY_NAME => 'value', |
-_ARRAY_NAME => 'value', |
31 |
-_MEMBERS => [qw|type|], |
-_MEMBERS => [qw|type port|], |
32 |
-_METHODS => [qw|reverse type|], |
-_METHODS => [qw|reverse type port value|], |
33 |
-allow_special_name => 1, ## not implemented yet |
-allow_special_name => 1, ## not implemented yet |
34 |
-allow_special_ipv4 => 1, ## |
-allow_special_ipv4 => 1, ## |
35 |
-allow_special_ipv6 => 1, ## |
-allow_special_ipv6 => 1, ## |
37 |
-encoding_before_decode => 'unknown-8bit', |
-encoding_before_decode => 'unknown-8bit', |
38 |
#field_param_name |
#field_param_name |
39 |
#field_name |
#field_name |
40 |
|
-fill_default_name => 1, ## host / "1" / perl-false |
41 |
|
-fill_default_port => 0, |
42 |
|
-fill_default_value => 0, |
43 |
#format |
#format |
44 |
-format_ipv4 => '[%vd]', |
-format_ipv4 => '[%vd]', |
45 |
-format_ipv6 => '[IPv6:%s]', |
-format_ipv6 => '[IPv6:%s]', |
48 |
#hook_encode_string |
#hook_encode_string |
49 |
#hook_decode_string |
#hook_decode_string |
50 |
-output_comment => 0, |
-output_comment => 0, |
51 |
|
-output_port => 0, |
52 |
-separator => '.', |
-separator => '.', |
53 |
-use_comment => 0, |
-use_comment => 0, |
54 |
-use_domain_literal => 1, |
-use_domain_literal => 1, |
55 |
-use_ipv4_address => 1, |
-use_ipv4_address => 1, |
56 |
-use_ipv6_address => 1, |
-use_ipv6_address => 1, |
57 |
|
-use_port => 0, |
58 |
); |
); |
59 |
sub _init ($;%) { |
sub _init ($;%) { |
60 |
my $self = shift; |
my $self = shift; |
87 |
= $self->Message::Util::delete_comment_to_array ($body) |
= $self->Message::Util::delete_comment_to_array ($body) |
88 |
if $self->{option}->{use_comment}; |
if $self->{option}->{use_comment}; |
89 |
my @d; |
my @d; |
90 |
|
$body =~ s{ : ([0-9]+) $ }{ |
91 |
|
$self->{port} = $1; |
92 |
|
''}ex if $self->{option}->{use_port}; |
93 |
$body =~ s{($REG{domain_literal}|[^\x5B\x2E])+}{ |
$body =~ s{($REG{domain_literal}|[^\x5B\x2E])+}{ |
94 |
my ($d, $isd) = ($&, 0); |
my ($d, $isd) = ($&, 0); |
95 |
$d =~ s/^$REG{WSP}+//; $d =~ s/$REG{WSP}+$//; |
$d =~ s/^$REG{WSP}+//; $d =~ s/$REG{WSP}+$//; |
149 |
} |
} |
150 |
$s{value}; |
$s{value}; |
151 |
} @{$self->{value}}; |
} @{$self->{value}}; |
152 |
|
if ($option{fill_default_value} && !length $d) { |
153 |
|
if ($option{fill_default_name} == 1) { |
154 |
|
$d = Message::Util::get_host_fqdn; |
155 |
|
} else { |
156 |
|
$d = $option{fill_default_name}; |
157 |
|
} |
158 |
|
} |
159 |
$s = sprintf $option{format_name}, $d; |
$s = sprintf $option{format_name}, $d; |
160 |
} |
} |
161 |
|
if ($option{use_port} && $option{output_port}) { |
162 |
|
my $port = $self->{port}; |
163 |
|
$port = $option{fill_default_port} if !$port && $option{fill_default_value}; |
164 |
|
$s .= ':' . (0+$self->{port}) if $port; |
165 |
|
} |
166 |
if ($option{use_comment} && $option{output_comment}) { |
if ($option{use_comment} && $option{output_comment}) { |
167 |
my $c = $self->_comment_stringify; |
my $c = $self->_comment_stringify; |
168 |
$s .= ' ' . $c if $c; |
$s .= ' ' . $c if $c; |