/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: y_ixcn.c,v 1.2 1997/09/25 18:26:04 ae59 Exp $ */
/*
$Log: y_ixcn.c,v $
 * Revision 1.2  1997/09/25  18:26:04  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:25:57  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : y_ixcn.c                              */
/*                                                              */
/*      Entry           : a_VOID y_ixcn(d,e_args)               */
/*                        y_dscp d;                             */
/*                        e_list                                */
/*                                                              */
/*      Arguments       : d - descriptor of dynamic array       */
/*                        e_args - variable argument list       */
/*                                                              */
/*      Return value    : char pointer to indexed element       */
/*                                                              */
/*      Description     : determine pointer to indexed element  */
/*                        with index checking.                  */
/*                                                              */
/*      Date    : 1993-01-19                                    */
/*      1993-01-19 : add allocation check =b=                   */
/*      1991-09-06 : reduce maximum line length                 */
/*      1991-05-29 : descrtype * replaced by y_dscp             */
/*      1990-12-12 : new name: y_inxc -> y_ixcn                 */
/*      1990-12-11 : type of variable i changed: byte -> a_intg */
/*      1990-11-12 : E_TPUSH+E_TPOPP                            */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
#if C_P_7
local a_VOID y_ixcn(y_dscp d,...)
#else
local a_VOID y_ixcn(d,e_args)

y_dscp d;
e_list
#endif
#else
local a_VOID y_ixcn(d,e_args)

y_dscp d;
e_list
#endif

        {
        a_btyp v = 0;
        a_intg i;
        a_intg k;
        va_list e_argv;

        E_TPUSH("y_ixcn")

        d = y_alck(d);

        e_open(d);

        for (i=0;i<((y_dscp)d)->numdim;i++)
           {
           /* possible pointer allignment problems              */
           k = e_ref(a_intg);
           if (k<((y_dscp)d)->fd[i].lbound ||
               k>((y_dscp)d)->fd[i].ubound)
              {
              e_trap(INDEX_RANGE,8,
                     E_TINT+E_TEXT(11),&i,
                     E_TINT+E_TEXT(4),&k,
                     E_TINT+E_TEXT(5),&((y_dscp)d)->fd[i].lbound,
                     E_TINT+E_TEXT(6),&((y_dscp)d)->fd[i].ubound);
              }
           v += (k-((y_dscp)d)->fd[i].lbound)* ((y_dscp)d)->fd[i].stride;
           }

        e_shut;

        E_TPOPP("y_ixcn")
        return((char *)(((y_dscp)d)->array)+v*((y_dscp)d)->elsize);
        }
