[net.sources] fromhexu.c

msimpson@bbncca.ARPA (Mike Simpson) (10/29/84)

/* fromhex.c, UNIX version */

#include <stdio.h>

int bytes,sum;

main()
{
	register i,v;
	register n;

	n = 0;
	v = 0;
	while ((i = getchar()) != EOF) {
		i &= 0177;
		if (i == '|') 
			break;
		if (i < 0100 || i > 0117)
			continue;
		v = (v << 4) | (i & 0xF);
		if ((++n & 1) == 0) {
			putchar(v);
			sum += v;
			v = 0;
			bytes++;
		}
	}
	n = 0;
	for (i = 0 ; i < 8 ; i++)
		n = (n << 4) | (getchar() & 0xF);
	if (n != (bytes + sum))
		fprintf(stderr, "bad checksum\n");
	else
		fprintf(stderr, "checksum good!\n");
	exit(0);
}
-- 
   >> don't shoot me, I'm just trying to be helpful ... <<
   Mike Simpson, BBN
   msimpson@bbnccf  (Arpanet/Internet/CSNet)
   {decvax,ihnp4,ima,linus,masscomp,sunybcs,wjh12}!bbncca!msimpson (Usenet)
   617-497-2819 (Ma Bell)

dlc@lanl.ARPA (11/14/84)

Recently, the news configuration here has been severely wounded, so I
think I posted some useful Macintosh software to net.micro.apple, and I
think I am posting this to net.sources.  The net.micro.apple message says
it is being posted to net.sources.  At least that's where I think they'll
end up.  Maybe both will go to both groups, or neither to neither!

The message is a copy of a fa.info-mac article about binhex that was written
in assembly, binhex.bas (for Microsoft BASIC), binhex.hex, and fromhex.hex.
I tried to send it to mod.sources, but I'm not convinced it arrived.

dlc@lanl.ARPA (11/19/84)

