Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!cmcl2!lanl!unm-la!unmvax!nmtsun!warner%hydrovax@nmt.edu From: warner%hydrovax@nmt.edu (M. Warner Losh) Newsgroups: comp.lang.c Subject: Descriptors in VMS C (was Re: VMS C & records in files) Message-ID: <1003@nmtsun.nmt.edu> Date: 24 Aug 88 21:03:37 GMT References: <612@philmds.UUCP> Sender: news@nmtsun.nmt.edu Organization: New Mexico Tech Hydrology Program Lines: 44 In article <612@philmds.UUCP>, leo@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@relay.cs.net My spelling and views are my own.