$include (..\lib\compStch.ext) /* *============================================================================ * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore, dba the ACME Software Deli, as the author * * While the ACME Software Deli does not work for money, there is nonetheless * a significant amount of work involved. The ACME Software Deli maintains the * rights to all code written, though it may be used and distributed as long as * the following conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in * your distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli *============================================================================ */ loadExecModule: do; $if not noID declare IDString (*) byte data ( '@(#)loadExec.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif $include (..\lib\comnDefs.ext) $set( loadExecSource ) $include (..\lib\loadExec.ext) $include (..\lib\sysCalls.ext) $include (..\lib\string.ext) $if LOGGING $include (..\lib\logger.ext) $endif loadExecAsm: procedure ( programSpecPtr, paramBlockPtr ) word external; declare programSpecPtr pointer, paramBlockPtr pointer; end loadExecAsm; loadExec: procedure ( commandLinePtr ) word reentrant public; declare commandLinePtr pointer, commandLine based commandLinePtr (*) byte; declare fcb_t literally 'structure ( fcbFlag byte, fileName ( 11 ) byte, contents ( 25 ) byte )', fcb ( 2 ) fcb_t, parameterBlock_t literally 'structure ( envSegment selector, commandTailPtr pointer, fcbPtrs ( 2 ) pointer )'; declare environmentBlockPtr pointer, commandTail ( 80h ) byte, programSpecification ( MAX_PATH ) byte, parameterBlock parameterBlock_t; declare pspAddress pointer, pspStruct based pspAddress pspStructure; /* * the PSP environment block is to be the same as the current process */ pspAddress = getPsp; parameterBlock.envSegment = pspStruct.environmentBlock; /* * create a command for the COMSPEC using the command line sent by the caller */ call strcpy( @commandTail( 1 ), @( ' /c', 0 ) ); if ( commandLine( 0 ) <> ' ' ) then call strcat( @commandTail( 1 ), @( ' ', 0 ) ); call strcat( @commandTail( 1 ), commandLinePtr ); commandTail( 0 ) = strlen( @commandTail( 1 ) ); parameterBlock.commandTailPtr = @commandTail; /* * get the %COMSPEC% variable since it tells me who the original command * environment is */ call strcpy( @programSpecification, getenv( @( 'COMSPEC', 0 ) ) ); call memset( @fcb( 0 ), 0, size( fcb( 0 ) ) ); call memset( @fcb( 1 ), 0, size( fcb( 1 ) ) ); parameterBlock.fcbPtrs( 0 ) = @fcb( 0 ); parameterBlock.fcbPtrs( 1 ) = @fcb( 1 ); /* * Perform the actual work we were sent here to do. * * Since all of the registers are lost, we must restore the stack after the * DOS call to load and execute an application. That being said, we will call * a specialized ASM function */ $if LOGGING call addToLog( DEBUG, __FILE__, __LINE__, @( 'program: %s commandTail: %s ([%d]%s)', 0 ), @programSpecification, parameterBlock.commandTailPtr, strlen( @commandTail(1) ), @commandTail(1) ); $endif return( loadExecAsm( @programSpecification, @parameterBlock ) ); end loadExec; end loadExecModule;