/************************************************************************* * * (c) Copyright 1992,1993,1994 by G & A Technical Software, Inc., * 28 Research Drive, Hampton, Virginia, 23666. * * All Rights Reserved. No part of this software or publication may be * reproduced, stored in a retrieval system, or transmitted, in any form * or by any means, electronic, mechanical, photocopying, recording, or * otherwise without the prior written permission of G & A Technical * Software, Inc. * ************************************************************************* * * Filename: callcr.c * * Purpose: Provides S3 calling mechanism for C subroutines and functions. * * Author: John Burton * * Date: 5/31/94 * ************************************************************************* * * Modification History: * * $Log: s3_callcr.c,v $ * Revision 2.1 1994/07/08 18:07:38 jcburt * No changes since last commit. Just bringing everything up to the same * revision number * * Revision 2.0.0.1 1994/06/28 18:48:27 jcburt * S3 Version 2.0 Initial Source * * ************************************************************************* * * Revision Control Information: */ static char rcsid[] = "$Id: s3_callcr.c,v 2.1 1994/07/08 18:07:38 jcburt Exp $"; static char rcsrev[] = "$Revision: 2.1 $"; /****************************************************************************/ /* Written by: */ /* John Burton */ /* jcburt@gatsibm.larc.nasa.gov */ /* Date: */ /* 02/20/92 */ /****************************************************************************/ /* Routines and Revision History: */ /* */ /* #define MULTIDIM */ /* - 10/15/91 Original version created (John Burton) */ /* */ /* int call_c_function */ /* - 10/20/91 Original version created (John Burton) */ /* - 01/30/92 Added dataset bounds violation checking (John Burton) */ /* */ /* void call_c_subroutine */ /* - 10/20/91 Original version created (John Burton) */ /* - 01/30/92 Added dataset bounds violation checking (John Burton) */ /* */ /****************************************************************************/ /************************************************************************* * * Include Files * *************************************************************************/ #ifdef _AIX #pragma alloca #endif #include "s3_defines.h" #include "s3_typedefs.h" #include "s3_externals.h" #include "s3_globals.h" /************************************************************************* * * Defines and Macros * *************************************************************************/ /* - Creates N levels of indirection for the data pointed to by data */ /* allowing called routines to manipulate data as if it were an N */ /* dimensional array */ #define MULTIDIM(arr,data,type,nd,dims) {\ int k,l,size,*q;\ char *start,**r,**s1,*t;\ r = &start;\ q = dims;\ size = 1;\ for(k=0;kNDIMS > 1) { for(j=0,h=(dl[i]->NDIMS)-1;jNDIMS;j++,h--) dims[h] = dl[i]->dimlist[j]->co.value; switch(dl[i]->type) { case BYTE: MULTIDIM(a[i],dl[i]->d.data,byte,dl[i]->NDIMS,dims); break; case STRING: MULTIDIM(a[i],dl[i]->d.data,char,dl[i]->NDIMS,dims); break; case CHAR: MULTIDIM(a[i],dl[i]->d.data,char,dl[i]->NDIMS,dims); break; case INT: MULTIDIM(a[i],dl[i]->d.data,int,dl[i]->NDIMS,dims); break; case REAL: MULTIDIM(a[i],dl[i]->d.data,float,dl[i]->NDIMS,dims); break; case DREAL: MULTIDIM(a[i],dl[i]->d.data,double,dl[i]->NDIMS,dims); break; case COMP: MULTIDIM(a[i],dl[i]->d.data,complex,dl[i]->NDIMS,dims); break; case DCOMP: MULTIDIM(a[i],dl[i]->d.data,dbl_complex,dl[i]->NDIMS,dims); break; } } else a[i] = (char *)dl[i]->d.data; } quit = s3_call_function(func,a,nds); if(bounds) for(i=0;iNDIMS > 1) { for(j=0,h=(dl[i]->NDIMS)-1;jNDIMS;j++,h--) dims[h] = dl[i]->dimlist[j]->co.value; switch(dl[i]->type) { case BYTE: MULTIDIM(a[i],dl[i]->d.data,byte,dl[i]->NDIMS,dims); break; case CHAR: MULTIDIM(a[i],dl[i]->d.data,char,dl[i]->NDIMS,dims); break; case STRING: MULTIDIM(a[i],dl[i]->d.data,char,dl[i]->NDIMS,dims); break; case INT: MULTIDIM(a[i],dl[i]->d.data,int,dl[i]->NDIMS,dims); break; case REAL: MULTIDIM(a[i],dl[i]->d.data,float,dl[i]->NDIMS,dims); break; case DREAL: MULTIDIM(a[i],dl[i]->d.data,double,dl[i]->NDIMS,dims); break; case COMP: MULTIDIM(a[i],dl[i]->d.data,complex,dl[i]->NDIMS,dims); break; case DCOMP: MULTIDIM(a[i],dl[i]->d.data,dbl_complex,dl[i]->NDIMS,dims); break; } } else a[i] = (char *)dl[i]->d.data; } s3_call_subroutine(func,a,nds); if(bounds) for(i=0;i