- Added missing files for new NAPI

This commit is contained in:
koennecke
2008-01-03 10:13:10 +00:00
parent 1f862889ce
commit 061b09b138
3 changed files with 165 additions and 0 deletions

22
napiconfig.h Executable file
View File

@ -0,0 +1,22 @@
#ifndef NAPICONFIG_H
#define NAPICONFIG_H
#include <nxconfig.h>
/*
* Type definitions
*/
#ifdef HAVE_STDINT_H
#include <stdint.h>
#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 */

100
nxstack.c Normal file
View File

@ -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 <http://www.neutron.anl.gov/NeXus/>
*/
#include <stdlib.h>
#include <string.h>
#include <napi.h>
#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;
}

43
nxstack.h Executable file
View File

@ -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 <http://www.neutron.anl.gov/NeXus/>
*/
#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