/* set_result.c */

/*		Copyright © 1989 by Donald T. Meyer, Stormgate Software
 *		All Rights Reserved
 */



#include "rxil.h"

#include <string.h>



/* NAME
 *		RxilSetResult
 *
 * SYNOPSIS
 *		RxilSetResult( rexxmsg, string );
 *
 *		struct RexxMsg *rexxmsg;
 *		char *string;
 *
 * FUNCTION
 *		This can be called to handle the details of placing a result
 *		string into the rexx message packet as the result Argstring.
 *		If the string pointer is NULL, a general failure code will
 *		be set.
 *		This will deal with inability to allocate the Argstring by
 *		setting a failure code in the RexxMsg.
 *
 * INPUTS
 *		rexxmsg = pointer to the RexxMsg that the reply is being set
 *			into.
 *		string = pointer to a null terminated text string which will
 *			be converted to an Argstring and returned.
 *
 * RESULT
 *
 *
 * SIDES
 *
 * HISTORY
 *		01-Aug-89	Creation.
 *
 * BUGS
 *
 * SEE ALSO
 *
 */

void RxilSetResult( struct RexxMsg *rexxmsg, char *string )
{
	if( string )
	{
		rexxmsg->rm_Result1 = RC_OK;
		rexxmsg->rm_Result2 =
			(ULONG)CreateArgstring( string, strlen(string) );

		if( rexxmsg->rm_Result2 == NULL )
		{
			/* Unable to create the argstring */
			rexxmsg->rm_Result1 = RC_ERROR;
			rexxmsg->rm_Result2 = 0;
		}
	}
	else
	{
		/* Result string is null, set general failure code */
		rexxmsg->rm_Result1 = RXERR_FAILED;
		rexxmsg->rm_Result2 = 0;
	}
}

