Gateway Functions
RAWI 980601

Basis functions
===============

Read Mail
---------

ToUser_U and FromUser_U are informational and
might have continuation headers. Must not be
used when writing out the Header_U. CC and BCC
info only in Header_U.

Dest records contain all the destinations from
the job.


Read News
---------

ToUser_U and FromUser_U are informational and
might have continuation headers. Must not be
used when writing out the Header_U.

Dest record is a destNews.


Read Netmail
------------

ToUser/Addr_F and FromUser/Addr_F are informational.
To/FromUser_F can be used during gating.

Dest record for the ToUser/Addr pair is set.
Gateway interprets headers when netmail hits
WaterGate's gateway.


Read Echomail
-------------

ToUser_F and FromUser/Addr_F are informational. ToAddr_F
is set to NullAdres. To/FromUser_F can be used during
gating.

Dest record is destEcho.


Write Mail
----------

Header_U and body parts are written out as-is.

Dest records are written to job.


Write News
----------

Header_U and body parts are written out as-is.


Write Netmail
-------------

FromUser/Addr_F are used. ToUser/Addr_F comes from Dest record.

Header_F, Body parts and Footer_F are written out as-is.

Extract files from body.


Write Echomail
--------------

FromUser/Addr_F and ToUser are used. No information is
taken from Dest Records.

Header_F, Body parts and Footer_F are written out as-is.



Delivering
==========

DeliverMail
-----------

Called when Msg.Ready_U is Mail. Checks each Dest record
and can change type to destFtn (netmail). Fills in ToUser/Addr_F
in that case.

Creates job for each destination user record and does a WriteMail
for each user record found in the destination records of type
destRFC.


DeliverNews
-----------

Called when Msg.Ready_U is News. Msg.AreaRecNrs decides where
to write. Header_U must list all newsgroups.

Writes a job for each user record found subscribed to one of
the areas. Header_U contains Message-ID.


DeliverNetmail
--------------

Called when Msg.Ready_F is Netmail. Dest record contains
destination record to-information. Can change destinations
to RFC. Fills in To_U field in that case.

Writes out Header_F, Body Parts and Footer_F as is.


DeliverEchomail
---------------

Called when Msg.Ready_F is Echomail. Takes FromUser/Addr_F
and ToUser_F. Runs through list of Msg.AreaRecNrs and exports
to all subscribed users.

Replaces MSGID, AREA: and X-POST: headers for each area and
then writes out Header_F, Body Parts and Footer_F for each.

Need to add zone-gating here.


Translating
===========

Preparing Mail
--------------

Header_U must be created/updated. Remove Newsgroups: and
Path: header. Add From:, To: and Cc: header lines.


Preparing News
--------------

Header_U must be created/updated. Fill in Newsgroups: header.
Remove From_ header. Keep To: and Cc: headers??


Preparing Netmail
-----------------

FromUser/Addr_F must be filled in. Header_F must be created/updated.
Remove AREA: and X-POST kludges. MSGID might be from echomail area!


Preparing Echomail
------------------

Can keep/Do not have to add AREA:, X-POST and MSGID since they will
be replaced anyway.

FromUser/Addr_F and ToUser_F must be filled in.



Gating Mail -> Netmail
----------------------

Create Header_F.
Fill in FromUser_F, FromAddr_F
Translate body from RFC to FTN
Do not extract files yet.


Gating Netmail -> Mail
----------------------

Create Header_U.
Fill in ToUser_U field.
Add attached files to body.
Translate body from FTN to RFC.


Gating News -> Echomail
-----------------------

Create Header_F.
Fill in FromUser/Addr_F and ToUser_F fields.
Translate body from RFC to FTN
Do not extract files yet.


Gating Echomail -> News
-----------------------

Create Header_U
Add Newsgroups: header.
Fill in ToUser_U field.
Add attached files to body (possible??)
Translate body from FTN to RFC.


Gating Mail -> News
-------------------

Update Header_U.
Remove From_; add Newsgroups: and Path:.


Gating News -> Mail
-------------------

Update Header_U.
Remove Path: and Newsgroups:. Add From_.



Distributed Responsibility
==========================

             Create/Read/Import   Translate        Write/Export
Header_F             x                x                 -
Footer_F             x                x                 -
FromUser_F           x                x                 -
FromAddr_F           x                x                 -
ToUser_F             x                x                 -
ToAddr_F             x                x                 -
Date_F               x                x                 -
MSGID                x                x                 x
REPLY                x                x                 ?
AREA                 -                -                 x
X-POST               -                -                 x
Attr_F               x                -                 -
ExtAttr_F            x                -                 -

Header_U             x                x                 -
From_U               x                x                 -
From:                -                x                 -
To:                  -                x                 -
Cc:                  -                x                 -
Bcc:                 -                x                 -
Newsgroups:          -                x                 -
Date:                x                x                 -
Message-ID:          x                x                 -
Organization:        -                x                 -
Path:                -                x                 -
From_                -                x                 -
