From 061b09b138a5b9781ef15fec2d376dfe3fab0d1c Mon Sep 17 00:00:00 2001 From: koennecke Date: Thu, 3 Jan 2008 10:13:10 +0000 Subject: [PATCH] - Added missing files for new NAPI --- napiconfig.h | 22 ++++++++++++ nxstack.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ nxstack.h | 43 ++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100755 napiconfig.h create mode 100644 nxstack.c create mode 100755 nxstack.h diff --git a/napiconfig.h b/napiconfig.h new file mode 100755 index 00000000..5b238331 --- /dev/null +++ b/napiconfig.h @@ -0,0 +1,22 @@ +#ifndef NAPICONFIG_H +#define NAPICONFIG_H + +#include + +/* + * Type definitions + */ +#ifdef HAVE_STDINT_H +#include +#else +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long uint64_t; + +#endif /* HAVE_STDINT_H */ +#endif /* NAPICONFIG_H */ diff --git a/nxstack.c b/nxstack.c new file mode 100644 index 00000000..bd2f492c --- /dev/null +++ b/nxstack.c @@ -0,0 +1,100 @@ +/* + This is some code to handle a stack of NeXus files. This is used to implement + external linking within the NeXus-API + + Copyright (C) 1997-2006 Mark Koennecke + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information, see +*/ +#include +#include +#include +#include "nxstack.h" + +/*----------------------------------------------------------------------- + Data definitions +---------------------------------------------------------------------*/ + +typedef struct { + pNexusFunction pDriver; + NXlink closeID; + char filename[1024]; +}fileStackEntry; + + +typedef struct __fileStack { + int fileStackPointer; + fileStackEntry fileStack[MAXEXTERNALDEPTH]; +}fileStack; +/*---------------------------------------------------------------------*/ +pFileStack makeFileStack(){ + pFileStack pNew = NULL; + + pNew = malloc(sizeof(fileStack)); + if(pNew == NULL){ + return NULL; + } + memset(pNew,0,sizeof(fileStack)); + pNew->fileStackPointer = -1; + return pNew; +} +/*---------------------------------------------------------------------*/ +void killFileStack(pFileStack self){ + if(self != NULL){ + free(self); + } +} +/*----------------------------------------------------------------------*/ +void pushFileStack(pFileStack self, pNexusFunction pDriv, char *file){ + int length; + + self->fileStackPointer++; + self->fileStack[self->fileStackPointer].pDriver = pDriv; + memset(&self->fileStack[self->fileStackPointer].closeID,0,sizeof(NXlink)); + length = strlen(file); + if(length >= 1024){ + length = 1023; + } + memcpy(&self->fileStack[self->fileStackPointer].filename,file,length); +} +/*----------------------------------------------------------------------*/ +void popFileStack(pFileStack self){ + self->fileStackPointer--; + if(self->fileStackPointer < -1){ + self->fileStackPointer = -1; + } +} +/*----------------------------------------------------------------------*/ +pNexusFunction peekFileOnStack(pFileStack self){ + return self->fileStack[self->fileStackPointer].pDriver; +} +/*---------------------------------------------------------------------*/ +char *peekFilenameOnStack(pFileStack self){ + return self->fileStack[self->fileStackPointer].filename; +} +/*----------------------------------------------------------------------*/ +void peekIDOnStack(pFileStack self, NXlink *id){ + memcpy(id, &self->fileStack[self->fileStackPointer].closeID, sizeof(NXlink)); +} +/*---------------------------------------------------------------------*/ +void setCloseID(pFileStack self, NXlink id){ + memcpy(&self->fileStack[self->fileStackPointer].closeID, &id, sizeof(NXlink)); +} +/*----------------------------------------------------------------------*/ +int fileStackDepth(pFileStack self){ + return self->fileStackPointer; +} diff --git a/nxstack.h b/nxstack.h new file mode 100755 index 00000000..e7a9568b --- /dev/null +++ b/nxstack.h @@ -0,0 +1,43 @@ +/* + This is some code to handle a stack of NeXus files. This is used to implement + external linking within the NeXus-API + + Copyright (C) 1997-2006 Mark Koennecke + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information, see +*/ +#ifndef NEXUSFILESTACK +#define NEXUSFILESTACK + +typedef struct __fileStack *pFileStack; +#define MAXEXTERNALDEPTH 16 + +pFileStack makeFileStack(); +void killFileStack(pFileStack self); + +void pushFileStack(pFileStack self, pNexusFunction pDriv, char *filename); +void popFileStack(pFileStack self); + +pNexusFunction peekFileOnStack(pFileStack self); +char *peekFilenameOnStack(pFileStack self); +void peekIDOnStack(pFileStack self, NXlink *id); +void setCloseID(pFileStack self, NXlink id); + +int fileStackDepth(pFileStack self); + +#endif +