|
c
c This program should be executed from a PRIV a account.
c
c Basically this allows you to change any persons newmail
c account record to a specified value.
c Can be quite funny if you give your friend 999999 new
c mail messages !!!
c
c share and enjoy...
c
c Justyn k (jka)
program mailfix
common/rec/user,flag,new,spare
character*31 user,find
integer*2 flag,new,spare(100)
character*1 buff(200)
equivalence (user,buff)
open(unit=1,file='sys$system:vmsmail.dat',organization='indexed',
1 form='formatted',access='keyed',
1 status='old')
1 write(5,*)'User name'
read(5,15,end=999)find
15 format(a)
read(1,22,err=1,key=find)l,(buff(j),j=1,l)
22 FORMAT(Q,200A)
write(5,*)new,'value for new messages'
read(5,*,end=1)i
new=i
rewrite(1,23)(buff(j),j=1,l)
23 FORMAT(200A)
goto 1
999 stop
end
|
| > Re .13: But would that work if the person has his forwarding address
> in NMAIL style (NM%node::user)?
Nope. But then you could always check the NMAIL queues...
Here's my version of MAILFIX which was written at the time of our
upgrade to 4.0 (funny how we both chose the same name...)
Note: You will need to modify line 255 to reflect your node name
or add code to find out what it is.
This program works fine for most cases. There are certain variations
of wildcards not allowed, and other cases that loop. Sorry, no
documentation on those bugs!
SLH "All good programs have bugs!"
1 ! MAILFIX.BAS
!
! Created: 03-MAY-1985
! Author: Scott L. Hesterman PXO SWS
! I would like to acknowledge the help of Gary R. Phoenix
! without whose help this project would not have been possible.
!
!Revision History
!
! 01.4 30-Oct-1985 SLH
! Alert user if an account has a FORWARDing Address
! Also check forwarding address for remote node name
!
! 01.3 30-Oct-1985 SLH
! Added a trap for non-existent user directory
! Added a trap for ^C at 3010
! Added version numbers
! Now user-defined mail directories are allowed for.
!
! 01.2 17-May-1985 SLH
! Fixed some of yesterday's wild coding...
! * Added general HELP
!
! 01.1 16-May-1985 SLH
! Improved wildcard prompting with added HELP
! Added error traps for non-existant user MAIL.MAI, eof for SYSUAF,
! and invalid MAIL.MAI file format.
!
! 01.0 09-May-1985 SLH
! Added ^Z handling
!
!
!-----------------------------------------------------------------------
!
!
!ABSTRACT:
!
! During the conversion from VMS 3.7 to 4.0 some users' mail files
! will end up with an incorrect New Message count.
! The mail file format for VMS 4.0 is different from 3.7
! When a user uses MAIL for the first time after the upgrade
! MAIL will convert the users personal MAIL.MAI file to the proper
! format. If, however, a user receives mail BEFORE converting the
! file he will be forever plagued by 'ghost messages'. That is to
! say, at every login and use of MAIL there will be at least one
! more message listed than is actually there. Typically it will
! always say "One messge waiting" when there are none.
!
!Theory of Operation:
! You are prompted for the VMS USERNAME to be fixed. The SYSUAF file
! is searched to find the user's login directory. If the user exists
! then the VMSMAIL file is searched to find the current message count.
! The user's own MAIL.MAI file is then examined to count all messages
! in the NEWMAIL folder.
!
! The VMSMAIL count will be displayed. If this does not match the
! NEWMAIL count then you are asked whether or not to correct the count.
! If you respond "yes", then the VMSMAIL record is immediatly updated.
! When finished simply enter EXIT as the user name.
!
20 ON ERROR GOTO 32000
A% = CTRLC !enable control C trapping
100 MAP (REKORD) BYTE REKORD(2048)
MAP (REKORD) DOUBLE MAILTIME, &
BYTE FOLDER_LENGTH, &
STRING FOLDER = 39%
170 MAP (VMSMAIL) STRING Mail_name = 31%, &
BYTE FILL(2), &
BYTE MSG_COUNT, &
STRING FILLER = 31%, &
BYTE MAIL_DIR_LEN, &
BYTE PERS_NAME_LEN, &
BYTE FORWARD_LEN, &
STRING NAME_MAIL_DIR = 128%, &
STRING F = 256%
180 MAP (SYSUAF) BYTE UAE(1600)
MAP (SYSUAF) BYTE FILL(4), &
STRING User_name = 32%, &
BYTE FILL(16), &
STRING ACCOUNT = 32%, &
BYTE OWNER_NAME_LEN, &
STRING OWNER_NAME = 31%, &
BYTE DEVICE_NAME_LEN, &
STRING DEVICE_NAME = 31%, &
BYTE DIR_NAME_LEN, &
STRING DIR_NAME = 63%, &
BYTE LGICMD_LEN, &
STRING LGICMD = 39% !? not sure ?
200 OPEN "SYS$SYSTEM:SYSUAF.DAT" FOR INPUT AS FILE #1% &
,ORGANIZATION INDEXED &
,RECORDTYPE ANY &
,ACCESS READ &
,ALLOW MODIFY &
,MAP SYSUAF
210 OPEN "SYS$SYSTEM:VMSMAIL.DAT" FOR INPUT AS FILE #2% &
,ORGANIZATION INDEXED VARIABLE &
,RECORDTYPE ANY &
,ACCESS MODIFY &
,ALLOW MODIFY &
,MAP VMSMAIL
240 declare string bell
250 bell = chr$(7)
updt$ = "NO"
declare string search_method
search_method = "SINGLE"
Confirm = 1
nulcnt = 0 ! number of null responses
255 Current_Node$="SWD005" ! Don't include ::
260 Print
Print "MAILFIX V01.4 *** VMS 4.1 30-Oct-1985 ***"
300 Print
305 if search_method = "WILDCARD" then goto 320
306 INPUT "User name to find (or EXIT to exit) ",Username$
Username$=Edit$(Username$,34%) ! Uppercase,
! no spaces
IF Username$="EXIT" &
or Username$="EXI" &
or Username$="EX" &
then goto 32100
307 IF Username$="QUIT" &
or Username$="QUI" &
or Username$="QU" &
then goto 32100
308 if Username$="HELP" &
or Username$="HEL" &
or Username$="HE" &
or Username$="H" &
then goto 8000
310 if Username$>"" then goto 314
311 nulcnt = nulcnt + 1
312 if nulcnt < 3 then goto 306
313 Print "Type HELP for assistance."
nulcnt = 0
goto 300
314 if Mid$(Username$,Len(Username$),1)<>"*" then goto 350
315 search_method="WILDCARD"
Username$=Left$(Username$,Len(Username$)-1)
Usrnamsav$=Username$
316 If Username$="" then Username$="A"
317 Find #1%, KEY #0 GE Username$
320 GET #1%
Username$ = edit$(User_name,34%)
325 if Usrnamsav$ = left$(Username$,len(Usrnamsav$)) then goto 500
330 search_method = "SINGLE" ! No Match Found
goto 300
349 ! No wild-card in progress
350 GET #1%, KEY #0 EQ Username$
400 if Username$=User_name then goto 500 ! exact match found
! No wild-card specified, No exact match found, but
! Search string exactly matches a found name up to search strings length
410 if Username$ = left$(User_name,len(Username$)) then goto 420
415 Print "No more matches for '";Username$;"'"
goto 300
420 Print " '";Username$;"' matches '";edit$(user_name,34%);"'"
Print "* Is this the correct user? <No> ";
input g$
g$ = left$(edit$(g$,34%),1)
if g$ = "" then g$="N"
430 if g$ <> "Y" &
then
Usrnam$ = Left$( edit$(user_name,34%)+"AAAAAAAAAAA" , 12)
Get #1%, key #0 GT Usrnam$
goto 410
! User says this is the one
440 Username$ = edit$(user_name,34%)
! We now have the right username in Username$
500 DEV$ = LEFT$(DEVICE_NAME,DEVICE_NAME_LEN)
DIR$ = LEFT$(DIR_NAME,DIR_NAME_LEN-1)
if search_method = "WILDCARD" &
then
Print
Print "User '";Username$;"'"
510 GET #2% , KEY #0 EQ Username$ !get MSG_COUNT
IF FORWARD_LEN = 0 then 580
520 Print "Mail is being forwarded to ";!
Username$=Left$( NAME_MAIL_DIR, FORWARD_LEN)
Print Username$ !
DC = instr(1%,Username$,"::") !check for remote node name
If DC = 0 then 350 !
530 Node$=Left$(Username$,DC-1) !
Username$=Right$(Username$,DC+2)!
If Node$=Current_Node$ then 350 !ok on current node
540 Print " ";Node$;" is a remote node."
goto 300
580 MAIL$ = MID$( NAME_MAIL_DIR, FORWARD_LEN+PERS_NAME_LEN+2, MAIL_DIR_LEN-1)
IF MAIL$="" then MAIL$="]"
590 dir$=dir$+mail$
CHECK_NEW_MAIL:
2000 !**********************************************************************
!
2200 NEW_MAIL_CNT = 0
OPEN DEV$+DIR$+"MAIL.MAI" FOR INPUT AS FILE #3% &
,ORGANIZATION INDEXED VARIABLE &
,RECORDTYPE ANY &
,ACCESS READ &
,ALLOW WRITE &
,MAP REKORD &
,RECORDSIZE 2048
2250 FIND #3%, KEY #1 EQ "NEWMAIL"
2260 GET #3%
IF LEFT$(FOLDER, 7%) <> "NEWMAIL" THEN GOTO 2260
2270 NEW_MAIL_CNT = NEW_MAIL_CNT + 1
GOTO 2260
2990 CLOSE #3%
3000 !**********************************************************************
!
Print " Master record indicates ";MSG_COUNT
IF MSG_COUNT = NEW_MAIL_CNT then 5000
3010 Print " Mail file actually has ";NEW_MAIL_CNT
INPUT "* Change it? <Yes> ", G$
G$=left$(edit$(G$,34%),3)
IF G$ = "Y" or G$="YES" or G$="" &
then
Msg_count = NEW_MAIL_CNT
UPDATE #2%
Print " We have updated ";Username$
updt$ = "YES"
else
Print " NOT changed."
3245 GOTO 6000
5000 Print " This is correct."
6000 if search_method = "SINGLE" then goto 300
6005 if Confirm = 0 then goto 300
6010 Print "Next, Go, or Quit <Next> ";
6020 input g$
g$=edit$(G$,34%)
6021 if g$="N" &
or g$="NE" &
or g$="NEX" &
or g$="NEXT" &
then goto 300
6022 if g$="G" &
or g$="GO" &
then
Confirm = 0
goto 300
6023 if g$="H" &
or g$="HE" &
or g$="HEL" &
or g$="HELP" &
then goto 6200
6024 if g$="Q" &
or g$="QU" &
or g$="QUI" &
or g$="QUIT" &
then
search_method = "SINGLE"
goto 300
6025 if g$="E" &
or g$="EX" &
or g$="EXI" &
or g$="EXIT" &
then goto 32100
6090 goto 300
6200 Print
Print "Type the command of your choice. Then press the RETURN key."
Print
Print "NEXT - Continue on with the next user name"
Print "GO - Continue on with no further prompting"
Print "QUIT - Stop processing users"
Print " (Abbreviations are ok)"
goto 6010
8000 Print "Sorry! No help is currently available. Try again in the"
Print "next update of this program."
goto 300
32000 !**********************************************************************
!
if ERL = 306 and ERR = 11 then ! ^Z from kybd
resume 32100 ! lets quit
end if !
!
IF ERL = 350 and ERR = 155 then
Print
Print bell;"No such user. (";Username$;")"
Print
resume 300
end if
!
if ERL = 320 and ERR = 11 then !end of SYSUAF file
Print "No more users." !
search_method = "SINGLE" !
resume 300 !
end if
!
if ERL = 420 and ERR = 11 then !^Z from kybd during user match
resume 300 !so quit searching
end if
!
IF ERL = 510 and ERR = 155 then !not in VMSMAIL.DAT
Print Username$;" not found in"; !big problem!!!
Print " VMSMAIL.DAT !!";bell !
resume 300 !
end if !
!
If ERL = 2200 and ERR = 1 then ! No Directory for user
Print "User directory does not exist"! assume NEW_MAIL_CNT = 0
Print bell; ! and continue
resume 3000 !
end if
!
If ERL = 2200 and ERR = 2 then ! Illegal file name
Print "Illegal file name: "; !
Print DEV$+DIR$;bell !
resume 300 !
end if
!
IF ERL = 2200 and ERR = 5 then !no MAIL.MAI file
Print "No mail file found for user ";!assume NEW_MAIL_CNT = 0
Print Username$;"...";bell !and continue
resume 3000 !
end if
!
if ERL = 2200 and ERR = 168 then !wrong file format
Print bell;"Old style mail file..." !
resume 3000 !
end if
!
if ERL = 2250 and ERR = 155 THEN !no outstanding mail
resume 2990 !
end if !
!
if ERL = 2260 and ERR = 11 then !end of file
resume 2990 !
end if !
!
IF ERL = 3010 and ERR = 11 then ! ^Z from kybd
Print "No change made to ";Username$ ! can't quit just yet...
Print
resume 300
END IF
!
IF ERL = 3010 and ERR = 28 then ! ^C from kybd
Print "No change made to ";Username$ ! can't quit just yet...
Print
resume 300
END IF
!
IF ERL = 6020 and ERR = 11 then ! ^Z from kybd during wildcard
search_method = "SINGLE" ! switch back to manual and
resume 300 ! continue
END IF
!
if ERL = 1 and ERR = 28 then ! ^C
Print "^C interrupt." ! (crude method)
confirm = 1 !
resume 300
!
!
!
32010 Print bell;"ERROR "; ERR; " - "; ERT$(ERR); " on line "; ERL
RESUME 32100
!
32100 if updt$ = "YES" &
then Print "VMSMAIL.DAT updated." &
else Print "No changes made to VMSMAIL.DAT."
32200 Print
END
|