/*****************************************************************/
/**                                                             **/
/**             (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_STDconsume_data[] = "@(#)STDconsume.c	1.10 10/19/92 13:47:31  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	6/28/90

	ROUTINE:	consume_data
	Version:	__ROr_STDconsume_data

PURPOSE:
	This routine obtains a requested number of bytes from the incoming
	network stream.

IN:
	instance - Buffer state is used
	size - the number of bytes to read.  If less than this number can be
		an error code is returned.

OUT:
	instance - Buffer and Receive state is updated.


CALLED ROUTINES:

	
MODIFICATION HISTORY:


*/

#include <elros/instance.h>
#include <elros/getP_element.h>

int __ROr_STDconsume_data(instance,size)

   __RO_Instance_Record *	instance;
   int *			size;

#define CONSUMPTION_BUFFER_SIZE	256
{
   unsigned char buffer[CONSUMPTION_BUFFER_SIZE];
   int length,left = *size;

   while (left>0)
   {
      length =  left > CONSUMPTION_BUFFER_SIZE ? CONSUMPTION_BUFFER_SIZE : left;
      __ROr_getP_Nelement(instance,length,buffer);
      left -= length;
   }
   return( SUCCESS );
}

