From:	CSBVAX::MRGATE!CARL%SCU.BITNET@jade.berkeley.edu@SMTP 17-SEP-1988 06:05
To:	ARISIA::EVERHART
Subj:	Unread.1_of_2


Received: by jade.berkeley.edu (5.54 (CFC 4.22.3)/1.16.18B)
	id AA12607; Sat, 17 Sep 88 02:56:34 PDT
Message-Id: <8809170956.AA12607@jade.berkeley.edu>
Date: Sat, 17 Sep 88 02:56 PDT
From: CARL FUSSELL <CARL%SCU.BITNET@jade.berkeley.edu>
Subject: Unread.1_of_2
To: CCSO-ALL@gunter-adam.arpa, ABSTINE@clvms.clarkson.edu,
        Everhart%Arisia.decnet@ge-crd.arpa, pung%ornl-knsms@milnetgw.ornl.gov,
        auvax!walterg@ucbvax.Berkeley.EDU, UDAA055@oak.cc.kcl.ac.uk,
        J.SKELTON%UK.AC.LSE.VAX1@UKACRL.BITNET

$!...................... Cut on the dotted line and save ......................
$! VAX/VMS archive file created by VMS_SHAR V-5.04-WJM 25-may-1988
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by CARL
$! on Saturday 17-SEP-1988 02:10:41.82
$!
$! ATTENTION: To keep each article below 34816 bytes, this program
$! has been transmitted in 2 parts.
$! You should concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 10 files:
$! ADD.COM CVTV5PROFILE.C DIST.LIS MAKE.COM NODENAMES.MAR UNREAD.CLD UNREAD.DOC
$! UNREAD.HLP VMSMAILFILE.FMT UNREAD.C
$!=============================================================================
$Set Symbol/Scope=(NoLocal,NoGlobal)
$Version=F$GetSYI("VERSION")
$If Version.ges."V4.4" then goto Version_OK
$Write SYS$Output "Sorry, you are running VMS ",Version, -
", but this procedure requires V4.4 or higher."
$Exit 44
$Version_OK:CR[0,8]=13
$Pass_or_Failed="failed!,passed."
$Goto Start
$Convert_File:
$Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1:Define/User_Mode SYS$Output NL:
$Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));a:=0;Loop ExitIf Mark(None)=End_of(b);
x:=Erase_Character(1);if x="V" then i:=LENGTH(CURRENT_LINE);
if i<>78 then MOVE_HORIZONTAL(i);if i>78 then ERASE_CHARACTER(78-i);endif;
if i<78 then COPY_TEXT(FAO("!#* ",78-i));endif;
Move_Horizontal(-Current_Offset);endif;endif;if a then Append_Line;
Move_Horizontal(-Current_Offset);endif;a:=(x="V");Move_Vertical(1);EndLoop;
POSITION(BEGINNING_OF(b));p:=" "&LINE_END;loop x:=SEARCH(p,Forward,Exact);
exitif x=0;POSITION(END_OF(x));s:=CURRENT_LINE;EDIT(s,Trim_trailing,Off);
ERASE_CHARACTER(LENGTH(s)-CURRENT_OFFSET);endloop;Position(Beginning_of(b));
Loop x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$Delete VMS_SHAR_DUMMY.DUMMY;*
$Checksum 'File_is
$Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2:Return
$Start:
$File_is="ADD.COM"
$Check_Sum_is=1749688624
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$!      Add the UNREAD command to the system command tables.
X$!
X$ SET COMMAND unread.cld
X$!
X$ install = "$install/command"
X$ install REPLACE SYS$LIBRARY:DCLTABLES.EXE
$GoSub Convert_File
$File_is="CVTV5PROFILE.C"
$Check_Sum_is=1427454130
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X#include <stdio.h>
X#include <ctype.h>
X
X#define V5MAX_VMSMAIL_RECORD`0092048
X#define V5VMSMAIL_KEY_SIZE        31
X
X/* Format of 5.0 mail profile file is:
X`00931 chars = Username
X`009Remainder = {Type} {0} {Length} {0} {Data} ... */
X
X#define VMSMAIL_NEWMAIL`009`0091
X#define VMSMAIL_FLAGS`009`0092
X
X#define VMSMAIL_CS_SEND`009`0091
X#define VMSMAIL_CS_REPLY`0092
X#define VMSMAIL_NOAUTOPURGE`0094
X#define VMSMAIL_CS_FORWARD`0098
X#define VMSMAIL_CC_PROMPT`00916
X
X#define VMSMAIL_MAILDIR`009`0093
X#define VMSMAIL_FORWARDADDR`0094
X#define VMSMAIL_PERSONALNAME`0095
X#define VMSMAIL_QUEUE`009`0099
X#define VMSMAIL_FORM`009`00913
X
X/*** The VMS V4 VMSMAIL.DAT file. ***/
X
X/*  The following information is taken from the VMS 4.4 fiche,
X    facility MAIL, file MAILDEF.SDL. */
X
X#define V4MAX_VMSMAIL_RECORD      512
X#define V4VMSMAIL_KEY_SIZE        31
X
Xstruct v4vmsmail_record {
X        char v4vmsmail_username[V4VMSMAIL_KEY_SIZE];
X        unsigned short v4flags;
X        unsigned short v4mailcnt;         /* count of unread messages */
X        char v4spare[30];
X        unsigned char v4dirlng;           /* length of directory name */
X        unsigned char v4pnmlng;           /* length of personal name */
X        unsigned char v4fwdlng;           /* length of forwarded name */
X        char v4fwdnam[V4MAX_VMSMAIL_RECORD-V4VMSMAIL_KEY_SIZE-37];
X`009`009                          /* first byte of data */
X`009`009`009`009`009  /* {dir}{personal}{forward} */
X};
X
Xstruct v5vmsmail_record {
X`009char v5vmsmail_username[V5VMSMAIL_KEY_SIZE];
X`009char v5profile[V5MAX_VMSMAIL_RECORD-V5VMSMAIL_KEY_SIZE];
X};
X
X/* Takes a string containing a V5 profile record``032
X   and returns a string containing the equivalent V4 profile record */
X
Xstruct v4vmsmail_record *cvtv5profile (v5r)
Xstruct v5vmsmail_record *v5r;
X{
X    static struct v4vmsmail_record v4r;
X
X    char dname[255], pname[255], fname[255], v[255];
X
X    int newmail, i,code,len;
X
X    dname[0] = '\0';
X    pname[0] = '\0';
X    fname[0] = '\0';
X    newmail = 0;
X
X    i = 0;
X    while (i<(V5MAX_VMSMAIL_RECORD-V5VMSMAIL_KEY_SIZE))
X`009{
X`009    code = v5r->v5profile[i];
X`009    len  = v5r->v5profile[i+2];
X`009    strncpy(v,&v5r->v5profile[i+4],len);
X`009    v[len] = '\0';
X
X`009    if (code <= 0) i = V5MAX_VMSMAIL_RECORD;
X
X`009    if (code == VMSMAIL_NEWMAIL)
X`009`009newmail = v[0];
X`009    else if (code == VMSMAIL_MAILDIR)
X`009`009strcpy(dname, v);
X`009    else if (code == VMSMAIL_FORWARDADDR)
X`009`009strcpy(fname, v);
X
X`009    i = i + 4 + len;
X`009}
X`009strcpy(v4r.v4vmsmail_username, v5r->v5vmsmail_username);
X`009v4r.v4mailcnt = newmail;
X`009v4r.v4dirlng = strlen(dname);
X`009strcpy(v4r.v4fwdnam,dname);
X`009v4r.v4pnmlng = strlen(pname);
X`009strcat(v4r.v4fwdnam,pname);
X`009v4r.v4fwdlng = strlen(fname);
X`009strcat(v4r.v4fwdnam,fname);
X`009return(&v4r);
X}
X
X
$GoSub Convert_File
$File_is="DIST.LIS"
$Check_Sum_is=1700879447
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X
XDirectory ACCLIB:[LOCAL.UNREAD.DIST]
X
VADD.COM;3           CVTV5PROFILE.C;23   DIST.LIS;1          MAKE.COM;7
X``032
VNODENAMES.MAR;4     UNREAD.C;188        UNREAD.CLD;11       UNREAD.DOC;3
X``032
XUNREAD.HLP;1        VMSMAILFILE.FMT;8  ``032
X
XTotal of 10 files.
$GoSub Convert_File
$File_is="MAKE.COM"
$Check_Sum_is=2070380725
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ cc/nolis/nodebug unread
X$ cc/nolis/nodebug cvtv5profile
X$ macro/nolis/nodebug nodenames
X$ link/nomap/notrace unread, nodenames, cvtv5profile, sys$input:/options
Xsys$share:vaxcrtl/share
$GoSub Convert_File
$File_is="NODENAMES.MAR"
$Check_Sum_is=1360102065
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X        .TITLE  NODENAMES       Node names for UNREAD.C
X        .IDENT  /1.0/
X
X;  Lists allowed source nodes for messages from the current username.
X
X        .PSECT  NODES, BYTE, PIC, SHR, NOEXE, RD, NOWRT
X
XNODE_NAMES::
X
X;  Put all allowed node names here, each in an ASCIC directive.
X
X        .ASCIC  "SCUACC"
X        .ASCIC  "SCUENG"
X
X;  This byte marks the end of the list.
X
X        .BYTE   0
X
X        .END
$GoSub Convert_File
$File_is="UNREAD.CLD"
$Check_Sum_is=1477214146
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
Xdefine verb unread
X        image "ACCLIB:[LOCAL]UNREAD"
X        parameter p1, prompt="To",
X                value ( required, list ), label=username
X`009qualifier PRIV, nonnegatable
X`009qualifier NEW, nonnegatable
$GoSub Convert_File
$File_is="UNREAD.DOC"
$Check_Sum_is=856687237
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
XTo build UNREAD, perform the following steps.
X
X   1. Run UNREAD.COM to generate the necessarys.  Be sure any trailing
X      blanks on lines are stripped as they tend to "mess up" checksums.
X
X   2. Edit UNREAD.CLD and change the directory where the UNREAD program
X      will be located.
X
X   3. Edit NODENAMES.MAR and substitute the correct cluster or DECNet
X      nodes for your site.
X
X   4. Run MAKE.COM to compile UNREAD.C into the image to be run.
X
X   5. Run ADD.COM to add the command to the system tables and reinstall
X      the new DCLTABLES image in memory.
X
X   6. The actual image UNREAD.EXE must be installed in memory as well
X      since it requires (sysprv) to run.
X
X`009$ INSTALL=="$INSTALL/COMMAND"
X`009$ INSTALL ADD ACCADM:[UTILITIES]UNREAD /PRIV=(SYSPRV)
X
X   7. Be sure and edit SYS$MANAGER:SYSTARTUP.COM so the image will get
X      installed at boot time... IE STEP 6
X
X   8. Add UNREAD.HLP to the appropriate help library.
X
XNote, you will have to logout/login again before you will see the effects
Xof step 5.
$GoSub Convert_File
$File_is="UNREAD.HLP"
$Check_Sum_is=1260810105
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X1 UNREAD
XThe UNREAD command will tell you if mail you've sent to a specified
Xuser or users has been read yet.  For example,
X
X     $ unread solomon, magoon
X
Xwill list, by date, time and subject, all the messages you've sent
Xto SOLOMON and MAGOON that they haven't read.  Bear in mind that,
Xalthough it involves the MAIL system, you can't actually issue
Xthis command from within MAIL; you must first exit to DCL.
X
XFormat:
X
X     UNREAD   username[,...]
$GoSub Convert_File
$File_is="VMSMAILFILE.FMT"
$Check_Sum_is=1078015060
$Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009`009   VMS VMSMAIL_PROFILE File Format
X
XThis was all determined empirically and as such, is not comprehensive or
Xeven guaranteed to be accurate.  A record containing 1 user's information
Xseems to be broken down as follows:
X
X    Field 1:`009USERNAME (31 characters)  (Key)
X
X    Field 2:`009FIELDTYPE    (16 bits - Numeric)
X`009`009FIELDLENGTH  (16 bits - Numeric, gives length in # of bytes)
X `009`009FIELD        (Numeric or character field)
X
X    Field 3-n:  {same as 2, just repeats)
X
XMaximum record length containing fields 1-n is:  2048 bytes
X
X
X
XThe field types appear to be as follows:
X
X  TYPE  DESCRIPTION         LENGTH              DATA TYPE IN FIELD
X    1`009Newmail count`009    length: 2 bytes`009Numeric field
X    2   Flags               length: 2 bytes`009Numeric field (bits)
X    3 `009Mail Directory`009    length: n chars`009Variable len char field
X    4`009Forwarding Addr`009    length: n chars`009Variable len char field
X    5`009Personal Name`009    length: n chars`009Variable len char field
X    6`009Unknown
X    7`009Unknown
X    8`009Unknown
X    9`009Default LP Queue    length: n chars`009Variable len char field
X   10`009Unknown
X   11`009Unknown
X   12`009Unknown
X   13 `009Default LP Form`009    length: n chars`009Variable len char field
X
XThe flag field appears to be a bit field defined as follows:
X
X  BIT`009WEIGHT`009DESCRIPTION
X    0`009   1`009Copy Self on SEND
X    1      2`009Copy Self on REPLY
X    2`009   4`009Auto Purge Disable
X    3`009   8`009Copy Self on FORWARD
X    4`009  16`009CC: Prompt Enable
X
XField types 1 and 2 (newmail count and flags) always appear to be the
Xfirst two following the key field (Username).  The remaining types can
Xappear in any order so you must look at the type field to determine
Xjust what type of field you are looking at.  This allows DEC to add
Xas many new capabilities as they need and allow a variable amount
Xof room for each capability.
X
XSample records:  (field values all in decimal)
X
X   User JSMITH with 5 new mail messages and his mail directory
X        being [JSMITH.MAIL] and Autopurge disabled.
X
X      JSMITH  -25 more spaces- 1  2  5  2  2  4  3  7 [.MAIL]
X
X   User PWILLIAMSON with 71 new mail messages, Personal Name =
X        Peter W., Mail dir = [PWILLIAMSON.MAILBOX] , Copy Self``032
X        on Reply + Auto purge + CC prompting enabled.
X
X      PWILLIAMSON -20 more spaces- 1  2  71  2  2  18  5  8  Peter W.
X      3  10 [.MAILBOX]``032
X
X   Again, the numeric fields are 16 bits.  Looking at say JSMITH, byte
X   by byte, you would see:
X
X      JSMITH  -25 more spaces- 1 0 2 0 5 0 2 0 2 0 4 0 3 0 7 0[.MAIL]
X
X
$GoSub Convert_File
$Goto Part2
