VMS C & records in files

M. Warner Losh warner at hydrovax.nmt.edu
Fri Aug 19 12:35:14 AEST 1988


In article <644 at eplrx7.UUCP>, ward at eplrx7.UUCP (Rick Ward) writes...
>On a related note, why couldn't Digital have made it easier to call system
>functions from C.  This difficulty alone makes C unusable on VMS, at least 
>in my opinion :(.  The problem is that you have to allocate and build 
>structures describing each variable you want to pass to a system routine.

It has been my experience you only need to build descriptors whenever you
are playing with strings.  Everything else is simply a matter of maybe
putting a & in front of what you want to call.  You can make your life
a lot easier if you use the following function (DEC, why didn't you provide
this?):

#include <stdio.h>
#include <descrip.h>

struct dsc$descriptor * make_descriptor(st)
char *st;
{
	struct dsc$descriptor * temp;

	temp = (struct dsc$descriptor *) malloc 
		(sizeof (struct dsc$descriptor));
	if (temp == NULL)
		return (NULL);
	temp->dsc$w_length = strlen (st);
	temp->dsc$a_pointer = st;
	temp->dsc$b_dtype = DSC$K_DTYPE_T;
	temp->dsc$b_class = DSC$K_CLASS_S;
	return (temp);
}

>YUCK!

Well, it is yucky if you include that code every time you want to make a 
simple system call.  The only caveat about this method is that you must 
free those allocated descriptors at some point.  All in all, it's fairly 
straight forward.

Now then, if you had done it the way that DEC documented it .....  The
VAX-C documentation that came with V2.2 is very bad.  Not as bad as many of 
the UNIX manuals, mind you, but still bad.  The stuff that comes with V2.3 
looks a lot better.

Warner
hydrovax%nmt at relay.cs.net



More information about the Comp.lang.c mailing list