Hi Robert,
WGet does it nicely, but the lack of dll inteface has also bothered me.
Would redirection of the output from WGet suffice for you?
For example:
load a rexx dll (rxtnsion.dll)
call a function that start wget with the parameters you want, but return as soon as wget has started. (rxExecPrgm)
loop until done (rc=number).
call another function that retrieve the text output from wget (last 1024 characters or so) for each call. (rxPrgmOut)
parse the output and do whatever...
next
read the html file retrieved (if any).
I wrote those functions to test with
CE2mp3 here in this forum.
The downside is that that it require the application to output 1024 characters for each call before it return with its present design. I can easily change that for you though. The "new" behaviour will probably then bee to specify a smaller value (<1024), unless someone else can tell me how to redesign the source code below to return data within a specified time frame instead... ;-)
/**
* function: rxExecPrgm( app_name, <parameters>, <environment> )
*
* This function returns an empty string if it couldn't start the application.
*/
APIRET APIENTRY __export rxExecPrgm( CHAR *name, ULONG numargs, RXSTRING args[], char* queuename, RXSTRING *retstr )
{
if( numargs < 1 )
return INVALID_ROUTINE;
var appName( args[0].strptr );
var params( ( numargs > 1 ) ? args[1].strptr : "" );
var appEnv( ( numargs > 2 ) ? args[2].strptr : "" );
HPIPE hpW;
CHAR szFailName[256];
HFILE hfSave = -1, hfNew = HF_STDOUT;
DosDupHandle( HF_STDOUT, &hfSave ); /* Saves standard output handle */
DosCreatePipe( &Output.hpR, &hpW, PIPESIZE ); /* Creates pipe */
DosDupHandle( hpW, &hfNew ); /* Duplicates standard output handle */
DosExecPgm( szFailName, sizeof( szFailName ), EXEC_ASYNCRESULT, params, appEnv, &Output.resCode, appName ); /* Starts child process */
DosClose( hpW ); /* Closes write handle to ensure */
/* Notification at child termination */
DosDupHandle( hfSave, &hfNew ); /* Brings stdout back */
appName.cpy( "pid=" ).cat( (int) Output.resCode.codeTerminate ).set( retstr );
Output.ulRead = 1;
return VALID_ROUTINE;
}
/**
* function: rxPrgmOut( <none> )
*
* This function returns an empty string if it couldn't start the application.
*/
APIRET APIENTRY __export rxPrgmOut( CHAR *name, ULONG numargs, RXSTRING args[], char* queuename, RXSTRING *retstr )
{
char achBuf[1024];
PID pidChild = 0;
var tmpBuf;
if ( Output.ulRead )
DosRead( Output.hpR, achBuf, sizeof( achBuf ), &Output.ulRead ); //<- Need a redesign?
if ( Output.ulRead ) {
tmpBuf.cpy( Output.buffer ).cat( achBuf, Output.ulRead );
Output.buffer.cpy( tmpBuf.splitAtLast( '\n', true ) ); //Remove delimiter
} else {
DosWaitChild( DCWA_PROCESS, /* Look at only the process specified */
DCWW_WAIT, /* Wait until a child terminates */
&Output.resCode, /* Termination codes returned */
&pidChild, /* pid of terminating process */
Output.resCode.codeTerminate ); /* Process (pid) to look at */
tmpBuf.cpy( "rc=" ).cat( (int) Output.resCode.codeTerminate );
}
tmpBuf.set( retstr );
return VALID_ROUTINE;
}
//Jan-Erik