I've already had a request for the assembly language binhex in a different form,
so I'm posting a uuencode version of binhex.rsrc in net.sources for those of
you who have macput and macterm.  Also, I think, but I'm not sure, that the
"version 2" of binhex I posted to net.sources is identical to the one that was
in net.micro.apple and (good grief, I didn't really intend to duplicate this
stuff all over, it's just that feed back was so S L O W   and probably broken)
mod.sources.  I hope next we'll see some useful Mac public domain applications
distributed via the new binhex format!

Just run through uudecode to make a binhex.rsrc file to run through macput.

  dlc@lanl.arpa   ( cmcl2 | csu-cs | nmtvax | unm-cvax )!lanl-a!dlc
----------
begin 644 bh.rsrc
M    $     )("    C@(    $Q!V?QED$%0  408=@ !(@@D0 (C"#8  &  
M"P0M0  $0 ,D<#I8/ $((  #,@@E  -*   ,!0  # ]%   ($TY6"&4$*   
M#4@I(  .* $C !0  P-P%  "!' Z4#U?8&<050  !@PH   ,*  3<!0  @8P
M   @!!!4  (C"#8  &  "R@",W 4  (&,   '41P.E@Q"@ $#T4   @90   
M;Q-.5@@ /V\D$#0  TH !@]%   (&6$@8"-_>E8X#A@   !A#T=/>&E"!0  
M T %!C   !9*  1/10  "!E   !5$TY6"  _:&00-  #2@ &#T4   @90   
M2Q-.5 AV?QED$%0  4,(-G\Z8  +#"]   $ !4005  %:@ B#T4   @90   
M.1-.5%     !0 M0319P)!DO @ K#$5C ! +)5( &$P%<Q <2V<#(    !  
M!W]_8  $   P  0  "@ !  ()  $  PB  0??B$ !!]_/T $'WX 0 0<# ! 
M!!P( $ $'   0 0<  ! !!P  $ $'   0 0<!W! !'\("$ $/A $0 0<)@) 
M! @Y 4 $ T]P> ( 1@ X 0 @ #@ 0!  .  @#  X ! #?C@ "  A>  $ $ X
M  (!     0(     1      H     !    =_?V  !W]_<  '?W]X  =_?WP 
M!W]_?@ '?W]_  =_?W] !W]_?T '?W]_0 =_?W] !W]_?T '?W]_0 =_?W] 
M!W]_?T '?W]_0 =_?W] !W]_?T '?W]_0 =_?W] !W]_?W@#?W]_> %_?W]X
M ']_?W@ /W]_>  ??W]X  ]_87@ !W] .  #?P    %^     'P     .   
M   0        ."!4"@1@          -$$"<2"P      %$@A4T0P        
M0!%*)"@C        $      %$   0            #]_?WA]0") :"!837<H
M.@@()D@W$@Q70&1        E4             DP  !             'W]X
M?S5@1# T6PQ1*"!<#@9@-%AL%R T6VUB !9/1 4H.!L-=@@R       %*E< 
M-AML%B 0"R=B "!<#@9@-%AL%R T6VU@       (%D       FI$*"P5! 8P
M-%L.1B@Y   !$   )5       % A6VU7 #D9+C<8,ED    )  %U&#);3$( 
M-AHM9B@0&4Q6*#(<8       $F@       (4+E9(.@ *$          %( 8@
M  Q #$  <P  "                "      ("   @        A@""H "R (
M2 $ )'@E0        2  !0 #( A((@<$$#1;208H/ @&(G 8"P0" #M<31<@
M.ADM8@ Q'B0%2#L9+C( )ADM5P R7$Q7*#D(#S08)%1D S@:# 83,!8,)G,@
M&%\D          T!(  5 #((0!H=;1<@- @)5@@Q4"HT:%4+! 8(-P@(5B T
M70UW$!=0+C<8,ELL)F R7$0&,#=<1 <@-!DD!&@P6&T6<#H;;C9 %P      
M  <@  4 "2 (%B(%)# W7$0&,#I<3D9 ,EQ$!D@W&4UW$#98+D9(-UM$!A@W
M6TY&"#%=! 1H,%HM9Q@Z&"\28!         )(  %  L@"!8B!"=8(5(J,@ ;
M3 9S,!I+!G,8&A\D!G@Y" 4#0!A.!1( '$XF$F@;#29# !<     "D ,0  R
M !=@"$@  !                $       I   @        /  XP !0 $A "
M $ET6         4  2  #F 10$0"2V, $!DN)Q W7$5B      $H !D !B  
M+T 9    (               &       .@  $        !X '&  *  D(" !
M$VDP        !0 !(  = "0H0"H0;79P.QDN)Q@T6VUB #=91 0(.!P-1D@Q
M6"Y&2#=;1 8@-UAN5F@R6TY" #H;9 8(-P@*5P V&VP6(! 937<0-E@N0@ R
M&VPW*#99+6<@$!H,%Q@0&$Q6*#<(##9X-EP-1B@Z&2Q""!      "D ,0  R
M !< "$T  !                (      "0  !@        -0 \  !) $F "
M $ET6         )  %  "D 28$04"#9X-QU,5Q Y6BUV<! ;;&( *EP-1G@P
M600&,#=<358(.@@,1G@Q72U6*#<=! <@-T@(%P X&PT6&#!=#19X-P@,1G@Q
M72U6*#<=! 9 ,%QD!A R62UB #%;;5< -ADN1B@R""        )0  )  U  
M.5$ $"\,         U   D $4  Y40 0+PP@    !& &(  9  U  &4@  @ 
M0                '!*      !2#5]X?BH-:D!_*B(J2!@05'I(/5@@ & !
M" =    _?WH &0]G0  !*CT3>!X  #I(/$]G0  "*B\6"  # 2%8/@  'VA^
M!F]   !_/WI * II?VAA*C9$$!-/9T]X?U(-7VA9*BX!  ]9?6, %G\V+0 @
M# <P  ,37S   3]\   9/WP   P_? ]X<#]\  @P/WP/>' _? ]X< P%7VA@
M @    09=V004T@%7VA:#V *2!\( W8    &)! S2V5?:%X2#5]H8RHE0P /
M= @# !U  &1P?4  +WA+  %@" 0_<F]X2S]R;WA+$%1R>!9_-TI('D@#<E@@
M/SDC !9_.2T ( P',  #$U\P  $  &  !P ,9! S:B<&   _; , %G\Y0& @
M   6,!@05'-X'@  %!!32V=/>']_?WI(/@IJ?VAG*B)4$%-2#5]H:2HR$P 6
M?SH@8"   !8P=PME7VAG*C V %\05'-X'@  &D@D3V5?:&82#5]89RHH9! S
M4@U?6&<J-F, #U@4 P 6?SE- " ,!S   Q-?,  !/W(@ $T ?$]X20 "3WA)
M  8  "8_<B  - )%4   ?S]$$%-/9T   2HI$W@>  !!>!9_/TI((E@ #W@R
M D50  !_/W004T]G0  !*BD3>!X  &%X%G\_>D@B6  />"0"15   '\_5!!3
M3V=   $J*1-X'@  <7@6?S]:2")8  ]X%BH^1$ V?S8B>!9_.&I(65@ #W!!
M# 5?:%H98 ]P/1!,<W@>  Q#>!X #$)X%G\V0W@>   *2'1, W8  #], W@>
M  AC>!X "&1 /0),!!!33V=/>']05'004U(-7V@/#V=   $J/210%G\C9C@ 
M/UHC>!X "&-X'@ (9$ ] P T0#T"1D004U(-7V@T#V=   !J/210%G\M!C@ 
M/U5D2'9_+08(  (09@@  @Y&"  "%B((/A4(54 J  0""#X(! ( $  $2@ &
M3T4   @90 !('QP )$AV?RT$*'9^.$8(  %^ U@@/SIA6#X  !]H?5)(=C  
M B0&"  !201(=G\C9@@  @UB6#0 ! ]H< IM   2/SQ# !0 !0 0(#P  U@@
M/ST"6#0 " ]H; IM   ;/SM&"   /@10%G\_=C@$$#\@2&98(  (7!@@ #@4
M$$U?:'D015]H>@]G0  %#V=  ",J$C105G\[!C@4$%5?:&P2#5]H.2H01$ ]
M DUJ0$(0/R!(4U@@  A"'  42'9_(V0H?   !@@  6XF !8255]H;AEL)!!6
M?SM$0#9_+BI 0A(/(% 9:A!$"'T",28(   J9P  4CU?: \1/P   !@@ #@7
M#F@/:&H&;T   '\_)% C64  0"\8(  (6A)%7UAG&6!F"   $P8 >! _($@P
M6"  "! 2/5]H#PP%7VAJ&"  .!,015]H?1@ #W@Q$D5?:']90B0(?0(J9@@ 
M ")A !9_/D8(   L1@ ($#\@2!X8(  ( @P%7VAY&"  ""08(   <A@@ "!\
M$CU?:#0,!5]H:Q@@ #!Q$$5?:'U+95]H8RHB1!!33V=   %05')X'C]_?WA_
M:B]"6"M_.6I("E!4=$ V?SHJ2$A,!5]H:0,(    65UB>!9_.6I(05@ #V@ 
M$#U?6&<02!$0#!)%7VA_665D$ -$ !8(   '!@ 2$$@!  PT)5]H>@T%7VAY
M-0@.."T.:"]H>1)%7VA_64!F"   &48  A@@   )%#D?>&T215]H?UE@1@@ 
M  4F "4= '!@ T  9C ) $!@ !]!0&  $# H9@@  09,"",00'X8"#AB91 #
M5#DO>' 33E10 UEC(& #0 !F. ,X8640 U@>0! #  =P, , ! $  Q@@ " #
M$TY6"    F< !E@@ !A]$D5?:'Y98&< !1@@ !AW$TY4$"!$0P8  P0#!@@ 
M 'P%"&1_?P1P.E _(#A96#H' !%8(  89P@%7VAP&"    T(!5]H<A@@   )
M' 1&"   =P, %G\]!@@   (F %<<0#X(3!@@ !A3%#D?>'P33E-X #@)!@@ 
M  !#  ]'8 Y !!@@   "! -V"  !!P8   !P1 AV?QED$%0  4,(-G\Z0  ,
M$'U?6&=(*1  $ @O0     0  !(030  %A!5   7*  C<!0  @8X! ,(?WAL
M64  ,#D&;0  %7YY9' Z3V=  ",/9T  (Q(/(#@+$%1T4!9_/T8P! ]G3WA_
M4%1V  0/9T   %(/(#!]$%1T0#9_(V-X'@  *DAU$D5?: \98 ]8/ ]G0  C
M#V=  ",2#R! 5%(/(#!M$%1T0#9_+0-X'@  &DAU$D5?:#098 ]8*A(]7V@/
M&"  *# < !0H?   !@@  1=#6" _.D%8/@  'VA]$DAV,  !/400%G\_8E@^
M%0A50"H_/ )8/@@$ @ 0/SQ$$#9_/000-G\^)! 6?SY&"  !,000(% ]7UAG
M!$,&.   /V8  P,#   166!E"&1_?P8 <0,($  $&21F"   6V)8(#\\!@@ 
M %IB6" _/$!@($  5B@( P,  !(9028(  !:!B@"#F@/:'08(  8/1(]7V@T
M&"  ($X8(  @11@@ "!D""U?:'  ! ((-G\\0  2# 5?:'0@+0  %"@!4W 4
M  (&,  !*@8(  $A1!A] 48V"   7P8P!09O0   ?S]F"  !'P-X'@ !(W@>
M  AJ0$E2#5]H.2H01!A] 45F"   6D8P!A(/(#!C:A!&"  !&D8 $A!_(# #
M6"  $%\90R1 /0%7:D!"&"  (%\< "1(=G\M!"AV?CA&"   >&8 !QP )$AV
M?RT$*'9^.$8(  !T U@@/SIA6#X  !]H?5)(=C   1H&"  !!R8(   ^1@ "
M&"  ($$215]89QEC9!A] 3-V"   308X Q@@  @"&!QD&'T!-W8(  !+!C "
M&"  ("\8(  (2!(]7V@T# 5?:&L8(  8/1!%7VA]4'\@*$@8(  0&QE@#W@D
M$'\@*#E8(  0%1E@#W@>$CU?: \,!5]H:A@@ !@I$$5?:'T+95]H8RHB1!!3
M3V=   (05')X'C]_?WA_:B]"6"]_.608?0$N)@@  #Y&, <0?R P"T1K   )
M1&L   H8!D08?0$J)@@  #M&,!,0?R H=D1K   '!&L   =$:P  " 1K   (
M43\@, Y1?2  "$P%7VAY&"  "#P8 D08?0$]9"A] 4-$.'4  F$ %G\^1@@ 
M "TB> 1+82004U!4>DA%2V5?:&<J(E004U(-7VAI*C(3 !9_.B!@(   %C!W
M"V5?:&<J,#8  #X@9$AV?R-C !9_.D8(  !4!! 6?S\F   ^'B8(   H9% 6
M?S]F,!(# !   1DI!! @&"   '$9* T(%G\^0R 6?SXM(" Y:R-8(3\^)@@ 
M  M& &X00'8(   %!B@1#$ &  T8(   #QDC#0@6?SY#(!9_/BT@(#EK(U@A
M/SXF"   !D4(9']\1' Z70!T4 -90F%@# $ 8  0 P!@ " 9(&  '@  %' Z
M>2%G< ,X8FX8"!1@=0AE/WM@$!X 'V1P.DA-7VAU!%@"6"1_/2405G\]8&!6
M0  "   _/68@ 1-.5$!S<' $"'9_&6005  !0P@V?SI@  P0?5U(8@@I$  0
M""U?:'< !$00-  %1!!4  5J  %/10  "!E  !!M$QMP"&%0?5U(8@II'VAU
M$%5?:'<33E<@ 7@Q 0 ,%&@5"&4_?P1P.E@@   !&"    $% P48($) (  8
M P @  49(2 P 0 1$& ! !\F* 8 0"  !WHI"  ! $=  '\33E-X #@)!@@!
M# -Q>  Z 08( 00#=@@"!5@$<#I 0   !T     8 P   !T9("5P !-.5 AV
M?GEA$ P984!@"  !)C #%%$%& !97D1P.E@]!! A!0,;$ $9(48  BQA!C #
M%#DO>'T02 1P.E!4<W@>   4$%-+9T]X?W]_>DA>2FI_:&,J#C-X'@  "D!#
M3V=   8J$2-X'@  "D!$#V=    J$11P.E@Y8W@>  $C>!X  FI 25(/(!@8
M:A!!6#X  $]H>DIM7VAP/SYD0#9_/EI 0@]G0  %#V=  !,J$C1 /0!F6D!"
M"FU?:'(_/F1 -G\^6D!"#V=   4/9T  ,RH2-$ ] &=*0$(33E8( #]O0W@>
M  $C>!X  FI 25(/(!AO*A!!6#X  $]H>DIM7VAP/SYD0#9_/EI 0@]G0  %
M#V=  !,J$C1 /0![:D!""FU?:'(_/F1 -G\^6D!"#V=   4/9T  ,RH2-$ ]
M %T*0$(33E0(=G\99!!4  %$&'8  2(()$ "(P@V  !@  L$+4  !$ #)' Z
M6#P!""   S(()0 #2@  # 4   P/10  "!-.5@AE!"@   U(*2  #B@!(P 4
M  ,#<!0  @1P.E ]7V!G$%4   8,*   #"@ $W 4  (&,   ( 005  "(P@V
M  !@  LH C-P%  "!C   !U$<#I8,0H ! ]%   (&4   &\33E8( #]O)! T
M  -*  8/10  "!EA(& C?WI6. X8    80]'3WAI0@4   - !08P   62@ $
M3T4   @90   51-.5@@ /VAD$#0  TH !@]%   (&4   $L33E0(=G\99!!4
M  %#"#9_.F  "PPO0  !  5$$%0 !6H (@]%   (&4   #D33E10%G\_)C@(
M$$5?:'T2/5]H#PP%7VAJ&" />",215]H?5EB!! 6?S\T2'9_+0, %G\Z9@@ 
M/V8$<#I0/5]@9Q!5   &#"U?:&H  P08=GYY<@@D0 0""#X     ?T $0P@^
3 S   !8050  %R@ (W 4  (&.&H 
 
end

wrs@cmu-cs-k.ARPA (Walter Smith) (12/16/84)

Here is the Unix version of fromhex.  Use it to convert BinHex.dl (in an
earlier post) for use on a Macintosh.

Usage is as a filter:    fromhex <BinHex.dl >BinHex.rsrc

Sorry I can't give credit to the author, but I don't know who/what he/it is.

----------CUT-HERE------------
/* fromhex.c, UNIX version */

#include <stdio.h>

int bytes,sum;

main()
{
	register i,v;
	register n;

	n = 0;
	v = 0;
	while ((i = getchar()) != EOF) {
		i &= 0177;
		if (i == '|') 
			break;
		if (i < 0100 || i > 0117)
			continue;
		v = (v << 4) | (i & 0xF);
		if ((++n & 1) == 0) {
			putchar(v);
			sum += v;
			v = 0;
			bytes++;
		}
	}
	n = 0;
	for (i = 0 ; i < 8 ; i++)
		n = (n << 4) | (getchar() & 0xF);
	if (n != (bytes + sum))
		fprintf(stderr, "bad checksum\n");
	else
		fprintf(stderr, "checksum good!\n");
	exit(0);
}
-- 
      Walter Smith, CS undergraduate, Carnegie-Mellon University
uucp: ...!seismo!cmu-cs-k!wrs
arpa: wrs@cmu-cs-k.ARPA
usps: Box 874; 5115 Margaret Morrison St.; Pittsburgh, PA  15213