/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

static char sccsid_ASNsendRO_end[] = "@(#)ASNsendRO_en.c	1.21 10/19/92 13:20:17 LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	6/27/90

	ROUTINE:	sendRO_end
	Version:	__ROr_ASNsendRO_end

PURPOSE:
	This routine completes the operation (EOC) and flushed the send_state
	array.

IN:
	instance - 

OUT:
	instance - Send state's buffer is flushed.  Exception state is updated.


CALLED ROUTINES:
	(instance->send_data)

	
MODIFICATION HISTORY:


*/

#include <elros/instance.h>
#include <elros/typecodes.h>
#include <elros/sendP_element.h>

int __ROr_ASNsendRO_end(instance,internal)

   __RO_Instance_Record *	instance;
   int *			internal;

{
   __RO_Give_table_Entry *thisop = &(instance->give_table[*internal]);

	/* Finish off the operation and flush the buffer */

   if (thisop->operation_class == __RO_RESULT &&
       thisop->encoded_representation)	/* Result, but not DEFAULT Result */
      __ROr_sendP_2element(instance,__ROe_EOC);
   __ROr_sendP_2element(instance,__ROe_EOC);



	/* Send the PDV Trailer -- end the PDV */

   if ((instance->sendPDV_end)(instance))
      return(EXCEPTION);

   return(SUCCESS);

}

