/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <descrip.h>

struct dsc$multipliers_1
{
    char *dsc$a_a0;
    long dsc$l_m[1];
};

struct dsc$bounds
{
    long dsc$l_l;
    long dsc$l_u;
};

void f(struct dsc$descriptor_nca *sa)
{
    struct dsc$descriptor_s *s;
    struct dsc$multipliers_1 *m;
    struct dsc$bounds *b;
    int i;
    printf("length = %d\n", sa->dsc$w_length);
    printf("dtype = %d\n", sa->dsc$b_dtype);
    printf("class = %d\n", sa->dsc$b_class);
    printf("pointer = %d\n", sa->dsc$a_pointer);
    printf("dimct = %d\n", sa->dsc$b_dimct);
    printf("arsize = %d\n", sa->dsc$l_arsize);
    s = (struct dsc$descriptor_s *)sa->dsc$a_pointer;
    for(i = 0; i < 3; i++)
    {
        printf("  length = %d\n", s->dsc$w_length);
        printf("  dtype = %d\n", s->dsc$b_dtype);
        printf("  class = %d\n", s->dsc$b_class);
        printf("  pointer = %d\n", s->dsc$a_pointer);
        s++;
    }
    m = (struct dsc$multipliers_1 *)(sa+1);
    printf("pointer = %d\n", m->dsc$a_a0);
    printf("multiplier = %d\n", m->dsc$l_m[0]);
    b = (struct dsc$bounds *)(m + 1);
    printf("lower = %d\n", b->dsc$l_l);
    printf("upper = %d\n", b->dsc$l_u);
    return;
}

