From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 21-NOV-1989 21:06
To:	MRGATE::"ARISIA::EVERHART"
Subj:	xbin 2 of 4

Message-Id:  <8911211852.AA05819@crdgw1.ge.com>
Received: From NWC.NAVY.MIL by CRVAX.SRI.COM with TCP; Tue, 21 NOV 89 07:51:11 PDT
Date: 21 Nov 89 07:23:00 PDT
From: "LEVINE PETER J" <levine%y.mil:amiga-relay-request@louie.udel.edu>
Subject: xbin 2 of 4
To: "info-vax" <info-vax@crvax.sri.com>

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X`009$clidef
X`009$rmsdef
X`009$fabdef
X`009$rabdef
X
Xbuflen `009= 256
Xreclen`009= 128
Xmacflen`009= 63
Xnum_q_chars`009= 82
Xdefaultflags`009= `094x2000
Xq_rept_flag`009= `094x90
Xq_crc_mask`009= `094x1021
X
Xc_space`009= `094a/ /
Xc_mesh`009= `094a/#/
Xc_colon`009= `094a/:/
Xc_dollar= `094a/$/
Xc_zero`009= `094a/0/
Xc_nine`009= `094a/9/
Xc_a`009= `094a/a/
Xc_z`009= `094a/z/
Xc_big_a`009= `094a/A/
Xc_big_z = `094a/Z/
Xc_q_low = `094a/!/
Xc_q_high= `094a/r/
Xl_spaces= `094x20202020
Xl_q_lows= `094x21212121
X
X`009.psect`009$data, rd, wrt, noexe
X
Xinfab:`009$fab`009fac=GET, fna=infile, dnm=<.hqx>, shr=GET, fop=SQO
Xinrab:`009$rab`009fab=infab, ubf=inbuff, usz=buflen
Xoutfab:`009$fab`009fac=<PUT TRN>, fna=outfile, dnm=<.mac>, rat=CR -
X`009`009fop=<TEF SQO>, mrs=reclen, rfm=FIX, shr=NIL
Xoutrab:`009$rab`009fab=outfab, rbf=outbuff, rsz=reclen
Xtmrfab:`009$fab`009fac=<PUT GET>, fnm=<sys$scratch:tmr.fil>, rat=CR -
X`009`009fop=<SQO TMD>, mrs=reclen, rfm=FIX, shr=NIL
Xtmrrab:`009$rab`009fab=tmrfab, rbf=outbuff, rsz=reclen
Xtmdfab:`009$fab`009fac=<PUT GET>, fnm=<sys$scratch:tmd.fil>, rat=CR -
X`009`009fop=<SQO TMD>, mrs=reclen, rfm=FIX, shr=NIL
Xtmdrab:`009$rab`009fab=tmdfab, rbf=outbuff, rsz=reclen
X
Xinptr:`009.long`0090
Xinlen:`009.word`0090
Xcmd_prefix:
X`009.ascii`009/xbin /
Xinbuff:`009.blkb`009buflen
Xoutbuff:
X`009.blkb`0092*reclen
Xq_buff:`009.blkb`0094
Xq_len:`009.byte`0090
Xlastch:`009.byte`0090
Xrept:`009.byte`0090
X
Xlen:`009.word`0090
Xdescr:`009.long`009buflen
X`009.address`009string
Xdescr2:`009.long`009buflen
X`009.address`009string
Xstring:`009.blkb`009buflen
Xinfile:`009.blkb`009buflen
Xoutfile:
X`009.blkb`009buflen
Xmacnlen:
X`009.word`0090
Xmacname:
X`009.blkb`009macflen
Xfiletype:
X`009.ascii`009/----/
Xfilecreator:
X`009.ascii`009/----/
Xfileflags:
X`009.word`009defaultflags
Xrsrc_len:
X`009.long`0090
Xdata_len:
X`009.long`0090
Xcrc:`009.long`0090
X
Xfile_cre_date:
X`009.long`0090
Xfile_mod_date:
X`009.long`0090
X
Xstatus_flags:
X`009.word`0090`009; bits mean as follows:
Xflag_q_format`009= 0`009; set if q format
Xflag_compressed`009= 1`009; set if compressed format
Xflag_got_rsrc`009= 2`009; set if the resource fork has been received
Xflag_got_data`009= 3`009; set if the data fork has been received
Xflag_copy_rsrc`009= 4`009; set if the resource fork is in a temporary file
Xflag_copy_data`009= 5`009; set if the data fork is in a temporary file
Xflag_created`009= 6`009; set if the output file has been created
Xflag_got_crc`009= 7`009; set if a checksum was found
Xflag_eof`009= 8`009; set if end of file has been hit
X
X
X`009.psect`009$code, pic, rd, nowrt, exe, shr, long
X
X; Q-format encryption characters
X; !"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ`091`096abcdefhijklmpqr
X; 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
X; 0               1               2               3`032
X
Xq_translate:
X`009.byte`009`094xFF`09132`093`009`009`009`009`009; `094@ - `094_
X`009.byte`009`094xFF, `094x00, `094x01, `094x02, `094x03, `094x04, `094x05,
V `094x06`009;   - '
X`009.byte`009`094x07, `094x08, `094x09, `094x0A, `094x0B, `094x0C, `094xFF,
V `094xFF`009; ( - /
X`009.byte`009`094x0D, `094x0E, `094x0F, `094x10, `094x11, `094x12, `094x13,
V `094xFF`009; 0 - 7
X`009.byte`009`094x14, `094x15, `094xFF, `094xFF, `094xFF, `094xFF, `094xFF,
V `094xFF`009; 8 - ?
X`009.byte`009`094x16, `094x17, `094x18, `094x19, `094x1A, `094x1B, `094x1C,
V `094x1D`009; @ - G
X`009.byte`009`094x1E, `094x1F, `094x20, `094x21, `094x22, `094x23, `094x24,
V `094xFF`009; H - O
X`009.byte`009`094x25, `094x26, `094x27, `094x28, `094x29, `094x2A, `094x2B,
V `094xFF`009; P - W
X`009.byte`009`094x2C, `094x2D, `094x2E, `094x2F, `094xFF, `094xFF, `094xFF,
V `094xFF`009; X - _
X`009.byte`009`094x30, `094x31, `094x32, `094x33, `094x34, `094x35, `094x36,
V `094xFF`009; `096 - g
X`009.byte`009`094x37, `094x38, `094x39, `094x3A, `094x3B, `094x3C, `094xFF,
V `094xFF`009; h - o
X`009.byte`009`094x3D, `094x3E, `094x3F, `094xFF, `094xFF, `094xFF, `094xFF,
V `094xFF`009; p - w
X`009.byte`009`094xFF, `094xFF, `094xFF, `094xFF, `094xFF, `094xFF, `094xFF,
V `094xFF`009; x - `094-
X`009.byte`009`094xFF`091128`093`009`009`009`009`009; high-bit chars
X
Xprompt:`009`009.ascid`009/$_ /
Xs_infile:`009.ascid`009/INFILE/
Xs_outfile:`009.ascid`009/OUTFILE/
Xs_macname:`009.ascid`009/MACNAME/
Xheader_thingie:`009.ascid`009/(This file must be converted with/
Xstars:`009`009.ascid`009/***/
Xs_compressed:`009.ascid`009/***compressed/
Xs_filetype:`009.ascid`009/***filetype/
Xs_data_fork:`009.ascid`009/***data fork/
Xs_rsrc_fork:`009.ascid`009/***resource fork/
Xs_end_of_data:`009.ascid`009/***end of data/
Xs_checksum:`009.ascid`009/***checksum:/
Xs_crc:`009`009.ascid`009/***crc:/
X
Xmsg_no_name:`009.ascid`009/No name for file (type=!AF, creator=!AF, / -
X`009`009`009'lengths: rsrc=!UL, data=!UL)!/Call it: '
Xmsg_garbage:`009.ascid`009/Warning -- Unrecognizable garbage found in file:/
Xmsg_extra_data:`009.ascid`009/Error -- Multiple data forks/
Xmsg_extra_rsrc:`009.ascid`009/Error -- Multiple resource forks/
Xmsg_extra_junk:`009.ascid`009/Warning -- file doesn't end where it should/
Xmsg_no_forks:`009.ascid`009/Warning -- File contains no forks/
Xmsg_no_checksum:.ascid`009/Warning -- No checksum found/
Xmsg_bad_checksum:
X`009`009.ascid`009/Warning -- Checksum mismatch: !XB should be !XB/
Xmsg_no_crc:`009.ascid`009/Warning -- No CRC found/
Xmsg_bad_crc:`009.ascid`009/Warning -- CRC mismatch: !XW should be !XW/
Xmsg_bad_crc_in:`009.ascid`009/Warning -- CRC mismatch in !AS: !XW should be
V !XW/
Xmsg_not_null:`009.ascid`009/Warning -- Byte following file name is not null/
Xmsg_header:`009.ascid`009/header/
Xmsg_data:`009.ascid`009/data fork/
Xmsg_rsrc:`009.ascid`009/resource fork/
X
X
X
X`009.entry`009xbin,`094m<>
X
X`009movl`009#buflen, descr
X`009movab`009inbuff, <descr+4>
X`009pushaw`009len
X`009pushl`009#0
X`009pushaq`009descr
X`009calls`009#3, g`094lib$get_foreign
X`009$iferr
X`009addw3`009#<inbuff-cmd_prefix>, len, descr
X`009movab`009cmd_prefix, <descr+4>
X`009pushaq`009prompt
X`009pushaw`009g`094lib$get_input
X`009pushaw`009g`094lib$get_input
X`009pushab`009parse_tables
X`009pushaq`009descr
X`009calls`009#5, g`094cli$dcl_parse
X`009$iferr
X
X`009movw`009#buflen, descr
X`009movab`009infile, <descr+4>
X`009pushaw`009len
X`009pushaq`009descr
X`009pushaq`009s_infile
X`009calls`009#3, g`094cli$get_value
X`009$iferr
X`009movw`009len, <infab+fab$b_fns>
X
X`009movw`009#buflen, descr
X`009movab`009outfile, <descr+4>
X`009pushaw`009<outfab+fab$b_fns>
X`009pushaq`009descr
X`009pushaq`009s_outfile
X`009calls`009#3, g`094cli$get_value
X`009cmpl`009r0, #cli$_absent
X`009beql`00910$
X`009$iferr
X10$:
X`009movl`009#macflen, descr
X`009movab`009macname, <descr+4>
X`009pushaw`009macnlen
X`009pushaq`009descr
X`009pushaq`009s_macname
X`009calls`009#3, g`094cli$get_value
X`009cmpl`009r0, #cli$_absent
X`009beql`00920$
X`009$iferr
X20$:
X`009$open`009fab=infab
X`009$iferr
X`009movab`009inrab, r10
X`009$connect`009rab=(r10)
X`009$iferr
X
Xheader_loop:
X`009$get`009rab=(r10)
X`009$iferr
X`009movab`009@rab$l_rbf(r10), r1
X`009cmpc3`009header_thingie, (r1), @<header_thingie+4>
X`009beql`009handle_header_thingie
X`009cmpc3`009stars, (r1), @<stars+4>
X`009bneq`00910$
X`009brw`009handle_stars
X10$:`009cmpb`009(r1), #c_mesh
X`009bneq`009header_loop
X
X; got a line starting with a mesh -- convert and remember it
X`009subw3`009#1, rab$w_rsz(r10), r0
X`009incl`009r1
X`009bsbw`009read_file_info
X`009brb`009header_loop
X
X; got a header thingie -- start looking for a line to tell us what type it i
Vs
Xhandle_header_thingie:
X`009$get`009rab=(r10)
X`009$iferr
X`009movab`009@rab$l_rbf(r10), r1
X`009cmpc3`009stars, (r1), @<stars+4>
X`009beql`009handle_stars
X`009cmpb`009(r1), #c_colon
X`009bneq`00910$
X`009brw`009handle_colon
X10$:`009cmpb`009(r1), #c_mesh
X`009bneq`009handle_header_thingie
X
X; found a header thingie followed by a line with a mesh
X`009subw3`009#1, rab$w_rsz(r10), r0
X`009incl`009r1
X`009bsbw`009read_file_info
X
X; reading through a hex-format file, looking for something to do
Xhex_format:
X`009$get`009rab=(r10)
X`009cmpl`009r0, #rms$_eof
X`009bneq`00910$
X`009brw`009handle_eof
X10$:`009$iferr
X`009cmpw`009rab$w_rsz(r10), stars
X`009blss`009hex_format
X`009cmpc3`009stars, @rab$l_rbf(r10), @<stars+4>
X`009bneq`009hex_format
X
X; found a line starting with stars -- it's hex format.  Do something intelli
Vgent
Xhandle_stars:
X`009movaq`009s_filetype, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009bneq`00910$
X`009$get`009rab=(r10)
X`009$iferr
X`009movw`009rab$w_rsz(r10), r0
X`009movab`009@rab$l_rbf(r10), r1
X`009bsbw`009read_file_info
X`009brw`009hex_format
X
X10$:`009movaq`009s_compressed, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009bneq`00920$
X`009bisw2`009#1@flag_compressed, status_flags
X`009brw`009hex_format
X
X20$:`009movaq`009s_rsrc_fork, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009bneq`00930$
X`009bbcs`009#flag_got_rsrc, status_flags, 21$
X`009pushaq`009msg_extra_rsrc
X`009calls`009#1, g`094lib$put_output
X`009movl`009#ss$_abort, r0
X`009ret
X21$:`009bisw2`009#1@flag_copy_rsrc, status_flags
X`009$create`009fab=tmrfab
X`009$iferr
X`009moval`009rsrc_len, r9
X`009movab`009tmrrab, r11
X`009$connect`009rab=(r11)
X`009$iferr
X`009brb`00935$
X
X30$:`009movaq`009s_data_fork, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009bneq`00940$
X`009bbcs`009#flag_got_data, status_flags, 31$
X`009pushaq`009msg_extra_data
X`009calls`009#1, g`094lib$put_output
X`009movl`009#ss$_abort, r0
X`009ret
X31$:`009bisw2`009#1@flag_copy_data, status_flags
X`009$create`009fab=tmdfab
X`009$iferr
X`009moval`009data_len, r9
X`009movab`009tmdrab, r11
X`009$connect`009rab=(r11)
X`009$iferr
X35$:`009bbs`009#flag_compressed, status_flags, 37$
X`009bsbw`009copy_hex_fork
X`009brw`009hex_format
X37$:`009bsbw`009copy_compressed_fork
X`009brw`009hex_format
X
X40$:`009movaq`009s_checksum, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009beql`00941$
X`009brw`00950$
X41$:`009bisw2`009#1@flag_got_crc, status_flags
X`009movzwl`009s_checksum, r1
X`009subw3`009r1, rab$w_rsz(r10), r0
X`009movab`009@rab$l_rbf(r10)`091r1`093, r1
X`009bsbw`009read_hex_number
X`009cmpb`009r2, crc
X`009beql`00949$
X`009movl`009#buflen, descr
X`009movab`009string, <descr+4>
X`009movzbl`009r2, -(sp)
X`009movzbl`009crc, -(sp)
X`009pushaq`009descr
X`009pushaw`009len
X`009pushaq`009msg_bad_checksum
X`009calls`009#5, g`094sys$fao
X`009$iferr
X`009movzwl`009len, descr
X`009pushaq`009descr
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X49$:`009brw`009hex_format
X
X50$:`009movaq`009s_crc, r0
X`009bsbw`009case_blind_prefix
X`009tstl`009r0
X`009beql`00951$
X`009brw`00960$
X51$:`009bisw2`009#1@flag_got_crc, status_flags
X`009movzwl`009s_crc, r1
X`009subw3`009r1, rab$w_rsz(r10), r0
X`009movab`009@rab$l_rbf(r10)`091r1`093, r1
X`009bsbw`009read_hex_number
X`009cmpw`009r2, crc
X`009beql`00959$
X`009movl`009#buflen, descr
X`009movab`009string, <descr+4>
X`009movzwl`009r2, -(sp)
X`009movzwl`009crc, -(sp)
X`009pushaq`009descr
X`009pushaw`009len
X`009pushaq`009msg_bad_crc
X`009calls`009#5, g`094sys$fao
X`009$iferr
X`009movzwl`009len, descr
X`009pushaq`009descr
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X59$:`009brw`009hex_format
X
X60$:`009pushaq`009msg_garbage
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X`009movzwl`009rab$w_rsz(r10), descr
X`009movab`009rab$l_rbf(r10), <descr+4>
X`009pushaq`009descr
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X`009brw`009hex_format
X
X
X; found a header thingie followed by a line with a colon -- it's q format
Xhandle_colon:
X`009bisw2`009#1@flag_q_format, status_flags`009`009; panic
X`009movab`009inrab, r10
X`009movab`009outrab, r11
X`009bsbw`009init_q
X`009bsbw`009read_q_header
X`009bsbw`009create_output
X`009movaq`009msg_data, r8
X`009movl`009data_len, r9
X`009bsbw`009copy_q_fork
X`009movaq`009msg_rsrc, r8
X`009movl`009rsrc_len, r9
X`009bsbw`009copy_q_fork
X
X`009bsbw`009get_q_long
X`009bbs`009#flag_eof, status_flags, 10$
X`009pushaq`009msg_extra_junk
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X
X10$:`009$disconnect`009rab=inrab
X`009$iferr
X`009$close`009fab=infab
X`009$iferr
X
X`009$disconnect`009rab=outrab
X`009$iferr
X`009$close`009fab=outfab
X`009$iferr
X
X`009movl`009#1, r0
X`009ret
X
X; hit eof at an ok place -- copy over the forks and exit
Xhandle_eof:
X`009bbs`009#flag_got_crc, status_flags, 20$`009; check for missing crc
X`009bbs`009#flag_compressed, status_flags, 10$
X`009bbc`009#flag_q_format, status_flags, 20$
X10$:`009pushaq`009msg_no_checksum
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X
X20$:`009bbs`009#flag_got_rsrc, status_flags, 30$`009; check for a complete
X`009bbs`009#flag_got_data, status_flags, 30$`009; lack of forks
X`009pushaq`009msg_no_forks
X`009calls`009#1, g`094lib$put_output
X`009$iferr
X
X30$:`009$disconnect`009rab=inrab`009`009`009; close up input file
X`009$iferr
X`009$close`009fab=infab
X`009$iferr
X
X`009bbs`009#flag_created, status_flags, 40$`009; output a MacBinary
X`009bsbw`009create_output`009`009`009`009; header if necessary
X
X40$:`009bbc`009#flag_copy_data, status_flags, 50$`009; copy over data fork
X`009movab`009tmdrab, r10`009`009`009`009; if necessary
X`009movab`009outrab, r11
X`009bsbw`009copy_fork
X
X50$:`009bbc`009#flag_copy_rsrc, status_flags, 60$`009; copy over resource
X`009movab`009tmrrab, r10`009`009`009`009; fork if necessary
X`009movab`009outrab, r11
X`009bsbw`009copy_fork
X
X60$:`009$disconnect`009rab=outrab`009`009`009; close up output file
X`009$iferr
X`009$close`009fab=outfab
X`009$iferr
X
X`009movl`009#1, r0`009`009`009`009`009; exit
X`009ret
X
X; handle errors
Xeof_ok:`009cmpl`009r0, #rms$_eof
X`009bneq`009error
X`009movl`009#1, r0
Xerror:`009ret
X
X;************************************************************************
X;***************************  read_file_info  ***************************
X;************************************************************************
X
X; Registers & parameters:
X;    r0 = line length
X;    r1 = pointer to line
X;    r2-3 = (clobbered)
X
Xread_file_info:
X`009movl`009(r1)+, filetype
X`009movl`009(r1)+, filecreator
X`009movw`009#defaultflags, fileflags
+-+-+-+-+-+-+-+-  END  OF PART 2 +-+-+-+-+-+-+-+-


