home *** CD-ROM | disk | FTP | other *** search
- /* This file in the BGI Emulator package to the specified directory
- */
- "@echo off"
- call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
-
- parse arg argument /* Get the arguments */
-
- /* Parse the arguments into separate parts of a stem variable */
- num_args = words(argument)
- do i=1 to num_args
- args.i = word(argument,i)
- end
-
- /* Check to make sure that the path to the BCOS2 installation is given */
- if (num_args < 1) then
- do
- say "You must specify the directory where Borland C++ for OS/2 is installed"
- exit 0
- end
-
- /* Now check to see if it is a valid path */
- rc = SysFileTree(args.1,stem,'D')
- if (stem.0 \= 1) then
- do
- say args.1" does not exist on this system"
- exit 0
- end
-
- /* Define the paths for different files */
-
- bcos2_path = args.1
- lib_path = bcos2_path"\lib"
- include_path = bcos2_path"\include"
- install_path = "."
-
- state = 0 /* Determines how much is done so far */
-
- /* If there are any problems, make sure things are set back to normal. */
-
- signal on failure name abnormal_term
- signal on halt name abnormal_term
- signal on syntax name abnormal_term
-
- /* Copies the library file to the appropriate place */
-
- state = 1
- "copy "install_path"\bgi.lib "lib_path
-
- /* Make edits to the graphics file
- This consists of three operations - commenting out the lines that prevent
- graphics.h from being compiled when OS/2 is the operating system,
- adding some stuff to the enum
- linestyles, and adding in all of the OS/2 function declarations.
- */
-
- gfile = include_path"\graphics.h"
- tmpfile = include_path"\graphics.bak"
- ch1file = install_path"\graphics.ch1" /* Stuff for linestyle */
- ch2file = install_path"\graphics.ch2" /* Function definitions */
-
- /* Copy the graphics.h file to graphics.bak */
- "copy "gfile" "tmpfile
- state = 1 /* Now we know graphics.bak exists */
-
- /* Remove the graphics.h file */
- "del "gfile
-
- say "**Modifying graphics.h file "
-
- /* Open the graphics.bak file and the new graphics.h file */
-
- err = stream(gfile,'C',"OPEN")
- if (err \= "READY:") then
- do
- say "Error: Unable to open new graphics.h file"
- call abnormal_term
- end
- state=3
-
- err = stream(tmpfile,'C',"OPEN")
- if (err \= "READY:") then
- do
- say "Error: Unable to open old graphics.h file"
- call abnormal_term
- end
- state=4
-
- /* Now read until we find the lines that prevent compiling graphics.h when
- OS/2 is the operating system
- */
-
- a=""
- do forever
- a=linein(tmpfile)
- if (stream(tmpfile) \= "READY") then /* If that was the last line of the file */
- do
- say "Unable to read from "tmpfile
- call abnormal_term
- end
- if (left(a,22) = "#if defined( __OS2__ )") then leave
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- end /* do */
-
- /* We now have the first line to be commented out. Comment out all lines until
- we get to #endif
- */
- do while (left(a,6) <> "#endif")
- err = lineout(gfile,"/* "a" */")
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- a=linein(tmpfile)
- if (stream(tmpfile) \= "READY") then /* If that was the last line of the file */
- do
- say "Unable to read from "tmpfile
- call abnormal_term
- end
- end /* do */
-
- err = lineout(gfile,"/* "a" */")
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
-
- /* Now, have to eliminate the cdecl line for OS/2 versions */
- a=""
- do forever
- a=linein(tmpfile)
- if (stream(tmpfile) \= "READY") then /* If that was the last line of the file */
- do
- say "Unable to read from "tmpfile
- call abnormal_term
- end
- if (pos("#define _Cdecl cdecl",a) \= 0) then leave
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- end /* do */
-
- /* Now, comment it out */
- err = lineout(gfile,"#if !defined( __OS2__ )")
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
-
- err = lineout(gfile,"#endif")
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
-
-
- /* Now, search for the enum linestyle part */
- do forever
- a=linein(tmpfile)
- if (stream(tmpfile) \= "READY") then /* If that was the last line of the file */
- do
- say "Unable to read from "tmpfile
- call abnormal_term
- end
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- if (pos("USERBIT_LINE",a) <> 0) then leave
- end /* do */
-
- /* Now, open up ch1file, and copy it into graphics.h */
- err = stream(ch1file,'C',"OPEN")
- if (err \= "READY:") then
- do
- say "Error: Unable to open "ch1file
- call abnormal_term
- end
- state=5
-
- do forever
- a=linein(ch1file)
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- if (stream(ch1file) \= "READY") then
- do
- leave
- end
- end /* do */
-
- err = stream(ch1file,'C',"CLOSE")
-
- state = 4 /* Go back to previous state now that file is closed */
-
-
- /* Now, find the place where the functions are defined */
- do forever
- a=linein(tmpfile)
- if (stream(tmpfile) \= "READY") then /* If that was the last line of the file */
- do
- say "Unable to read from "tmpfile
- call abnormal_term
- end
- if (pos("far _Cdecl arc(int __x",a) <> 0) then leave
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- end /* do */
-
- /* Save the current line for use later */
- b=a
-
- /* Now insert the ch2file */
- err = stream(ch2file,'C',"OPEN")
- if (err \= "READY:") then
- do
- say "Error: Unable to open "ch2file
- call abnormal_term
- end
- state=6
-
- do forever
- a=linein(ch2file)
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- if (stream(ch2file) \= "READY") then leave
- end /* do */
- err = stream(ch2file,'C',"CLOSE")
-
- state = 4 /* Go back to previous state now that file is closed */
-
- /* Write out the rest of the file, and then append a #endif */
- a=b
- do forever
- err = lineout(gfile,a)
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
- if (stream(tmpfile) \= "READY") then leave
- a=linein(tmpfile)
- end /* do */
-
- err=lineout(gfile,"#endif")
- if (err \= 0) then
- do
- say "Error writing to "gfile
- call abnormal_term
- end
-
- /* Close the open files */
- err = stream(gfile,'C',"CLOSE")
- err = stream(tmpfile,'C',"CLOSE")
-
- exit 1
-
- abnormal_term: nop
-
- say "Restoring to original configuration"
- if (state >= 1) then
- do
- "del "lib_path"\bgi.lib"
- end
-
- if (state >= 2) then
- do
- "copy "tmpfile" "gfile /* Restore graphics.h */
- "del "tmpfile
- end
-
- if (state >= 3) then
- do
- err = stream(gfile,'C',"CLOSE")
- end
-
- if (state >= 4) then
- do
- err = stream(tmpfile,'C',"CLOSE")
- end
-
- if (state = 5) then
- do
- err = stream(ch1file,'C',"CLOSE")
- end
-
- if (state = 6) then
- do
- err = stream(ch2file,'C',"CLOSE")
- end
-
- exit 0
-