/*****************************************************************/
/**                                                             **/
/**             (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_sendP_octstr[] = "@(#)sendP_octstr.c	1.20 10/20/92 06:01:37 LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		Robyne M. Sumpter	
			Network Systems Division

	DATE WRITTEN:	7/9/90

	ROUTINE:	__ROr_BERsendP_OctetString
			

PURPOSE:
	Encode the value data of the strings in ASN.1.
	

IN:
	instance
		Send state and buffer.
	value -	The data to be encoded
	valuelength - Length of the data to be encoded.
 	maxlength - Maximum length of the encoded data.
	

OUT:
	instance -
		Send state and error state are update.
		Data buffer.


CALLED ROUTINES:
		__ROr_encP_length
		instance->send_data
	

	
MODIFICATION HISTORY:


*/

#include <elros/instance.h>
#include <elros/enc_dcd.h>
#include <elros/encP_length.h>
#include <elros/sendP_element.h>

int __ROr_BERsendP_OctetString( instance, value, valuelength, maxlength, maxlength2)

   __RO_Instance_Record *instance;	/* pointer to instance record	*/
   void 		*value;		/* location of unencoded value	*/
   unsigned long	*valuelength;	/* physical length of unencoded value */
   unsigned long	*maxlength;	/* maximum length of encoded data */
   unsigned long	*maxlength2;	/* 2nd max length for 2 part encoding */

   {

	/* if there is not enough space in the  buffer for 	*/
	/* both the length and the data ENC_length will		*/
	/* write out the buffer.				*/

   if( *maxlength && *valuelength > *maxlength ) {
	__RO_RETURN_RUNTIME( instance, __ROx_ENC_EXCEEDEDMAXLEN );
   }

   __ROr_encP_length( instance,  valuelength );

   __ROr_sendP_Nelement( instance, value, *valuelength );

   return (SUCCESS);
   }
