(view source code of bin2rexx.rex as plain text)
/*
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Bin2Rexx last update: 31/12/2002 º
º (C) 1997-2002, Rob van der Woude º
º http://www.robvanderwoude.com º
º Convert small binaries to Rexx programs that will recreate those same º
º binaries when executed. º
º Originally written to allow creation of icon files from installation º
º scripts. º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
*/
/* Initialize RexxUtil */
Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
Call sysloadfuncs
/* Get OS and location of this script */
Parse Source os type program
If os = "OS/2" Then rexxext = "cmd"; Else rexxext = "rex"
/* Check command line parameters */
Parse arg binfile outfile dummy
If binfile = "" Then Call Syntax
If dummy <> "" Then Call Syntax
If outfile = "" Then outfile = binfile
/* Define output file name */
rexxfile = Strip( Directory( ), "T", "\" )||"\bin."||rexxext
/* Check if source and target files exist and take appropriate actions */
If Argchk( binfile ) = 0 Then Call Syntax
If Argchk( rexxfile ) = 1 Then Call Blocked rexxfile
Call SysFileTree binfile, "found.", "F"
If found.0 <> 1 Then Do
Call Syntax
Exit
End
Parse Value found.1 With fdate ftime fsize fattr fname
Call LineOut rexxfile, '/* Recreate '||Filespec( "N", binfile )||' */'
Call LineOut rexxfile, '/* This file was created on '||date( "E" )||' '||time( "N" )||' */'
Call LineOut rexxfile, '/* by Bin2Rexx, (C) 1997-2002, Rob van der Woude */'
Call LineOut rexxfile, '/* http://www.robvanderwoude.com */'
Call LineOut rexxfile, ''
Call LineOut rexxfile, '/* Load RexxUtil */'
Call LineOut rexxfile, 'Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"'
Call LineOut rexxfile, 'Call sysloadfuncs'
Call LineOut rexxfile, ''
Call LineOut rexxfile, 'tempfile = "'||outfile||'"'
Call LineOut rexxfile, 'Call SysFileTree tempfile, "exist.", "F"'
Call LineOut rexxfile, 'If exist.0 > 0 Then Do'
Call LineOut rexxfile, ' Call Beep 220, 250'
Call LineOut rexxfile, ' Say ""'
Call LineOut rexxfile, ' Say " File "||Filespec( "N", tempfile )||" already exists"'
Call LineOut rexxfile, ' Say ""'
Call LineOut rexxfile, ' Exit'
Call LineOut rexxfile, 'End'
Call LineOut rexxfile, ''
binstr = CharIn( binfile, 1, Min( 26, fsize ) )
Call LineOut rexxfile, 'Call CharOut tempfile, "'||C2X( binstr )||'"X'
i = 1
Do Until Chars( binfile ) = 0
binstr = CharIn( binfile, ( 26 * i ) + 1, Min( 26, fsize - ( i * 26 ) ) )
Call LineOut rexxfile, 'Call CharOut tempfile, "'||C2X( binstr )||'"X'
i = i + 1
End
Call LineOut rexxfile, 'Call LineOut tempfile'
Call LineOut rexxfile
Exit
/* Check if specified file exists */
Argchk: Procedure
If Strip( Arg( 1 ) ) = "" Then Call Syntax
Call SysFileTree Strip( Arg( 1 ) ), "exist.", "F", , "**---"
If exist.0 = 1 Then Do
chk = 1
End
Else Do
chk = 0
End
Return chk
Syntax:
Say
Say "Bin2Rexx, Version 2.00"
Say "Convert small binaries to Rexx programs that will in turn recreate those"
Say "same binaries when executed"
Say
Say "Usage: BIN2REXX binary_in [ binary_out ]"
Say
Say 'Where: "binary_in" is the name of the binary file to be converted'
Say ' "binary_out" is the name of the binary file to be recreated'
Say " (if binary_out is not specified, binary_in will be used)"
Say
Say "Example: BIN2REXX SAMPLE.ICO"
Say
Say " would convert a file named SAMPLE.ICO into a Rexx program named"
Say " BIN."||Translate( rexxext )||" that would, whenever executed, create an exact copy"
Say " of SAMPLE.ICO"
Say
Say "Written by Rob van der Woude"
Say "http://www.robvanderwoude.com"
Exit 1
return
Blocked: Procedure
Say ""
Say " File "||Filespec( "N", arg( 1 ) )||" already exists."
Say ""
Call Syntax
Return
page last modified: 2024-04-16; loaded in 0.0062 seconds