From: epg <> Date: Mon, 30 Dec 2002 02:25:03 +0000 (+0000) Subject: (logincoming): Move part of log_headers here. X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/a3bb3fc0be841b35f089935afac64289da9b5978?ds=sidebyside;hp=12d2edfc52cd9f4e55757c2a900bede64641c9bd (logincoming): Move part of log_headers here. (log_headers): Pass the array of contents for each header to logincoming rather than indexing here. logincoming now checks for an empty array (i.e. message missing this header) before trying to index into it (it used to bomb). --- diff --git a/minc b/minc index 070e22f..9f3f9ac 100755 --- a/minc +++ b/minc @@ -246,22 +246,34 @@ sub mylog { } } -sub logincoming { mylog('info', INCOMINGCHAR, @_); } sub logsave { mylog('notice', SAVECHAR, @_); } sub loginfo { mylog('info', INFOCHAR, @_); } sub logdebug { mylog('debug', DEBUGCHAR, @_); } sub logwarn { mylog('warning', WARNCHAR, @_); } sub logerr { mylog('error', ERRORCHAR, @_); } +sub logincoming { + my ($text, @contents) = @_; + my $last; + + if (@contents) { + $last = $contents[-1]; + } else { + $last = ''; + } + + mylog('info', INCOMINGCHAR, $text, $last); +} + sub log_headers { my %headers = @_; # For an explanation of the %headers structure, see the # get_headers function below. - logincoming('From: ', @{$headers{'return-path'}}[-1]); - logincoming('To: ', @{$headers{'to'}}[-1]); - logincoming('Subject: ', @{$headers{'subject'}}[-1]); - logincoming('Message-Id: ', @{$headers{'message-id'}}[-1]); + logincoming('From: ', @{$headers{'return-path'}}); + logincoming('To: ', @{$headers{'to'}}); + logincoming('Subject: ', @{$headers{'subject'}}); + logincoming('Message-Id: ', @{$headers{'message-id'}}); }