From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 14-NOV-1990 05:06:33.14
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	PLM$MAIL, part 1 of 10

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA29497; Wed, 14 Nov 90 04:45:50 EST
Received: From ICNUCEVM.CNUCE.CNR.IT by CRVAX.SRI.COM with TCP; Wed, 14 NOV 90 01:33:10 PST
Received: from ITOPOLI.BITNET by ICNUCEVM.CNUCE.CNR.IT (IBM VM SMTP R1.2.2MX) with BSMTP id 0269; Wed, 14 Nov 90 10:30:10 MET
Date: Wed, 14 Nov 90 10:29 GMT+1
From: "P.L. Montessoro * CENS-CNR * +39-11-556.7013" <PIERLUCA%ITOPOLI.BITNET@ICNUCEVM.CNUCE.CNR.IT>
Subject: PLM$MAIL, part 1 of 10
To: info-vax@kl.sri.com
Message-Id: <04DBF810753F20028A@ITOPOLI.BITNET>
X-Envelope-To: info-vax@kl.sri.com
X-Vms-To: INFOVAX

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On 14-NOV-1990 09:32:38.68   By user PIERLUCA
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 10 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! 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. ADDMAILDEF.H;1
$!       2. PLM$MAIL.C;1
$!       3. PLM$MAIL.CFG;1
$!       4. PLM$MAIL.DOC;1
$!
$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 = "!"
$ if f$getsyi("version") .ges. "V4.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/nolog '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/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ 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");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);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 g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X#define MAIL$_FACILITY  126
X#define MAIL$_CODERR  8290316
X#define MAIL$_UPGRADE  8290324
X#define MAIL$_UAFGETERR  8290330
X#define MAIL$_UAFOPNERR  8290338
X#define MAIL$_NOSUCHUSR  8290346
X#define MAIL$_NOTREADIN  8290354
X#define MAIL$_LOGLINK  8290362
X#define MAIL$_CREPRIJOB  8290370
X#define MAIL$_SENDERR  8290378
X#define MAIL$_NOMOREMSG  8290386
X#define MAIL$_NOMSGS  8290394
X#define MAIL$_USERSPEC  8290402
X#define MAIL$_SENDABORT  8290410
X#define MAIL$_EDITPROC  8290418
X#define MAIL$_INVCMD  8290426
X#define MAIL$_NOTFOUND  8290434
X#define MAIL$_NETIOERR  8290442
X#define MAIL$_USERDSABL  8290450
X#define MAIL$_FORWLOOP  8290458
X#define MAIL$_NAMTOOBIG  8290466
X#define MAIL$_ILLCHAR  8290474
X#define MAIL$_DATIMUSED  8290482
X#define MAIL$_NOTISAM  8290490
X#define MAIL$_DELMSG  8290498
X#define MAIL$_DELWASTE  8290506
X#define MAIL$_NOFOLDER  8290514
X#define MAIL$_NOTEXIST  8290522
X#define MAIL$_NOTSUBDIR  8290530
X#define MAIL$_ILLSUBDIR  8290538
X#define MAIL$_ILLFOLNAM  8290546
X#define MAIL$_NOMSGPRI  8290554
X#define MAIL$_ALTPRIJOB  8290562
X#define MAIL$_ILLPERNAM  8290570
X#define MAIL$_NOSUCHUSRAT  8290578
X#define MAIL$_SENDERRAT  8290586
X#define MAIL$_CONABORT  8290594
X#define MAIL$_NOTCALEDT  8290602
X#define MAIL$_FILECONFUSED  8290610
X#define MAIL$_CAPTIVE  8290618
X#define MAIL$_IVPROTVAL  8290626
X#define MAIL$_RECTOBIG  8290634
X#define MAIL$_ILLCTXADR  8290642
X#define MAIL$_WRONGCTX  8290650
X#define MAIL$_FAILGETVM  8290658
X#define MAIL$_INVITMCOD  8290666
X#define MAIL$_MISREQITM  8290674
X#define MAIL$_INVITMLEN  8290682
X#define MAIL$_FILEOPEN  8290690
X#define MAIL$_NOFILEOPEN  8290698
X#define MAIL$_CONITMCOD  8290706
X#define MAIL$_NOMORECTX  8290714
X#define MAIL$_WRONGFILE  8290722
X#define MAIL$_ILLTPRT  8290730
X#define MAIL$_INVITMVAL  8290738
X#define MAIL$_ERACTED  8290746
X#define MAIL$_FORMSG  8290754
X#define MAIL$_NOTFORMSG  8290762
X#define MAIL$_ERRACTRNS  8290770
X#define MAIL$_BADVALUE  8290778
X#define MAIL$_CLOSEDEL  8290786
X#define MAIL$_FILNOTDEL  8290794
X#define MAIL$_OPENIN  8290802
X#define MAIL$_OPENOUT  8290810
X#define MAIL$_PARSEFAIL  8290818
X#define MAIL$_READERR  8290826
X#define MAIL$_SEARCHFAIL  8290834
X#define MAIL$_SYSERROR  8290842
X#define MAIL$_NOSYSNAM  8290850
X#define MAIL$_NOSYSPRV  8290858
X#define MAIL$_PROTOCOL  8290866
X#define MAIL$_NOACCPTMSG  8290874
X#define MAIL$_SELECTED  8306307
X#define MAIL$_DELMSGS  8306315
X#define MAIL$_CVTFILE  8306323
X#define MAIL$_DELSPACE  8306331
X#define MAIL$_NEWFOLDER  8306339
X#define MAIL$_RECLPLSWAIT  8306347
X#define MAIL$_REENTER  8306355
X#define MAIL$_MOREMSG  8314304
X#define MAIL$_DIRHD0  8314312
X#define MAIL$_DIRHD10  8314320
X#define MAIL$_DIRHD20  8314328
X#define MAIL$_DIRDEL10  8314336
X#define MAIL$_ISUB10  8314344
X#define MAIL$_ISUB20  8314352
X#define MAIL$_ISUB30  8314360
X#define MAIL$_PRESRET  8314368
X#define MAIL$_YOUHAVENEW  8314376
X#define MAIL$_MAIL10  8314384
X#define MAIL$_MAIL20  8314392
X#define MAIL$_WANTOSEND  8314400
X#define MAIL$_NOTIFY10  8314408
X#define MAIL$_NOTIFY20  8314416
X#define MAIL$_JOBENTERED  8314424
X#define MAIL$_SHOW10  8314432
X#define MAIL$_SHOW20  8314440
X#define MAIL$_SHOW30  8314448
X#define MAIL$_SHOW40  8314456
X#define MAIL$_SHOW50  8314464
X#define MAIL$_SHOW60  8314472
X#define MAIL$_SHOW70  8314480
X#define MAIL$_SHOW80  8314488
X#define MAIL$_SHOW90  8314496
X#define MAIL$_SHOW100  8314504
X#define MAIL$_SHOW110  8314512
X#define MAIL$_EDIT10  8314520
X#define MAIL$_INFO10  8314528
X#define MAIL$_INFO20  8314536
X#define MAIL$_INFO30  8314544
X#define MAIL$_SEND  8314552
X#define MAIL$_REPLY  8314560
X#define MAIL$_SHOW120  8314568
X#define MAIL$_SHOW130  8314576
X#define MAIL$_INFO50  8314584
X#define MAIL$_SHOW140  8314592
X#define MAIL$_SHOW150  8314600
X#define MAIL$_SHOW160  8314608
X#define MAIL$_ISUB50  8314616
X#define MAIL$_MAIL30  8314624
X#define MAIL$_RETCONT  8314632
X#define MAIL$_NEWSEQ  8314640
X#define MAIL$_MAILDIR  8314648
X#define MAIL$_MAILFILE  8314656
X#define MAIL$_MAILFOLDER  8314664
X#define MAIL$_MAIL40  8314672
X#define MAIL$_CRENEWFOLD  8314680
X#define MAIL$_NONEWMAIL  8314688
X#define MAIL$_SHOWKEY10  8314696
X#define MAIL$_SHOWKEY20  8314704
X#define MAIL$_SHOWKEY30  8314712
X#define MAIL$_SHOWKEY40  8314720
X#define MAIL$_SHOWKEY50  8314728
X#define MAIL$_SHOWKEY60  8314736
X#define MAIL$_SHOWKEY70  8314744
X#define MAIL$_NOTIFY30  8314752
X#define MAIL$_NOTIFY40  8314760
X#define MAIL$_NOPARENT  8314768
X#define MAIL$_FILEMPTY  8314776
X#define MAIL$_NONEFOUND  8314784
X#define MAIL$_NOMOREREC  8314792
X#define MAIL$_USERFWD  8314800
X#define MAIL$_PROMPT  8314808
X#define MAIL$_INFO12  8314816
X#define MAIL$_INFO14  8314824
X#define MAIL$_INFO16  8314832
X#define MAIL$_INFO18  8314840
X#define MAIL$_CRENEWFILE  8314848
X#define MAIL$_SHOW15  8314856
X#define MAIL$_SHOW25  8314864
X#define MAIL$_SHOW35  8314872
X#define MAIL$_FORWARD  8314880
X#define MAIL$_SHOW200  8314888
X#define MAIL$_SHOW205  8314896
X#define MAIL$_SHOW210  8314904
X#define MAIL$_SHOW215  8314912
X#define MAIL$_CLOSEIN  8314920
X#define MAIL$_CLOSEOUT  8314928
X#define MAIL$_INVQUAVAL  8314936
X#define MAIL$_WRITEERR  8314944
X#define MAIL$_SHOW220  8314952
X#define MAIL$_SHOW225  8314960
X#define MAIL$_MSGTEXT  8322305
X#define MAIL$_MSGINFO  8322313
X#define MAIL$_MSGSENT  8322321
X#define MAIL$_MSGSENTAT  8322329
X#define MAIL$_YES  8322337
X#define MAIL$_COPIEDR  8322345
X#define MAIL$_CREATED  8322353
X#define MAIL$_RENAMED  8322361
X#define MAIL$_TEXT  8322369
$ CALL UNPACK ADDMAILDEF.H;1 374099451
$ create/nolog 'f'
X     `032
X        `032
X          /*                                                       */`032
X          /*                                                       */`032
X          /*   plm$mail.c: yet another mail user interface ...     */`032
X          /*                                                       */`032
X          /*                          Pier Luca Montessoro         */`032
X          /*                                                       */`032
X
X
X/***************************************************************************
V****
X
X   Copyright (C) 1990 Pier Luca MONTESSORO
X
X   CENS-CNR (Italian National Research Council)      Tel.   +39-11-556.7013
X   Politecnico di Torino                             Fax.   +39-11-556.7099
X   10129 Torino - ITALY                              Telex. 220646 POLITO I
X
X   Bitnet: pierluca@itopoli.bitnet            Span/Physnet: 39494::PIERLUCA
X
X
X   This  program comes without any warranty. The author does not accept any
X   responsibility for any damage caused by use or mis-use of this program.`0
V32
X
X   This  program  is NOT in public domain. It may be reproduced freely, but
X   including this copyright notion.
X
X****************************************************************************
V***/
X
X
X  `032
X/***************************************************************************
V****
X
X   usage:  `032
X
X      plm$mail `091folder`093      (folder names are case-sensitive)
X
X
X   configuration file format (sys$login:plm$mail.cfg):
X
X      <mailfile name> (normally MAIL)
X      <default folder name> (the one to be processed, normally NEWMAIL)
X      <default extraction directory for messages in group "OTHERS">
X      <default extraction directory for bigmail messages>
X      f/s/m  "<key substring>" <default extraction directory> <group name>
X      ...
X      f/s/m  "<key substring>" <default extraction directory> <group name>
X
X   where
X      "f" means 'search for <key substring> in "From:" field'
X      "s" means 'search for <key substring> in "Subject:" field'
X      "m" means 'search for <key substring> in the text of the message field
V'
X
X
X****************************************************************************
V***/
X
X
X#include <stdio.h>
X#include <string.h>
X#include <descrip.h>
X#include <ssdef.h>
X#include <jpidef.h>
X#include <lnmdef.h>
X#include <maildef.h>
X#include "addmaildef.h"                                             `032
X#include <nam.h>
X
X
X`012
X/***************************************************************************
V***/
X
X/* default items for automatic selection */
X
X#define   BIGMAIL_STRING      "MHFTU 2.0 message"
X#define   BIGMAIL_GROUP_NAM   "BIGMAIL"
X                                                                        `032
V   `032
X
X`012
X/***************************************************************************
V***/
X        `032
X/* site-specific items */
X
X#define   CONFIG_FILE         "SYS$LOGIN:PLM$MAIL.CFG"
X#define   NEWMAIL_FOLDER      "NEWMAIL"
X#define   OLDMAIL_FOLDER      "MAIL"
X#define   DIS_FILE_EXTENSION  ".DIS"
X#define   MAIL_FILE_EXTENSION ".MAI"
X#define   PLM$MAIL_PROMPT     "PLM$MAIL> "
X#define   MAX_LIST_LINES      22
X
Xchar      mail_file_name `091512`093;
Xchar      mail_file_directory `091512`093;
Xchar      folder_name `091512`093;
X
X
Xtypedef struct msg_dsc
X`123
X   unsigned long      id;
X   char               *from;
X   char               *subject;
X   char               *date;
X   unsigned char      read;
X   unsigned char      extracted;
X   unsigned char      deleted;
X   struct msg_dsc     *next;
X   struct msg_dsc     *previous;
X`125  MSG_DSC;
X
X#define BEG_OF_MSG_LIST (AUTOSELECT *) -1
X#define END_OF_MSG_LIST (AUTOSELECT *) -2
X
Xtypedef struct autoselect
X`123
X   char               *group_name;
X   unsigned long      selected_number;
X   char               key_code;
X   char               *substring;
X   char               *default_subdir;
X   struct autoselect  *next;`032
X   struct autoselect  *previous;`032
X   struct msg_dsc     *msg_list_ptr;
X   struct msg_dsc     *msg_list_last_ptr;`032
X`125  AUTOSELECT;
X
Xtypedef struct folder_dsc
X`123       `032
X   struct folder_dsc  *next; `032
X   char               *folder_name;
X   int                message_number;
X`125  FOLDER_DSC;
X
X
XAUTOSELECT     *autoselect_list = (AUTOSELECT *) NULL;
XAUTOSELECT     *autoselect_list_tail = (AUTOSELECT *) NULL;
XFOLDER_DSC     *folder_list = (FOLDER_DSC *) NULL, *last_folder;
X
X`012
X/***************************************************************************
V***/
X
X/* callable mail interface items */
X
Xtypedef struct itmlst
X`123
X   short  buffer_length;
X   short  item_code;
X   long   buffer_address;
X   long   return_address;
X`125  ITMLST;
X
X
Xunsigned long  dummy;
Xunsigned long  dummy_length;
Xchar           msg_buffer `091256`093;
Xunsigned long  msg_length;
Xchar           subj_buffer `091256`093;
Xunsigned long  subj_length;
Xchar           from_buffer `091256`093;
Xunsigned long  from_length;
Xchar           date_buffer `091256`093;
Xunsigned long  date_length;
Xchar           to_buffer `091256`093;
Xunsigned long  to_length;
Xchar           filename_buffer `091256`093;
Xunsigned long  filename_length;
Xchar           directory_buffer `091256`093;
Xunsigned long  directory_length;
Xunsigned long  msg_id;
Xunsigned long  id_length;
Xunsigned short new_msg_count;
Xchar           return_string `091256`093;
X
Xunsigned long  file_context = 0;
Xunsigned long  message_context = 0;
Xunsigned long  send_context = 0;
Xunsigned long  user_context = 0;
X
X`012
X/***************************************************************************
V***/
X
X/* function templates */
X
Xint create_folder_list (unsigned long *dummy, struct dsc$descriptor *name);
Xint create_folder_announce (unsigned long *dummy, struct dsc$descriptor *nam
Ve);
Xvoid build_message_filename (char *file_name, char *directory_name,`032
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-

