WebExplodeToBuf( )

Syntax . . Returns . . Program Example . . Related Topics. . A-Z Index . . Home


Processes an AppPage with the special tags embedded within it. The processed AppPage will be returned in a buffer.

Example

returnCode = WebExplodeToBuf(cntrlHandle, myAppPage, "param1=3600", buffer);

Syntax

int *WebExplodeToBuf(void *controlHandle, 
		char *appPage,
		char *variableList,
		char ** buffer)
controlHandle The handle to the control structure.
appPage The handle to the AppPage. Use the value returned by wcLoad( ).
variableList A supplemental list of variables for the current call to WebExplode( ). Variables in the list are specified as name-value pairs, separated by ampersands (&), as follows:
name1=value1&name2=value2[&name=value]...
buffer The buffer where the exploded AppPage is kept.

Returns

0 Successful AppPage explosion.
Error code Failure or exception. For a list of possible error codes, see Error Messages.

Program Example

The following code shows how WebExplodeToBuf( ) is used in an application.

int main(int argc, char **argv)
{
	wc_t	*wcp;
	int	ret;
	char	*newbuf;
	int tempNo = 0;
	
	char *pagePtr ;
	char *pgID ;
	char *dbname, *dbuser, *dbpass;


	if((ret = wcInit(argc, argv, &wcp)) != ERR_OK) {
		return wcTraceWarn(wcp, ret);
	}

	/*Get Input from file InputFile*/
	GetInput(wcp);

	while (1) {
		if((ret = wcConOpen (wcp, 0)) < 0) {
			if (ret == ERR_MSGSHUTDOWN) {
				wcDBClose (wcp, wcAppPageConnName(wcp)) ;
				return wcExit(wcp) ;
			}
			return wcTraceErr(wcp, ret);
		}

		if ( (ret = wcGetVariable(wcp, "$MI_SERVER", &dbname)) != 0 ){
			return wcTraceWarn(wcp, ret);
		}
		if ( (ret = wcGetVariable(wcp, "$MI_USER", &dbuser)) != 0 ){
			return wcTraceWarn(wcp, ret);
		}
		if ( (ret = wcGetVariable(wcp, "$MI_PASSWORD", &dbpass)) != 0 ){
			return wcTraceWarn(wcp, ret);
		}
		if ( (ret = wcDBOpen(wcp, wcAppPageConnName(wcp) /*connName */, dbname, dbuser , dbpass)) < 0) {
			return wcTraceWarn(wcp, ret) ;
		}

		wcGetVariable (wcp, "$MIval", &pgID) ;
		if (pgID != NULL) {
			wcLoad (wcp, pgID, &pagePtr) ;
			ret = WebExplodeToBuf(wcp, pagePtr, "testing=TRUE", &newbuf);
			if (ret <0 )
				wcPrintf (wcp, 
					 "Error in webExplode Function <BR>",
					thisProgram);
			else 
				wcPrintf(wcp,
					"%s",newbuf);
				wcPrintf (wcp, 
					"<BR>%s webExplode Function Pass<BR>",
					thisProgram);
		}
	
		wcDropVariable(wcp, "$MIval");

		if(newbuf != NULL) 
			wcDriverFreeBuffer(newbuf); /*user has to free the buffer*/
	
		if((ret = wcConClose(wcp)) < 0)
			return wcTraceWarn(wcp, ret);
	} 
	wcDBClose (wcp, wcAppPageConnName(wcp)) ;

	return wcExit(wcp);
}

Related Topics

wcLoad( )
wcPrintf( )
wcLogPrintf( )
wcGetVariable( )


Top of Page . . Syntax . . Returns . . Program Example . . A-Z Index . . Home