home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / mail / elm / 3695 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  10.1 KB

  1. Xref: sparky comp.mail.elm:3695 comp.os.vms:19181
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!olivea!sgigate!sgi!wdl1!wdl1.wdl.loral.com!rob
  3. From: rob@icarus.ssd.loral.com (Rob Riepel)
  4. Newsgroups: comp.mail.elm,comp.os.vms
  5. Subject: Re: converting VMS MAIL folder to elm
  6. Message-ID: <ROB.92Dec12151131@icarus.ssd.loral.com>
  7. Date: 12 Dec 92 23:12:13 GMT
  8. References: <johnson.3.724125554@kelvin.jpl.nasa.gov>
  9. Sender: news@wdl.loral.com
  10. Organization: Space Systems/Loral
  11. Lines: 321
  12. In-Reply-To: johnson@kelvin.jpl.nasa.gov's message of 12 Dec 92 01:59:15 GMT
  13.  
  14.  
  15. In article <johnson.3.724125554@kelvin.jpl.nasa.gov>
  16.     johnson@kelvin.jpl.nasa.gov (Glenn Johnson) writes:
  17.  
  18. > Is there a way to convert VMS MAIL folders to elm format?
  19. > (Preserving the dates and original sender etc.)
  20.  
  21. Time to post this again:  VMS FORTRAN program to convert VMSmail folders to
  22.                           Unix mail folders.
  23.  
  24. ..rob
  25.  
  26. $! ------------------ CUT HERE -----------------------
  27. $ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
  28. $!
  29. $! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
  30. $!   On 10-FEB-1992 14:04:20.74   By user ROB 
  31. $!
  32. $! This VMS_SHARE Written by:
  33. $!    Andy Harper, Kings College London UK
  34. $!
  35. $! Acknowledgements to:
  36. $!    James Gray       - Original VMS_SHARE
  37. $!    Michael Bednarek - Original Concept and implementation
  38. $!
  39. $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
  40. $! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
  41. $!
  42. $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
  43. $!       1. V2U_MAIL.FOR;1
  44. $!
  45. $set="set"
  46. $set symbol/scope=(nolocal,noglobal)
  47. $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
  48. $e="write sys$error  ""%UNPACK"", "
  49. $w="write sys$output ""%UNPACK"", "
  50. $ if f$trnlnm("SHARE_LOG") then $ w = "!"
  51. $ ve=f$getsyi("version")
  52. $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
  53. $ e "-E-OLDVER, Must run at least VMS 4.4"
  54. $ v=f$verify(v)
  55. $ exit 44
  56. $UNPACK: SUBROUTINE ! P1=filename, P2=checksum
  57. $ if f$search(P1) .eqs. "" then $ goto file_absent
  58. $ e "-W-EXISTS, File ''P1' exists. Skipped."
  59. $ delete 'f'*
  60. $ exit
  61. $file_absent:
  62. $ if f$parse(P1) .nes. "" then $ goto dirok
  63. $ dn=f$parse(P1,,,"DIRECTORY")
  64. $ w "-I-CREDIR, Creating directory ''dn'."
  65. $ create/dir 'dn'
  66. $ if $status then $ goto dirok
  67. $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
  68. $ delete 'f'*
  69. $ exit
  70. $dirok:
  71. $ w "-I-PROCESS, Processing file ''P1'."
  72. $ if .not. f$verify() then $ define/user sys$output nl:
  73. $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
  74. PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
  75. SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
  76. CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
  77. LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
  78. BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
  79. IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
  80. MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
  81. ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
  82. 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
  83. POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
  84. ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
  85. COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
  86. "output_file"));ENDPROCEDURE;Unpacker;QUIT;
  87. $ delete/nolog 'f'*
  88. $ CHECKSUM 'P1'
  89. $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
  90. $ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
  91. $ ENDSUBROUTINE
  92. $START:
  93. $ create 'f'
  94. X  `09program v2u_mail
  95. X
  96. Xc`09convert mail files from VMS to UNIX
  97. X
  98. Xc`09V2U_MAIL, a hack by Rob Riepel (rob@ssvax1.ssd.loral.com)
  99. Xc
  100. Xc`09  This program was whipped up to convert my VMSmail to Unix.  I
  101. Xc`09  hope it works for you too.  If you make improvements, please
  102. Xc`09  let me know.  If you're seriously into hackery, use the callable
  103. Xc`09  mail interface to parse through the VMSmail messages, and make
  104. Xc`09  sure the Unix mail headers conform to the relevant RFCs.
  105. X
  106. Xc`09INSTRUCTIONS
  107. Xc`09============
  108. Xc
  109. Xc`09v2u_mail will will read standard VMSmail files and convert them
  110. Xc`09to Unix file files.  To use the program, first compile and link
  111. Xc`09it.
  112. Xc
  113. Xc`09   $ FOR V2U_MAIL
  114. Xc`09   $ LIN V2U_MAIL
  115. Xc
  116. Xc`09Next, assign the logical MAIL_DIR to point to the directory where
  117. Xc`09all your VMSmail is stashed.
  118. Xc
  119. Xc`09   $ ASSIGN SYS$LOGIN_DEVICE:`5BMY_HOME.MAIL`5D MAIL_DIR
  120. Xc
  121. Xc`09Move to the directory where you want the Unix mail folders, and
  122. Xc`09run V2U_MAIL.
  123. Xc
  124. Xc`09   $ SET DEFAULT `5BMY_HOME.UNIX_MAIL`5D
  125. Xc`09   $ RUN `5BMY_HOME.V2U_MAIL`5DV2U_MAIL
  126. Xc
  127. Xc`09A Unix mail file will be created for each folder in your VMSmail.
  128. X
  129. Xc
  130. Xc`09%Id: v2u_mail.for_v 1.2 92/02/10 13:55:22 rob Exp %
  131. Xc
  132. Xc`09%Log:`09v2u_mail.for_v %
  133. Xc`09Revision 1.2  92/02/10  13:55:22  rob
  134. Xc`09Increased buffer sizes to handle long lines, from's, subjects, and cc's.
  135. Xc`09Added comments, including instructions for use.
  136. Xc`09Added RCS keywords.
  137. Xc`09
  138. X
  139. X`09implicit integer*4 (a-z)
  140. X
  141. X`09common`09/count/`09mcount
  142. X
  143. X`09character     `09cbuf*2048
  144. X`09integer*4`09ibuf(2048), mcount /0/
  145. X        integer*2 `09rlen
  146. X`09equivalence`09(cbuf,ibuf)
  147. X
  148. Xc`09open the mail file, twice
  149. X
  150. X `09open(`09unit=10,
  151. X     &`09`09file='mail_dir:mail.mai',
  152. X     &`09`09access='keyed',
  153. X     &`09`09key=(1:8:integer,10:48:character),
  154. X     &`09`09blocksize=2048,
  155. X     &`09`09organization='indexed',
  156. X     &`09`09recordtype='variable',
  157. X     &`09`09form='formatted',
  158. X     &         `09shared,
  159. X     &`09`09readonly,
  160. X     &`09`09status='old')
  161. X
  162. X `09open(`09unit=11,
  163. X     &`09`09file='mail_dir:mail.mai',
  164. X     &`09`09access='keyed',
  165. X     &`09`09key=(1:8:integer,10:48:character),
  166. X     &`09`09blocksize=2048,
  167. X     &`09`09organization='indexed',
  168. X     &`09`09recordtype='variable',
  169. X     &`09`09form='formatted',
  170. X     &         `09shared,
  171. X     &`09`09readonly,
  172. X     &`09`09status='old')
  173. X
  174. Xc`09read and process the first record
  175. X
  176. X`09read(10,'(Q,A2048)',keyge='A',keyid=1)rlen,cbuf
  177. X`09call process_record(ibuf,ibuf,cbuf,rlen)
  178. X
  179. Xc`09process the remaining records
  180. X`09
  181. X`09do while (1 .eq. 1)
  182. X`09    read(10,'(Q,A2048)',end=100)rlen,cbuf
  183. X`09    call process_record(ibuf,ibuf,cbuf,rlen)
  184. X  `09end do
  185. X
  186. Xc`09we're done, write out the last folder's message count and leave
  187. X
  188. X  100`09continue
  189. X`09if (mcount .gt. 0) write(6,10)null,mcount
  190. X   10`09format(a1,i3,' messages')
  191. X`09close(10)
  192. X`09call exit
  193. X`09end
  194. X
  195. X`09subroutine process_record(bbuf,ibuf,cbuf,rlen)
  196. X
  197. Xc`09this is where all the work gets done
  198. X
  199. X`09implicit integer*4 (a-z)
  200. X
  201. X`09common`09/count/`09mcount
  202. X
  203. X`09byte`09     bytes(2), bbuf(2048)
  204. X`09integer*2    dlen
  205. X`09integer*4    ibuf(2048)
  206. X`09character    cbuf*2048, folder*39, null*1, line*2048, name*80
  207. X`09character    from*255, to*255, cc*255, subject*255, date*25
  208. X`09character*3  aday(7) /'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat','Sun'/
  209. X`09character    ctime*80
  210. X`09logical`09     iam
  211. X
  212. X`09equivalence  (dlen,bytes)
  213. X
  214. X`09save folder, flen
  215. X
  216. X`09null = char(0)
  217. X
  218. Xc`09open a new UNIX mail file for each VMS mail folder
  219. X
  220. X`09len = index(cbuf(10:),null)
  221. X`09if (folder(1:flen) .ne. cbuf(10:10+len-1)) then
  222. X`09    close(20)
  223. X`09    flen = len
  224. X`09    folder(1:len) = cbuf(10:10+len-1)
  225. X`09    folder(flen+1:) = '.'
  226. X`09    if (mcount .gt. 0) write(6,10)null,mcount
  227. X   10`09    format(a1,i3,' messages')
  228. X`09    mcount = 0
  229. X`09    write(6,20)folder(1:flen)
  230. X   20`09    format(1x,'Processing folder ',a,t35,'...',$)
  231. X`09    open(20,name=folder(1:flen+1),status='new',recl=2048,
  232. X     &`09`09    carriagecontrol='list')
  233. X`09endif
  234. X
  235. Xc`09count the messages
  236. X
  237. X`09mcount = mcount + 1
  238. X
  239. Xc`09parse out the from, to, subject, etc...
  240. X
  241. X`09base = 91
  242. X`09bytes(1) = bbuf(base)
  243. X`09bytes(2) = bbuf(base+1)
  244. X`09from_len = dlen
  245. X`09from = cbuf(base+2:base+from_len+1)
  246. X`09from_len_short = index(from,' ') - 1
  247. X
  248. X`09base = base + dlen + 4
  249. X`09bytes(1) = bbuf(base)
  250. X`09bytes(2) = bbuf(base+1)
  251. X`09to_len = dlen
  252. X`09to = cbuf(base+2:base+to_len+1)
  253. X
  254. X`09base = base + dlen + 4
  255. X`09bytes(1) = bbuf(base)
  256. X`09bytes(2) = bbuf(base+1)
  257. X`09cc_len = dlen
  258. X`09cc = cbuf(base+2:base+cc_len+1)
  259. X
  260. X`09base = base + dlen + 4
  261. X`09bytes(1) = bbuf(base)
  262. X`09bytes(2) = bbuf(base+1)
  263. X`09subject_len = dlen
  264. X`09subject = cbuf(base+2:base+subject_len+1)
  265. X
  266. Xc`09do the time thing
  267. X
  268. X`09call lib$day_of_week(ibuf(1),day)
  269. X`09call lib$sys_asctim(time_len,ctime,ibuf(1),)
  270. X`09ctime(5:5) = char(ichar(ctime(5:5)) + 32)
  271. X`09ctime(6:6) = char(ichar(ctime(6:6)) + 32)
  272. X`09write(date,30)aday(day),ctime(4:6),ctime(1:2),ctime(13:20),ctime(8:11)
  273. X   30`09format(5(1x,a))
  274. X
  275. Xc`09write out the mail header
  276. X
  277. X`09write(20,60)from(1:from_len_short),date,
  278. X     &`09`09    from(1:from_len_short),date,
  279. X     &`09`09    to(1:to_len)
  280. X`09if (cc_len .gt. 0)write(20,62)cc(1:cc_len)
  281. X`09write(20,64)from(1:from_len),subject(1:subject_len)
  282. X
  283. X   60`09format(    'From ',2a,/,
  284. X     &             'Return-path: <',a,'>'/,
  285. X     &             'Date: ',a,/
  286. X     &             'To: ',a)
  287. X   62`09format(    'Cc: ',a)
  288. X   64`09format(    'From: ',a,/,
  289. X     &             'Subject: ',a,/,
  290. X     &             'Status: RO',/)
  291. X
  292. Xc`09attempt to read the body as a mail file record
  293. Xc`09and write out the records to the new file
  294. X`09
  295. X`09read(11,'(Q,A2048)',keyid=0,key=ibuf(15),err=80)rlen,cbuf
  296. X`09base = 49
  297. X
  298. X`09do while (base .lt. rlen)
  299. X`09    bytes(1) = bbuf(base)
  300. X`09    bytes(2) = bbuf(base+1)
  301. Xd`09    write(6,*)dlen
  302. Xc`09    write(20,'(1x,A)')cbuf(base+2:base+dlen+1)
  303. X`09    write(20,'(A)')cbuf(base+2:base+dlen+1)
  304. X`09    base = base + dlen + 2
  305. X`09end do
  306. X`09write(20,'(/)')
  307. X`09return
  308. X
  309. Xc`09body is in a separte file, open it and copy it to the new
  310. Xc`09mail file
  311. X
  312. X   80`09continue
  313. X`09write(name,100)ibuf(15),ibuf(16)
  314. X  100`09format('mail_dir:mail$',2Z8.8,'.mai')
  315. X`09inquire(file=name,exist=iam)
  316. X`09if(.not.iam)write(name,100)ibuf(16),ibuf(15)
  317. Xd`09write(6,110)name
  318. Xd 110`09format(1x,'>',a,'<')
  319. X`09open(12,name=name,status='old',readonly)
  320. X  120`09continue
  321. X`09    read(12,'(Q,A)',end=140)llen,line
  322. Xd`09    write(6,*)llen
  323. Xc`09    write(20,'(1x,A)')line(1:llen)
  324. X`09    write(20,'(A)')line(1:llen)
  325. X`09go to 120
  326. X
  327. X  140`09continue
  328. X`09write(20,'(/)')
  329. X`09close(12)
  330. X`09return
  331. X`09end
  332. $ CALL UNPACK V2U_MAIL.FOR;1 1897075167
  333. $ v=f$verify(v)
  334. $ EXIT
  335.