[comp.lang.c] VMS Descriptors

EDSTROM%UNCAEDU.BITNET@wiscvm.wisc.EDU (06/23/87)

Steve Summit in Message-ID: <1142@copper.TEK.COM> writes:

>There are some header files or something that come with VAXC,
>DEC's VMS C compiler, that make handling descriptors a bit
>easier.

This is correct about descriptors being easy to use. His version of the VMS
"hello world" program might look like this:

    #include descrip
    #define IO$_WRITEVBLK 0x30

    main()
    {
       assign_channel (&channel, "sys$output");
       sys$qiow(0, channel, IO$_WRITEVBLK, 0, 0, 0, "Hello, world!\r", 14,
                                0, 0, 0, 0);
    }

    #define STR_DESC(A,B) struct dsc$descriptor_s A = {strlen(B),DSC$K_DTYPE_T,\
     DSC$K_CLASS_S,B}

    assign_channel (chan, dev_name)
    short int *chan;
    char      *dev_name;
    {
       STR_DESC(device, dev_name);
       sys$assign(&device, chan, 0, 0);
    }


The common calling protocol on VMS is one of its best features. I suppose its
unlikely that this could be built into the major languages. (Sigh.) There
seems to be enough trouble defining the ANSI C specifications without trying
to co-ordinate the ANSI boards for each of the other languages. It is nice not
having to translate old or borrowed FORTRAN, BASIC or PASCAL routines to use
in a new C program. Especially if you don't understand the language the original
routine was written in.

wesommer@athena.mit.edu (William Sommerfeld) (06/24/87)

In article <7960@brl-adm.ARPA> EDSTROM%UNCAEDU.BITNET@wiscvm.wisc.EDU writes:

>This is correct about descriptors being easy to use. His version of the VMS
>"hello world" program might look like this:
>
[ 21 lines of obscure C code follow ]

That doesn't look easy at all.  I don't really know that much about
VMS, but.. 

\begin{flame}
sys$qiow() appears to be the equivalent to either write(), or
writev(), or probably both at the same time, on UNIX systems.  This
routine takes 12 arguments??!?  Eight of which are zero in this
case??!??  No wonder DEC can't get the C runtime library to work
correctly.

Without those descriptors, on my UNIX system, I can write:

main()
{
	write(1, "Hello, world!\n", 14);
}
\end{flame}

I also note that the macro he uses to initialize the descriptor uses
illegal Kernighan and Ritchie C: you can't initialize an automatic
structure.  

					- Bill