Date: Mon, 10 Jun 1991 21:51:22 EDT
From: "Earle F. Ake - SAIC" <ake@Dayton.SAIC.COM>
To: madison@vms.ecs.rpi.edu
Message-ID: <00949EF5.BD536EAC.16436@Dayton.SAIC.COM>
Subject: New news/mail gateway changes

Matt,

	I have made some changes to the mail/news gateway that Ted Nieland
submitted.  There was a problem where messages from the mailing-list bound for
the newsgroup that had a blank as the first line of the message would only have
the headers of the message posted to the newsgroup.  I fixed that.  I also found
some problems with the command procedure using labels of the form 'label_one-1'.
Using the '-' character in a command procedure label is a no-no.  I also wrote
up better instructions on how everything fits together.  Let me know what you
think and make it available in the [.contrib] directory is you want.


Earle
_____________________________________________________________________________
             ____ ____    ___
Earle Ake   /___ /___/ / /     Science Applications International Corporation
           ____//   / / /__                 Dayton, Ohio
-----------------------------------------------------------------------------
Internet: ake@dayton.saic.com        uucp: dayvb!ake         SPAN: 28284::ake


$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On  3-JUN-1991 13:17:09.54   By user AKE (Earle Ake - SAIC (513) 429-6500)
$!                                        ake@dayton.saic.com
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. AAAREADME.TXT;2
$!       2. GATEMAIL.C;16
$!       3. GATEMAIL.TXT;2
$!       4. GATENEWS.C;3
$!       5. GATENEWS.TXT;2
$!       6. INSTRUCTIONS.TXT;12
$!       7. NEWSSKIM-FRAG.COM;11
$!       8. SITE_DELIVER.COM;27
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
XThis is a set of programs and command procedures to set up a Network News to
V`20
XInternet Mail List gateway.  This code allows the NEWS Articles to be sent t
Vo`20
Xa Mail List and Mail articles to be posted to NEWS.   Once the messages have
V`20
Xbeen transferred from one system to another, then the normal distribution`20
Xmethods for that system will transfer the messages to other systems.
X
XThis program requires the MX messaging system and ANU News.  Since MX suppor
Vts`20
XMultinet TCP/IP, CMU TCP/IP, and UCX TCP/IP, plus DECUS UUCP and Joiner JNET
V`20
Xnetwork software, this system can be used to interconnect any of these syste
Vms.
X
XProblems and corrections can be sent to Ted Nieland`20
X(nieland_t@asd-yf.wpafb.af.mil).
X
XThis code is based on the work of Bob Sloane to convert messages between NEW
VS`20
Xand JNET.
X
X----------------------------------------------------------------------------
V----
X3 June 1991
X
XSome work was done on the command procedures involved and a bug fix was made
V to
Xthe gatenews.c file.  A detailed instructions.txt file was added fully
Xexplaining setting up the gateway programs in either direction.
X
XEarle Ake (ake@dayton.saic.com)
$ CALL UNPACK AAAREADME.TXT;2 253501677
$ create 'f'
X/*
X *    Gatemail - a program to convert Mail messages from a mailing list into
X *               News articles suitable for input to the ANU-NEWS ADD FILE
X *               command.
X *
X *    Copyright 1989 by Robert R. Sloane <sloane@kuhub.cc.ukans.edu>.
X *               Permission is granted to anyone to make or distribute copie
Vs
X *               of this program, provided that this copyright notice is
X *               preserved.
X *
X *`09Updated to support MX by Ted Nieland <nieland_t@asd-yf.wpafb.af.mil>
X * `09March 1991
X */
X#include <stdio.h>
X#include <ssdef.h>
X
XFILE *mfd;`09/* MAIL file */
XFILE *bfd;`09/* NEWS Batch file */
X
Xmain(int argc, char **argv) `7B
X    char line`5B1024`5D;
X    int i;
X/*
X *    make sure user gave us both file names and the newsgroup name.
X */
X    if (argc < 2) `7B
X`09printf("Usage: gtmail <input> <output> <list-address> <newsgroup>\n");
X`09exit(SS$_NORMAL);
X    `7D
X    if (argc < 5)
X`09exit(SS$_INSFARG);
X/*
X *    now open the input file
X */
X    if ( !(mfd=fopen(argv`5B1`5D,"r")) ) `7B
X`09perror("can't open input file:");
X`09exit(SS$_ABORT);
X    `7D
X/*
X *    and the output file
X */
X    if ( !(bfd=fopen(argv`5B2`5D,"a")) ) `7B
X`09perror("can't open output file:");
X`09exit(SS$_ABORT);
X    `7D
X/*
X *    now Start processing the mail message
X */
X    while ( get_head(line) ) `7B
X/*
X *    check to see if this is the start of a new mail message
X *    and if it is, process it.  MX will Start the message with the`20
X *    "Received: " part of the header
X */
X`09if ( strncmp(line,"Received: ",10) == 0 ) `7B
X/*
X *    now output the headers we want to keep `20
X */
X`09    fputs("#! rnews ???\n",bfd);        /* output batch separator */
X`09    fputs("Path: ",bfd); fputs(argv`5B3`5D,bfd); fputs("\n",bfd);
X`09    fputs("Newsgroups: ",bfd); fputs(argv`5B4`5D,bfd); fputs("\n",bfd);
X/*
X *    go through the rest of the header of the message
X *    drop any Path headers, received headers, and such that will
X *    confuse NEWS.  Any others just copy into the output file.
X */
X`09    while (get_head(line)) `7B            /* look for first null line */
X`09`09if (strncmp(line,"Return-path: ",13) == 0 )continue;
X`09`09if (strncmp(line,"Newsgroups: ", 12) == 0 )continue;
X`09`09if (strncmp(line,"Received: ",   10) == 0 )continue;
X`09`09if (strncmp(line,"X-To: ",        6) == 0 )continue;
X`09`09if (strncmp(line,"Path: ",        6) == 0 )continue;
X`09`09if (strncmp(line,"To: ",          4) == 0 )continue;
X`09`09fputs(line,bfd);
X`09    `7D
X`09    fputs("\n",bfd);                    /* mark end of headers */
X        `7D
X/*
X *    if we get here, the headers are done, so copy each line of the text
X */
X`09else `7B
X/*
X *    Check each line, and if it looks like and NEWS Batch file separator,
X *    put a > in front of is, so NEWS won't get confused.
X */
X`09    if (!strncmp(line,"#! rnews ",9))
X`09`09fputs(">",bfd);
X`09    fputs(line,bfd);
X`09`7D
X    `7D
X    while (get_line(line)) `7B            /* look for first null line */
X        fputs(line,bfd);
X    `7D
X`7D
X/*
X *    get_line: get one line of text from the input file, exit on EOF.
X *              If the line consists of just a form feed, concatenate the
X *              next line on the end.  Makes looking for \f\nFrom:\t that
X *              separates mail messages easier to find.
X */
Xget_line( char *line ) `7B
X    int status;
X    extern char *mygets();
X/*
X *    read the next line from the file
X */
X    if ( !mygets(line,1024,mfd) ) `7B
X`09fclose(bfd);
X`09exit(SS$_NORMAL);
X    `7D
X/*
X *    if this line is just a FORMFEED, Combine it with the next line
X */
X    if ( line`5B0`5D == '\f' && line`5B1`5D == '\n' ) `7B
X`09if ( !mygets(line+2,1022,mfd) ) `7B  /* get the next line */
X`09    fclose(bfd);                  /* trailing formfeeds ignored */
X`09    exit(SS$_NORMAL);
X`09`7D
X    `7D
X    return 1;
X`7D
X/*
X *    get_head: routine to get a single header line from the input file.
X *              RFC822 standard continuation lines are concatenated together
X *              to make processing easier.  I assume that no header line wil
Vl
X *              be longer than 1024 characters.
X */
Xget_head( char *line ) `7B
X    int ch;
X    extern char *mygets();
X/*
X *    read the header line
X */
X    if ( !mygets(line,1024,mfd) ) `7B
X`09fclose(bfd);                        /* close off the output file */
X`09exit(SS$_ENDOFFILE);                /* error in header, exit */
X    `7D
X/*
X *    if this line is just a newline, then we have reached the end of the
X *    headers.
X */
X    if ( *line == '\n' ) return 0;
X/*
X *    if the next line begins with a blank, then it is a continuation
X *    of this line. Append it to the end of the current line.
X */
X    while ( ungetc(getc(mfd),mfd) == ' ' )
X`09if ( !mygets(line+strlen(line),1024-strlen(line),mfd) ) `7B
X`09    fclose(bfd);
X`09    exit(SS$_ENDOFFILE);
X`09`7D
X    return 1;
X`7D
X/*
X *    You may have been wondering why I used mygets rather than the standard
X *    C library routine gets.  I started out that way, but there seems to be
X *    a problem in the C library when using ungetc, getc, and gets together
X *    on the same file.  It was easier to just write my own than try to find
X *    out what the problem was with DEC's routine.
X */
Xchar *mygets( char *line, int max, FILE *fd ) `7B
X    int i,ch;
X/*
X *    read up to max characters from the input file
X */
X    for ( i=0; i<max-1; ++i ) `7B
X/*
X *    if there are no more characters, exit
X */
X`09if ( (ch=getc(fd)) == EOF ) `7B
X`09    line`5Bi`5D = '\0';
X`09    return 0;
X`09`7D
X/*
X *    stuff the current character in the users line buffer
X */
X`09line`5Bi`5D = ch;
X/*
X *    if this is a newline, then we are done for now, so return.
X */
X`09if ( ch == '\n' ) `7B
X`09    line`5Bi+1`5D = '\0';          /* put EOS on the end of the string */
X`09    return line;
X`09`7D
X    `7D
X/*
X *    if we get here, the line was longer than the users buffer.
X *    put and EOS on the string, and return.
X */
X    line`5Bmax`5D = '\0';
X    return line;
X`7D
$ CALL UNPACK GATEMAIL.C;16 91298208
$ create 'f'
XGATEMAIL is a program to take articles extracted from a VMS MAIL file and tu
Vrn
Xthem into News articles suitable for inserting in the NEWS database using th
Ve
XNEWS ADD FILE command. This program is currently in use to gateway the ANU-N
VEWS
Xmailing list to the news.software.anu-news newsgroup.  This program has only
Xbeen tested using MX under VMS and may or may not work for other mailing lis
Vts.`20
X
XThe first thing needed is a subscription to the mailing list.  Create an ali
Vas`20
Xfor MX for the address for the mailing list to send the messages.  The alias
Xwill should readdress the mail to the MX Site interface.  Such a defintion
Xis:
X
X`09define alias gate-mx-list mx-list@host.site
X
XMake sure you have the site support loaded for MX and you have a path define
Vd`20
Xfor *.site to be SITE.
X
XNext you need to either edit your SITE_DELIVER.COM file in MX_EXE or create`
V20
Xone similar to the one in this package.  The SITE_DELIVER command procedure`
V20
Xneeds to look for the address specified in the site forwarded address used i
Vn`20
Xthe alias and they process it using the GATEMAIL program.  GATEMAIL has four
V`20
Xparameters.  The first parameter is the name of the mail message file that M
VX`20
Xhas provided.  The second parameter is name of the news batch file that the`
V20
Xprogram will create.  The third parameter is the mailing list address.  The`
V20
Xfourth parameter is the newsgroup name.
X
XOnce you have the SITE_DELIVER command procedure installed in MX_EXE, then y
Vou`20
Xneed to edit NEWSSKIM.COM to process the new news batch files created by`20
XGATEMAIL.  This is done by adding a line such as
X
X`09`09add file/delete newsgate*.batch
X
Xto the message processing section of the NEWSSKIM command procedure.
X
XSee the file SITE_DELIVER.COM for additional details.
X
XReport problems to Ted Nieland, NIELAND_T@ASD-YF.WPAFB.AF.MIL.
X
$ CALL UNPACK GATEMAIL.TXT;2 120003079
$ create 'f'
X/*
X *    Gatenews: a program to take Batches of NEWS from the ANU-NEWS program
X *              and feed them to a mailing list via BITNET.
X *
X *    Copyright 1989 by Robert R. Sloane <sloane@kuhub.cc.ukans.edu>.
X *               Permission is granted to anyone to make or distribute copie
Vs
X *               of this program, provided that this copyright notice is
X *               preserved.
X *
X *    Modified to Support MX and ANUNEWS by M. Edward (Ted) Nieland
X *    March 1990   Will support TCP/IP, UUCP, and BITNET through MX.
X */
X#include <stdio.h>
X#include <ssdef.h>
X
XFILE *mfd = 0;`09/* MAIL file */
XFILE *mafd = 0;`09/* MAIL address file */
XFILE *bfd;`09/* NEWS Batch file */
X
Xmain(int argc, char **argv) `7B
X    char line`5B1024`5D;
X    int i;
X    char sendcmd`5B1024`5D;
X    int control;
X    extern char *mygets();
X/*
X *    make sure user gave us the file name and the mailing address.
X */
X    if (argc < 3) `7B
X`09printf("Usage: gtnews <input> <address> <origin-address> \n");
X`09exit(SS$_NORMAL);
X    `7D
X    if (argc < 4)
X`09exit(SS$_INSFARG);
X/*
X *    now open the input file
X */
X    if ( !(bfd=fopen(argv`5B1`5D,"r")) ) `7B
X`09perror("can't open input file:");
X`09exit(SS$_ABORT);
X    `7D
X/*
X *    now fix up the command to send the mail
X */
X    strcpy(sendcmd,"MX_ENTER TEMPMAIL.TMP TEMPADD.TMP ");
X    strcat(sendcmd,argv`5B3`5D);
X/*
X *    we don't want to send control messages to the mailing list, so set up
X *    a flag that says the current message is a control message.  If we find
X *    a Control: line in the message this will be 1, otherwise 0
X */
X    control = 0;                       /* not a control message for now */
X/*
X *    now copy selected parts of the input to the output file
X */
X    while ( mygets(line,1024,bfd) ) `7B
X/*
X *    check to see if this is the start of a new mail message
X *    and if it is, process it.
X */
X`09if ( !strncmp(line,"#! rnews ",9) `7C`7C !mfd ) `7B
X/*
X *    first we need to close any previous file and send it to the mailing li
Vst
X */
X`09    if ( mfd && !control ) `7B
X`09`09fclose(mfd);
X`09`09mfd = 0;
X`09`09system(sendcmd);
X`09    `7D
X`09    else if ( mfd ) `7B
X`09`09fclose(mfd);
X`09`09mfd = 0;
X`09`09delete("TEMPMAIL.TMP;");
X`09    `7D
X/*
X *    now open a new output temp file to hold the mail message
X */
X`09    if ( !(mfd=fopen("TEMPMAIL.TMP","w")) ) `7B
X`09`09perror("can't open scratch file:");
X`09`09exit(SS$_ABORT);
X`09    `7D
X/*
X *    now open a new output temp file to hold the mail address
X */
X`09    if ( !(mafd=fopen("TEMPADD.TMP","w")) ) `7B
X`09`09perror("can't open scratch file:");
X`09`09exit(SS$_ABORT);
X`09    `7D
X            fputs(argv`5B2`5D,mafd);
X            fputs("\n",mafd);
X/*
X *    skip over unwanted headers and output the ones we want to keep
X */
X`09    fputs("To: ",mfd); fputs(argv`5B2`5D,mfd); fputs("\n",mfd);
X`09    control=0;                         /* assume it's no control msg */
X`09    while (get_head(line)) `7B           /* look for first null line */
X`09`09if (!strncmp(line,"From: ",         6))fputs(line,mfd);
X`09`09if (!strncmp(line,"Date: ",         6))fputs(line,mfd);
X`09`09if (!strncmp(line,"Sender: ",       8))fputs(line,mfd);
X`09`09if (!strncmp(line,"Subject: ",      9))fputs(line,mfd);
X`09`09if (!strncmp(line,"Reply-to: ",    10))fputs(line,mfd);
X`09`09if (!strncmp(line,"Message-ID: ",  12))fputs(line,mfd);
X`09`09if (!strncmp(line,"Organization: ",14))fputs(line,mfd);
X`09`09if (!strncmp(line,"Control: ",      9))control=1;
X`09    `7D
X`09    fputs("\n",mfd);                  /* mark the end of the headers */
X`09`7D
X`09else
X/*
X *    if we get here, the headers for this message have been processed,
X *    so output the line of text.
X */
X`09    fputs(line,mfd);
X    `7D
X/*
X *    found the end of the input file, so send off the last message, if we
X *    haven't already.
X */
X    if ( mfd && !control ) `7B
X`09fclose(mfd);
X`09fclose(mafd);
X`09system(sendcmd);
X        delete("TEMPMAIL.TMP;");
X        delete("TEMPADD.TMP;");
X    `7D
X    else if ( mfd ) `7B
X`09fclose(mfd);
X`09if ( mafd ) `7B
X`09    fclose(mafd);
X`09    delete("TEMPMAIL.TMP;");
X`09`7D
X`09delete("TEMPADD.TMP;");
X    `7D
X`7D
X/*
X *    get_head: get one header line from the input file. Continuation lines
X *    are concatenated into one long line.  It is assumed that no header lin
Ve
X *    is longer than 1024 characters.
X */
Xget_head( char *line ) `7B
X    int ch;
X    char cline`5B1024`5D;
X    extern char *mygets();
X/*
X *    get the next header line from the input file.
X */
X    if ( !mygets(line,1024,bfd) ) `7B
X`09fclose(mfd);
X`09exit(SS$_ENDOFFILE);                  /* shouldn't get EOF here */
X    `7D
X/*
X *    if this line is null, it marks the end of the headers.
X */
X    if ( *line == '\n' ) return 0;   /* return false if no more headers */
X/*
X *    make sure the header lines aren't longer than 80 characters.
X *    fold and continue them if needed.
X */
X    fold_header(line);
X/*
X *    if the next input line starts with a blank, it is a continuation of th
Vis
X *    line, so concatenate it onto the end of this line.
X */
X    while ( ungetc(ch=fgetc(bfd),bfd) == ' ' ) `7B
X`09if ( !mygets(cline,1024-strlen(line),bfd) ) `7B
X`09    fclose(mfd);
X`09    exit(SS$_ENDOFFILE);     /* this shouldn't happen */
X`09`7D
X`09fold_header(cline);
X`09strcat(line,cline);
X    `7D
X    return 1;
X`7D
X/*
X *    fold_header: folds headers so that they don't exceed the 80 column lim
Vit
X *               on BITNET mail messages.
X */
Xfold_header( char *line ) `7B
X    char cline`5B1024`5D;
X    char ch;
X    char *cp;
X
X    cline`5B0`5D = '\0';
X    while ( strlen(line) > 80 ) `7B
X`09ch = line`5B80`5D;`09`09`09      /* save the 80th character */
X`09line`5B80`5D = '\0';                      /* truncate line at col 80 */
X`09cp = strrchr( line, ' ' );            /* find the rightmost blank */
X`09line`5B80`5D = ch;                        /* in the first 80 characters *
V/
X`09if ( cp == NULL ) `7B                   /* if there is no delimiter */
X`09    strcpy( &line`5B81`5D,&line`5B80`5D );    /* make room for a blank */
X`09    line`5B80`5D = ' ';                   /* and put one in */
X`09    cp = &line`5B80`5D;`09`09      /* set pointer to the blank */
X`09`7D
X`09*cp = '\0';                           /* end the line at the blank */
X`09strcat(cline,line);                   /* build the new line */
X`09strcat(cline,"\n ");                  /* and continue it later */
X`09strcpy(line,cp+1);                    /* now move rest of line over */
X    `7D
X    strcat(cline,line); strcpy(line,cline);   /* now put the line back */
X`7D
X/*
X *    You may have been wondering why I used mygets rather than the standard
X *    C library routine gets.  I started out that way, but there seems to be
X *    a problem in the C library when using ungetc, getc, and gets together
X *    on the same file.  It was easier to just write my own than try to find
X *    out what the problem was with DEC's routine.
X */
Xchar *mygets( char *line, int max, FILE *fd ) `7B
X    int i,ch;
X/*
X *    read up to max characters from the input file
X */
X    for ( i=0; i<max-1; ++i ) `7B
X/*
X *    if there are no more characters, exit
X */
X`09if ( (ch=getc(fd)) == EOF ) `7B
X`09    line`5Bi`5D = '\0';
X`09    return 0;
X`09`7D
X/*
X *    stuff the current character in the users line buffer
X */
X`09line`5Bi`5D = ch;
X/*
X *    if this is a newline, then we are done for now, so return.
X */
X`09if ( ch == '\n' ) `7B
X`09    line`5Bi+1`5D = '\0';          /* put EOS on the end of the string */
X`09    return line;
X`09`7D
X    `7D
X/*
X *    if we get here, the line was longer than the users buffer.
X *    put and EOS on the string, and return.
X */
X    line`5Bmax`5D = '\0';
X    return line;
X`7D
$ CALL UNPACK GATENEWS.C;3 1733336823
$ create 'f'
XGATENEWS is a program to take an RFC1036 standard news batch file and mail
Xthe individual articles to a mailing list using the SITE interface to MX. `2
V0
X
XFirst you must configure News to create the "batches" for the newsgroup. Add
Xa line to you NEWS.SYS file specifying a dummy system name:
X
Xnews-group-gate:news.group:B:NEWS_MANAGER_DEV:`5BGATE_news-group`5DNEWS.BATC
VH
X
XIf the newsgroup is to be distributed to other systems, you will need to upd
Vate
Xyour NEWS.DISTRIBUTION file to reflect the groups distribution to forward th
Ve
Xarticles to other systems.  See the file NEWSSKIM-FRAG.COM for an example of
V`20
Xhow to do such.
X
XReport any problems to Ted Nieland, NIELAND_T@ASD-YF.WPAFB.AF.MIL.
$ CALL UNPACK GATENEWS.TXT;2 526860241
$ create 'f'
X`09In this example my site is "dayton.saic.com" and I am setting up a
Xbi-directional gateway to the "vmsnet.networks.tcp-ip.multinet" newsgroup.
XThe mailing-list is maintained by TGV and the address of the mailing-list is
X"info-multinet@tgv.com".  MX 2.3 and ANU-News 6.0-3 were used.
X
X
X`09`09`09Gatewaying News to a Mailing List
X`09`09`09---------------------------------
X
X`09To create a gateway that will pass articles posted to a newsgroup on to
Xa mailing list, the following steps are taken:
X
X`091) Create a subdirectory under news_manager that will hold the articles
Xbound for the newsgroup.  I set up a gateway to pass news articles from the
Xnewsgroup vmsnet.networks.tcp-ip.multinet to the mailing list info-multinet.
X
X$ create/directory news_manager_dev:`5Bgate_info-multinet`5D
X
XThe "GATE_" prefix is used in the subdirectory name to trigger a new piece o
Vf
Xcode that will be placed in the news_manager:newsskim.com file.
X
X`092) Add an entry in the news_manager:news.sys file that puts articles
Xposted to the newsgroup into the previously created subdirectory.
X
X#
Xinfo-multinet-gate:\
Xvmsnet.networks.tcp-ip.multinet\
X:B:NEWS_MANAGER_DEV/`5BGATE_info-multinet`5DNEWS.BATCH
X#
X
X`09Also be sure that you add the appropriate entries to the file
XNEWS_MANAGER:NEWS.DISTRIBUTION so articles posted from other sites will make
V it
Xto the mailing list 'node'.
X
X#
Xother-news-nodes:`09info-multinet-gate
X#
X
X`093) The code fragment that is in the newsskim-frag.com file should be
Xadded to the file news_manager:newsskim.com.  In this example the address of
V the
Xinfo-multinet mailing list is "info-multinet@tgv.com".  In the newsskim-frag
V.com
Xexample, the address is added as follows:
X
X$    write sys$output "Gateway NEWS to mailing lists"
X$    set on
X$`09define info-multinet "<info-multinet@tgv.com>"
X
XNotice that the logical name I am defining matches the subdirectory created
Xunder news_manager minus the "gate_" portion.  THIS IS IMPORTANT!
X
X`09NEWS_MANAGER_DEV:`5BGATE_info-multinet`5D
X
X`094) Compile and link the gatenews program and then copy the executable
Xto the MX_EXE directory.
X
X$ cc gatenews
X$ link gatenews
X$ copy gatenews.exe mx_exe:
X
XThat should be all you need to do to gateway articles posted in the newsgrou
Vp
Xto the mailing list.
X
X`09Operation of newsgroup to mailing-list gateway.  News articles that
Xcome in from other sites are put into the gateway subdirectory.  The newsski
Vm
Xprocedure collects these articles and sends them onto to the mailing-list
Xmaintainer via the MX mail handler.
X`0C
X`09`09`09Gatewaying a Mailing List to a Newsgroup
X`09`09`09----------------------------------------
X
X`09To create a gateway that will pass articles posted to a mailing list on
Xto a newsgroup, the following steps are taken:
X
X`091) Using MCP, make sure that a path is defined for the SITE delivery
Xagent.
X
X$ MCP :== $MX_EXE:MCP/FILE=MX_DIR:MX_CONFIG.MXCFG
X$ MCP
X%MCP-I-READCFG, read configuration from file MX_ROOT:`5B000000`5DMX_CONFIG.M
VXCFG;1
XMCP> define path *.SITE SITE
XMCP> save
X%MCP-I-WROTECFG, wrote configuration to file MX_ROOT:`5B000000`5DMX_CONFIG.M
VXCFG;2
XMCP> exit
X
X`092) In this example I am setting up a gateway between the mailing list
Xinfo-multinet and the newsgroup vmsnet.networks.tcp-ip.multinet.  Define an
Xaddress that will be on the mailing list and will accept the mail bound for
V the
Xnewsgroup.
X
X$ MCP :== $MX_EXE:MCP/FILE=MX_DIR:MX_CONFIG.MXCFG
X$ MCP
X%MCP-I-READCFG, read configuration from file MX_ROOT:`5B000000`5DMX_CONFIG.M
VXCFG;2
XMCP> define alias gate-info-multinet info-multinet@dayton.saic.com.site
XMCP> save
X%MCP-I-WROTECFG, wrote configuration to file MX_ROOT:`5B000000`5DMX_CONFIG.M
VXCFG;3
XMCP> exit
X
X`093) Uncomment out the code in SYS$STARTUP:MX_STARTUP.COM to run the
XSITE agent during startup.  While there you might want to get the SITE agent
Xgoing as well by issuing the command "$ @MX_EXE:MX_START SITE".
X
X$!
X$! Site-specific agent: edit and uncomment to activate.
X$!
X$ @MX_EXE:MX_START SITE
X$!
X
X`094) After those changed have been made, use MCP to reset the
Xrunning processes.
X
X$ MCP :== $MX_EXE:MCP
X$ MCP RESET/ALL
X
X`095) Edit the file site_deliver.com and then copy to the MX_EXE directory.
XThe following lines are specific changes for the info-multinet gateway.  The
Xsite address string to look for has been previously defined in the MCP ALIAS
Xcommand in step 2 above.  The list_addr is what will be placed on the "Path:
V"
Xline of the news article.  The newsgroup is the name of the newsgroup to pos
Vt
Xthe item.
X
X
X$ site_addr1 = "<INFO-MULTINET@DAYTON.SAIC.COM.SITE>"
X$ list_addr1 = "info-multinet-gate!list"
X$ newsgroup1 = "vmsnet.networks.tcp-ip.multinet"
X$ gateway_num = 1`09! <=== Change when adding or deleting a gateway
X
X
XMake sure that the list_addr matches the site added to the news.sys file abo
Vve.
X
X$ list_addr1 = "info-multinet-gate!list"
X                `5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E
X
Xinfo-multinet-gate:\
X`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E`5E
X
XIMPORTANT!  IF THE SITE NAME IN THE NEWS.SYS DOES NOT MATCH THE SITE USED FO
VR
XTHE GATEMAIL PROGRAM, THE MESSAGES POSTED TO THE MAILING LIST WILL GO THROUG
VH
XTHIS PROCEDURE AND BE LOOPED BACK TO THE MAILING LIST!!!
X
X`096) Compile and link the gatemail program and then copy to the MX_EXE
Xdirectory.
X
X$ cc gatemail
X$ link gatemail
X$ copy gatemail.exe mx_exe:
X
X`097) You need to add a line in the NEWS_MANAGER:NEWSSKIM.COM file to
Xadd the news batches automatically.  The following is added to the message
Xprocessing section of the NEWSSKIM command procedure.
X
X`09`09add file/delete news_manager:newsgate*.batch
X
X`098) Now the last step is to get the gateway address
X"gate-info-multinet@dayton.saic.com" subscribed to the mailing list either b
Vy
Xcontacting the mailing list maintainer directly or using the MLFAKE utility
Xprovided in MX.
X
X`09Operation of mailing-list to newsgroup gateway.  Messages come in to
Xthe router addressed to the user "gate-info-multinet@dayton.saic.com".  MX
Xparses this address and finds there is an alias defined for it and rewrites
Xthe address as "info-multinet@dayton.saic.com.site".  The router then sees t
Vhat
Xthe address ends in ".SITE" and passes it along to the SITE agent.  The site
Xagent runs the MX_EXE:SITE_DELIVER.COM.  The message is then moved to the
XNEWS_MANAGER directory awaiting the newsskim job to add it to the newsgroup.
$ CALL UNPACK INSTRUCTIONS.TXT;12 1028929732
$ create 'f'
X$!
X$!  This is a fragment of NEWSSKIM.COM to show how to set up the`20
X$!  news to MAIL List interface.
X$!
X$ !**********************************************************************
X$ !`09Copy news items to other sites
X$ !
X$ ! Search for all directories of the form news_manager:gate_<node>.dir
X$ ! Process the files using the GATENEWS program for MX.
X$ !
X$ !
X$ Gate:
X$ set verify
X$    gatenews :== $mx_exe:gatenews.exe
X$    mx_enter :== $mx_exe:mx_site_in.exe
X$    write sys$output "Gateway NEWS to mailing lists"
X$    set on
X$`09define wpafb-net "<wpafb-net@asd-yf.wpafb.af.mil>"
X$`09define wpafb-admin "<wpafb-admin@asd-yf.wpafb.af.mil>"`20
X$`09define wpafb-dec "<wpafb-dec@asd-yf.wpafb.af.mil>"`20
X$`09define wpafb-mail "<wpafb-mail@asd-yf.wpafb.af.mil>"`20
X$ gsearch_1:
X$    gatedir = f$search("news_manager:gate_*.dir",2)
X$ write sys$output gatedir
X$    if gatedir .eqs. "" then goto abort
X$    list = f$parse(gatedir,,,"NAME","SYNTAX_ONLY") - "GATE_"
X$ write sys$output list
X$    senddir = "news_manager_dev:`5Bgate_" + list + "`5D;"
X$    savedfiles = senddir - ";" + "*.*;*"
X$ write sys$output savedfiles
X$ gsearch_2:
X$        file = f$search(savedfiles,4)
X$ write sys$output file
X$        if file .eqs. "" then goto gsearch_1
X$            on error then goto gno_copy_2
X$            write sys$output "Gating list ''list'"
X$            list_add = f$trnlog("''list'")
X$            gatenews 'file 'list_add 'list_add
X$            delete 'file
X$ gno_copy_2:
X$        goto gsearch_2
X$!
X$ abort:
$ CALL UNPACK NEWSSKIM-FRAG.COM;11 973081938
$ create 'f'
X$ set verify
X$! Site Delivery command procedure for MX to do NEWS/Mailing List Gateway
X$! The code here will process an incoming mail message to change it to`20
X$! NEWS Format.
X$!
X$!
X$!
X$!  P1 is the name of the file containing the mail message with the headers
X$!  P2 is the name of the file containing the mail addresses
X$!  P3 is the PFC822 address of the originator of the message.
X$!
X$ site_addr1 = "<LIST-1@HOST.SITE>"
X$ list_addr1 = "node.anywhere.us!list-1"
X$ newsgroup1 = "list-address-1"
X$!
X$ site_addr2 = "<LIST-2@HOST.SITE>"
X$ list_addr2 = "node.anywhere.us!list-2"
X$ newsgroup2 = "list-address-2"
X$!
X$ gateway_num = 2`09! <=== Change when adding or deleting a gateway
X$!
X$ gatemail :== $ mx_exe:gatemail.exe
X$ timestamp = f$cvtime(f$time()) - "-" - "-" - " " - ":" - ":" - "." - " "
X$ timestamp = f$extract(2,14,timestamp)
X$ open add_file 'p2
X$ read add_file address1
X$ close add_file
X$ address1 = f$edit(address1, "upcase")
X$ eol = f$length(address1)
X$ i = 1
X$!
X$ 10:
X$ site_addr = f$edit(site_addr'i', "upcase")
X$ list_addr = list_addr'i'
X$ newsgroup = newsgroup'i'
X$ if f$locate("''site_addr'",address1) .nes. eol then goto proc_list
X$ i = i + 1
X$ if i .le. gateway_num then goto 10
X$!
X$! Notify Postmaster
X$!
X$ mail 'p1 postmaster/subject="Strange Message given to MX SITE"
X$ delete 'p1
X$ delete 'p2
X$ exit
X$!
X$!
X$!Process Message for Mailing-List
X$!
X$ proc_list:
X$ on error then goto Gate_err
X$ gatemail 'p1 news_manager:newsgate_'timestamp'.batch "''list_addr'" "''new
Vsgroup'"
X$ del 'p1
X$ del 'p2
X$ exit
X$!
X$!Gateway Error Handling
X$!
X$ Gate_err:
X$ mail 'p1 postmaster/subject="Error handling message for Gateway"
X$ del 'p1
X$ del 'p2
X$ exit
$ CALL UNPACK SITE_DELIVER.COM;27 1124731644
$ v=f$verify(v)
$ EXIT
--------------------------------------------------------------------------------
Return-Path: <@mdmvs.ecs.rpi.edu,@vms.ecs.rpi.edu:ake@Dayton.SAIC.COM>
Received: from vms.ecs.rpi.edu by mdmvs.ecs.rpi.edu (MX V2.3-1) with SMTP; Mon,
          10 Jun 1991 21:51:40 EDT
Received: from DAYVC.DAYTON.SAIC.COM by vms.ecs.rpi.edu (MX V2.3-1) with SMTP;
          Mon, 10 Jun 1991 21:50:50 EDT
Received: by Dayton.SAIC.COM (MX V2.3-1) id 16436; Mon, 10 Jun 1991 21:51:22 EDT
