ToolChain/bin/targets/m68k-amigaos/ndk/Tutorials/ARexx/Host/Host.c
struct RexxParseData *
CreateRexxParseData(VOID)
{
	struct Process * ThisProcess;
	struct RexxParseData * Data;
	LONG Error;

		/* No data was allocated yet. */

	Data = NULL;

		/* No error has occured yet. */

	Error = 0;

		/* Allocate the basic parser data. */

	Data = AllocVec(sizeof(struct RexxParseData),MEMF_ANY|MEMF_CLEAR);

		/* Did we get the memory? */

	if(Data == NULL)
		Error = ERROR_NO_FREE_STORE;

		/* Allocate the ReadArgs data. */

	if(Error == 0)
	{
			/* AllocDosObjectTagList is a dos.library call which
			 * can be made by a Task.
			 */

		Data->ReadArgs = AllocDosObjectTagList(DOS_RDARGS,NULL);

			/* Did we get the data? */

		if(Data->ReadArgs == NULL)
			Error = ERROR_NO_FREE_STORE;
	}

		/* Did we succeed? */

	if(Error == 0)
		return(Data);
	else
	{
			/* Clean up the parser data; in this case failure
			 * means either the ReadArgs data or the data
			 * structure itself could not be allocated. Thus,
			 * we only need to take care of the data, a single
			 * call to FreeVec() is sufficient. Since FreeVec()
			 * can be called with a NULL parameter we do not
			 * need to check if the data pointer is valid.
			 */

		FreeVec(Data);

			/* Obtain the control structure for this Process
			 * or Task. We need to set an error code, but the
			 * system call we will make can only be made by
			 * a Process.
			 */

		ThisProcess = (struct Process *)FindTask(NULL);

			/* If a process is making the call, set the
			 * error code so it can later be retrieved
			 * through IoErr().
			 */

		if(ThisProcess->pr_Task.tc_Node.ln_Type == NT_PROCESS)
			SetIoErr(Error);

			/* Return failure. */

		return(NULL);
	}
}
/****** Host/CreateRexxParseData *********************************************
*
*   NAME
*       CreateRexxParseData -- Create working data for command parsing.
*
*   SYNOPSIS
*       Data = CreateRexxParseData()
*
*       struct RexxParseData *CreateRexxParseData(VOID);
*
*   FUNCTION
*       The commands the host receives from the Rexx resident process will
*       need further processing. This is what the command parser will do,
*       but it needs environment data to work with. This routine allocates
*       the work space it needs.
*
*   INPUTS
*       None
*
*   RESULT
*       Data - Pointer to RexxParseData structure or NULL if it could not
*           be allocated. If NULL is returned the error code can be
*           obtained through IoErr().
*
*   SEE ALSO
*       dos.library/AllocDosObject
*       dos.library/IoErr
*
******************************************************************************
*
*/
Host/CreateRexxParseData
NAME
CreateRexxParseData -- Create working data for command parsing.

SYNOPSIS
Data = CreateRexxParseData()



FUNCTION
The commands the host receives from the Rexx resident process will
need further processing. This is what the command parser will do,
but it needs environment data to work with. This routine allocates
the work space it needs.

INPUTS
None

RESULT
Data - Pointer to RexxParseData structure or NULL if it could not
be allocated. If NULL is returned the error code can be
obtained through IoErr().


Host / CreateRexxParseData NAME CreateRexxParseData -- Create working data for command parsing . SYNOPSIS Data = CreateRexxParseData () FUNCTION The commands the host receives from the Rexx resident process will need further processing . This is what the command parser will do but it needs environment data to work with . This routine allocates the work space it needs . INPUTS None RESULT Data - Pointer to RexxParseData structure or NULL if it could not be allocated . If NULL is returned the error code can be obtained through IoErr () .
struct RexxParseData *
CreateRexxParseData(VOID)
{
	struct Process * ThisProcess;
	struct RexxParseData * Data;
	LONG Error;
	Data = NULL;
	Error = 0;
	Data = AllocVec(sizeof(struct RexxParseData),MEMF_ANY|MEMF_CLEAR);
	if(Data == NULL)
		Error = ERROR_NO_FREE_STORE;
	if(Error == 0)
	{
		Data->ReadArgs = AllocDosObjectTagList(DOS_RDARGS,NULL);
		if(Data->ReadArgs == NULL)
			Error = ERROR_NO_FREE_STORE;
	}
	if(Error == 0)
		return(Data);
	else
	{
		FreeVec(Data);
		ThisProcess = (struct Process *)FindTask(NULL);
		if(ThisProcess->pr_Task.tc_Node.ln_Type == NT_PROCESS)
			SetIoErr(Error);
		return(NULL);
	}
}
struct RexxParseData * CreateRexxParseData ( VOID ) { struct Process * ThisProcess ; struct RexxParseData * Data ; LONG Error ; Data = NULL ; Error = 0 ; Data = AllocVec ( sizeof ( struct RexxParseData ) , MEMF_ANY | MEMF_CLEAR ) ; if ( Data == NULL ) Error = ERROR_NO_FREE_STORE ; if ( Error == 0 ) { Data -> ReadArgs = AllocDosObjectTagList ( DOS_RDARGS , NULL ) ; if ( Data -> ReadArgs == NULL ) Error = ERROR_NO_FREE_STORE ; } if ( Error == 0 ) return ( Data ) ; else { FreeVec ( Data ) ; ThisProcess = ( struct Process * ) FindTask ( NULL ) ; if ( ThisProcess -> pr_Task . tc_Node . ln_Type == NT_PROCESS ) SetIoErr ( Error ) ; return ( NULL ) ; } }
Host/CreateRexxParseData
NAME
CreateRexxParseData -- Create working data for command parsing.
Host / CreateRexxParseData NAME CreateRexxParseData -- Create working data for command parsing .
/* No data was allocated yet. */ /* No error has occured yet. */ /* Allocate the basic parser data. */ /* Did we get the memory? */ /* Allocate the ReadArgs data. */ /* AllocDosObjectTagList is a dos.library call which
			 * can be made by a Task.
			 */ /* Did we get the data? */ /* Did we succeed? */ /* Clean up the parser data; in this case failure
			 * means either the ReadArgs data or the data
			 * structure itself could not be allocated. Thus,
			 * we only need to take care of the data, a single
			 * call to FreeVec() is sufficient. Since FreeVec()
			 * can be called with a NULL parameter we do not
			 * need to check if the data pointer is valid.
			 */ /* Obtain the control structure for this Process
			 * or Task. We need to set an error code, but the
			 * system call we will make can only be made by
			 * a Process.
			 */ /* If a process is making the call, set the
			 * error code so it can later be retrieved
			 * through IoErr().
			 */ /* Return failure. */