[Info-vax] naming convention in VMS MAIL
Hein RMS van den Heuvel
heinvandenheuvel at gmail.com
Sun Dec 23 17:06:41 EST 2018
On Wednesday, December 19, 2018 at 4:25:53 PM UTC-5, Phillip Helbig (undress to reply) wrote:
> VMS MAIL has files like MAIL$45870BB2000500B0.MAI;1. The digits are not
> random, but are related to (at least) the date and time. What is the
> exact format? Has it changed in the last 25 years?
Hmm, I don't know why our friend Steve start to waffle about API's, opaqueness, performance and such. The question was highly specific. "What is the exact format". There is no suggestion Philips wants to do something useful with that. Perhaps just curious.
Good links though.
Anyway...
The format was once changes in the early 90's or so when the old linear date-time to name mapping was found to deliver horrible performance problems on mail 'purge' due to constant directory block shuffles as folks tend to delete old Email.
The revised algorithm picked a 'middle' piece of the date-time as MSB somewhat randomizing external messages over the sub-directory, but potentially leaving horribly sparse directories.
All that don't matter much.
Below a piece of (sadly undocumented) DCL I wrote ages ago which has the core algorithm. The script finds 'missing' mail records in the MAIL.MAI indexed file opening it twice, once to scan, once to to lookups.
I know I have written a better description, but can't find is just now.
The mail 'message key' is constructed as:
$mes="12345678" ! Allocate 8 bytes
$mes[48,16]=%x0005 ! Hard coded
$mes[00,32]=F$CVSI(16,32,rec) ! MSB form binary date-time
$mes[32,16]=F$CVSI(48,16,rec) ! LSB from binary date-time
Enjoy,
Hein
$start:
$i = 0
$key = "12345678"
$if p2.eqs."" then p2 = "MAIL.MAI"
$if p1.eqs."" then p1 = 8 ! No mails older than 5-JAN-1866 5:59:41.36
$start_date = p1 ! 96="2-Sep-1992", 97="24-Jul-1993", 98="15-Jun-1994"
$key[00,32]=%x00000001
$key[32,32]=%x'p1'0000
$mes="12345678"
$mes[48,16]=%x0005
$j = 0
$OPEN/READ/SHARE=WRITE/ERROR=Oooops file 'p2'
$OPEN/READ/SHARE=WRITE/ERROR=Oooops mess 'p2'
$READ/MATCH=GE/KEY=&key file rec ! Position in file
$loop:
$READ/END=Done file rec ! Ok, so we do not process the first record...
$ i = i + 1
$bin_date = F$EXTRACT(0,8,rec)
$asc_date = F$FAO("!%D",f$cvui(32,32,f$fao("!AD",8,bin_date)))
$k1 = F$FAO("!XL", F$CVSI(0,32,rec))
$k2 = F$FAO("!XL", F$CVSI(32,32,rec))
$if F$CVSI(387,1,rec) then goto loop ! bit 3, byte 48, external flag.
$mes[00,32]=F$CVSI(16,32,rec)
$mes[32,16]=F$CVSI(48,16,rec)
$READ/MATCH=EQ/KEY=&mes/ERRO=not_found mess message
$goto loop
$not_found:
$j = j + 1
$write sys$output f$fao("!XL !XL !XL !XL", F$CVSI(0,32,rec), -
F$CVSI(32,32,rec), F$CVSI(0,32,mes), F$CVSI(32,32,mes))
$write sys$output k2, " ", k1, " ", asc_date, " ", i, " ", j
$goto loop
$Done:
$WRITE sys$output i, " messages processed in total."
$CLOSE file
$EXIT
More information about the Info-vax
mailing list