/*****************************************************************/
/**                                                             **/
/**             (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_vector[] = "@(#)sendP_vector.c	1.2 10/20/92 06:01:50 LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		Linda Stanberry
			Computer Software and Networking Division

	DATE WRITTEN:	04/24/92

	ROUTINE:	__ROr_BERsendP_Array

PURPOSE:
	Encode an integer or real array in ASN.1

IN:
	instance - Instance variable
	value - Pointer to array of values
	valuelength - Length of each value in array
	maxlength - Maximum length allowed for each ELROS value
	maxlength2 - unused
	number - number of elements in the array
        elemtag - tag to emit for element type

OUT:
	Updates instance buffer and error states


CALLED ROUTINES:
	

	
MODIFICATION HISTORY:


*/

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


int __ROr_BERsendP_Array(instance, value, valuelength, 
                         maxlength, maxlength2, number, elemtag)

  __RO_Instance_Record * instance;
  void * value;
  unsigned long *valuelength;
  unsigned long *maxlength;
  unsigned long *maxlength2;
  unsigned long number;
  char *elemtag;

{
  int i;

  switch (*elemtag) {

    case 0x02: /* Integer */
      for (i=0; i< number; i++) {
        __ROr_sendP_1element(instance,elemtag);
        if ( instance->sendP_Integer(instance,(char *)value+(*valuelength*i),
                                     valuelength,maxlength,0) )
          return EXCEPTION;
      }
      break;

    case 0x09: /* Real */
      for (i=0; i< number; i++) {
        __ROr_sendP_1element(instance,elemtag);
        if ( instance->sendP_Real(instance,(char *)value+(*valuelength*i),
                                  valuelength,maxlength,maxlength2) )
          return EXCEPTION;
      }
      break;

    default:
      __RO_RETURN_RUNTIME(instance,__ROx_INTERNAL_MUTUAL);
  }     

  return (SUCCESS);
}

