/***************************************************************
* fsd: C-function, type: *dsc$descriptor_s
*
*
convert C-string to pointer to VMS string descriptor
*
* struct dsc$descriptor_s *fsd(char *cstring)
* Returns NULL in error case, pointer to a string descriptor if success.
* Example:
* if (fstring=fsd("+DIR")) BDAPR(&lun,fsd("+DIR")); else return EXIT_FAILURE;
* unlike fs(), which uses a fixed length pool of descriptors,
* fsd() dynamically allocates each descriptor.
* The descriptors can be freed by fsd_free(descriptor).
Author: Joseph Huber , Munich,Germany
****************************************************************/
#include
#include
#include
#include
#include "fsd.h"
struct dsc$descriptor_s *fsd(char *cstring)
{
struct dsc$descriptor_s *fstring;
fstring = \
(struct dsc$descriptor_s *)malloc(sizeof(struct dsc$descriptor_s));
if (fstring == NULL) {perror("fsd malloc failed:");return NULL;}
fstring->dsc$b_dtype = DSC$K_DTYPE_T; /* type is CHARACTER */
fstring->dsc$b_class = DSC$K_CLASS_S; /* string descriptor */
fstring->dsc$w_length = strlen(cstring); /* length of string */
fstring->dsc$a_pointer = cstring; /* pointer to string */
return fstring;
}
void fsd_free (void *ptr) { free(ptr); }