+ return $status;
+}
+
+################################# splitaddress #################################
+# split mail address into local and domain part
+# IN : $address: a mail address
+# OUT: $local : local part
+# $domain: domain part
+sub splitaddress {
+ my($address)=@_;
+ (my $lp = $address) =~ s/^([^@]+)@.*/$1/;
+ (my $domain = $address) =~ s/[^@]+\@(\S*)$/$1/;
+ return ($lp,$domain);
+};
+
+################################ parse_dns_reply ###############################
+# parse DNS response codes and return code and description
+# IN : $response: a DNS response code
+# OUT: "$response ($desciption)"
+sub parse_dns_reply {
+ my($response)=@_;
+ my %dnsrespcodes = (NOERROR => 'empty response',
+ NXDOMAIN => 'non-existent domain',
+ SERVFAIL => 'DNS server failure',
+ REFUSED => 'DNS query refused',
+ FORMERR => 'format error',
+ NOTIMP => 'not implemented');
+ if(defined($dnsrespcodes{$response})) {
+ return sprintf('%s (%s)',$response,$dnsrespcodes{$response});
+ } else {
+ return $response;
+ };
+};
+
+############################### print_dns_result ###############################
+# print and log result of DNS query
+# IN : $domain: domain the DNS was queried for
+# $type : record type (MX, A, ...)
+# $count : number of records found
+# $error : DNS response code
+# \$log : reference to the log (to be printed out via -l)
+# OUT: ---
+# \$log will be changed
+sub print_dns_result {
+ my ($domain,$type,$count,$error,$logr) = @_;
+ if (defined($count)) {
+ printf(" %d %s record(s) found for %s\n",$count,$type,$domain) if !($options{'q'});
+ $$logr .= sprintf("%s DNS record(s):\n",$type);
+ } else {
+ printf(" No %s records found for %s: %s\n",$type,$domain,parse_dns_reply($error)) if !($options{'q'});
+ $$logr .= sprintf("No %s records found: %s\n",$type,parse_dns_reply($error));
+ };
+ return;