]> diplodocus.org Git - minc/commitdiff
(logincoming): Move part of log_headers here.
authorepg <>
Mon, 30 Dec 2002 02:25:03 +0000 (02:25 +0000)
committerepg <>
Mon, 30 Dec 2002 02:25:03 +0000 (02:25 +0000)
(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).

minc

diff --git a/minc b/minc
index 070e22f..9f3f9ac 100755 (executable)
--- 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 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.
 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'}});
 }
 
 \f
 }
 
 \f