Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!hc!lanl!unm-la!unmvax!nmtsun!warner@hydrovax.nmt.edu From: warner@hydrovax.nmt.edu (M. Warner Losh) Newsgroups: comp.lang.c Subject: Re: VMS C & records in files Message-ID: <966@nmtsun.nmt.edu> Date: 19 Aug 88 02:35:14 GMT Sender: news@nmtsun.nmt.edu Organization: New Mexico Tech Hydrology Program Lines: 45 In article <644@eplrx7.UUCP>, ward@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#include 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@relay.cs.net