/*****************************************************************/
/**                                                             **/
/**             (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_conv_genstr[] = "@(#)conv_charstr.c	1.3 10/20/92 05:36:28  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	11/6/90

	ROUTINE:	__ROr_convert_GeneralString_const


PURPOSE:
	This routine copies a character string into an ELROS
	variable with length checking and zero filling

IN:
	valuelength - length in bytes of value variable
	constant - string of value expression

OUT:
	value - value specified by the constant argument


CALLED ROUTINES:

	
MODIFICATION HISTORY:


*/

#include <elros/exceptions.h>

#include <memory.h>

int __ROr_convert_CharString_const(value,valuelength,maxlength,maxlength2,constant)

   char *value;
   unsigned long valuelength;
   unsigned long maxlength;
   unsigned long maxlength2;
   char *constant;

{
   char *byteptr = value;
   unsigned char byte;
   unsigned long len = strlen(constant);
   int i,j;

   if (maxlength < len)
      return(__ROx_CONST_STRINGLENGTH);

   if (!maxlength) {
      byteptr = (char *)malloc(len + 1);
      if (!byteptr)
        return(__ROx_GENERAL_MALLOCFAILED);
      *(char**)value = byteptr;
   }
      
   strcpy(byteptr,constant);

   return(SUCCESS);
}



