home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
035
/
cenvi29.zip
/
WINSPAWN.CMM
< prev
next >
Wrap
Text File
|
1994-08-02
|
4KB
|
107 lines
//*****************************************************************
//*** WinSpawn.cmm - Run from CEnvi for Windows to allow the ***
//*** ver.1 WinSpawn() routine in WinSpawn.lib to ***
//*** call the spawn command in Windows sessions ***
//*** running under WINOS2. ***
//*****************************************************************
if ( !defined(_WINDOWS_) ) {
printf("\a\nThis program must be executed from CEnvi for Windows\n");
printf("to serve the OS/2 WinSpawn() routine from CEnvi for OS/2.\n");
printf("Press any key to exit...");
getch();
printf("\n");
exit(EXIT_FAILURE);
}
#include <OptParms.lib>
main(argc,argv)
{
Hide = OptionalParameter(argc,argv,"HIDE");
FileName = argv[1];
WaitTime = atoi(argv[2]);
if ( 3 != argc || WaitTime < 1 ) {
Instructions();
return EXIT_FAILURE;
}
// Give this session the name of the file
sprintf(NewTitle,"WinSpawn: %s",FileName);
DynamicLink("USER","SETWINDOWTEXT",SWORD16,PASCAL,ScreenHandle(),NewTitle);
// If want to be hidden, then hide it
if ( Hide )
DynamicLink("USER","SHOWWINDOW",SWORD16,PASCAL,ScreenHandle(),0);
SpawnForever(FileName,WaitTime);
return EXIT_SUCCESS;
}
#define WIN_SPAWN 0 // spawn command and return immediately
#define WIN_SPAWN_WAIT 1 // spawn and wait until command is finished
#define WIN_SPAWN_EXIT 2 // spawn and then exit WinSpawn.cmm
SpawnForever(pFileSpec,pDelay)
// get all messages from WinSpawn.lib and spawn them
{
sprintf(FullPipeSpec,"\\PIPE\\%s",pFileSpec);
lExit = False;
do {
suspend(pDelay);
// try to read command from pipe file
if ( fp = fopen(FullPipeSpec,"r+b") ) {
// read the action to perform, how many bytes in the message,
// and then the message
if ( fread(lAction,UWORD32,fp)
&& fread(lCommandLen,UWORD32,fp) && lCommandLen
&& fread(lCommand,lCommandLen,fp) ) {
// final check that Command is CommandLen long
if ( strlen(lCommand) == (lCommandLen-1) ) {
// perform spawn command
if ( 1 == lCommandLen ) {
lResult = 0; // nothing happened
} else {
lResult = spawn(WIN_SPAWN_WAIT == lAction ? P_WAIT : P_NOWAIT,
lCommand);
}
// send back return code
rewind(fp);
BLObPut(lResultBLOb,0,lResult,SWORD32);
fwrite(lResultBLOb,BLObSize(lResultBLOb),fp);
if ( WIN_SPAWN_EXIT == lAction )
lExit = True;
}
}
fclose(fp);
}
} while ( !lExit );
}
Instructions()
{
puts("\a");
puts(`WinSpawn - Perform the CEnvi spawn() function from WINOS2`);
puts(``)
puts(`SYNTAX: CENVI WINSPAWN <PipeSpec> <Delay> [/HIDE]`)
puts(``)
puts(`WHERE: PipeSpec - Unique 8.3 name to identify this WINSPAWN session`)
puts(` Delay - time (milliseconds) to delay between checks`)
puts(` HIDE - Optional; hide thise CEnvi program icon`)
puts(``)
puts(`Examples: the following examples run from OS/2`)
puts(` START /FS /F C:\CENVIWIN\CENVI.EXE D:\CENVIOS2\WinSpawn FAXER 3000`)
puts(` START /WIN C:\CENVIWIN\CENVI.EXE FAXER 5000 /HIDE`)
puts(``)
puts(`Press any key to exit...`)
getch()
}