/*****************************************************************/
/**                                                             **/
/**             (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_form_int[] = "@(#)form_int.c	1.14 10/20/92 05:45:43  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	11/6/90

	ROUTINE:	__ROr_format_Integer


PURPOSE:
	This routine converts an integer value into printable format

IN:
	value - value to print
	valuelength - length in bytes of value variable
	maxlength - length in bytes of value variable
	maxlength2
	type_info - parameters vector for lengths of this type

OUT:
RETURNS malloc'ed character string

CALLED ROUTINES:

	
MODIFICATION HISTORY:


*/

#include <elros/exceptions.h>
#include <elros/enc_dcd.h>
#include <elros/typeinfo.h>
#include <elros/extend_arith.h>

#include <malloc.h>
#include <memory.h>

char *__ROr_format_Integer(value,valuelength,maxlength,maxlength2,type_info)

	void *value;
	unsigned long valuelength;
	unsigned long maxlength;
	unsigned long maxlength2;
	__RO_Type_Info *type_info;

{
   unsigned char *byteptr = 
	(unsigned char *)memcpy(malloc(valuelength),value,valuelength);
   char *buffer = malloc((int)(2+DECIMAL_DIGIT_COUNT(maxlength)));
   int little_endian;
   int i,stop;


   if (__RO_IS_NATIVE_TYPE(type_info,Integer_lengths,maxlength,valuelength))
      little_endian = (maxlength=valuelength,LITTLE_ENDIAN);
   else
      little_endian = type_info->non_native_endianness == __ROm_LITTLE_ENDIAN;

   if (!little_endian)
      swapends(byteptr,maxlength);
      

   Itoa(byteptr,maxlength,buffer);

   free(byteptr);
   return(buffer);
}


