- Fixed a bug in napi5.c

This commit is contained in:
koennecke
2006-03-03 15:30:54 +00:00
parent 00b09053ca
commit 5532f937dc
18 changed files with 692 additions and 433 deletions

View File

@ -23,6 +23,7 @@
/* status flags */ /* status flags */
int iReconfig; int iReconfig;
int iUpdate; int iUpdate;
pStringDict pOption;
/* interface functions */ /* interface functions */
int (*Configure)(pHistDriver self, int (*Configure)(pHistDriver self,
SConnection *pCon, SConnection *pCon,
@ -71,7 +72,7 @@
#line 474 "histogram.w" #line 474 "histogram.w"
#line 228 "histogram.w" #line 229 "histogram.w"
pHistDriver CreateHistDriver(pStringDict pDict); pHistDriver CreateHistDriver(pStringDict pDict);
void DeleteHistDriver(pHistDriver self); void DeleteHistDriver(pHistDriver self);

View File

@ -11,7 +11,7 @@
#ifndef SICSHISTMEMINT #ifndef SICSHISTMEMINT
#define SICSHISTMEMINT #define SICSHISTMEMINT
#line 250 "histogram.w" #line 251 "histogram.w"
typedef struct __HistMem { typedef struct __HistMem {
pObjectDescriptor pDes; pObjectDescriptor pDes;
@ -21,7 +21,6 @@
int iInit; int iInit;
pICountable pCountInt; pICountable pCountInt;
pICallBack pCall; pICallBack pCall;
pStringDict pOption;
} HistMem; } HistMem;
#line 490 "histogram.w" #line 490 "histogram.w"

View File

@ -465,7 +465,7 @@
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
if(argc < 2) if(argc > 2)
{ {
iRet = AddCommand(pSics,argv[2], RunWrapper,NULL,NULL); iRet = AddCommand(pSics,argv[2], RunWrapper,NULL,NULL);
} else { } else {

View File

@ -94,6 +94,9 @@
{ {
self->FreePrivate(self); self->FreePrivate(self);
} }
if(self->pOption){
DeleteStringDict(self->pOption);
}
if(self->data) if(self->data)
{ {
killHMData(self->data); killHMData(self->data);

View File

@ -388,6 +388,7 @@
{ {
pHistMem pNew = NULL; pHistMem pNew = NULL;
pSite site = NULL; pSite site = NULL;
pStringDict pOption;
/* make memory */ /* make memory */
pNew = (pHistMem)malloc(sizeof(HistMem)); pNew = (pHistMem)malloc(sizeof(HistMem));
@ -432,24 +433,24 @@
pNew->pCountInt->Continue = HistContinue; pNew->pCountInt->Continue = HistContinue;
/* initialise options dictionary */ /* initialise options dictionary */
pNew->pOption = CreateStringDict(); pOption = CreateStringDict();
if(!pNew->pOption) if(!pOption)
{ {
DeleteDescriptor(pNew->pDes); DeleteDescriptor(pNew->pDes);
free(pNew); free(pNew);
return NULL; return NULL;
} }
StringDictAddPair(pNew->pOption,"driver",driver); StringDictAddPair(pOption,"driver",driver);
StringDictAddPair(pNew->pOption,"update","0"); StringDictAddPair(pOption,"update","0");
/* initialise driver */ /* initialise driver */
if(strcmp(driver,"sim") == 0) if(strcmp(driver,"sim") == 0)
{ {
pNew->pDriv = CreateSIMHM(pNew->pOption); pNew->pDriv = CreateSIMHM(pOption);
} }
else if(strcmp(driver,"mcstas") == 0) else if(strcmp(driver,"mcstas") == 0)
{ {
pNew->pDriv = NewMcStasHM(pNew->pOption); pNew->pDriv = NewMcStasHM(pOption);
} }
else else
{ {
@ -457,20 +458,21 @@
if(site != NULL) if(site != NULL)
{ {
pNew->pDriv = site->CreateHistogramMemoryDriver(driver, pNew->pDriv = site->CreateHistogramMemoryDriver(driver,
pNew->pOption); pOption);
} }
} }
if(pNew->pDriv == NULL) if(pNew->pDriv == NULL)
{ {
DeleteDescriptor(pNew->pDes); DeleteDescriptor(pNew->pDes);
DeleteStringDict(pNew->pOption); DeleteStringDict(pOption);
free(pNew); free(pNew);
return NULL; return NULL;
} }
pNew->iAccess = usUser; pNew->iAccess = usUser;
pNew->iExponent = 0; pNew->iExponent = 0;
pNew->iInit = 0; pNew->iInit = 0;
pNew->pDriv->pOption = pOption;
return pNew; return pNew;
} }
@ -500,10 +502,6 @@
{ {
DeleteCallBackInterface(self->pCall); DeleteCallBackInterface(self->pCall);
} }
if(self->pOption)
{
DeleteStringDict(self->pOption);
}
free(self); free(self);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -533,7 +531,7 @@
return 0; return 0;
} }
StringDictAddPair(pNew->pOption,"name",argv[1]); StringDictAddPair(pNew->pDriv->pOption,"name",argv[1]);
/* install HM as command */ /* install HM as command */
iRet = AddCommand(pSics,argv[1],HistAction,DeleteHistMemory,(void *)pNew); iRet = AddCommand(pSics,argv[1],HistAction,DeleteHistMemory,(void *)pNew);
@ -551,7 +549,7 @@
{ {
assert(self); assert(self);
strtolower(name); strtolower(name);
return StringDictGet(self->pOption,name, result,iLen); return StringDictGet(self->pDriv->pOption,name, result,iLen);
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
int HistSetOption(pHistMem self, char *name, char *value) int HistSetOption(pHistMem self, char *name, char *value)
@ -561,10 +559,10 @@
assert(self); assert(self);
self->iInit = 1; self->iInit = 1;
strtolower(name); strtolower(name);
status = StringDictUpdate(self->pOption,name, value); status = StringDictUpdate(self->pDriv->pOption,name, value);
if(status == 0) if(status == 0)
{ {
return StringDictAddPair(self->pOption,name, value); return StringDictAddPair(self->pDriv->pOption,name, value);
} }
return 1; return 1;
} }
@ -577,13 +575,13 @@
assert(self); assert(self);
assert(pCon); assert(pCon);
iRet = HistDriverConfig(self->pDriv,self->pOption,pCon); iRet = HistDriverConfig(self->pDriv,self->pDriv->pOption,pCon);
if(!iRet) if(!iRet)
{ {
SCWrite(pCon,"ERROR: failed to configure histogram memory",eError); SCWrite(pCon,"ERROR: failed to configure histogram memory",eError);
return 0; return 0;
} }
iRet = self->pDriv->Configure(self->pDriv,pCon, self->pOption,pSics); iRet = self->pDriv->Configure(self->pDriv,pCon, self->pDriv->pOption,pSics);
if(!iRet) if(!iRet)
{ {
SCWrite(pCon,"ERROR: failed to configure histogram memory",eError); SCWrite(pCon,"ERROR: failed to configure histogram memory",eError);
@ -974,17 +972,17 @@ static int checkHMEnd(pHistMem self, char *text){
memset(pValue, 0, sizeof(pValue)); memset(pValue, 0, sizeof(pValue));
memset(name, 0, sizeof(name)); memset(name, 0, sizeof(name));
iRet = StringDictGet(self->pOption,"name",name,19); iRet = StringDictGet(self->pDriv->pOption,"name",name,19);
if(0==iRet) { if(0==iRet) {
strcpy(name,"*"); strcpy(name,"*");
} }
iRet = StringDictGet(self->pOption,"driver",pValue,sizeof(pValue)-1); iRet = StringDictGet(self->pDriv->pOption,"driver",pValue,sizeof(pValue)-1);
if(0<iRet) { if(0<iRet) {
sprintf(pBuffer,"%s.driver = %s",name,pValue); sprintf(pBuffer,"%s.driver = %s",name,pValue);
SCWrite(pCon,pBuffer,eStatus); SCWrite(pCon,pBuffer,eStatus);
} }
iRet = StringDictGetAsNumber(self->pOption,"update",&fVal); iRet = StringDictGetAsNumber(self->pDriv->pOption,"update",&fVal);
if(0<iRet) { if(0<iRet) {
sprintf(pBuffer,"%s.update = %d",name,(int)rint(fVal)); sprintf(pBuffer,"%s.update = %d",name,(int)rint(fVal));
} else { } else {
@ -992,7 +990,7 @@ static int checkHMEnd(pHistMem self, char *text){
} }
SCWrite(pCon,pBuffer,eStatus); SCWrite(pCon,pBuffer,eStatus);
iRet = StringDictGetAsNumber(self->pOption,"rank",&fVal); iRet = StringDictGetAsNumber(self->pDriv->pOption,"rank",&fVal);
if(0<iRet) { if(0<iRet) {
iRank = (int)rint(fVal); iRank = (int)rint(fVal);
sprintf(pBuffer,"%s.rank = %d",name,iRank); sprintf(pBuffer,"%s.rank = %d",name,iRank);
@ -1002,14 +1000,14 @@ static int checkHMEnd(pHistMem self, char *text){
} }
for(i=0; i<iRank; i++){ for(i=0; i<iRank; i++){
sprintf(pValue,"dim%1.1d",i); sprintf(pValue,"dim%1.1d",i);
iRet = StringDictGetAsNumber(self->pOption,pValue,&fVal); iRet = StringDictGetAsNumber(self->pDriv->pOption,pValue,&fVal);
if(0<iRet){ if(0<iRet){
sprintf(pBuffer,"%s.dim%1.1d = %d",name,i,(int)rint(fVal)); sprintf(pBuffer,"%s.dim%1.1d = %d",name,i,(int)rint(fVal));
SCWrite(pCon,pBuffer,eStatus); SCWrite(pCon,pBuffer,eStatus);
} }
} }
pKey = StringDictGetNext(self->pOption,pValue,sizeof(pValue)-1); pKey = StringDictGetNext(self->pDriv->pOption,pValue,sizeof(pValue)-1);
while(pKey != NULL) { while(pKey != NULL) {
iDiscard=0; iDiscard=0;
if(0==strcmp("name",pKey)) iDiscard=1; if(0==strcmp("name",pKey)) iDiscard=1;
@ -1021,7 +1019,7 @@ static int checkHMEnd(pHistMem self, char *text){
snprintf(pBuffer,511,"%s.%s = %s",name,pKey,pValue); snprintf(pBuffer,511,"%s.%s = %s",name,pKey,pValue);
SCWrite(pCon,pBuffer,eStatus); SCWrite(pCon,pBuffer,eStatus);
} }
pKey = StringDictGetNext(self->pOption,pValue,sizeof(pValue)-1); pKey = StringDictGetNext(self->pDriv->pOption,pValue,sizeof(pValue)-1);
} }
/* Display Count Mode */ /* Display Count Mode */
@ -1259,6 +1257,16 @@ static int checkHMEnd(pHistMem self, char *text){
HMListOption(self,pCon); HMListOption(self,pCon);
return 1; return 1;
} }
/* stop */
else if(strcmp(argv[1],"stop") == 0)
{ if(!SCMatchRights(pCon,usUser))
{
return 0;
}
self->pDriv->Halt(self->pDriv);
SCSendOK(pCon);
return 1;
}
/* normal counting*/ /* normal counting*/
else if(strcmp(argv[1],"count") == 0) else if(strcmp(argv[1],"count") == 0)
{ {
@ -1693,11 +1701,6 @@ static int checkHMEnd(pHistMem self, char *text){
} }
} }
lVal = HistSum(self,pCon,iaStart,iaEnd); lVal = HistSum(self,pCon,iaStart,iaEnd);
if(lVal < 0)
{
SCWrite(pCon,"ERROR: summing failed",eError);
return 0;
}
sprintf(pBueffel,"%s.sum = %ld",argv[0],lVal); sprintf(pBueffel,"%s.sum = %ld",argv[0],lVal);
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return 1; return 1;

View File

@ -128,6 +128,7 @@ $\langle$HistType {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ /* status flags */@\\ \mbox{}\verb@ /* status flags */@\\
\mbox{}\verb@ int iReconfig;@\\ \mbox{}\verb@ int iReconfig;@\\
\mbox{}\verb@ int iUpdate;@\\ \mbox{}\verb@ int iUpdate;@\\
\mbox{}\verb@ pStringDict pOption;@\\
\mbox{}\verb@ /* interface functions */@\\ \mbox{}\verb@ /* interface functions */@\\
\mbox{}\verb@ int (*Configure)(pHistDriver self,@\\ \mbox{}\verb@ int (*Configure)(pHistDriver self,@\\
\mbox{}\verb@ SConnection *pCon,@\\ \mbox{}\verb@ SConnection *pCon,@\\
@ -313,7 +314,6 @@ $\langle$HistST {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ int iInit;@\\ \mbox{}\verb@ int iInit;@\\
\mbox{}\verb@ pICountable pCountInt;@\\ \mbox{}\verb@ pICountable pCountInt;@\\
\mbox{}\verb@ pICallBack pCall;@\\ \mbox{}\verb@ pICallBack pCall;@\\
\mbox{}\verb@ pStringDict pOption;@\\
\mbox{}\verb@ } HistMem;@\\ \mbox{}\verb@ } HistMem;@\\
\mbox{}\verb@@$\diamond$ \mbox{}\verb@@$\diamond$
\end{list} \end{list}

View File

@ -95,6 +95,7 @@ definition:
/* status flags */ /* status flags */
int iReconfig; int iReconfig;
int iUpdate; int iUpdate;
pStringDict pOption;
/* interface functions */ /* interface functions */
int (*Configure)(pHistDriver self, int (*Configure)(pHistDriver self,
SConnection *pCon, SConnection *pCon,
@ -256,7 +257,6 @@ histogram memory object is fairly simple:
int iInit; int iInit;
pICountable pCountInt; pICountable pCountInt;
pICallBack pCall; pICallBack pCall;
pStringDict pOption;
} HistMem; } HistMem;
@} @}
According to the general Sics object interface the first field is the object According to the general Sics object interface the first field is the object

View File

@ -320,9 +320,6 @@ static long SumRow(HistInt *iData, int iDataLength, int iStart, int iEnd){
for(i = iStart; i < iEnd; i++){ for(i = iStart; i < iEnd; i++){
lSum += iData[i]; lSum += iData[i];
} }
if(lSum < 0){
lSum = -lSum;
}
return lSum; return lSum;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -332,7 +329,7 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
pHMdata self = hist->pDriv->data; pHMdata self = hist->pDriv->data;
int i, iHistLength, status, iIndex; int i, iHistLength, status, iIndex;
char pBueffel[256]; char pBueffel[256];
unsigned long lSum; unsigned long lSum, lRowSum;
assert(self); assert(self);
@ -380,8 +377,9 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
lSum = 0; lSum = 0;
for(i = iStart[0]; i < iEnd[0]; i++){ for(i = iStart[0]; i < iEnd[0]; i++){
iIndex = i*self->iDim[1]; iIndex = i*self->iDim[1];
lSum += SumRow(self->localBuffer,iHistLength, lRowSum = SumRow(self->localBuffer,iHistLength,
iIndex+iStart[1], iIndex+iEnd[1]); iIndex+iStart[1], iIndex+iEnd[1]);
lSum += lRowSum;
} }
break; break;
default: default:

342
napi.c
View File

@ -23,7 +23,7 @@
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
static const char* rscid = "$Id: napi.c,v 1.12 2005/09/07 13:51:12 koennecke Exp $"; /* Revision interted by CVS */ static const char* rscid = "$Id: napi.c,v 1.13 2006/03/03 15:30:55 koennecke Exp $"; /* Revision interted by CVS */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -34,14 +34,13 @@ static const char* rscid = "$Id: napi.c,v 1.12 2005/09/07 13:51:12 koennecke Exp
#include <stdarg.h> #include <stdarg.h>
#include "napi.h" #include "napi.h"
static int iFortifyScope; static int iFortifyScope;
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
HDF-5 cache size special stuff HDF-5 cache size special stuff
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
long nx_cacheSize = 1024000; /* 1MB, HDF-5 default */ long nx_cacheSize = 1024000; /* 1MB, HDF-5 default */
NXstatus CALLING_STYLE NXsetcache(long newVal) NXstatus NXsetcache(long newVal)
{ {
if(newVal > 0) if(newVal > 0)
{ {
@ -50,6 +49,8 @@ NXstatus CALLING_STYLE NXsetcache(long newVal)
} }
return NX_ERROR; return NX_ERROR;
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static NXstatus NXisXML(CONSTCHAR *filename) static NXstatus NXisXML(CONSTCHAR *filename)
{ {
@ -66,6 +67,7 @@ static NXstatus NXisXML(CONSTCHAR *filename)
} }
return NX_ERROR; return NX_ERROR;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -83,12 +85,16 @@ static NXstatus NXisXML(CONSTCHAR *filename)
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
NX_EXTERNAL void CALLING_STYLE NXMSetError(void *pData, extern void NXMSetError(void *pData,
void (*NewError)(void *pD, char *text)) void (*NewError)(void *pD, char *text))
{ {
NXpData = pData; NXpData = pData;
NXIReportError = NewError; NXIReportError = NewError;
} }
/*----------------------------------------------------------------------*/
extern ErrFunc NXMGetError(){
return NXIReportError;
}
#ifdef HDF5 #ifdef HDF5
#include "napi5.h" #include "napi5.h"
@ -143,7 +149,7 @@ static int determineFileType(CONSTCHAR *filename)
return 0; return 0;
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopen(CONSTCHAR *filename, NXaccess am, NXhandle *gHandle) NXstatus NXopen(CONSTCHAR *filename, NXaccess am, NXhandle *gHandle)
{ {
int hdf_type=0; int hdf_type=0;
int iRet=0; int iRet=0;
@ -274,7 +280,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXclose (NXhandle *fid) NXstatus NXclose (NXhandle *fid)
{ {
NXhandle hfil; NXhandle hfil;
int status; int status;
@ -293,7 +299,7 @@ static int determineFileType(CONSTCHAR *filename)
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXmakegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NXmakegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxmakegroup(pFunc->pNexusData, name, nxclass); return pFunc->nxmakegroup(pFunc->pNexusData, name, nxclass);
@ -301,7 +307,7 @@ static int determineFileType(CONSTCHAR *filename)
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NXopengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxopengroup(pFunc->pNexusData, name, nxclass); return pFunc->nxopengroup(pFunc->pNexusData, name, nxclass);
@ -309,7 +315,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXclosegroup (NXhandle fid) NXstatus NXclosegroup (NXhandle fid)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxclosegroup(pFunc->pNexusData); return pFunc->nxclosegroup(pFunc->pNexusData);
@ -317,7 +323,7 @@ static int determineFileType(CONSTCHAR *filename)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXmakedata (NXhandle fid, CONSTCHAR *name, int datatype, NXstatus NXmakedata (NXhandle fid, CONSTCHAR *name, int datatype,
int rank, int dimensions[]) int rank, int dimensions[])
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
@ -336,7 +342,7 @@ static int determineFileType(CONSTCHAR *filename)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXcompmakedata (NXhandle fid, CONSTCHAR *name, int datatype, NXstatus NXcompmakedata (NXhandle fid, CONSTCHAR *name, int datatype,
int rank, int dimensions[],int compress_type, int chunk_size[]) int rank, int dimensions[],int compress_type, int chunk_size[])
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
@ -355,7 +361,7 @@ static int determineFileType(CONSTCHAR *filename)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXcompress (NXhandle fid, int compress_type) NXstatus NXcompress (NXhandle fid, int compress_type)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxcompress (pFunc->pNexusData, compress_type); return pFunc->nxcompress (pFunc->pNexusData, compress_type);
@ -364,7 +370,7 @@ static int determineFileType(CONSTCHAR *filename)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXopendata (NXhandle fid, CONSTCHAR *name) NXstatus NXopendata (NXhandle fid, CONSTCHAR *name)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxopendata(pFunc->pNexusData, name); return pFunc->nxopendata(pFunc->pNexusData, name);
@ -373,7 +379,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
NXstatus CALLING_STYLE NXclosedata (NXhandle fid) NXstatus NXclosedata (NXhandle fid)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxclosedata(pFunc->pNexusData); return pFunc->nxclosedata(pFunc->pNexusData);
@ -381,7 +387,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXputdata (NXhandle fid, void *data) NXstatus NXputdata (NXhandle fid, void *data)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxputdata(pFunc->pNexusData, data); return pFunc->nxputdata(pFunc->pNexusData, data);
@ -389,7 +395,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXputattr (NXhandle fid, CONSTCHAR *name, void *data, NXstatus NXputattr (NXhandle fid, CONSTCHAR *name, void *data,
int datalen, int iType) int datalen, int iType)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
@ -398,7 +404,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXputslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXstatus NXputslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxputslab(pFunc->pNexusData, data, iStart, iSize); return pFunc->nxputslab(pFunc->pNexusData, data, iStart, iSize);
@ -406,7 +412,7 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXgetdataID (NXhandle fid, NXlink* sRes) NXstatus NXgetdataID (NXhandle fid, NXlink* sRes)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxgetdataID(pFunc->pNexusData, sRes); return pFunc->nxgetdataID(pFunc->pNexusData, sRes);
@ -415,13 +421,13 @@ static int determineFileType(CONSTCHAR *filename)
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXmakelink (NXhandle fid, NXlink* sLink) NXstatus NXmakelink (NXhandle fid, NXlink* sLink)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxmakelink(pFunc->pNexusData, sLink); return pFunc->nxmakelink(pFunc->pNexusData, sLink);
} }
/* --------------------------------------------------------------------*/ /* --------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopensourcegroup(NXhandle fid) NXstatus NXopensourcegroup(NXhandle fid)
{ {
char target_path[512]; char target_path[512];
int status, type = NX_CHAR, length = 511; int status, type = NX_CHAR, length = 511;
@ -436,7 +442,7 @@ static int determineFileType(CONSTCHAR *filename)
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXflush(NXhandle *pHandle) NXstatus NXflush(NXhandle *pHandle)
{ {
NXhandle hfil; NXhandle hfil;
int status; int status;
@ -452,7 +458,7 @@ static int determineFileType(CONSTCHAR *filename)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXmalloc (void** data, int rank, NXstatus NXmalloc (void** data, int rank,
int dimensions[], int datatype) int dimensions[], int datatype)
{ {
int i; int i;
@ -487,7 +493,7 @@ static int determineFileType(CONSTCHAR *filename)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXfree (void** data) NXstatus NXfree (void** data)
{ {
if (data == NULL) { if (data == NULL) {
NXIReportError (NXpData, "ERROR: passing NULL to NXfree"); NXIReportError (NXpData, "ERROR: passing NULL to NXfree");
@ -505,7 +511,7 @@ static int determineFileType(CONSTCHAR *filename)
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NXgetnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype) NXstatus NXgetnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxgetnextentry(pFunc->pNexusData, name, nxclass, datatype); return pFunc->nxgetnextentry(pFunc->pNexusData, name, nxclass, datatype);
@ -552,7 +558,7 @@ static char *nxitrim(char *str)
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetdata (NXhandle fid, void *data) NXstatus NXgetdata (NXhandle fid, void *data)
{ {
int status, type, rank, iDim[NX_MAXRANK]; int status, type, rank, iDim[NX_MAXRANK];
char *pPtr, *pPtr2; char *pPtr, *pPtr2;
@ -577,7 +583,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetinfo (NXhandle fid, int *rank, NXstatus NXgetinfo (NXhandle fid, int *rank,
int dimension[], int *iType) int dimension[], int *iType)
{ {
int status; int status;
@ -607,7 +613,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetslab (NXhandle fid, void *data, NXstatus NXgetslab (NXhandle fid, void *data,
int iStart[], int iSize[]) int iStart[], int iSize[])
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
@ -617,7 +623,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetnextattr (NXhandle fileid, NXname pName, NXstatus NXgetnextattr (NXhandle fileid, NXname pName,
int *iLength, int *iType) int *iLength, int *iType)
{ {
pNexusFunction pFunc = (pNexusFunction)fileid; pNexusFunction pFunc = (pNexusFunction)fileid;
@ -627,7 +633,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetattr (NXhandle fid, char *name, void *data, int* datalen, int* iType) NXstatus NXgetattr (NXhandle fid, char *name, void *data, int* datalen, int* iType)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxgetattr(pFunc->pNexusData, name, data, datalen, iType); return pFunc->nxgetattr(pFunc->pNexusData, name, data, datalen, iType);
@ -636,7 +642,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetattrinfo (NXhandle fid, int *iN) NXstatus NXgetattrinfo (NXhandle fid, int *iN)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxgetattrinfo(pFunc->pNexusData, iN); return pFunc->nxgetattrinfo(pFunc->pNexusData, iN);
@ -645,7 +651,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetgroupID (NXhandle fileid, NXlink* sRes) NXstatus NXgetgroupID (NXhandle fileid, NXlink* sRes)
{ {
pNexusFunction pFunc = (pNexusFunction)fileid; pNexusFunction pFunc = (pNexusFunction)fileid;
return pFunc->nxgetgroupID(pFunc->pNexusData, sRes); return pFunc->nxgetgroupID(pFunc->pNexusData, sRes);
@ -653,7 +659,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXgetgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass) NXstatus NXgetgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxgetgroupinfo(pFunc->pNexusData, iN, pName, pClass); return pFunc->nxgetgroupinfo(pFunc->pNexusData, iN, pName, pClass);
@ -662,7 +668,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXsameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID) NXstatus NXsameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID)
{ {
pNexusFunction pFunc = (pNexusFunction)fileid; pNexusFunction pFunc = (pNexusFunction)fileid;
return pFunc->nxsameID(pFunc->pNexusData, pFirstID, pSecondID); return pFunc->nxsameID(pFunc->pNexusData, pFirstID, pSecondID);
@ -670,14 +676,14 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXinitattrdir (NXhandle fid) NXstatus NXinitattrdir (NXhandle fid)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxinitattrdir(pFunc->pNexusData); return pFunc->nxinitattrdir(pFunc->pNexusData);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXsetnumberformat (NXhandle fid, NXstatus NXsetnumberformat (NXhandle fid,
int type, char *format) int type, char *format)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
@ -698,7 +704,7 @@ static char *nxitrim(char *str)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXinitgroupdir (NXhandle fid) NXstatus NXinitgroupdir (NXhandle fid)
{ {
pNexusFunction pFunc = (pNexusFunction)fid; pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxinitgroupdir(pFunc->pNexusData); return pFunc->nxinitgroupdir(pFunc->pNexusData);
@ -927,7 +933,7 @@ static NXstatus stepOneGroupUp(NXhandle hfil, char *name)
return NX_ERROR; return NX_ERROR;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopenpath(NXhandle hfil, CONSTCHAR *path) NXstatus NXopenpath(NXhandle hfil, CONSTCHAR *path)
{ {
int status, run = 1; int status, run = 1;
NXname pathElement; NXname pathElement;
@ -964,7 +970,7 @@ NXstatus CALLING_STYLE NXopenpath(NXhandle hfil, CONSTCHAR *path)
return NX_OK; return NX_OK;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXopengrouppath(NXhandle hfil, CONSTCHAR *path) NXstatus NXopengrouppath(NXhandle hfil, CONSTCHAR *path)
{ {
int status, run = 1; int status, run = 1;
NXname pathElement; NXname pathElement;
@ -1000,6 +1006,13 @@ NXstatus CALLING_STYLE NXopengrouppath(NXhandle hfil, CONSTCHAR *path)
} }
return NX_OK; return NX_OK;
} }
NXstatus NXIprintlink(NXhandle fid, NXlink* link)
{
pNexusFunction pFunc = (pNexusFunction)fid;
return pFunc->nxprintlink(pFunc->pNexusData, link);
}
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
format NeXus time. Code needed in every NeXus file driver format NeXus time. Code needed in every NeXus file driver
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
@ -1081,7 +1094,7 @@ char *NXIformatNeXusTime(){
* NXhandle. We could store the NXhandle value in the FORTRAN array * NXhandle. We could store the NXhandle value in the FORTRAN array
* instead, but that would mean writing far more wrappers * instead, but that would mean writing far more wrappers
*/ */
NXstatus CALLING_STYLE NXfopen(char * filename, NXaccess* am, NXstatus NXfopen(char * filename, NXaccess* am,
NexusFunction* pHandle) NexusFunction* pHandle)
{ {
NXstatus ret; NXstatus ret;
@ -1106,7 +1119,7 @@ char *NXIformatNeXusTime(){
* array holding the NexusFunction structure. We need to malloc() * array holding the NexusFunction structure. We need to malloc()
* a temporary copy as NXclose will try to free() this * a temporary copy as NXclose will try to free() this
*/ */
NXstatus CALLING_STYLE NXfclose (NexusFunction* pHandle) NXstatus NXfclose (NexusFunction* pHandle)
{ {
NXhandle h; NXhandle h;
NXstatus ret; NXstatus ret;
@ -1118,7 +1131,7 @@ char *NXIformatNeXusTime(){
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXfflush(NexusFunction* pHandle) NXstatus NXfflush(NexusFunction* pHandle)
{ {
NXhandle h; NXhandle h;
NXstatus ret; NXstatus ret;
@ -1129,7 +1142,7 @@ char *NXIformatNeXusTime(){
return ret; return ret;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXfmakedata(NXhandle fid, char *name, int *pDatatype, NXstatus NXfmakedata(NXhandle fid, char *name, int *pDatatype,
int *pRank, int dimensions[]) int *pRank, int dimensions[])
{ {
NXstatus ret; NXstatus ret;
@ -1157,7 +1170,7 @@ char *NXIformatNeXusTime(){
} }
NXstatus CALLING_STYLE NXfcompmakedata(NXhandle fid, char *name, NXstatus NXfcompmakedata(NXhandle fid, char *name,
int *pDatatype, int *pDatatype,
int *pRank, int dimensions[], int *pRank, int dimensions[],
int *compression_type, int chunk[]) int *compression_type, int chunk[])
@ -1190,12 +1203,12 @@ char *NXIformatNeXusTime(){
return ret; return ret;
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXfcompress(NXhandle fid, int *compr_type) NXstatus NXfcompress(NXhandle fid, int *compr_type)
{ {
return NXcompress(fid,*compr_type); return NXcompress(fid,*compr_type);
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXfputattr(NXhandle fid, char *name, void *data, NXstatus NXfputattr(NXhandle fid, char *name, void *data,
int *pDatalen, int *pIType) int *pDatalen, int *pIType)
{ {
return NXputattr(fid, name, data, *pDatalen, *pIType); return NXputattr(fid, name, data, *pDatalen, *pIType);
@ -1214,3 +1227,242 @@ char *NXIformatNeXusTime(){
va_end(valist); va_end(valist);
return ret; return ret;
} }
/*
* windows stdcall aliases
*/
#ifdef _WIN32
NXstatus __stdcall NXISETCACHE(long newVal)
{
return NXsetcache(newVal);
}
void __stdcall NXNXNXREPORTERROR(void *pData, char *string)
{
NXNXNXReportError(pData, string);
}
NXstatus __stdcall NXIOPEN(CONSTCHAR *filename, NXaccess am, NXhandle *gHandle)
{
return NXopen(filename, am, gHandle);
}
NXstatus __stdcall NXICLOSE(NXhandle *fid)
{
return NXclose(fid);
}
NXstatus __stdcall NXIFLUSH(NXhandle* pHandle)
{
return NXflush(pHandle);
}
NXstatus __stdcall NXIMAKEGROUP(NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass)
{
return NXmakegroup(handle, name, NXclass);
}
NXstatus __stdcall NXIOPENGROUP(NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass)
{
return NXopengroup(handle, name, NXclass);
}
NXstatus __stdcall NXIOPENPATH(NXhandle handle, CONSTCHAR *path)
{
return NXopenpath(handle, path);
}
NXstatus __stdcall NXIOPENGROUPPATH (NXhandle handle, CONSTCHAR *path)
{
return NXopengrouppath(handle, path);
}
NXstatus __stdcall NXICLOSEGROUP(NXhandle handle)
{
return NXclosegroup(handle);
}
NXstatus __stdcall NXIMAKEDATA (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[])
{
return NXmakedata (handle, label, datatype, rank, dim);
}
NXstatus __stdcall NXICOMPMAKEDATA (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[])
{
return NXcompmakedata (handle, label, datatype, rank, dim, comp_typ, bufsize);
}
NXstatus __stdcall NXICOMPRESS (NXhandle handle, int compr_type)
{
return NXcompress (handle, compr_type);
}
NXstatus __stdcall NXIOPENDATA (NXhandle handle, CONSTCHAR* label)
{
return NXopendata (handle, label);
}
NXstatus __stdcall NXICLOSEDATA(NXhandle handle)
{
return NXclosedata(handle);
}
NXstatus __stdcall NXIPUTDATA(NXhandle handle, void* data)
{
return NXputdata(handle, data);
}
NXstatus __stdcall NXIPUTATTR(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType)
{
return NXputattr(handle, name, data, iDataLen, iType);
}
NXstatus __stdcall NXIPUTSLAB(NXhandle handle, void* data, int start[], int size[])
{
return NXputslab(handle, data, start, size);
}
NXstatus __stdcall NXIGETDATAID(NXhandle handle, NXlink* pLink)
{
return NXgetdataID(handle, pLink);
}
NXstatus __stdcall NXIMAKELINK(NXhandle handle, NXlink* pLink)
{
return NXmakelink(handle, pLink);
}
NXstatus __stdcall NXIOPENSOURCEGROUP(NXhandle handle)
{
return NXopensourcegroup(handle);
}
NXstatus __stdcall NXIGETDATA(NXhandle handle, void* data)
{
return NXgetdata(handle, data);
}
NXstatus __stdcall NXIGETINFO(NXhandle handle, int* rank, int dimension[], int* datatype)
{
return NXgetinfo(handle, rank, dimension, datatype);
}
NXstatus __stdcall NXIGETNEXTENTRY(NXhandle handle, NXname name, NXname nxclass, int* datatype)
{
return NXgetnextentry(handle, name, nxclass, datatype);
}
NXstatus __stdcall NXIGETSLAB(NXhandle handle, void* data, int start[], int size[])
{
return NXgetslab(handle, data, start, size);
}
NXstatus __stdcall NXIGETNEXTATTR(NXhandle handle, NXname pName, int *iLength, int *iType)
{
return NXgetnextattr(handle, pName, iLength, iType);
}
NXstatus __stdcall NXIGETATTR(NXhandle handle, char* name, void* data, int* iDataLen, int* iType)
{
return NXgetattr(handle, name, data, iDataLen, iType);
}
NXstatus __stdcall NXIGETATTRINFO(NXhandle handle, int* no_items)
{
return NXgetattrinfo(handle, no_items);
}
NXstatus __stdcall NXIGETGROUPID(NXhandle handle, NXlink* pLink)
{
return NXgetgroupID(handle, pLink);
}
NXstatus __stdcall NXIGETGROUPINFO(NXhandle handle, int* no_items, NXname name, NXname nxclass)
{
return NXgetgroupinfo(handle, no_items, name, nxclass);
}
NXstatus __stdcall NXISAMEID(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID)
{
return NXsameID(handle, pFirstID, pSecondID);
}
NXstatus __stdcall NXIINITGROUPDIR(NXhandle handle)
{
return NXinitgroupdir(handle);
}
NXstatus __stdcall NXIINITATTRDIR(NXhandle handle)
{
return NXinitattrdir(handle);
}
NXstatus __stdcall NXISETNUMBERFORMAT(NXhandle handle, int type, char *format)
{
return NXsetnumberformat(handle,type, format);
}
NXstatus __stdcall NXIMALLOC(void** data, int rank, int dimensions[], int datatype)
{
return NXmalloc(data, rank, dimensions, datatype);
}
NXstatus __stdcall NXIFREE(void** data)
{
return NXfree(data);
}
#if 0
/*-----------------------------------------------------------------------
NAPI internals
------------------------------------------------------------------------*/
extern void NXMSetError(void *pData, void (*ErrFunc)(void *pD, char *text));
extern void (*NXIReportError)(void *pData,char *text);
extern void *NXpData;
extern char *NXIformatNeXusTime();
#endif
/* FORTRAN internals */
NXstatus __stdcall NXIFOPEN(char * filename, NXaccess* am,
NexusFunction* pHandle)
{
return NXfopen(filename, am, pHandle);
}
NXstatus __stdcall NXIFCLOSE (NexusFunction* pHandle)
{
return NXfclose (pHandle);
}
NXstatus __stdcall NXIFPUTATTR(NXhandle fid, char *name, void *data,
int *pDatalen, int *pIType)
{
return NXfputattr(fid, name, data, pDatalen, pIType);
}
NXstatus __stdcall NXIFCOMPRESS(NXhandle fid, int *compr_type)
{
return NXfcompress(fid, compr_type);
}
NXstatus __stdcall NXIFCOMPMAKEDATA(NXhandle fid, char *name,
int *pDatatype,
int *pRank, int dimensions[],
int *compression_type, int chunk[])
{
return NXfcompmakedata(fid, name, pDatatype, pRank, dimensions,
compression_type, chunk);
}
NXstatus __stdcall NXIFMAKEDATA(NXhandle fid, char *name, int *pDatatype,
int *pRank, int dimensions[])
{
return NXfmakedata(fid, name, pDatatype, pRank, dimensions);
}
NXstatus __stdcall NXIFFLUSH(NexusFunction* pHandle)
{
return NXfflush(pHandle);
}
#endif /* _WIN32 */

252
napi.h
View File

@ -21,7 +21,7 @@
For further information, see <http://www.neutron.anl.gov/NeXus/> For further information, see <http://www.neutron.anl.gov/NeXus/>
$Id: napi.h,v 1.9 2005/09/07 13:51:12 koennecke Exp $ $Id: napi.h,v 1.10 2006/03/03 15:30:55 koennecke Exp $
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -33,18 +33,8 @@
#define CONSTCHAR const char #define CONSTCHAR const char
#if defined(_WIN32) && defined(_DLL)
# ifdef NX45DLL_EXPORTS
# define NX_EXTERNAL __declspec(dllexport)
# else
# define NX_EXTERNAL __declspec(dllimport)
# endif
#else
# define NX_EXTERNAL
#endif
#ifdef _WIN32 #ifdef _WIN32
#define snprintf nxisnprintf //#define snprintf nxisnprintf
extern int nxisnprintf(char* buffer, int len, const char* format, ... ); extern int nxisnprintf(char* buffer, int len, const char* format, ... );
#endif /* _WIN32 */ #endif /* _WIN32 */
@ -133,16 +123,12 @@ typedef struct {
#define CONCAT(__a,__b) __a##__b /* token concatenation */ #define CONCAT(__a,__b) __a##__b /* token concatenation */
#if defined(__unix) || defined(__unix__) || defined (__VMS) || defined(__APPLE__)
# ifdef __VMS # ifdef __VMS
# define MANGLE(__arg) __arg # define MANGLE(__arg) __arg
# else # else
# define MANGLE(__arg) CONCAT(__arg,_) # define MANGLE(__arg) CONCAT(__arg,_)
# endif # endif
# define CALLING_STYLE /* blank */
# define NXopen MANGLE(nxiopen) # define NXopen MANGLE(nxiopen)
# define NXclose MANGLE(nxiclose) # define NXclose MANGLE(nxiclose)
# define NXmakegroup MANGLE(nximakegroup) # define NXmakegroup MANGLE(nximakegroup)
@ -180,7 +166,10 @@ typedef struct {
# define NXinitattrdir MANGLE(nxiinitattrdir) # define NXinitattrdir MANGLE(nxiinitattrdir)
# define NXsetnumberformat MANGLE(nxisetnumberformat) # define NXsetnumberformat MANGLE(nxisetnumberformat)
# define NXsetcache MANGLE(nxisetcache) # define NXsetcache MANGLE(nxisetcache)
/* FORTRAN helpers - for NeXus internal use only */
/*
* FORTRAN helpers - for NeXus internal use only
*/
# define NXfopen MANGLE(nxifopen) # define NXfopen MANGLE(nxifopen)
# define NXfclose MANGLE(nxifclose) # define NXfclose MANGLE(nxifclose)
# define NXfflush MANGLE(nxifflush) # define NXfflush MANGLE(nxifflush)
@ -189,80 +178,6 @@ typedef struct {
# define NXfcompress MANGLE(nxifcompress) # define NXfcompress MANGLE(nxifcompress)
# define NXfputattr MANGLE(nxifputattr) # define NXfputattr MANGLE(nxifputattr)
#elif defined(_WIN32)
/*
* START OF WINDOWS SPECIFIC CONFIGURATION
*
* Added by Freddie Akeroyd 9/8/2002
*
* Various PC calling conventions - you need only uncomment one of the following definitions of MANGLE()
* anlong with the appropriate CALLING_STYLE
* The choice arises because under Windows the default way FORTRAN calls FORTRAN is different
* from the dafault way C calls C, and so when you need to have FORTRAN calling C you must
* force them to use the same convention. Notice the use of "default way" above ... by choice
* of compiler options (or compiler vendor) you may actually have FORTRAN calling in the C way
* etc., so you might need to experiment with the options below until you get no "unresolved symbols"
*
* Choice 1: Should allow both FORTRAN and C NeXus interfaces to work in a "default" setup
* Choice 2: For when choice 1: gives problems and you only require the C interface
* Choice 3: An alternative to 1: which may allow both FORTRAN and C in a non-default setup
*/
# define MANGLE(__arg) __arg /* Choice 1 */
# define CALLING_STYLE __stdcall /* Choice 1 */
/* # define MANGLE(__arg) __arg /* Choice 2 */
/* # define CALLING_STYLE /* Choice 2 */
/* # define MANGLE(__arg) CONCAT(__arg,_) /* Choice 3 */
/* # define CALLING_STYLE __stdcall /* Choice 3 */
/*
* END OF WINDOWS SPECIFIC CONFIGURATION
*/
# define NXopen MANGLE(NXIOPEN)
# define NXclose MANGLE(NXICLOSE)
# define NXflush MANGLE(NXIFLUSH)
# define NXmakegroup MANGLE(NXIMAKEGROUP)
# define NXopengroup MANGLE(NXIOPENGROUP)
# define NXopenpath MANGLE(NXIOPENPATH)
# define NXopengrouppath MANGLE(NXIOPENGROUPPATH)
# define NXclosegroup MANGLE(NXICLOSEGROUP)
# define NXmakedata MANGLE(NXIMAKEDATA)
# define NXcompress MANGLE(NXICOMPRESS)
# define NXopendata MANGLE(NXIOPENDATA)
# define NXclosedata MANGLE(NXICLOSEDATA)
# define NXgetdata MANGLE(NXIGETDATA)
# define NXgetslab MANGLE(NXIGETSLAB)
# define NXgetattr MANGLE(NXIGETATTR)
# define NXgetdim MANGLE(NXIGETDIM)
# define NXputdata MANGLE(NXIPUTDATA)
# define NXputslab MANGLE(NXIPUTSLAB)
# define NXputattr MANGLE(NXIPUTATTR)
# define NXputdim MANGLE(NXIPUTDIM)
# define NXgetinfo MANGLE(NXIGETINFO)
# define NXgetgroupinfo MANGLE(NXIGETGROUPINFO)
# define NXsameID MANGLE(NXISAMEID)
# define NXinitgroupdir MANGLE(NXIINITGROUPDIR)
# define NXgetnextentry MANGLE(NXIGETNEXTENTRY)
# define NXgetattrinfo MANGLE(NXIGETATTRINFO)
# define NXinitattrdir MANGLE(NXIINITATTRDIR)
# define NXsetnumberformat MANGLE(NXISETNUMBERFORMAT)
# define NXgetnextattr MANGLE(NXIGETNEXTATTR)
# define NXgetgroupID MANGLE(NXIGETGROUPID)
# define NXgetdataID MANGLE(NXIGETDATAID)
# define NXmakelink MANGLE(NXIMAKELINK)
# define NXopensourcegroup MANGLE(NXIOPENSOURCEGROUP)
# define NXmalloc MANGLE(NXIMALLOC)
# define NXfree MANGLE(NXIFREE)
/* FORTRAN helpers - for NeXus internal use only */
# define NXfopen MANGLE(NXIFOPEN)
# define NXfclose MANGLE(NXIFCLOSE)
# define NXfflush MANGLE(NXIFFLUSH)
# define NXfmakedata MANGLE(NXIFMAKEDATA)
# define NXfcompmakedata MANGLE(NXIFCOMPMAKEDATA)
# define NXfcompress MANGLE(NXIFCOMPRESS)
# define NXfputattr MANGLE(NXIFPUTATTR)
#else
# error Cannot compile - unknown operating system
#endif
/* /*
* Standard interface * Standard interface
@ -271,105 +186,120 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
NX_EXTERNAL NXstatus CALLING_STYLE NXopen(CONSTCHAR * filename, NXaccess access_method, NXhandle* pHandle); extern NXstatus NXopen(CONSTCHAR * filename, NXaccess access_method, NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NXclose(NXhandle* pHandle); extern NXstatus NXclose(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NXflush(NXhandle* pHandle); extern NXstatus NXflush(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NXmakegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); extern NXstatus NXmakegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NXopengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); extern NXstatus NXopengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NXopenpath (NXhandle handle, CONSTCHAR *path); extern NXstatus NXopenpath (NXhandle handle, CONSTCHAR *path);
NX_EXTERNAL NXstatus CALLING_STYLE NXopengrouppath (NXhandle handle, CONSTCHAR *path); extern NXstatus NXopengrouppath (NXhandle handle, CONSTCHAR *path);
NX_EXTERNAL NXstatus CALLING_STYLE NXclosegroup(NXhandle handle); extern NXstatus NXclosegroup(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); extern NXstatus NXmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]);
NX_EXTERNAL NXstatus CALLING_STYLE NXcompmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); extern NXstatus NXcompmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]);
NX_EXTERNAL NXstatus CALLING_STYLE NXcompress (NXhandle handle, int compr_type); extern NXstatus NXcompress (NXhandle handle, int compr_type);
NX_EXTERNAL NXstatus CALLING_STYLE NXopendata (NXhandle handle, CONSTCHAR* label); extern NXstatus NXopendata (NXhandle handle, CONSTCHAR* label);
NX_EXTERNAL NXstatus CALLING_STYLE NXclosedata(NXhandle handle); extern NXstatus NXclosedata(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXputdata(NXhandle handle, void* data); extern NXstatus NXputdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); extern NXstatus NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType);
NX_EXTERNAL NXstatus CALLING_STYLE NXputslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NXputslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetdataID(NXhandle handle, NXlink* pLink); extern NXstatus NXgetdataID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NXmakelink(NXhandle handle, NXlink* pLink); extern NXstatus NXmakelink(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NXopensourcegroup(NXhandle handle); extern NXstatus NXopensourcegroup(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetdata(NXhandle handle, void* data); extern NXstatus NXgetdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetinfo(NXhandle handle, int* rank, int dimension[], int* datatype); extern NXstatus NXgetinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype); extern NXstatus NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NXgetslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); extern NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType); extern NXstatus NXgetattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetattrinfo(NXhandle handle, int* no_items); extern NXstatus NXgetattrinfo(NXhandle handle, int* no_items);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetgroupID(NXhandle handle, NXlink* pLink); extern NXstatus NXgetgroupID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NXgetgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass); extern NXstatus NXgetgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
NX_EXTERNAL NXstatus CALLING_STYLE NXsameID(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID); extern NXstatus NXsameID(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID);
NX_EXTERNAL NXstatus CALLING_STYLE NXinitgroupdir(NXhandle handle); extern NXstatus NXinitgroupdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXinitattrdir(NXhandle handle); extern NXstatus NXinitattrdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXsetnumberformat(NXhandle handle, extern NXstatus NXsetnumberformat(NXhandle handle,
int type, char *format); int type, char *format);
NX_EXTERNAL NXstatus CALLING_STYLE NXmalloc(void** data, int rank, int dimensions[], int datatype); extern NXstatus NXmalloc(void** data, int rank, int dimensions[], int datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NXfree(void** data); extern NXstatus NXfree(void** data);
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
NAPI internals NAPI internals
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/
NX_EXTERNAL void CALLING_STYLE NXMSetError(void *pData, void (*ErrFunc)(void *pD, char *text)); typedef void (*ErrFunc)(void *data, char *text);
extern void NXMSetError(void *pData, ErrFunc);
extern ErrFunc NXMGetError();
extern void (*NXIReportError)(void *pData,char *text); extern void (*NXIReportError)(void *pData,char *text);
extern void *NXpData; extern void *NXpData;
extern char *NXIformatNeXusTime(); extern char *NXIformatNeXusTime();
extern NXstatus NXIprintlink(NXhandle fid, NXlink* link);
/* /*
another special function for setting the default cache size for HDF-5 another special function for setting the default cache size for HDF-5
*/ */
NX_EXTERNAL NXstatus CALLING_STYLE NXsetcache(long newVal); extern NXstatus NXsetcache(long newVal);
/*
* We need to include CALLING_STYLE in the function pointer definition
* or else we get a type mismatch on Win32
*/
typedef struct { typedef struct {
NXhandle *pNexusData; NXhandle *pNexusData;
int stripFlag; int stripFlag;
NXstatus (CALLING_STYLE *nxclose)(NXhandle* pHandle); NXstatus ( *nxclose)(NXhandle* pHandle);
NXstatus (CALLING_STYLE *nxflush)(NXhandle* pHandle); NXstatus ( *nxflush)(NXhandle* pHandle);
NXstatus (CALLING_STYLE *nxmakegroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); NXstatus ( *nxmakegroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NXstatus (CALLING_STYLE *nxopengroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); NXstatus ( *nxopengroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NXstatus (CALLING_STYLE *nxclosegroup)(NXhandle handle); NXstatus ( *nxclosegroup)(NXhandle handle);
NXstatus (CALLING_STYLE *nxmakedata) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); NXstatus ( *nxmakedata) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]);
NXstatus (CALLING_STYLE *nxcompmakedata) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); NXstatus ( *nxcompmakedata) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]);
NXstatus (CALLING_STYLE *nxcompress) (NXhandle handle, int compr_type); NXstatus ( *nxcompress) (NXhandle handle, int compr_type);
NXstatus (CALLING_STYLE *nxopendata) (NXhandle handle, CONSTCHAR* label); NXstatus ( *nxopendata) (NXhandle handle, CONSTCHAR* label);
NXstatus (CALLING_STYLE *nxclosedata)(NXhandle handle); NXstatus ( *nxclosedata)(NXhandle handle);
NXstatus (CALLING_STYLE *nxputdata)(NXhandle handle, void* data); NXstatus ( *nxputdata)(NXhandle handle, void* data);
NXstatus (CALLING_STYLE *nxputattr)(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); NXstatus ( *nxputattr)(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType);
NXstatus (CALLING_STYLE *nxputslab)(NXhandle handle, void* data, int start[], int size[]); NXstatus ( *nxputslab)(NXhandle handle, void* data, int start[], int size[]);
NXstatus (CALLING_STYLE *nxgetdataID)(NXhandle handle, NXlink* pLink); NXstatus ( *nxgetdataID)(NXhandle handle, NXlink* pLink);
NXstatus (CALLING_STYLE *nxmakelink)(NXhandle handle, NXlink* pLink); NXstatus ( *nxmakelink)(NXhandle handle, NXlink* pLink);
NXstatus (CALLING_STYLE *nxgetdata)(NXhandle handle, void* data); NXstatus ( *nxgetdata)(NXhandle handle, void* data);
NXstatus (CALLING_STYLE *nxgetinfo)(NXhandle handle, int* rank, int dimension[], int* datatype); NXstatus ( *nxgetinfo)(NXhandle handle, int* rank, int dimension[], int* datatype);
NXstatus (CALLING_STYLE *nxgetnextentry)(NXhandle handle, NXname name, NXname nxclass, int* datatype); NXstatus ( *nxgetnextentry)(NXhandle handle, NXname name, NXname nxclass, int* datatype);
NXstatus (CALLING_STYLE *nxgetslab)(NXhandle handle, void* data, int start[], int size[]); NXstatus ( *nxgetslab)(NXhandle handle, void* data, int start[], int size[]);
NXstatus (CALLING_STYLE *nxgetnextattr)(NXhandle handle, NXname pName, int *iLength, int *iType); NXstatus ( *nxgetnextattr)(NXhandle handle, NXname pName, int *iLength, int *iType);
NXstatus (CALLING_STYLE *nxgetattr)(NXhandle handle, char* name, void* data, int* iDataLen, int* iType); NXstatus ( *nxgetattr)(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
NXstatus (CALLING_STYLE *nxgetattrinfo)(NXhandle handle, int* no_items); NXstatus ( *nxgetattrinfo)(NXhandle handle, int* no_items);
NXstatus (CALLING_STYLE *nxgetgroupID)(NXhandle handle, NXlink* pLink); NXstatus ( *nxgetgroupID)(NXhandle handle, NXlink* pLink);
NXstatus (CALLING_STYLE *nxgetgroupinfo)(NXhandle handle, int* no_items, NXname name, NXname nxclass); NXstatus ( *nxgetgroupinfo)(NXhandle handle, int* no_items, NXname name, NXname nxclass);
NXstatus (CALLING_STYLE *nxsameID)(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID); NXstatus ( *nxsameID)(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID);
NXstatus (CALLING_STYLE *nxinitgroupdir)(NXhandle handle); NXstatus ( *nxinitgroupdir)(NXhandle handle);
NXstatus (CALLING_STYLE *nxinitattrdir)(NXhandle handle); NXstatus ( *nxinitattrdir)(NXhandle handle);
NXstatus (CALLING_STYLE *nxsetnumberformat)(NXhandle handle, NXstatus ( *nxsetnumberformat)(NXhandle handle, int type, char *format);
int type,char *format); NXstatus ( *nxprintlink)(NXhandle handle, NXlink* link);
} NexusFunction, *pNexusFunction; } NexusFunction, *pNexusFunction;
/*---------------------*/ /*---------------------*/
extern long nx_cacheSize; extern long nx_cacheSize;
/* FORTRAN internals */
extern NXstatus NXfopen(char * filename, NXaccess* am,
NexusFunction* pHandle);
extern NXstatus NXfclose (NexusFunction* pHandle);
extern NXstatus NXfputattr(NXhandle fid, char *name, void *data,
int *pDatalen, int *pIType);
extern NXstatus NXfcompress(NXhandle fid, int *compr_type);
extern NXstatus NXfcompmakedata(NXhandle fid, char *name,
int *pDatatype,
int *pRank, int dimensions[],
int *compression_type, int chunk[]);
extern NXstatus NXfmakedata(NXhandle fid, char *name, int *pDatatype,
int *pRank, int dimensions[]);
extern NXstatus NXfflush(NexusFunction* pHandle);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

68
napi4.c
View File

@ -21,7 +21,7 @@
For further information, see <http://www.neutron.anl.gov/NeXus/> For further information, see <http://www.neutron.anl.gov/NeXus/>
$Id: napi4.c,v 1.5 2005/09/07 13:51:12 koennecke Exp $ $Id: napi4.c,v 1.6 2006/03/03 15:30:55 koennecke Exp $
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#include <stdlib.h> #include <stdlib.h>
@ -320,7 +320,7 @@ extern void *NXpData;
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4open(CONSTCHAR *filename, NXaccess am, NXstatus NX4open(CONSTCHAR *filename, NXaccess am,
NXhandle* pHandle) NXhandle* pHandle)
{ {
pNexusFile pNew = NULL; pNexusFile pNew = NULL;
@ -454,7 +454,7 @@ extern void *NXpData;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4close (NXhandle* fid) NXstatus NX4close (NXhandle* fid)
{ {
pNexusFile pFile = NULL; pNexusFile pFile = NULL;
int iRet; int iRet;
@ -492,7 +492,7 @@ extern void *NXpData;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4makegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NX4makegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iNew, iRet; int32 iNew, iRet;
@ -536,7 +536,7 @@ extern void *NXpData;
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4opengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NX4opengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iRef; int32 iRef;
@ -570,7 +570,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4closegroup (NXhandle fid) NXstatus NX4closegroup (NXhandle fid)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -603,7 +603,7 @@ extern void *NXpData;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4makedata (NXhandle fid, CONSTCHAR *name, int datatype, int rank, NXstatus NX4makedata (NXhandle fid, CONSTCHAR *name, int datatype, int rank,
int dimensions[]) int dimensions[])
{ {
pNexusFile pFile; pNexusFile pFile;
@ -728,7 +728,7 @@ extern void *NXpData;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4compmakedata (NXhandle fid, CONSTCHAR *name, int datatype, int rank, NXstatus NX4compmakedata (NXhandle fid, CONSTCHAR *name, int datatype, int rank,
int dimensions[],int compress_type, int chunk_size[]) int dimensions[],int compress_type, int chunk_size[])
{ {
pNexusFile pFile; pNexusFile pFile;
@ -895,7 +895,7 @@ extern void *NXpData;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4compress (NXhandle fid, int compress_type) NXstatus NX4compress (NXhandle fid, int compress_type)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iRank, iAtt, iType, iRet; int32 iRank, iAtt, iType, iRet;
@ -959,7 +959,7 @@ extern void *NXpData;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4opendata (NXhandle fid, CONSTCHAR *name) NXstatus NX4opendata (NXhandle fid, CONSTCHAR *name)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iNew; int32 iNew;
@ -1001,7 +1001,7 @@ extern void *NXpData;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4closedata (NXhandle fid) NXstatus NX4closedata (NXhandle fid)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
@ -1026,7 +1026,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4putdata (NXhandle fid, void *data) NXstatus NX4putdata (NXhandle fid, void *data)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iStart[MAX_VAR_DIMS], iSize[MAX_VAR_DIMS], iStride[MAX_VAR_DIMS]; int32 iStart[MAX_VAR_DIMS], iSize[MAX_VAR_DIMS], iStride[MAX_VAR_DIMS];
@ -1063,7 +1063,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus NXstatus
CALLING_STYLE NX4putattr (NXhandle fid, CONSTCHAR *name, void *data, int datalen, int iType) NX4putattr (NXhandle fid, CONSTCHAR *name, void *data, int datalen, int iType)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet, type; int iRet, type;
@ -1126,7 +1126,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4putslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXstatus NX4putslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
@ -1183,7 +1183,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4getdataID (NXhandle fid, NXlink* sRes) NXstatus NX4getdataID (NXhandle fid, NXlink* sRes)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1206,7 +1206,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4makelink (NXhandle fid, NXlink* sLink) NXstatus NX4makelink (NXhandle fid, NXlink* sLink)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iVG, iRet, dataID, type = DFNT_CHAR8, length; int32 iVG, iRet, dataID, type = DFNT_CHAR8, length;
@ -1230,10 +1230,19 @@ extern void *NXpData;
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/
NXstatus NX4printlink (NXhandle fid, NXlink* sLink)
{
pNexusFile pFile;
pFile = NXIassert (fid);
printf("HDF4 link: iTag = %d, iRef = %d, target=\"%s\"\n", sLink->iTag, sLink->iRef, sLink->targetPath);
return NX_OK;
}
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4flush(NXhandle *pHandle) NXstatus NX4flush(NXhandle *pHandle)
{ {
char *pFileName, *pCopy = NULL; char *pFileName, *pCopy = NULL;
int access, dummy, iRet, i, iStack; int access, dummy, iRet, i, iStack;
@ -1314,7 +1323,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype) NXstatus NX4getnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet, iStackPtr, iCurDir; int iRet, iStackPtr, iCurDir;
@ -1396,7 +1405,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getdata (NXhandle fid, void *data) NXstatus NX4getdata (NXhandle fid, void *data)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iStart[MAX_VAR_DIMS], iSize[MAX_VAR_DIMS]; int32 iStart[MAX_VAR_DIMS], iSize[MAX_VAR_DIMS];
@ -1421,7 +1430,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus NXstatus
CALLING_STYLE NX4getinfo (NXhandle fid, int *rank, int dimension[], NX4getinfo (NXhandle fid, int *rank, int dimension[],
int *iType) int *iType)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1453,7 +1462,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXstatus NX4getslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile pFile; pNexusFile pFile;
int32 myStart[MAX_VAR_DIMS], mySize[MAX_VAR_DIMS]; int32 myStart[MAX_VAR_DIMS], mySize[MAX_VAR_DIMS];
@ -1496,7 +1505,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getnextattr (NXhandle fileid, NXname pName, NXstatus NX4getnextattr (NXhandle fileid, NXname pName,
int *iLength, int *iType) int *iLength, int *iType)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1539,7 +1548,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getattr (NXhandle fid, char *name, void *data, int* datalen, int* iType) NXstatus NX4getattr (NXhandle fid, char *name, void *data, int* datalen, int* iType)
{ {
pNexusFile pFile; pNexusFile pFile;
int32 iNew, iType32; int32 iNew, iType32;
@ -1648,7 +1657,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getattrinfo (NXhandle fid, int *iN) NXstatus NX4getattrinfo (NXhandle fid, int *iN)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
@ -1674,7 +1683,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4getgroupID (NXhandle fileid, NXlink* sRes) NXstatus NX4getgroupID (NXhandle fileid, NXlink* sRes)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1697,7 +1706,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus NXstatus
CALLING_STYLE NX4getgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass) NX4getgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1718,7 +1727,7 @@ extern void *NXpData;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX4sameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID) NXstatus NX4sameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1733,7 +1742,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4initattrdir (NXhandle fid) NXstatus NX4initattrdir (NXhandle fid)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
@ -1750,7 +1759,7 @@ extern void *NXpData;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX4initgroupdir (NXhandle fid) NXstatus NX4initgroupdir (NXhandle fid)
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
@ -1795,4 +1804,5 @@ void NX4assignFunctions(pNexusFunction fHandle)
fHandle->nxsameID=NX4sameID; fHandle->nxsameID=NX4sameID;
fHandle->nxinitgroupdir=NX4initgroupdir; fHandle->nxinitgroupdir=NX4initgroupdir;
fHandle->nxinitattrdir=NX4initattrdir; fHandle->nxinitattrdir=NX4initattrdir;
fHandle->nxprintlink=NX4printlink;
} }

56
napi4.h
View File

@ -7,40 +7,42 @@
* HDF4 interface * HDF4 interface
*/ */
NX_EXTERNAL NXstatus CALLING_STYLE NX4open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle); extern NXstatus NX4open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4close(NXhandle* pHandle); extern NXstatus NX4close(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4flush(NXhandle* pHandle); extern NXstatus NX4flush(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4makegroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass); extern NXstatus NX4makegroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX4opengroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass); extern NXstatus NX4opengroup (NXhandle handle, CONSTCHAR* Vgroup, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX4closegroup(NXhandle handle); extern NXstatus NX4closegroup(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4makedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); extern NXstatus NX4makedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX4compmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); extern NXstatus NX4compmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX4compress (NXhandle handle, int compr_type); extern NXstatus NX4compress (NXhandle handle, int compr_type);
NX_EXTERNAL NXstatus CALLING_STYLE NX4opendata (NXhandle handle, CONSTCHAR* label); extern NXstatus NX4opendata (NXhandle handle, CONSTCHAR* label);
NX_EXTERNAL NXstatus CALLING_STYLE NX4closedata(NXhandle handle); extern NXstatus NX4closedata(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getdata(NXhandle handle, void* data); extern NXstatus NX4getdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NX4getslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType); extern NXstatus NX4getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
NX_EXTERNAL NXstatus CALLING_STYLE NX4putdata(NXhandle handle, void* data); extern NXstatus NX4putdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NX4putslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NX4putslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX4putattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); extern NXstatus NX4putattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getinfo(NXhandle handle, int* rank, int dimension[], int* datatype); extern NXstatus NX4getinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass); extern NXstatus NX4getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX4initgroupdir(NXhandle handle); extern NXstatus NX4initgroupdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype); extern NXstatus NX4getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getattrinfo(NXhandle handle, int* no_items); extern NXstatus NX4getattrinfo(NXhandle handle, int* no_items);
NX_EXTERNAL NXstatus CALLING_STYLE NX4initattrdir(NXhandle handle); extern NXstatus NX4initattrdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); extern NXstatus NX4getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
extern NXstatus NX4getgroupID(NXhandle handle, NXlink* pLink);
extern NXstatus NX4getdataID(NXhandle handle, NXlink* pLink);
extern NXstatus NX4makelink(NXhandle handle, NXlink* pLink);
extern NXstatus NX4printlink(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getgroupID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX4getdataID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX4makelink(NXhandle handle, NXlink* pLink);
void NX4assignFunctions(pNexusFunction fHandle); void NX4assignFunctions(pNexusFunction fHandle);

124
napi5.c
View File

@ -62,8 +62,10 @@ extern void *NXpData;
forward declaration of NX5closegroup in order to get rid of a nasty forward declaration of NX5closegroup in order to get rid of a nasty
warning warning
*/ */
NXstatus CALLING_STYLE NX5closegroup (NXhandle fid); NXstatus NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------*/
static void ignoreError(void *data, char *text){
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static pNexusFile5 NXI5assert(NXhandle fid) static pNexusFile5 NXI5assert(NXhandle fid)
@ -112,7 +114,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5open(CONSTCHAR *filename, NXaccess am, NXstatus NX5open(CONSTCHAR *filename, NXaccess am,
NXhandle* pHandle) NXhandle* pHandle)
{ {
hid_t attr1,aid1, aid2; hid_t attr1,aid1, aid2;
@ -301,7 +303,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5close (NXhandle* fid) NXstatus NX5close (NXhandle* fid)
{ {
pNexusFile5 pFile = NULL; pNexusFile5 pFile = NULL;
int iRet; int iRet;
@ -348,7 +350,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5makegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NX5makegroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
hid_t iRet; hid_t iRet;
@ -404,7 +406,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
return strstr(member_name, attr_name) ? 1 : 0; return strstr(member_name, attr_name) ? 1 : 0;
} }
NXstatus CALLING_STYLE NX5opengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass) NXstatus NX5opengroup (NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -436,6 +438,11 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
} }
/* check contents of group attribute */ /* check contents of group attribute */
attr1 = H5Aopen_name(pFile->iCurrentG, "NX_class"); attr1 = H5Aopen_name(pFile->iCurrentG, "NX_class");
if (attr1 < 0)
{
NXIReportError (NXpData, "Error opening group attribute!");
return NX_ERROR;
}
atype=H5Tcopy(H5T_C_S1); atype=H5Tcopy(H5T_C_S1);
H5Tset_size(atype,128); H5Tset_size(atype,128);
iRet = H5Aread(attr1, atype, data); iRet = H5Aread(attr1, atype, data);
@ -478,6 +485,11 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
} }
/* check contains of group attribute */ /* check contains of group attribute */
attr1 = H5Aopen_name(pFile->iCurrentG, "NX_class"); attr1 = H5Aopen_name(pFile->iCurrentG, "NX_class");
if (attr1 < 0)
{
NXIReportError (NXpData, "Error opening group attribute!");
return NX_ERROR;
}
atype=H5Tcopy(H5T_C_S1); atype=H5Tcopy(H5T_C_S1);
H5Tset_size(atype,128); H5Tset_size(atype,128);
iRet = H5Aread(attr1, atype, data); iRet = H5Aread(attr1, atype, data);
@ -496,6 +508,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
pFile->iStack5[pFile->iStackPtr].iVref=pFile->iCurrentG; pFile->iStack5[pFile->iStackPtr].iVref=pFile->iCurrentG;
strcpy(pFile->iStack5[pFile->iStackPtr].irefn,name); strcpy(pFile->iStack5[pFile->iStackPtr].irefn,name);
pFile->iAtt5.iCurrentIDX=0; pFile->iAtt5.iCurrentIDX=0;
pFile->iCurrentD = 0;
if(pFile->iCurrentLGG != NULL){ if(pFile->iCurrentLGG != NULL){
free(pFile->iCurrentLGG); free(pFile->iCurrentLGG);
} }
@ -506,7 +519,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5closegroup (NXhandle fid) NXstatus NX5closegroup (NXhandle fid)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int i,ii; int i,ii;
@ -563,7 +576,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5compmakedata (NXhandle fid, CONSTCHAR *name, NXstatus NX5compmakedata (NXhandle fid, CONSTCHAR *name,
int datatype, int datatype,
int rank, int dimensions[], int rank, int dimensions[],
int compress_type, int chunk_size[]) int compress_type, int chunk_size[])
@ -732,7 +745,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5makedata (NXhandle fid, CONSTCHAR *name, int datatype, NXstatus NX5makedata (NXhandle fid, CONSTCHAR *name, int datatype,
int rank, int dimensions[]) int rank, int dimensions[])
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -756,7 +769,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5compress (NXhandle fid, int compress_type) NXstatus NX5compress (NXhandle fid, int compress_type)
{ {
printf(" NXcompress ERROR: NeXus API based on HDF5 doesn't support\n"); printf(" NXcompress ERROR: NeXus API based on HDF5 doesn't support\n");
printf(" NXcompress function! Using HDF5 library,\n"); printf(" NXcompress function! Using HDF5 library,\n");
@ -767,7 +780,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5opendata (NXhandle fid, CONSTCHAR *name) NXstatus NX5opendata (NXhandle fid, CONSTCHAR *name)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
char pBuffer[256]; char pBuffer[256];
@ -807,7 +820,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5closedata (NXhandle fid) NXstatus NX5closedata (NXhandle fid)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int iRet; int iRet;
@ -828,7 +841,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
NXstatus CALLING_STYLE NX5putdata (NXhandle fid, void *data) NXstatus NX5putdata (NXhandle fid, void *data)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
hid_t iRet; hid_t iRet;
@ -850,7 +863,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5putattr (NXhandle fid, CONSTCHAR *name, void *data, NXstatus NX5putattr (NXhandle fid, CONSTCHAR *name, void *data,
int datalen, int iType) int datalen, int iType)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -967,7 +980,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5putslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXstatus NX5putslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int iRet, i; int iRet, i;
@ -1036,9 +1049,11 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5getdataID (NXhandle fid, NXlink* sRes) NXstatus NX5getdataID (NXhandle fid, NXlink* sRes)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
ErrFunc oldErr;
int datalen, type = NX_CHAR;
pFile = NXI5assert (fid); pFile = NXI5assert (fid);
@ -1048,15 +1063,31 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
if(pFile->iCurrentD <= 0){ if(pFile->iCurrentD <= 0){
return NX_ERROR; return NX_ERROR;
} }
strcpy(sRes->iTag5,"");
strcpy(sRes->iRef5,"/"); strcpy(sRes->iRef5,"/");
strcat(sRes->iRef5,pFile->name_ref); strcat(sRes->iRef5,pFile->name_ref);
strcpy(sRes->iRefd,pFile->iCurrentLD); strcpy(sRes->iRefd,pFile->iCurrentLD);
oldErr = NXMGetError();
NXMSetError(NXpData, ignoreError);
datalen = 1024;
memset(&sRes->targetPath,0,datalen*sizeof(char));
NX5getattr(fid,"target",&sRes->targetPath,&datalen,&type);
return NX_OK; return NX_OK;
} }
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5makelink (NXhandle fid, NXlink* sLink) NXstatus NX5printlink (NXhandle fid, NXlink* sLink)
{
pNexusFile5 pFile;
pFile = NXI5assert (fid);
printf("HDF5 link: iTag5 = \"%s\", iRef5 = \"%s\", iRefd = \"%s\"\n", sLink->iTag5, sLink->iRef5, sLink->iRefd);
return NX_OK;
}
/* ------------------------------------------------------------------- */
NXstatus NX5makelink (NXhandle fid, NXlink* sLink)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
/* int iRet; */ /* int iRet; */
@ -1076,7 +1107,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
strcpy(sLink->iTag5,pFile->name_ref); strcpy(sLink->iTag5,pFile->name_ref);
} else { } else {
/* group link */ /* group link */
strcpy(buffer,pFile->iCurrentLGG); strcpy(buffer,pFile->name_ref);
strcat(buffer, sLink->iTag5); strcat(buffer, sLink->iTag5);
strcpy(sLink->iTag5,"/"); strcpy(sLink->iTag5,"/");
strcat(sLink->iTag5,buffer); strcat(sLink->iTag5,buffer);
@ -1127,7 +1158,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5flush(NXhandle *pHandle) NXstatus NX5flush(NXhandle *pHandle)
{ {
pNexusFile5 pFile = NULL; pNexusFile5 pFile = NULL;
int iRet; int iRet;
@ -1206,7 +1237,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass) NXstatus NX5getgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
hid_t atype,attr_id; hid_t atype,attr_id;
@ -1243,7 +1274,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getnextentry (NXhandle fid,NXname name, NXname nxclass, int *datatype) NXstatus NX5getnextentry (NXhandle fid,NXname name, NXname nxclass, int *datatype)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
hid_t grp, attr1,type,atype; hid_t grp, attr1,type,atype;
@ -1253,6 +1284,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
char ph_name[1024]; char ph_name[1024];
info_type op_data; info_type op_data;
int iRet_iNX=-1; int iRet_iNX=-1;
char pBuffer[256];
pFile = NXI5assert (fid); pFile = NXI5assert (fid);
op_data.iname = NULL; op_data.iname = NULL;
@ -1295,7 +1327,17 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
} }
strcat(ph_name,name); strcat(ph_name,name);
grp=H5Gopen(pFile->iFID,ph_name); grp=H5Gopen(pFile->iFID,ph_name);
if (grp < 0) {
sprintf (pBuffer, "ERROR: Group %s does not exist!", ph_name);
NXIReportError (NXpData, pBuffer);
return NX_ERROR;
}
attr1 = H5Aopen_name(grp, "NX_class"); attr1 = H5Aopen_name(grp, "NX_class");
if (attr1 < 0) {
H5Gclose(grp);
NXIReportError (NXpData, "Error opening group class");
return NX_ERROR;
}
type=H5T_C_S1; type=H5T_C_S1;
atype=H5Tcopy(type); atype=H5Tcopy(type);
H5Tset_size(atype,128); H5Tset_size(atype,128);
@ -1385,7 +1427,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getdata (NXhandle fid, void *data) NXstatus NX5getdata (NXhandle fid, void *data)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int iStart[H5S_MAX_RANK], status; int iStart[H5S_MAX_RANK], status;
@ -1468,7 +1510,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getinfo (NXhandle fid, int *rank, int dimension[], int *iType) NXstatus NX5getinfo (NXhandle fid, int *rank, int dimension[], int *iType)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int i, iRank, mType, iRet; int i, iRank, mType, iRet;
@ -1551,7 +1593,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXstatus NX5getslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
hssize_t myStart[H5S_MAX_RANK]; hssize_t myStart[H5S_MAX_RANK];
@ -1686,7 +1728,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
return 1; return 1;
} }
NXstatus CALLING_STYLE NX5getnextattr (NXhandle fileid, NXname pName, NXstatus NX5getnextattr (NXhandle fileid, NXname pName,
int *iLength, int *iType) int *iLength, int *iType)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -1717,7 +1759,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
NXIReportError (NXpData, "ERROR iterating through ROOT Attr. list!"); NXIReportError (NXpData, "ERROR iterating through ROOT Attr. list!");
return NX_ERROR; return NX_ERROR;
} }
} else { } else if (pFile->iCurrentD > 0) {
intern_idx=H5Aget_num_attrs(pFile->iCurrentD); intern_idx=H5Aget_num_attrs(pFile->iCurrentD);
if (intern_idx > idx) { if (intern_idx > idx) {
iRet=H5Aiterate(pFile->iCurrentD,&idx,attr_info,&iname); iRet=H5Aiterate(pFile->iCurrentD,&idx,attr_info,&iname);
@ -1728,10 +1770,15 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
} }
intern_idx=-1; intern_idx=-1;
if (iRet < 0) { if (iRet < 0) {
NXIReportError (NXpData, "ERROR iterating through Attr. list!"); NXIReportError (NXpData, "ERROR iterating through data Attr. list!");
return NX_ERROR; return NX_ERROR;
} }
} }
else
{
pFile->iAtt5.iCurrentIDX = 0;
return NX_EOD; /* no group attributes */
}
if (iRet>0) if (iRet>0)
{ {
pFile->iAtt5.iCurrentIDX++; pFile->iAtt5.iCurrentIDX++;
@ -1836,7 +1883,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getattr (NXhandle fid, char *name, void *data, int* datalen, int* iType) NXstatus NX5getattr (NXhandle fid, char *name, void *data, int* datalen, int* iType)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int iNew, iRet; int iNew, iRet;
@ -1938,7 +1985,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getattrinfo (NXhandle fid, int *iN) NXstatus NX5getattrinfo (NXhandle fid, int *iN)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
char *iname = NULL; char *iname = NULL;
@ -2000,7 +2047,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5getgroupID (NXhandle fileid, NXlink* sRes) NXstatus NX5getgroupID (NXhandle fileid, NXlink* sRes)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
int u; int u;
@ -2017,6 +2064,11 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
strcpy(sRes->iTag5,"/"); strcpy(sRes->iTag5,"/");
strcat(sRes->iTag5, pFile->iCurrentLGG); strcat(sRes->iTag5, pFile->iCurrentLGG);
strcpy(sRes->iRefd,""); strcpy(sRes->iRefd,"");
/*
TODO: once we have group attributes, this should be set to
the groups target attribute
*/
strcpy(sRes->targetPath, sRes->iTag5);
return NX_OK; return NX_OK;
} }
/* not reached */ /* not reached */
@ -2025,14 +2077,12 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
NXstatus CALLING_STYLE NX5sameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID) NXstatus NX5sameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
pFile = NXI5assert (fileid); pFile = NXI5assert (fileid);
if ((strcmp(pFirstID->iTag5,pSecondID->iTag5) == 0) & if ((strcmp(pFirstID->targetPath,pSecondID->targetPath) == 0)){
(strcmp(pFirstID->iRef5,pSecondID->iRef5) == 0) &
(strcmp(pFirstID->iRefd,pSecondID->iRefd) == 0)) {
return NX_OK; return NX_OK;
} else { } else {
return NX_ERROR; return NX_ERROR;
@ -2041,7 +2091,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5initattrdir (NXhandle fid) NXstatus NX5initattrdir (NXhandle fid)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -2052,7 +2102,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NX5initgroupdir (NXhandle fid) NXstatus NX5initgroupdir (NXhandle fid)
{ {
pNexusFile5 pFile; pNexusFile5 pFile;
@ -2091,5 +2141,5 @@ void NX5assignFunctions(pNexusFunction fHandle)
fHandle->nxsameID=NX5sameID; fHandle->nxsameID=NX5sameID;
fHandle->nxinitgroupdir=NX5initgroupdir; fHandle->nxinitgroupdir=NX5initgroupdir;
fHandle->nxinitattrdir=NX5initattrdir; fHandle->nxinitattrdir=NX5initattrdir;
fHandle->nxprintlink=NX5printlink;
} }

55
napi5.h
View File

@ -4,40 +4,41 @@
/* HDF5 interface */ /* HDF5 interface */
NX_EXTERNAL NXstatus CALLING_STYLE NX5open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle); extern NXstatus NX5open(CONSTCHAR *filename, NXaccess access_method, NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5close(NXhandle* pHandle); extern NXstatus NX5close(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5flush(NXhandle* pHandle); extern NXstatus NX5flush(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5makegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); extern NXstatus NX5makegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX5opengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); extern NXstatus NX5opengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX5closegroup(NXhandle handle); extern NXstatus NX5closegroup(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5makedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); extern NXstatus NX5makedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX5compmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); extern NXstatus NX5compmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX5compress (NXhandle handle, int compr_type); extern NXstatus NX5compress (NXhandle handle, int compr_type);
NX_EXTERNAL NXstatus CALLING_STYLE NX5opendata (NXhandle handle, CONSTCHAR* label); extern NXstatus NX5opendata (NXhandle handle, CONSTCHAR* label);
NX_EXTERNAL NXstatus CALLING_STYLE NX5closedata(NXhandle handle); extern NXstatus NX5closedata(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5putdata(NXhandle handle, void* data); extern NXstatus NX5putdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NX5putattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); extern NXstatus NX5putattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType);
NX_EXTERNAL NXstatus CALLING_STYLE NX5putslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NX5putslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getdataID(NXhandle handle, NXlink* pLink); extern NXstatus NX5getdataID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX5makelink(NXhandle handle, NXlink* pLink); extern NXstatus NX5makelink(NXhandle handle, NXlink* pLink);
extern NXstatus NX5printlink(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getdata(NXhandle handle, void* data); extern NXstatus NX5getdata(NXhandle handle, void* data);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getinfo(NXhandle handle, int* rank, int dimension[], int* datatype); extern NXstatus NX5getinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype); extern NXstatus NX5getnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getslab(NXhandle handle, void* data, int start[], int size[]); extern NXstatus NX5getslab(NXhandle handle, void* data, int start[], int size[]);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); extern NXstatus NX5getnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType); extern NXstatus NX5getattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getattrinfo(NXhandle handle, int* no_items); extern NXstatus NX5getattrinfo(NXhandle handle, int* no_items);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getgroupID(NXhandle handle, NXlink* pLink); extern NXstatus NX5getgroupID(NXhandle handle, NXlink* pLink);
NX_EXTERNAL NXstatus CALLING_STYLE NX5getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass); extern NXstatus NX5getgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
NX_EXTERNAL NXstatus CALLING_STYLE NX5initgroupdir(NXhandle handle); extern NXstatus NX5initgroupdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NX5initattrdir(NXhandle handle); extern NXstatus NX5initattrdir(NXhandle handle);
void NX5assignFunctions(pNexusFunction fHandle); void NX5assignFunctions(pNexusFunction fHandle);

2
nxio.c
View File

@ -514,7 +514,7 @@ int isDataNode(mxml_node_t *node){
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int isTextData(mxml_node_t *node){ static int isTextData(mxml_node_t *node){
const char *attr = NULL; const char *attr = NULL;
int rank, type, iDim[NX_MAXRANK]; int rank, type = 0, iDim[NX_MAXRANK];
if(!isDataNode(node)){ if(!isDataNode(node)){
return 0; return 0;

76
nxxml.c
View File

@ -92,7 +92,7 @@ static void errorCallbackForMxml(const char *txt){
NXIReportError(NXpData,(char *)txt); NXIReportError(NXpData,(char *)txt);
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXopen(CONSTCHAR *filename, NXaccess am, NXstatus NXXopen(CONSTCHAR *filename, NXaccess am,
NXhandle* pHandle) { NXhandle* pHandle) {
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
FILE *fp = NULL; FILE *fp = NULL;
@ -171,7 +171,7 @@ NXstatus CALLING_STYLE NXXopen(CONSTCHAR *filename, NXaccess am,
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXclose (NXhandle* fid){ NXstatus NXXclose (NXhandle* fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
FILE *fp = NULL; FILE *fp = NULL;
@ -193,7 +193,7 @@ NXstatus CALLING_STYLE NXXclose (NXhandle* fid){
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXflush(NXhandle *fid){ NXstatus NXXflush(NXhandle *fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
FILE *fp = NULL; FILE *fp = NULL;
@ -214,7 +214,7 @@ NXstatus CALLING_STYLE NXXflush(NXhandle *fid){
/*======================================================================= /*=======================================================================
Group functions Group functions
=========================================================================*/ =========================================================================*/
NXstatus CALLING_STYLE NXXmakegroup (NXhandle fid, CONSTCHAR *name, NXstatus NXXmakegroup (NXhandle fid, CONSTCHAR *name,
CONSTCHAR *nxclass){ CONSTCHAR *nxclass){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *newGroup = NULL; mxml_node_t *newGroup = NULL;
@ -261,7 +261,7 @@ static mxml_node_t *searchGroupLinks(pXMLNexus xmlHandle, CONSTCHAR *name,
return NULL; return NULL;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXopengroup (NXhandle fid, CONSTCHAR *name, NXstatus NXXopengroup (NXhandle fid, CONSTCHAR *name,
CONSTCHAR *nxclass){ CONSTCHAR *nxclass){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *newGroup = NULL; mxml_node_t *newGroup = NULL;
@ -295,7 +295,7 @@ NXstatus CALLING_STYLE NXXopengroup (NXhandle fid, CONSTCHAR *name,
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXclosegroup (NXhandle fid){ NXstatus NXXclosegroup (NXhandle fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *newGroup = NULL; mxml_node_t *newGroup = NULL;
char error[1024]; char error[1024];
@ -317,7 +317,7 @@ NXstatus CALLING_STYLE NXXclosegroup (NXhandle fid){
/*========================================================================= /*=========================================================================
dataset functions dataset functions
=========================================================================*/ =========================================================================*/
NXstatus CALLING_STYLE NXXcompmakedata (NXhandle fid, CONSTCHAR *name, NXstatus NXXcompmakedata (NXhandle fid, CONSTCHAR *name,
int datatype, int datatype,
int rank, int rank,
int dimensions[], int dimensions[],
@ -357,7 +357,7 @@ static char *buildTypeString(int datatype, int rank, int dimensions[]){
return typestring; return typestring;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXmakedata (NXhandle fid, NXstatus NXXmakedata (NXhandle fid,
CONSTCHAR *name, int datatype, CONSTCHAR *name, int datatype,
int rank, int dimensions[]){ int rank, int dimensions[]){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
@ -453,7 +453,7 @@ static int strtrimcr(char *szStr, char *szSet)
return(j - i); /* Return the difference between old and new length */ return(j - i); /* Return the difference between old and new length */
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXopendata (NXhandle fid, CONSTCHAR *name){ NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *dataNode = NULL; mxml_node_t *dataNode = NULL;
char error[1024]; char error[1024];
@ -492,7 +492,7 @@ NXstatus CALLING_STYLE NXXopendata (NXhandle fid, CONSTCHAR *name){
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXclosedata (NXhandle fid){ NXstatus NXXclosedata (NXhandle fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
xmlHandle = (pXMLNexus)fid; xmlHandle = (pXMLNexus)fid;
@ -518,7 +518,7 @@ static mxml_node_t *findData(mxml_node_t *node){
return NULL; return NULL;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXputdata (NXhandle fid, void *data){ NXstatus NXXputdata (NXhandle fid, void *data){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL; mxml_node_t *userData = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -550,7 +550,7 @@ NXstatus CALLING_STYLE NXXputdata (NXhandle fid, void *data){
return NX_OK; return NX_OK;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetdata (NXhandle fid, void *data){ NXstatus NXXgetdata (NXhandle fid, void *data){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL; mxml_node_t *userData = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -582,7 +582,7 @@ NXstatus CALLING_STYLE NXXgetdata (NXhandle fid, void *data){
return NX_OK; return NX_OK;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetinfo (NXhandle fid, int *rank, NXstatus NXXgetinfo (NXhandle fid, int *rank,
int dimension[], int *iType){ int dimension[], int *iType){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL; mxml_node_t *userData = NULL;
@ -671,7 +671,7 @@ static void putSlabData(pNXDS dataset, pNXDS slabData, int dim,
} }
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXputslab (NXhandle fid, void *data, NXstatus NXXputslab (NXhandle fid, void *data,
int iStart[], int iSize[]){ int iStart[], int iSize[]){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
@ -735,7 +735,7 @@ static void getSlabData(pNXDS dataset, pNXDS slabData, int dim,
} }
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetslab (NXhandle fid, void *data, NXstatus NXXgetslab (NXhandle fid, void *data,
int iStart[], int iSize[]){ int iStart[], int iSize[]){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL; mxml_node_t *userData = NULL;
@ -772,7 +772,7 @@ NXstatus CALLING_STYLE NXXgetslab (NXhandle fid, void *data,
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
static NXstatus CALLING_STYLE NXXsetnumberformat(NXhandle fid, static NXstatus NXXsetnumberformat(NXhandle fid,
int type, char *format){ int type, char *format){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -866,14 +866,14 @@ static char *formatAttributeData(void *data, int datalen, int iType){
break; break;
} }
if(intData){ if(intData){
snprintf(number,79,"%s%ld",type,iValue); snprintf(number,79,"%s%d",type,iValue);
} else { } else {
snprintf(number,79,"%s%f",type,dValue); snprintf(number,79,"%s%f",type,dValue);
} }
return number; return number;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXputattr (NXhandle fid, CONSTCHAR *name, void *data, NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
int datalen, int iType){ int datalen, int iType){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -909,7 +909,7 @@ NXstatus CALLING_STYLE NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
return NX_OK; return NX_OK;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetattr (NXhandle fid, char *name, NXstatus NXXgetattr (NXhandle fid, char *name,
void *data, int* datalen, int* iType){ void *data, int* datalen, int* iType){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -1006,7 +1006,7 @@ NXstatus CALLING_STYLE NXXgetattr (NXhandle fid, char *name,
return NX_OK; return NX_OK;
} }
/*====================== search functions =================================*/ /*====================== search functions =================================*/
NXstatus CALLING_STYLE NXXgetnextentry (NXhandle fid,NXname name, NXstatus NXXgetnextentry (NXhandle fid,NXname name,
NXname nxclass, int *datatype){ NXname nxclass, int *datatype){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *next = NULL, *userData; mxml_node_t *next = NULL, *userData;
@ -1020,11 +1020,8 @@ NXstatus CALLING_STYLE NXXgetnextentry (NXhandle fid,NXname name,
if(isDataNode(xmlHandle->stack[xmlHandle->stackPointer].current)){ if(isDataNode(xmlHandle->stack[xmlHandle->stackPointer].current)){
/* /*
be nice to users: close the open dataset even as this is be nice to user: silently fix this problem
a usage error
*/ */
NXIReportError(NXpData,
"WARNING: fixing bad NAPI usage: dataset still open");
NXXclosedata(fid); NXXclosedata(fid);
} }
@ -1084,7 +1081,7 @@ NXstatus CALLING_STYLE NXXgetnextentry (NXhandle fid,NXname name,
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NX_EXTERNAL NXstatus CALLING_STYLE NXXinitgroupdir(NXhandle fid){ extern NXstatus NXXinitgroupdir(NXhandle fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
int stackPtr; int stackPtr;
@ -1101,7 +1098,7 @@ NX_EXTERNAL NXstatus CALLING_STYLE NXXinitgroupdir(NXhandle fid){
return NX_OK; return NX_OK;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetnextattr (NXhandle fid, NXname pName, NXstatus NXXgetnextattr (NXhandle fid, NXname pName,
int *iLength, int *iType){ int *iLength, int *iType){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
@ -1157,7 +1154,7 @@ NXstatus CALLING_STYLE NXXgetnextattr (NXhandle fid, NXname pName,
return NX_OK; return NX_OK;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NX_EXTERNAL NXstatus CALLING_STYLE NXXinitattrdir(NXhandle fid){ extern NXstatus NXXinitattrdir(NXhandle fid){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
int stackPtr; int stackPtr;
@ -1180,7 +1177,7 @@ NX_EXTERNAL NXstatus CALLING_STYLE NXXinitattrdir(NXhandle fid){
return NX_OK; return NX_OK;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetgroupinfo (NXhandle fid, int *iN, NXstatus NXXgetgroupinfo (NXhandle fid, int *iN,
NXname pName, NXname pClass){ NXname pName, NXname pClass){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *child = NULL; mxml_node_t *child = NULL;
@ -1213,7 +1210,7 @@ NXstatus CALLING_STYLE NXXgetgroupinfo (NXhandle fid, int *iN,
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetattrinfo (NXhandle fid, int *iN){ NXstatus NXXgetattrinfo (NXhandle fid, int *iN){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
int stackPtr, currentAtt; int stackPtr, currentAtt;
@ -1328,7 +1325,7 @@ static char *findLinkPath(mxml_node_t *node){
return result; return result;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetdataID (NXhandle fid, NXlink* sRes){ NXstatus NXXgetdataID (NXhandle fid, NXlink* sRes){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
char *linkPath = NULL; char *linkPath = NULL;
@ -1351,7 +1348,7 @@ NXstatus CALLING_STYLE NXXgetdataID (NXhandle fid, NXlink* sRes){
return NX_OK; return NX_OK;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXgetgroupID (NXhandle fid, NXlink* sRes){ NXstatus NXXgetgroupID (NXhandle fid, NXlink* sRes){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL; mxml_node_t *current = NULL;
char *linkPath = NULL; char *linkPath = NULL;
@ -1378,8 +1375,20 @@ NXstatus CALLING_STYLE NXXgetgroupID (NXhandle fid, NXlink* sRes){
free(linkPath); free(linkPath);
return NX_OK; return NX_OK;
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXmakelink (NXhandle fid, NXlink* sLink){ NXstatus NXXprintlink (NXhandle fid, NXlink* sLink)
{
pXMLNexus xmlHandle = NULL;
xmlHandle = (pXMLNexus)fid;
assert(xmlHandle);
printf("XML link: target=\"%s\"\n", sLink->targetPath);
return NX_OK;
}
/*-----------------------------------------------------------------------*/
NXstatus NXXmakelink (NXhandle fid, NXlink* sLink){
pXMLNexus xmlHandle = NULL; pXMLNexus xmlHandle = NULL;
mxml_node_t *current = NULL, *linkNode = NULL; mxml_node_t *current = NULL, *linkNode = NULL;
mxml_node_t *linkedNode = NULL; mxml_node_t *linkedNode = NULL;
@ -1405,7 +1414,7 @@ NXstatus CALLING_STYLE NXXmakelink (NXhandle fid, NXlink* sLink){
return NX_OK; return NX_OK;
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
NXstatus CALLING_STYLE NXXsameID (NXhandle fileid, NXlink* pFirstID, NXstatus NXXsameID (NXhandle fileid, NXlink* pFirstID,
NXlink* pSecondID){ NXlink* pSecondID){
if(strcmp(pFirstID->targetPath,pSecondID->targetPath) == 0) { if(strcmp(pFirstID->targetPath,pSecondID->targetPath) == 0) {
return NX_OK; return NX_OK;
@ -1448,5 +1457,6 @@ void NXXassignFunctions(pNexusFunction fHandle){
fHandle->nxinitgroupdir=NXXinitgroupdir; fHandle->nxinitgroupdir=NXXinitgroupdir;
fHandle->nxinitattrdir=NXXinitattrdir; fHandle->nxinitattrdir=NXXinitattrdir;
fHandle->nxsetnumberformat=NXXsetnumberformat; fHandle->nxsetnumberformat=NXXsetnumberformat;
fHandle->nxprintlink=NXXprintlink;
} }

56
nxxml.h
View File

@ -22,55 +22,57 @@
#ifndef NEXUSXML #ifndef NEXUSXML
#define NEXUSXML #define NEXUSXML
NX_EXTERNAL NXstatus CALLING_STYLE NXXopen(CONSTCHAR *filename, extern NXstatus NXXopen(CONSTCHAR *filename,
NXaccess access_method, NXaccess access_method,
NXhandle* pHandle); NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NXXclose(NXhandle* pHandle); extern NXstatus NXXclose(NXhandle* pHandle);
NX_EXTERNAL NXstatus CALLING_STYLE NXXflush(NXhandle* pHandle); extern NXstatus NXXflush(NXhandle* pHandle);
NXstatus CALLING_STYLE NXXmakegroup (NXhandle fid, CONSTCHAR *name, NXstatus NXXmakegroup (NXhandle fid, CONSTCHAR *name,
CONSTCHAR *nxclass); CONSTCHAR *nxclass);
NXstatus CALLING_STYLE NXXopengroup (NXhandle fid, CONSTCHAR *name, NXstatus NXXopengroup (NXhandle fid, CONSTCHAR *name,
CONSTCHAR *nxclass); CONSTCHAR *nxclass);
NXstatus CALLING_STYLE NXXclosegroup (NXhandle fid); NXstatus NXXclosegroup (NXhandle fid);
NXstatus CALLING_STYLE NXXcompmakedata (NXhandle fid, CONSTCHAR *name, NXstatus NXXcompmakedata (NXhandle fid, CONSTCHAR *name,
int datatype, int datatype,
int rank, int rank,
int dimensions[], int dimensions[],
int compress_type, int chunk_size[]); int compress_type, int chunk_size[]);
NXstatus CALLING_STYLE NXXmakedata (NXhandle fid, NXstatus NXXmakedata (NXhandle fid,
CONSTCHAR *name, int datatype, CONSTCHAR *name, int datatype,
int rank, int dimensions[]); int rank, int dimensions[]);
NXstatus CALLING_STYLE NXXopendata (NXhandle fid, CONSTCHAR *name); NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name);
NXstatus CALLING_STYLE NXXclosedata (NXhandle fid); NXstatus NXXclosedata (NXhandle fid);
NXstatus CALLING_STYLE NXXputdata (NXhandle fid, void *data); NXstatus NXXputdata (NXhandle fid, void *data);
NXstatus CALLING_STYLE NXXgetdata (NXhandle fid, void *data); NXstatus NXXgetdata (NXhandle fid, void *data);
NXstatus CALLING_STYLE NXXgetinfo (NXhandle fid, int *rank, NXstatus NXXgetinfo (NXhandle fid, int *rank,
int dimension[], int *iType); int dimension[], int *iType);
NXstatus CALLING_STYLE NXXputslab (NXhandle fid, void *data, NXstatus NXXputslab (NXhandle fid, void *data,
int iStart[], int iSize[]); int iStart[], int iSize[]);
NXstatus CALLING_STYLE NXXgetslab (NXhandle fid, void *data, NXstatus NXXgetslab (NXhandle fid, void *data,
int iStart[], int iSize[]); int iStart[], int iSize[]);
NXstatus CALLING_STYLE NXXputattr (NXhandle fid, CONSTCHAR *name, void *data, NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
int datalen, int iType); int datalen, int iType);
NXstatus CALLING_STYLE NXXgetattr (NXhandle fid, char *name, NXstatus NXXgetattr (NXhandle fid, char *name,
void *data, int* datalen, int* iType); void *data, int* datalen, int* iType);
NXstatus CALLING_STYLE NXXgetnextentry (NXhandle fid,NXname name, NXstatus NXXgetnextentry (NXhandle fid,NXname name,
NXname nxclass, int *datatype); NXname nxclass, int *datatype);
NX_EXTERNAL NXstatus CALLING_STYLE NXXgetnextattr(NXhandle handle, extern NXstatus NXXgetnextattr(NXhandle handle,
NXname pName, int *iLength, int *iType); NXname pName, int *iLength, int *iType);
NX_EXTERNAL NXstatus CALLING_STYLE NXXinitgroupdir(NXhandle handle); extern NXstatus NXXinitgroupdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXXinitattrdir(NXhandle handle); extern NXstatus NXXinitattrdir(NXhandle handle);
NX_EXTERNAL NXstatus CALLING_STYLE NXXgetattrinfo (NXhandle fid, int *iN); extern NXstatus NXXgetattrinfo (NXhandle fid, int *iN);
NX_EXTERNAL NXstatus CALLING_STYLE NXXgetgroupinfo (NXhandle fid, int *iN, extern NXstatus NXXgetgroupinfo (NXhandle fid, int *iN,
NXname pName, NXname pClass); NXname pName, NXname pClass);
NX_EXTERNAL NXstatus CALLING_STYLE NXXgetdataID (NXhandle fid, NXlink* sRes); extern NXstatus NXXgetdataID (NXhandle fid, NXlink* sRes);
NX_EXTERNAL NXstatus CALLING_STYLE NXXgetgroupID (NXhandle fid, NXlink* sRes); extern NXstatus NXXgetgroupID (NXhandle fid, NXlink* sRes);
NX_EXTERNAL NXstatus CALLING_STYLE NXXmakelink (NXhandle fid, NXlink* sLink); extern NXstatus NXXmakelink (NXhandle fid, NXlink* sLink);
NX_EXTERNAL NXstatus CALLING_STYLE NXXsameID (NXhandle fileid, extern NXstatus NXXprintlink (NXhandle fid, NXlink* sLink);
extern NXstatus NXXsameID (NXhandle fileid,
NXlink* pFirstID, NXlink* pSecondID); NXlink* pFirstID, NXlink* pSecondID);
void NXXassignFunctions(pNexusFunction fHandle); void NXXassignFunctions(pNexusFunction fHandle);
#endif #endif

View File

@ -1,7 +1,5 @@
# Counter counter # Counter counter
counter SetPreset 500.000000 counter SetPreset 10.000000
counter SetMode Timer counter SetMode Timer
hm CountMode timer hm CountMode timer
hm preset 600.000000 hm preset 10.000000
hm genbin 1000.000000 1000.000000 1000
hm init