#include stdio
#include descrip
#include "sysdefs:stcdefs"

/*+
 *  NAME
 *	strcpy_D --  copy descriptor string to normal C string
 *
 *  DESCRIPTION
 *	Copies a descriptor string to a normal 
 * 	C string - adds a NULL to the C string 	
 *
 *  RETURN VALUE
 *
 *  HISTORY
 *	3/28/88		Bauer			Initial implementation.
-*/
PROC strcpy_D (into_string, from_D)			

char			into_string[];						/* Destination string				*/
struct dsc$descriptor 	*from_D;						/* Source string				*/

BEGIN

	strncpy(into_string,							
		from_D->dsc$a_pointer,
		from_D->dsc$w_length );
	into_string[from_D->dsc$w_length] = NULL;

END

/*+
 *  NAME
 *	create_descriptor --  creates VMS string descriptor from normal
 *			      C string
 *  DESCRIPTION
 *	Creates VMS descriptor by allocating string for the 
 *	C string, copying the string and setting appropriate
 *	descriptor flags.
 *
 *  RETURN VALUE
 *
 *  HISTORY
 *	3/28/88		Bauer		Initial implementation.
-*/

PROC create_descriptor ( d_pointer, string )

struct dsc$descriptor 		*d_pointer;					/* Descriptor pointer				*/
char				*string;					/* String to go into the descriptor		*/

BEGIN

	d_pointer->dsc$w_length = strlen (string);				
	d_pointer->dsc$a_pointer = malloc(d_pointer->dsc$w_length + 1);
	strcpy (d_pointer->dsc$a_pointer, string);
	d_pointer->dsc$b_dtype = DSC$K_DTYPE_T;
	d_pointer->dsc$b_class = DSC$K_CLASS_S;

END

