# Copyright (C) 1993-1998 Ken'ichi Fukamachi
#          All rights reserved. 
#               1993-1996 fukachan@phys.titech.ac.jp
#               1996-1998 fukachan@sapporo.iij.ad.jp
# 
# FML is free software; you can redistribute it and/or modify
# it under the terms of GNU General Public License.
# See the file COPYING for more details.
#
# $Id: liblmtp.pl,v 1.3 2000/05/12 15:30:24 fukachan Exp $
#

sub DoSmtpFeed
{
    ;
}


sub SetupSmtpFeed
{
    local($smtpfeed);
    $smtpfeed = &SearchPath("smtpfeed", "/usr/libexec") || 
	"/usr/libexed/smtpfeed";

    require 'open2.pl';
    if (&open2(RS, S, $smtpfeed)) { 
	&Log("open2(RS, S, $smtpfeed)") if $debug;
    }
    else {
	&Log("SmtpIO: cannot exec $smtpfeed");
	return "SmtpIO: cannot exec $smtpfeed";
    };
}


package lmtp;

sub Copy
{
    local($in, $out) = @_;
    local($mode) = (stat($in))[2];
    open(COPYIN,  $in)      || (&Log("ERROR: Copy::In [$!]"), return 0);
    open(COPYOUT, "> $out") || (&Log("ERROR: Copy::Out [$!]"), return 0);
    select(COPYOUT); $| = 1; select(STDOUT);
    chmod $mode, $out;
    while (sysread(COPYIN, $_, 4096)) { print COPYOUT $_;}
    close(COPYOUT);
    close(COPYIN); 
    1;
}


1;
