Descriptors in VMS C (was Re: VMS C & records in files)
M. Warner Losh
warner%hydrovax at nmt.edu
Thu Aug 25 07:03:37 AEST 1988
In article <612 at philmds.UUCP>, leo at philmds.UUCP (Leo de Wit) writes...
>
>Don't know which version of VMS C you're using, but this is from
>descrip.h on our system, the last 5 lines (maybe you overlooked them):
>
[$DESCRITOR macro deleted]
This macro can only be used when you know what the string is that you are
dealing with in advance. While this is true for a large number of cases,
it isn't true in ALL cases.
For example, if you want to translate the logical name TT, you can do
something like:
$DESCRIPTOR (tt_dsc, "TT);
/* system call to translate logical name */
but if you want to see if some user is on the system (not know at compile
time) for a program like TALK or PHONE then you have to generate the
descriptor somehow. You can use the $DESCRIPTOR macro to set up the
storage, but you'd still have to fill in an address and length. You can
use the function I posted, or you could write a macro that looks something
like:
#define fill_in_desc(d,s) {d->dsc$w_length = strlen(s); \
d->dsc$a_address = s;}
and use it like this:
func(str)
char *str;
{
$DESCRIPTOR(user_string_dsc, "");
fill_in_desc(user_string_dsc, str);
}
and that would also take care of the problem of freeing stuff up, since it
is done by the 'C' compiler via automatic variables. So this would be an
even better solution than the function that I posted. Leo, thank you for
pointing out this macro. It made me rethink some of the methods that I was
using.
Warner warner%hydrovax%nmt at relay.cs.net
My spelling and views are my own.
More information about the Comp.lang.c
mailing list