+ ### TODO: VERBOSITY on how chanconf returned 1 or 0 or -1.
+ my %chan = &getChanConfList($param);
+ my $nomatch = 0;
+ if (!defined $msgType) {
+ $nomatch++;
+ } else {
+ $nomatch++ if ($msgType eq "");
+ $nomatch++ unless ($msgType =~ /^(public|private)$/i);
+ }
+
+### debug purposes only.
+# if ($debug) {
+# &DEBUG("param => $param, msgType => $msgType.");
+# foreach (keys %chan) {
+# &DEBUG(" $_ => $chan{$_}");
+# }
+# }
+
+ if ($nomatch) {
+ if ($chan{$chan}) {
+ &DEBUG("ICC: other: $chan{$chan} (_default/$param)") if ($debug);
+ } elsif ($chan{_default}) {
+ &DEBUG("ICC: other: $chan{_default} (_default/$param)") if ($debug);
+ } else {
+ &DEBUG("ICC: other: 0 ($param)") if ($debug);
+ }
+ return $chan{$chan} || $chan{_default} || 0;
+ } elsif ($msgType =~ /^(public|private)$/i) {
+ if ($chan{$chan}) {
+ &DEBUG("ICC: $msgType: $chan{$chan} ($chan/$param)") if ($debug);
+ } elsif ($chan{_default}) {
+ &DEBUG("ICC: $msgType: $chan{_default} (_default/$param)") if ($debug);
+ } else {
+ &DEBUG("ICC: $msgType: 0 ($param)") if ($debug);
+ }
+ return $chan{$chan} || $chan{_default} || 0;
+ }
+
+ &DEBUG("ICC: no-match: 0/$param (msgType = $msgType)");
+
+ return 0;
+}
+
+#####
+# Usage: &getChanConf($param);
+# About: Retrieve value for 'param' value in current/default chan.
+# Return: scalar for success, undef for failure.
+sub getChanConf {
+ my($param,$c) = @_;
+
+ if (!defined $param) {
+ &WARN("gCC: param == NULL.");
+ return 0;
+ }
+
+ # this looks evil...
+ if (0 and !defined $chan) {
+ &DEBUG("gCC: ok !chan... doing _default instead.");
+ }
+
+ $c ||= $chan;
+ $c ||= "_default";
+ $c = "_default" if ($c eq "*"); # FIXME
+ my @c = grep /^\Q$c\E$/i, keys %chanconf;
+
+ if (@c) {
+ if (0 and $c[0] ne $c) {
+ &WARN("c ne chan ($c[0] ne $chan)");
+ }
+ if (!defined $chanconf{$c[0]}{$param} and ($c ne '_default')) {
+ return &getChanConf($param, '_default');
+ }
+ #&DEBUG("gCC: $param,$c \"" . $chanconf{$c[0]}{$param} . '"');
+ return $chanconf{$c[0]}{$param};
+ }
+
+ #&DEBUG("gCC: returning _default... " . $chanconf{"_default"}{$param});
+ return $chanconf{"_default"}{$param};
+}
+
+sub getChanConfDefault {
+ my($what, $default, $chan) = @_;
+ $chan ||= "_default";
+
+ if (exists $param{$what}) {
+ if (!exists $cache{config}{$what}) {
+ &status("config ($chan): backward-compatible option: found param{$what} ($param{$what}) instead of chan option");
+ $cache{config}{$what} = 1;
+ }
+
+ return $param{$what};
+ }
+ my $val = &getChanConf($what, $chan);
+ return $val if (defined $val);
+
+ $param{$what} = $default;
+ &status("config ($chan): auto-setting param{$what} = $default");
+ $cache{config}{$what} = 1;
+ return $default;
+}
+
+
+#####
+# Usage: &findChanConf($param);
+# About: Retrieve value for 'param' value from any chan.
+# Return: scalar for success, undef for failure.
+sub findChanConf {
+ my($param) = @_;
+
+ if (!defined $param) {
+ &WARN("param == NULL.");
+ return 0;
+ }
+
+ my $c;
+ foreach $c (keys %chanconf) {
+ foreach (keys %{ $chanconf{$c} }) {
+ next unless (/^$param$/);
+
+ return $chanconf{$c}{$_};
+ }
+ }
+
+ return;
+}
+
+sub showProc {
+ my ($prefix) = $_[0] || "";
+