From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 18-MAY-1992 20:41:13.68
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Fix NEWMAIL counter  (program)

In article <15MAY92.14500852@nauvax.ucc.nau.edu>, acm@nauvax.ucc.nau.edu writes...
# 
#   Here's one solution to an FAQ.  Whenever your new mail count deviates from
#what's actually in NEWMAIL just run the following program and it will adjust
#the newmail count to the number of messages actually in NEWMAIL.
# 
#            MAILCOUNT.MAR follows:

Tony's program was so good, I've converted it into a front end for
anyone who runs MAIL.  I haven't tested it, but you're welcome to...

Ehud
-----
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 15-MAY-1992 15:49:49.35   By user GAVRON 
$!
$! 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 2 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. AAAREADME.TXT;2
$!       2. MAIL.CLD;2
$!       3. XMAIL.CLD;2
$!       4. MAILCNT.MAR;3
$!       5. MAIL_JACKET.C;2
$!
$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'
X
XThis will put a front-end routine on MAIL so that it automatically
Xfixes up the newmail count.  No warranties.
X
XTake XMAIL.CLD and install it in your command tables.  This copies
X`09the current MAIL verb into an XMAIL verb.  If you have the
X`09Verb utility then you ought to use it instead and do:
X`09`09$ verb /out=mail.cld mail
X`09`09$ copy mail.cld xmail.cld
X`09`09$ edit/edt/nocom/nojou xmail.cld
X`09`09*s/verb mail/vrb xmail/1:999
X`09`09*ex
X`09`09$ edit/edt/nocom/nojou mail.cld
X`09`09*s/image mail/image mail_jacket/1:999
X`09`09*ex
X
XCompile MAIL_JACKET.  Assemble MAILCNT.  Link the two together
X`09`09$ cc/noopt/notrace/nodebug mail_jacket
X`09`09$ mac mailcnt
X`09`09$ link mail_jacket,mailcnt
X
XCopy the executable to sys$common:`5Bsysexe`5D
X`09`09$ copy mail_jacket.exe sys$common:`5Bsysexe`5D
X
XTake MAIL.CLD and install it in your command tables.  This makes
X`09the MAIL verb call the MAIL_JACKET executable.
X
XEnjoy
X
XEhud Gavron
Xgavron@aces.com
$ CALL UNPACK AAAREADME.TXT;2 1684945915
$ create 'f'
Xdefine verb MAIL
X   image MAIL_JACKET
X   parameter P1, label=FILE, prompt="File"
X      value (type=$infile)
X   parameter P2, label=TOLIST, prompt="To"
X      value (list)
X   qualifier SUBJECT
X      value (required)
X   qualifier FOREIGN, nonnegatable
X   qualifier TYPE
X      value (default="0")
X   qualifier PERSONAL_NAME, label=P_NAME
X      value
X   qualifier TRANSPORT
X      value
X   qualifier DECMAIL, syntax=DECMAIL
X   qualifier EDIT
X      value (list,type=EDIT_TYPES)
X   qualifier PROTOCOL, syntax=PROT_SYNTAX, nonnegatable
X      value (required)
X   qualifier SERVER, syntax=SERVER_SYNTAX
X   qualifier SELF
X
Xdefine syntax DECMAIL
X   image DECMAIL
X
Xdefine type EDIT_TYPES
X   keyword SEND
X   keyword REPLY
X      value (type=REPLY_TYPES)
X   keyword FORWARD
X
Xdefine type REPLY_TYPES
X   keyword EXTRACT
X
Xdefine syntax PROT_SYNTAX
X   image MAIL_SERVER
X
Xdefine syntax SERVER_SYNTAX
X   image MAIL_SERVER
X   qualifier PROTOCOL, nonnegatable
X      value
X
$ CALL UNPACK MAIL.CLD;2 152717822
$ create 'f'
Xdefine verb XMAIL
X   image MAIL
X   parameter P1, label=FILE, prompt="File"
X      value (type=$infile)
X   parameter P2, label=TOLIST, prompt="To"
X      value (list)
X   qualifier SUBJECT
X      value (required)
X   qualifier FOREIGN, nonnegatable
X   qualifier TYPE
X      value (default="0")
X   qualifier PERSONAL_NAME, label=P_NAME
X      value
X   qualifier TRANSPORT
X      value
X   qualifier DECMAIL, syntax=DECMAIL
X   qualifier EDIT
X      value (list,type=EDIT_TYPES)
X   qualifier PROTOCOL, syntax=PROT_SYNTAX, nonnegatable
X      value (required)
X   qualifier SERVER, syntax=SERVER_SYNTAX
X   qualifier SELF
X
Xdefine syntax DECMAIL
X   image DECMAIL
X
Xdefine type EDIT_TYPES
X   keyword SEND
X   keyword REPLY
X      value (type=REPLY_TYPES)
X   keyword FORWARD
X
Xdefine type REPLY_TYPES
X   keyword EXTRACT
X
Xdefine syntax PROT_SYNTAX
X   image MAIL_SERVER
X
Xdefine syntax SERVER_SYNTAX
X   image MAIL_SERVER
X   qualifier PROTOCOL, nonnegatable
X      value
X
$ CALL UNPACK XMAIL.CLD;2 421374416
$ create 'f'
X;---------------------------------------------------------------------------
V--
X`09.TITLE`09RESET New Mail counter
X`09.IDENT`09/V1.0/
X;
X;***************************************************************************
V***
X;*
V                                                                         `20
V  *
X;*  COPYRIGHT (c) 1992
V                                                        *
X;*  Anthony C. McCracken
V                                                      *
X;*  ALL RIGHTS RESERVED
V                                                       *
X;*
V                                                                         `20
V  *
X;*  THIS PROGRAM HAS BEEN RELEASED INTO THE PUBLIC DOMAIN.  IT MAY BE FREELY
V  *
X;*  DISTRIBUTED AND USED.  THE SOURCE MAY BE MODIFIED AS WELL TO SUIT ONE'S
V   *
X;*  PARTICULAR NEEDS.  THIS PROGRAM MUST NOT BE SOLD.
V                         *
X;*
V                                                                         `20
V  *
X;*  THE AUTHOR ASSUMES NO RESPONSIBILITY FOR THE USE OF THIS PROGRAM ON ANY
V   *
X;*  OTHER COMPUTER SYSTEMS.
V                                                   *
X;*
V                                                                         `20
V  *
X;***************************************************************************
V***
X;
X`20
X;++
X; FACILITY:`09VMS MAIL
X;
X; ABSTRACT:`09This program counts the number of messages in the NEWMAIL
X;`09`09folder and set the new message count accordingly.
X;
X; ENVIRONMENT:`09USER MODE
X;
X; SECURITY:`09NONE
X;
X; AUTHOR:`09Anthony C. McCracken
X;
X; CREATION DATE:  15-May-1992
X;
X; USAGE:`09$ RUN RSETNMCT
X;
X; MODIFIED BY:`09Ehud Gavron`0915-May-1992
X;`09`09`09`09Made into a jacket frontend for MAIL :-)
X
X`09ROUTINE = 1`09; use this as a jacket routine
X;
X;--
X`20
X`09$SSDEF
X`09$MAILDEF
X`20
X;++
X;   Define macros
X;--
X`20
X;+
X; Builds ITEM_LIST_3 structures
X;-
X`09.MACRO`09.ITEM_3`09BUFLEN=0,ICODE=0,BADDR=0,RLADDR=0
X`09`09.WORD`09`09BUFLEN
X`09`09.WORD`09`09ICODE
X`09`09.ADDRESS`09BADDR
X`09`09.ADDRESS`09RLADDR
X`09.ENDM`09.ITEM_3
X`20
X;+
X; Makes the call to MAIL$MAILFILE_rtn easier.  All four parameters must be
X; specified.  The macro then sets up the stack for the CALLS to the desired
X; rotuine.
X;-
X`09.MACRO`09MAILFILE`09RTN,CTXT,INIL=0,OUTIL=0
X`09`09.IF B`09<RTN>
X`09`09`09.ERROR`09;Routine must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.IF B`09CTXT
X`09`09`09.ERROR`09;Context must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.GLOBL`09RTN
X`09`09.IF EQ OUTIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09OUTIL,CONTEXT=L
X`09`09.ENDC
X`09`09.IF EQ`09INIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09INIL,CONTEXT=L
X`09`09.ENDC
X`09`09$PUSHADR`09CTXT,CONTEXT=L
X`09`09CALLS`09#3,G`5EMAIL$MAILFILE_'RTN
X`09.ENDM`09MAILFILE
X`20
X;+
X; Makes the call to MAIL$MESSAGE_rtn easier.  All four parameters must be
X; specified.  The macro then sets up the stack for the CALLS to the desired
X; rotuine.
X;-
X`09.MACRO`09MAILMESSAGE`09RTN,CTXT,INIL=0,OUTIL=0
X`09`09.IF B`09RTN
X`09`09`09.ERROR`09;Routine must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.IF B`09CTXT
X`09`09`09.ERROR`09;Context must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.GLOBL`09RTN
X`09`09.IF EQ OUTIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09OUTIL,CONTEXT=L
X`09`09.ENDC
X`09`09.IF EQ`09INIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09INIL,CONTEXT=L
X`09`09.ENDC
X`09`09$PUSHADR`09CTXT,CONTEXT=L
X`09`09CALLS`09#3,G`5EMAIL$MESSAGE_'RTN
X`09.ENDM`09MAILMESSAGE
X`20
X;+
X; Makes the call to MAIL$USER_rtn easier.  All four parameters must be
X; specified.  The macro then sets up the stack for the CALLS to the desired
X; rotuine.
X;-
X`09.MACRO`09MAILUSER`09RTN,CTXT,INIL=0,OUTIL=0
X`09`09.IF B`09RTN
X`09`09`09.ERROR`09;Routine must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.IF B`09CTXT
X`09`09`09.ERROR`09;Context must be specified
X`09`09`09.MEXIT
X`09`09.ENDC
X`09`09.GLOBL`09RTN
X`09`09.IF EQ OUTIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09OUTIL,CONTEXT=L
X`09`09.ENDC
X`09`09.IF EQ`09INIL
X`09`09`09PUSHL`09#0
X`09`09.IFF
X`09`09`09$PUSHADR`09INIL,CONTEXT=L
X`09`09.ENDC
X`09`09$PUSHADR`09CTXT,CONTEXT=L
X`09`09CALLS`09#3,G`5EMAIL$USER_'RTN
X`09.ENDM`09MAILUSER
X`20
X`09.PSECT`09RWDATA,RD,WRT,NOEXE,LONG
X;+
X; Context variables used by MAIL$ routines.
X;-
X`20
XMFCTX:`09.LONG`090`09`09; MAIL FILE context
XMMCTX:`09.LONG`090`09`09; MAIL MESSAGE context
XMUCTX:`09.LONG`090`09`09; MAIL USER context
X`20
X;+
X; The following are used in the computation of the actual new message count.
X;-
X`20
XFNAME:`09.ASCII`09/NEWMAIL/`09; MAIL Folder name
XFNAME_S = .-FNAME
X`20
XNMCNT:`09.LONG`090`09`09; Number of messages in NEWMAIL
X`20
X;+
X; The following item lists are passed to the MAIL$ routines to get informati
Von
X; or set parameters within VAX MAIL.
X;-
X`20
XNLITM:`09.ITEM_3`09`09; A null item list
X`20
XMMBITM:`09.ITEM_3`094,MAIL$_MESSAGE_FILE_CTX,MFCTX,0
X`09.ITEM_3`09`09; Used to initialize the mail message context
X`20
XMMSITM:`09.ITEM_3`090,MAIL$_NOSIGNAL,0,0
X`09.ITEM_3`09FNAME_S,MAIL$_MESSAGE_FOLDER,FNAME,0
X`09.ITEM_3`09`09; Used to select the NEWMAIL folder if it exists
X`20
XNMCITM:`09.ITEM_3`094,MAIL$_MESSAGE_SELECTED,NMCNT,0
X`09.ITEM_3`09`09; Retrieves the actual newmail messages
X`20
XSNMITM:`09.ITEM_3`092,MAIL$_USER_SET_NEW_MESSAGES,NMCNT,0
X`09.ITEM_3`09`09; Sets newmail count to equal the new message count
X`20
X;++
X; Routine to open the mail file, select the NEWMAIL folder, get the number o
Vf
X; messages, access the MAIL PROFILE and set the newmail count to the actual
X; number of messages present.
X;--
X`09.PSECT`09CODE,RD,NOWRT,EXE,BYTE
X.IF NDF ROUTINE
X`09.ENTRY`09MAIN,`5EM<>
X.IFF
X`09.ENTRY`09ACM_MAILCNT,`5Em<>
X.ENDC
X;+
X; Open the mail file.
X;-
X`09MAILFILE`09RTN=BEGIN,CTXT=MFCTX,INIL=NLITM,OUTIL=NLITM
X`09MAILFILE`09RTN=OPEN,CTXT=MFCTX,INIL=NLITM,OUTIL=NLITM
X;+
X; Select NEWMAIL
X;-
X`09MAILMESSAGE`09RTN=BEGIN,CTXT=MMCTX,INIL=MMBITM,OUTIL=NLITM
X`09MAILMESSAGE`09RTN=SELECT,CTXT=MMCTX,INIL=MMSITM,OUTIL=NMCITM
X;+
X; Set the newmail count.
X;-
X`09MAILUSER`09RTN=BEGIN,CTXT=MUCTX,INIL=NLITM,OUTIL=NLITM
X`09MAILUSER`09RTN=SET_INFO,CTXT=MUCTX,INIL=SNMITM,OUTIL=NLITM
X;+
X; Cleanup and exit mail.
X;-
X`09MAILUSER`09RTN=END,CTXT=MUCTX,INIL=NLITM,OUTIL=NLITM
X`09MAILMESSAGE`09RTN=END,CTXT=MMCTX,INIL=NLITM,OUTIL=NLITM
X`09MAILFILE`09RTN=CLOSE,CTXT=MFCTX,INIL=NLITM,OUTIL=NLITM
X`09MAILFILE`09RTN=END,CTXT=MFCTX,INIL=NLITM,OUTIL=NLITM
X;+
X; Exit program
X;-
X`09$EXIT_S
X.IF NDF ROUTINE
X`09.END`09MAIN
X.IFF
X`09.END
X.ENDC`20
X;---------------------------------------------------------------------------
X`20
X;`20
X;`20
X;+----------------------------------------+---------------------------------
V--+
X;`7C Anthony C. McCracken                   `7C
V                                   `7C
X;`7C Northern Arizona University            `7C Boom boom boom,,, Still goin
Vg !   `7C
X;`7C Flagstaff, Arizona                     `7C
V                                   `7C
X;`7C                                        `7C VMS just keeps going and goi
Vng and`7C
X;`7C acm@nauvax                   BitNet    `7C going.  Nothing outlasts VAX
V/VMS. `7C
X;`7C acm@nauvax.ucc.nau.edu       Internet  `7C
V                                   `7C
X;`7C 602.523.9422.us.west         Noise net `7C
V                                   `7C
X;+----------------------------------------+---------------------------------
V--+
$ CALL UNPACK MAILCNT.MAR;3 355439618
$ create 'f'
X/*
X * Routine to replace one verb by another
X *
X * Ehud Gavron`09<Gavron@ACES.COM>
X * Associates in Consulting and Educational Services, Tucson AZ
X * 04-Jan-1992
X */
X
X#include <climsgdef.h>
X#include <descrip.h>
X#include <ssdef.h>
X#include <strdef.h>
X#define line_length 255
X#define verb_length 255
X#define NEW_VERB "XMAIL"`09/* To call mail */
X
Xchar buf_verb`5Bverb_length`5D;`09/* Buffer for the verb */
Xchar buf_cmnd`5Bline_length`5D;`09/* Buffer for the new whole command */
Xchar buf_line`5Bline_length`5D;`09/* Buffer for the whole line */
X
X
Xcmain()
X`7B
X  $DESCRIPTOR(newverb_desc,NEW_VERB);`09/* The replacement verb descriptor *
V/ `20
X  $DESCRIPTOR(verb_desc,"$VERB");
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X  $DESCRIPTOR(line_desc,"$LINE");
X  $DESCRIPTOR(input_verb,buf_verb);
X  $DESCRIPTOR(input_line,buf_line);
X  $DESCRIPTOR(output_cmd,buf_cmnd);
X  unsigned long ss_stat;
X  if ((ss_stat = cli$get_value(&verb_desc,&input_verb,&input_verb.dsc$w_leng
Vth))
X`09!= SS$_NORMAL) `7B
X`09sys$exit(ss_stat);
X`09`7D
X  if ((ss_stat = cli$get_value(&line_desc,&input_line,&input_line.dsc$w_leng
Vth))
X`09!= SS$_NORMAL) `7B
X`09sys$exit(ss_stat);
X`09`7D
X  input_line.dsc$a_pointer +=input_verb.dsc$w_length;
X  ss_stat = str$concat(&output_cmd,&newverb_desc,&input_line);
X  if ((ss_stat != SS$_NORMAL) && (ss_stat !=STR$_TRU)) `7B
X`09sys$exit(ss_stat);
X`09`7D
X  acm_mailcnt();
X
X  lib$do_command(&output_desc);
X`7D`20
$ CALL UNPACK MAIL_JACKET.C;2 324011664
$ v=f$verify(v)
$ EXIT

