Cleaned up Makefiles after port to Linux, updated nxdict and napi

This commit is contained in:
cvs
2000-02-21 08:11:15 +00:00
parent cbc7fdf334
commit 9a7084ed23
11 changed files with 423 additions and 130 deletions

View File

@ -5,19 +5,20 @@
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
BINTARGET=$(HOME)/bin/sics BINTARGET=$(HOME)/bin/sics
#------- comment and uncommanet this if a fortified version is required.
# A -DFORTIFY needs to be added to the CFLAGS as well.
#FORTIFYOBJ = fortify.o strdup.o #FORTIFYOBJ = fortify.o strdup.o
FORTIFYOBJ = FORTIFYOBJ =
#CC=cc
CC=gcc
TCLOBJ=initcl.o TCLOBJ=initcl.o
#TCLOBJ=init8.o #TCLOBJ=init8.o
#comment and uncomment according if a difrac version is required #----- comment and uncomment according if a difrac version is required
#DIFOBJ= #DIFOBJ=
#DIFIL= #DIFIL=
#DIFOBJ=difrac.o -Ldifrac -ldif -lfor #DIFOBJ=difrac.o -Ldifrac -ldif -lfor
#----
#---- for Linux
DIFOBJ=difrac.o -Ldifrac -ldif DIFOBJ=difrac.o -Ldifrac -ldif
DIFIL= difrac.o DIFIL= difrac.o
@ -48,24 +49,31 @@ VELOOBJ = velo.o velosim.o velodorn.o velodornier.o
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .tcl .htm .c .o .SUFFIXES: .tcl .htm .c .o
#------------- for Digital Unix
HDFROOT=/data/koenneck
CC=cc
EXTRA=
CFLAGS = -I$(HDFROOT)/include -Ihardsup -std1 -g -warnprotos -c
#CFLAGS = -I$(HDFROOT)/include -DFORTIFY -Ihardsup -g -std1 -warnprotos -c
LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -ltcl7.6 -lfor -lmfhdf -ldf \
$(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc
#CFLAGS = -I/data/koenneck/include -Ihardsup -std1 -g -warnprotos -c #------- for cygnus
#CFLAGS = -I/data/koenneck/include -DFORTIFY -Ihardsup -g -std1 -warnprotos -c #HDFROOT=../HDF411
#CFLAGS = -I/data/koenneck/include -Ihardsup -std1 -warnprotos -c #CC=gcc
#LIBS = -L/data/koenneck/lib -Lhardsup -lhlib -ltcl7.6 -lmfhdf -ldf \ #EXTRA=
# /data/koenneck/lib/libjpeg.a -lz -lm -ll -lc #CFLAGS = -I$(HDFROOT)/include -Ihardsup -DFORTIFY -DCYGNUS -g -c
#LIBS= -L$(HDFROOT)/lib -Lhardsup -lhlib -ltcl80 \
# for cygnus
#CFLAGS = -I../HDF411/include -Ihardsup -DFORTIFY -DCYGNUS -g -c
#LIBS= -L../HDF411/lib -Lhardsup -lhlib -ltcl80 \
# -lmfhdf -ldf -ljpeg -lz -lm # -lmfhdf -ldf -ljpeg -lz -lm
# for linux #---------- for linux
CFLAGS = -I/usr/local/include -Ihardsup -fwritable-strings -DCYGNUS -g -c #HDFROOT=/usr/local
LIBS= -L/usr/local/lib -Lhardsup -L /home/koenneck/tcl76/lib -lhlib -ltcl7.6 \ #TCLROOT=/home/koenneck/tcl76
-lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl #CC=gcc
#EXTRA= #CFLAGS = -I$(HDFROOT)/include -Ihardsup -fwritable-strings -DCYGNUS -g -c
EXTRA=nintf.o #LIBS= -L$(HDFROOT)/lib -Lhardsup -L$(TCLROOT)/lib -lhlib \
# -ltcl7.6 -lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl
#EXTRA=nintf.o
.c.o: .c.o:

View File

@ -1,3 +1,3 @@
50 537199956
NEVER, EVER modify or delete this file NEVER, EVER modify or delete this file
You'll risk eternal damnation and a reincarnation as a cockroach!|n You'll risk eternal damnation and a reincarnation as a cockroach!|n

View File

@ -3,21 +3,25 @@
# #
# Mark Koennecke, November 1996 # Mark Koennecke, November 1996
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
#CC=cc
CC= gcc
OBJ= el734_utility.o asynsrv_utility.o stredit.o \ OBJ= el734_utility.o asynsrv_utility.o stredit.o \
strjoin.o geterrno.o el737_utility.o sinqhm.o serialsinq.o \ strjoin.o geterrno.o el737_utility.o sinqhm.o serialsinq.o \
itc4util.o dillutil.o table.o el755_utility.o el755_errorlog.o \ itc4util.o dillutil.o table.o el755_utility.o el755_errorlog.o \
makeprint.o makeprint.o
#---------- for Redhat linux #---------- for Redhat linux
CFLAGS= -I/usr/local/include -I. -I../ -DLINUX -g -c #CC= gcc
#CFLAGS= -I/usr/local/include -I. -I../ -DLINUX -g -c
#------------ for DigitalUnix #------------ for DigitalUnix
#CFLAGS= -I/data/koenneck/include -I. -I../ -std1 -g -c CC=cc
CFLAGS= -I/data/koenneck/include -I. -I../ -std1 -g -c
#------------ for DigitalUnix with Fortify #------------ for DigitalUnix with Fortify
#CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c #CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c
#------------ for CYGNUS toolchain on Win32 #------------ for CYGNUS toolchain on Win32
#CC=gcc
#CFLAGS= -I. -I../ -DCYGNUS -g -c #CFLAGS= -I. -I../ -DCYGNUS -g -c
.c.o: .c.o:
$(CC) $(CFLAGS) $*.c $(CC) $(CFLAGS) $*.c

282
napi.c
View File

@ -3,7 +3,7 @@
Application Program Interface Routines Application Program Interface Routines
Copyright (C) 1997, 1998, 1999 Mark Koennecke, Przemek Klosowski Copyright (C) 1997-2000 Mark Koennecke, Przemek Klosowski
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -35,7 +35,7 @@
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* Revision interted by CVS */ static const char* rscid = "$Id: napi.c,v 1.2 2000/02/21 08:11:15 cvs Exp $"; /* Revision interted by CVS */
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -397,6 +397,8 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
{ {
gmt_offset += 3600; gmt_offset += 3600;
} }
#elif defined(__MWERKS__)
gmt_offset = difftime (timer, mktime(gmtime(&timer)));
#else #else
gmt_offset = time_info->tm_gmtoff; gmt_offset = time_info->tm_gmtoff;
#endif #endif
@ -679,11 +681,6 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
return NX_OK; return NX_OK;
} }
NXstatus NXfcompress(NXhandle fid, int *compr_type)
{
return NXcompress(fid,*compr_type);
}
NXstatus NXfmakedata(NXhandle fid, char *name, int *pDatatype, NXstatus NXfmakedata(NXhandle fid, char *name, int *pDatatype,
int *pRank, int dimensions[]) int *pRank, int dimensions[])
{ {
@ -716,6 +713,7 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
int32 iNew; int32 iNew;
char pBuffer[256]; char pBuffer[256];
int i, iRet; int i, iRet;
int32 myDim[MAX_VAR_DIMS];
pFile = NXIassert (fid); pFile = NXIassert (fid);
@ -762,6 +760,13 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
} }
} }
/* cast the dimensions array properly for non 32-bit ints */
for(i = 0; i < rank; i++)
{
myDim[i] = (int32)dimensions[i];
}
/* behave nicely, if there is still an SDS open */ /* behave nicely, if there is still an SDS open */
if (pFile->iCurrentSDS != 0) { if (pFile->iCurrentSDS != 0) {
SDendaccess (pFile->iCurrentSDS); SDendaccess (pFile->iCurrentSDS);
@ -776,7 +781,8 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
} }
/* dataset creation */ /* dataset creation */
iNew = SDcreate (pFile->iSID, (char*)name, datatype, rank, (int32*)dimensions); iNew = SDcreate (pFile->iSID, (char*)name, (int32)datatype,
(int32)rank, myDim);
if (iNew < 0) { if (iNew < 0) {
sprintf (pBuffer, "ERROR: cannot create SDS %s, check arguments", sprintf (pBuffer, "ERROR: cannot create SDS %s, check arguments",
name); name);
@ -837,6 +843,55 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
} }
NXstatus NXfcompress(NXhandle fid, int *compr_type)
{
return NXcompress(fid,*compr_type);
}
NXstatus
NXcompress (NXhandle fid, int compress_type)
{
pNexusFile pFile;
int32 iRank, iAtt, iType, iRet, i, e;
int32 iSize[MAX_VAR_DIMS];
NXname pBuffer;
char pError[512];
comp_info compstruct;
char *str;
pFile = NXIassert (fid);
/* check if there is an SDS open */
if (pFile->iCurrentSDS == 0) {
NXIReportError (NXpData, "ERROR: no SDS open");
return NX_ERROR;
}
/* first read dimension information */
SDgetinfo (pFile->iCurrentSDS, pBuffer, &iRank, iSize, &iType, &iAtt);
/*
according to compression type initialize compression
information
*/
if(compress_type == NX_COMP_LZW)
{
compstruct.deflate.level = 6;
}
else if(compress_type == NX_COMP_HUF)
{
compstruct.skphuff.skp_size = DFKNTsize(iType);
}
iRet = SDsetcompress(pFile->iCurrentSDS, compress_type, &compstruct);
if (iRet < 0) {
sprintf (pError, "ERROR: failure to compress data to %s", pBuffer);
NXIReportError (NXpData, pError);
return NX_ERROR;
}
return NX_OK;
}
NXstatus NXstatus
NXclosedata (NXhandle fid) NXclosedata (NXhandle fid)
{ {
@ -889,6 +944,9 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
NXgetslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXgetslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile pFile; pNexusFile pFile;
int32 myStart[MAX_VAR_DIMS], mySize[MAX_VAR_DIMS];
int32 i, iRank, iType, iAtt;
NXname pBuffer;
pFile = NXIassert (fid); pFile = NXIassert (fid);
@ -897,10 +955,32 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
NXIReportError (NXpData, "ERROR: no SDS open"); NXIReportError (NXpData, "ERROR: no SDS open");
return NX_ERROR; return NX_ERROR;
} }
/* actually read */
SDreaddata (pFile->iCurrentSDS, (int32*)iStart, NULL, (int32*)iSize, data); /* if an int is not 32-bit we have to cast them properly in order
to kill a bug.
*/
if(sizeof(int) != 4)
{
SDgetinfo (pFile->iCurrentSDS, pBuffer,
&iRank, myStart, &iType, &iAtt);
for(i = 0; i < iRank; i++)
{
myStart[i] = (int32)iStart[i];
mySize[i] = (int32)iSize[i];
}
/* finally read */
SDreaddata (pFile->iCurrentSDS, myStart, NULL,
mySize, data);
return NX_OK; return NX_OK;
} }
else
{
/* read directly */
SDreaddata (pFile->iCurrentSDS, (int32*)iStart, NULL,
(int32*)iSize, data);
return NX_OK;
}
}
NXstatus NXstatus
@ -1007,57 +1087,15 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
return NX_OK; return NX_OK;
} }
NXstatus
NXcompress (NXhandle fid, int compress_type)
{
pNexusFile pFile;
int32 iRank, iAtt, iType, iRet, i, e;
int32 iSize[MAX_VAR_DIMS];
NXname pBuffer;
char pError[512];
comp_info compstruct;
char *str;
pFile = NXIassert (fid);
/* check if there is an SDS open */
if (pFile->iCurrentSDS == 0) {
NXIReportError (NXpData, "ERROR: no SDS open");
return NX_ERROR;
}
/* first read dimension information */
SDgetinfo (pFile->iCurrentSDS, pBuffer, &iRank, iSize, &iType, &iAtt);
/*
according to compression type initialize compression
information
*/
if(compress_type == NX_COMP_LZW)
{
compstruct.deflate.level = 6;
}
else if(compress_type == NX_COMP_HUF)
{
compstruct.skphuff.skp_size = DFKNTsize(iType);
}
iRet = SDsetcompress(pFile->iCurrentSDS, compress_type, &compstruct);
if (iRet < 0) {
sprintf (pError, "ERROR: failure to compress data to %s", pBuffer);
NXIReportError (NXpData, pError);
return NX_ERROR;
}
return NX_OK;
}
NXstatus NXstatus
NXputslab (NXhandle fid, void *data, int iStart[], int iSize[]) NXputslab (NXhandle fid, void *data, int iStart[], int iSize[])
{ {
pNexusFile pFile; pNexusFile pFile;
int iRet; int iRet;
int iStride[MAX_VAR_DIMS], i; int32 iStride[MAX_VAR_DIMS];
int32 myStart[MAX_VAR_DIMS], mySize[MAX_VAR_DIMS];
int32 i, iRank, iType, iAtt;
NXname pBuffer;
pFile = NXIassert (fid); pFile = NXIassert (fid);
@ -1072,9 +1110,31 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
iStride[i] = 1; iStride[i] = 1;
} }
/* actually write */ /* if an int is not 32-bit we have to cast them properly in order
iRet = SDwritedata (pFile->iCurrentSDS, (int32*)iStart, to kill a bug.
(int32*)iStride, (int32*)iSize, data); */
if(sizeof(int) != 4)
{
SDgetinfo (pFile->iCurrentSDS, pBuffer,
&iRank, myStart, &iType, &iAtt);
for(i = 0; i < iRank; i++)
{
myStart[i] = (int32)iStart[i];
mySize[i] = (int32)iSize[i];
}
/* finally write */
iRet = SDwritedata (pFile->iCurrentSDS, myStart,
iStride, mySize, data);
}
else
{
/* write directly */
iRet = SDwritedata (pFile->iCurrentSDS,iStart,
iStride, iSize, data);
}
/* deal with HDF errors */
if (iRet < 0) { if (iRet < 0) {
NXIReportError (NXpData, "ERROR: writing slab failed"); NXIReportError (NXpData, "ERROR: writing slab failed");
return NX_ERROR; return NX_ERROR;
@ -1098,12 +1158,12 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
if (pFile->iCurrentSDS != 0) { if (pFile->iCurrentSDS != 0) {
/* SDS attribute */ /* SDS attribute */
iRet = SDsetattr (pFile->iCurrentSDS, (char*)name, iType, iRet = SDsetattr (pFile->iCurrentSDS, (char*)name, (int32)iType,
datalen, data); (int32)datalen, data);
} else { } else {
/* global attribute */ /* global attribute */
iRet = SDsetattr (pFile->iSID, (char*)name, iType, iRet = SDsetattr (pFile->iSID, (char*)name, (int32)iType,
datalen, data); (int32)datalen, data);
} }
if (iRet < 0) { if (iRet < 0) {
@ -1119,7 +1179,7 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
{ {
pNexusFile pFile; pNexusFile pFile;
NXname pBuffer; NXname pBuffer;
int32 iAtt; int32 iAtt, myDim[MAX_VAR_DIMS], i, iRank, mType;
pFile = NXIassert (fid); pFile = NXIassert (fid);
@ -1129,13 +1189,85 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
return NX_ERROR; return NX_ERROR;
} }
/* read information */ /* read information */
SDgetinfo (pFile->iCurrentSDS, pBuffer, (int32*)rank, (int32*)dimension, SDgetinfo (pFile->iCurrentSDS, pBuffer, &iRank, myDim,
(int32*)iType, &iAtt); &mType, &iAtt);
/* conversion to proper ints for the platform */
*iType = (int)mType;
*rank = (int)iRank;
for(i = 0; i < iRank; i++)
{
dimension[i] = (int)myDim[i];
}
return NX_OK; return NX_OK;
} }
/*-------------------------------------------------------------------------*/
NXstatus
NXgetgroupinfo (NXhandle fid, int *iN, NXname pName, NXname pClass)
{
pNexusFile pFile;
int pFile = NXIassert (fid);
/* check if there is a group open */
if (pFile->iCurrentVG == 0) {
*iN = Vlone (pFile->iVID, NULL, 0);
strcpy (pName, "root");
strcpy (pClass, "NXroot");
}
else {
*iN = Vntagrefs (pFile->iCurrentVG);
Vgetname (pFile->iCurrentVG, pName);
Vgetclass (pFile->iCurrentVG, pClass);
}
return NX_OK;
}
/*-------------------------------------------------------------------------*/
NXstatus
NXgetattrinfo (NXhandle fid, int *iN)
{
pNexusFile pFile;
int iRet;
int32 iData, iAtt, iRank, iType;
int32 iDim[MAX_VAR_DIMS];
NXname pNam;
pFile = NXIassert (fid);
if (pFile->iCurrentSDS != 0) { /* SDS level */
iRet = SDgetinfo (pFile->iCurrentSDS, pNam, &iRank, iDim, &iType,
&iAtt);
} else { /* global level */
iRet = SDfileinfo (pFile->iSID, &iData, &iAtt);
}
if (iRet < 0) {
NXIReportError (NXpData, "NX_ERROR: HDF cannot read attribute numbers");
*iN = 0;
return NX_ERROR;
}
*iN = iAtt;
return iRet;
}
NXstatus
NXinitgroupdir (NXhandle fid)
{
pNexusFile pFile;
int iRet;
pFile = NXIassert (fid);
NXIKillDir (fid);
iRet = NXIInitDir (pFile);
if (iRet < 0) {
NXIReportError (NXpData,
"NX_ERROR: no memory to store directory info");
return NX_EOD;
}
return NX_OK;
}
/*-------------------------------------------------------------------------*/
NXstatus
NXgetnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype) NXgetnextentry (NXhandle fid, NXname name, NXname nxclass, int *datatype)
{ {
pNexusFile pFile; pNexusFile pFile;
@ -1214,6 +1346,20 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
return NX_ERROR; /* not reached */ return NX_ERROR; /* not reached */
} }
/*-------------------------------------------------------------------------*/
NXstatus
NXinitattrdir (NXhandle fid)
{
pNexusFile pFile;
int iRet;
pFile = NXIassert (fid);
NXIKillAttDir (fid);
iRet = NXIInitAttDir (pFile);
if (iRet == NX_ERROR)
return NX_ERROR;
return NX_OK;
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
NXstatus NXstatus
@ -1297,7 +1443,6 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
return NX_ERROR; /* not reached */ return NX_ERROR; /* not reached */
} }
NXstatus NXstatus
NXmakelink (NXhandle fid, NXlink* sLink) NXmakelink (NXhandle fid, NXlink* sLink)
{ {
@ -1371,3 +1516,4 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /*
*data = NULL; *data = NULL;
return NX_OK; return NX_OK;
} }

21
napi.h
View File

@ -3,7 +3,7 @@
NeXus API header file NeXus API header file
Copyright (C) 1997, 1998, 1999 Mark Koennecke, Przemek Klosowski Copyright (C) 1997-2000 Mark Koennecke, Przemek Klosowski
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -33,14 +33,14 @@
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.1 2000/02/07 10:38:56 cvs Exp $ $Id: napi.h,v 1.2 2000/02/21 08:11:15 cvs Exp $
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef NEXUSAPI #ifndef NEXUSAPI
#define NEXUSAPI #define NEXUSAPI
#define NEXUS_VERSION "1.3.0" /* major.minor.patch */ #define NEXUS_VERSION "1.3.1" /* major.minor.patch */
#ifdef GENIE_IMPLEMENTATION__ /* OpenGENIE is fussy about consts */ #ifdef GENIE_IMPLEMENTATION__ /* OpenGENIE is fussy about consts */
# define CONSTCHAR const char # define CONSTCHAR const char
@ -119,6 +119,7 @@ typedef char NXname[VGNAMELENMAX];
#define NX_CHAR DFNT_CHAR8 #define NX_CHAR DFNT_CHAR8
/* Map NeXus compression methods to HDF compression methods */ /* Map NeXus compression methods to HDF compression methods */
#define NX_COMP_NONE COMP_CODE_NONE
#define NX_COMP_LZW COMP_CODE_DEFLATE #define NX_COMP_LZW COMP_CODE_DEFLATE
#define NX_COMP_RLE COMP_CODE_RLE #define NX_COMP_RLE COMP_CODE_RLE
#define NX_COMP_HUF COMP_CODE_SKPHUFF #define NX_COMP_HUF COMP_CODE_SKPHUFF
@ -166,7 +167,11 @@ extern "C" {
# define NXputattr MANGLE(nxiputattr) # define NXputattr MANGLE(nxiputattr)
# define NXputdim MANGLE(nxiputdim) # define NXputdim MANGLE(nxiputdim)
# define NXgetinfo MANGLE(nxigetinfo) # define NXgetinfo MANGLE(nxigetinfo)
# define NXgetgroupinfo MANGLE(nxigetgroupinfo)
# define NXinitgroupdir MANGLE(nxiinitgroupdir)
# define NXgetnextentry MANGLE(nxigetnextentry) # define NXgetnextentry MANGLE(nxigetnextentry)
# define NXgetattrinfo MANGLE(nxigetattrinfo)
# define NXinitattrdir MANGLE(nxiinitattrdir)
# define NXgetnextattr MANGLE(nxigetnextattr) # define NXgetnextattr MANGLE(nxigetnextattr)
# define NXgetgroupID MANGLE(nxigetgroupid) # define NXgetgroupID MANGLE(nxigetgroupid)
# define NXgetdataID MANGLE(nxigetdataid) # define NXgetdataID MANGLE(nxigetdataid)
@ -177,7 +182,7 @@ extern "C" {
# define NXfopen MANGLE(nxifopen) # define NXfopen MANGLE(nxifopen)
# define NXfclose MANGLE(nxifclose) # define NXfclose MANGLE(nxifclose)
# define NXfmakedata MANGLE(nxifmakedata) # define NXfmakedata MANGLE(nxifmakedata)
# define NXfcompress MANGLE(nxfcompress) # define NXfcompress MANGLE(nxifcompress)
# define NXfputattr MANGLE(nxifputattr) # define NXfputattr MANGLE(nxifputattr)
#elif defined(_WIN32) #elif defined(_WIN32)
/* /*
@ -204,7 +209,11 @@ extern "C" {
# define NXputattr NXIPUTATTR_ # define NXputattr NXIPUTATTR_
# define NXputdim MANGLE(NXIPUTDIM) # define NXputdim MANGLE(NXIPUTDIM)
# define NXgetinfo MANGLE(NXIGETINFO) # define NXgetinfo MANGLE(NXIGETINFO)
# define NXgetgroupinfo MANGLE(NXIGETGROUPINFO)
# define NXinitgroupdir MANGLE(NXIINITGROUPDIR)
# define NXgetnextentry MANGLE(NXIGETNEXTENTRY) # define NXgetnextentry MANGLE(NXIGETNEXTENTRY)
# define NXgetattrinfo MANGLE(NXIGETATTRINFO)
# define NXinitattrdir MANGLE(NXIINITATTRDIR)
# define NXgetnextattr MANGLE(NXIGETNEXTATTR) # define NXgetnextattr MANGLE(NXIGETNEXTATTR)
# define NXgetgroupID MANGLE(NXIGETGROUPID) # define NXgetgroupID MANGLE(NXIGETGROUPID)
# define NXgetdataID MANGLE(NXIGETDATAID) # define NXgetdataID MANGLE(NXIGETDATAID)
@ -245,7 +254,11 @@ extern "C" {
NXstatus NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); NXstatus NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType);
NXstatus NXgetinfo(NXhandle handle, int* rank, int dimension[], int* datatype); NXstatus NXgetinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
NXstatus NXgetgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass);
NXstatus NXinitgroupdir(NXhandle handle);
NXstatus NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype); NXstatus NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype);
NXstatus NXgetattrinfo(NXhandle handle, int* no_items);
NXstatus NXinitattrdir(NXhandle handle);
NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType);
NXstatus NXgetgroupID(NXhandle handle, NXlink* pLink); NXstatus NXgetgroupID(NXhandle handle, NXlink* pLink);

147
nxdict.c
View File

@ -41,7 +41,7 @@
extern void *NXpData; extern void *NXpData;
extern void (*NXIReportError)(void *pData, char *pBuffer); extern void (*NXIReportError)(void *pData, char *pBuffer);
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#define DEFDEBUG 1 /*#define DEFDEBUG 1*/
/* define DEFDEBUG when you wish to print your definition strings before /* define DEFDEBUG when you wish to print your definition strings before
action. This can help a lot to resolve mysteries when working with action. This can help a lot to resolve mysteries when working with
dictionaries. dictionaries.
@ -665,10 +665,13 @@
#define DCLOSE 11 #define DCLOSE 11
#define DATTR 12 #define DATTR 12
#define DEND 13 #define DEND 13
#define DLZW 14
#define DHUF 15
#define DRLE 16
/*----------------- Keywords ----------------------------------------*/ /*----------------- Keywords ----------------------------------------*/
static TokDat TokenList[8] = { static TokDat TokenList[11] = {
{"SDS",DSDS}, {"SDS",DSDS},
{"NXLINK",DLINK}, {"NXLINK",DLINK},
{"NXVGROUP",DGROUP}, {"NXVGROUP",DGROUP},
@ -676,6 +679,9 @@
{"-type",DTYPE}, {"-type",DTYPE},
{"-rank",DRANK}, {"-rank",DRANK},
{"-attr",DATTR}, {"-attr",DATTR},
{"-LZW",DLZW},
{"-HUF",DHUF},
{"-RLE",DRLE},
{NULL,0} }; {NULL,0} };
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -744,7 +750,7 @@
sStat->pToken[i] = '\0'; sStat->pToken[i] = '\0';
/*--------- try to find word in Tokenlist */ /*--------- try to find word in Tokenlist */
for(i = 0; i < 7; i++) for(i = 0; i < 10; i++)
{ {
if(strcmp(sStat->pToken,TokenList[i].pText) == 0) if(strcmp(sStat->pToken,TokenList[i].pText) == 0)
{ {
@ -988,6 +994,7 @@
{"DFNT_UINT16",DFNT_UINT16}, {"DFNT_UINT16",DFNT_UINT16},
{"DFNT_INT32",DFNT_INT32}, {"DFNT_INT32",DFNT_INT32},
{"DFNT_UINT32",DFNT_UINT32}, {"DFNT_UINT32",DFNT_UINT32},
{"DFNT_CHAR",DFNT_CHAR},
{NULL,-122} }; {NULL,-122} };
@ -1033,6 +1040,7 @@
{ {
int iType = DFNT_FLOAT32; int iType = DFNT_FLOAT32;
int iRank = 1; int iRank = 1;
int iCompress = 0;
int32 iDim[MAX_VAR_DIMS]; int32 iDim[MAX_VAR_DIMS];
int iList; int iList;
int iRet, iStat; int iRet, iStat;
@ -1103,6 +1111,15 @@
return iRet; return iRet;
} }
break; break;
case DLZW:
iCompress = NX_COMP_LZW;
break;
case DRLE:
iCompress = NX_COMP_RLE;
break;
case DHUF:
iCompress = NX_COMP_HUF;
break;
case DEND: case DEND:
break; break;
default: default:
@ -1150,6 +1167,15 @@
LLDdelete(iList); LLDdelete(iList);
return iRet; return iRet;
} }
/* deal with compression, if appropriate */
if(iCompress != 0)
{
iRet = NXcompress(hfil,iCompress);
if(!iRet)
{
NXIReportError(NXpData,"Failed to compress data set");
}
}
/* put attributes in */ /* put attributes in */
iRet = LLDnodePtr2First(iList); iRet = LLDnodePtr2First(iList);
while(iRet != 0) while(iRet != 0)
@ -1221,7 +1247,7 @@
#line 1034 "nxdict.w" #line 1034 "nxdict.w"
static int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse) int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse)
{ {
int iRet; int iRet;
char pError[256]; char pError[256];
@ -1278,7 +1304,7 @@
#line 1576 "nxdict.w" #line 1576 "nxdict.w"
static NXstatus NXDIUnwind(NXhandle hFil, int iDepth) NXstatus NXDIUnwind(NXhandle hFil, int iDepth)
{ {
int i, iRet; int i, iRet;
@ -1514,6 +1540,9 @@
return iStat; return iStat;
} }
#line 2416 "nxdict.w" #line 2416 "nxdict.w"
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
@ -1553,8 +1582,95 @@
#line 2418 "nxdict.w" #line 2418 "nxdict.w"
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
int dimension[], int *iType)
{
NXdict pDict;
ParDat pParse;
int iRet, i, iStat;
pDict = NXDIAssert(dict);
/* parse and act on definition string */
pParse.iMayCreate = 0;
pParse.pPtr = pDef;
pParse.iDepth = 0;
#ifdef DEFDEBUG
printf("Getting: %s\n",pDef);
#endif
iRet = NXDIDefParse(hFil,pDict,&pParse);
if(iRet == NX_ERROR)
{
/* unwind and throw up */
NXDIUnwind(hFil,pParse.iDepth);
return NX_ERROR;
}
/* only SDS can be written */
if(pParse.iTerminal != TERMSDS)
{
NXIReportError(NXpData,
"ERROR: can only write to an SDS!");
iStat = NX_ERROR;
}
else
{
/* the SDS should be open by now, read it */
iStat = NXgetinfo(hFil, rank,dimension, iType);
iRet = NXclosedata(hFil);
}
/* rewind the hierarchy */
iRet = NXDIUnwind(hFil,pParse.iDepth);
if(iRet != NX_OK)
{
return NX_ERROR;
}
return iStat;
}
/*------------------------------------------------------------------------*/
NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
int dimension[], int *iType)
{
NXdict pDict;
int iRet;
char pDefinition[1024];
pDynString pReplaced = NULL;
pDict = NXDIAssert(dict);
/* get Definition String */
iRet = NXDget(pDict,pAlias,pDefinition,1023);
if(iRet != NX_OK)
{
sprintf(pDefinition,"ERROR: alias %s not recognized",pAlias);
NXIReportError(NXpData,pDefinition);
return NX_ERROR;
}
/* do text replacement */
pReplaced = NXDItextreplace(dict,pDefinition);
if(!pReplaced)
{
return NX_ERROR;
}
/* call NXDgetdef */
iRet = NXDinfodef(hFil,dict,GetCharArray(pReplaced),rank,dimension,iType);
DeleteDynString(pReplaced);
return iRet;
}
/*------------------------------------------------------------------------*/
#line 1849 "nxdict.w" #line 1849 "nxdict.w"
NXstatus NXDdeflink(NXhandle hFil, NXdict dict, NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
@ -1706,7 +1822,7 @@
iDate = time(NULL); iDate = time(NULL);
psTime = localtime(&iDate); psTime = localtime(&iDate);
memset(pBuffer,0,iBufLen); memset(pBuffer,0,iBufLen);
strftime(pBuffer,iBufLen,"%Y-%d-%m %H:%M:%S",psTime); strftime(pBuffer,iBufLen,"%Y-%m-%d %H:%M:%S",psTime);
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
NXstatus NXUwriteglobals(NXhandle pFile, NXstatus NXUwriteglobals(NXhandle pFile,
@ -1723,7 +1839,7 @@
/* store global attributes */ /* store global attributes */
iStat = NXputattr(pFile,"file_name",filename, iStat = NXputattr(pFile,"file_name",filename,
strlen(filename)+1,DFNT_INT8); strlen(filename)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return NX_ERROR; return NX_ERROR;
@ -1732,7 +1848,7 @@
/* write creation time */ /* write creation time */
SNXFormatTime(pBueffel,512); SNXFormatTime(pBueffel,512);
iStat = NXputattr(pFile,"file_time",pBueffel, iStat = NXputattr(pFile,"file_time",pBueffel,
strlen(pBueffel)+1,DFNT_INT8); strlen(pBueffel)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return NX_ERROR; return NX_ERROR;
@ -1740,7 +1856,7 @@
/* instrument name */ /* instrument name */
iStat = NXputattr(pFile,"instrument",instrument, iStat = NXputattr(pFile,"instrument",instrument,
strlen(instrument)+1,DFNT_INT8); strlen(instrument)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1748,7 +1864,7 @@
/* owner */ /* owner */
iStat = NXputattr(pFile,"owner",owner, iStat = NXputattr(pFile,"owner",owner,
strlen(owner)+1,DFNT_INT8); strlen(owner)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1756,7 +1872,7 @@
/* Adress */ /* Adress */
iStat = NXputattr(pFile,"owner_adress",adress, iStat = NXputattr(pFile,"owner_adress",adress,
strlen(adress)+1,DFNT_INT8); strlen(adress)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1764,7 +1880,7 @@
/* phone */ /* phone */
iStat = NXputattr(pFile,"owner_telephone_number",phone, iStat = NXputattr(pFile,"owner_telephone_number",phone,
strlen(phone)+1,DFNT_INT8); strlen(phone)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1772,7 +1888,7 @@
/* fax */ /* fax */
iStat = NXputattr(pFile,"owner_fax_number",fax, iStat = NXputattr(pFile,"owner_fax_number",fax,
strlen(fax)+1,DFNT_INT8); strlen(fax)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1780,7 +1896,7 @@
/* email */ /* email */
iStat = NXputattr(pFile,"owner_email",email, iStat = NXputattr(pFile,"owner_email",email,
strlen(email)+1,DFNT_INT8); strlen(email)+1,NX_CHAR);
if(iStat == NX_ERROR) if(iStat == NX_ERROR)
{ {
return iStat; return iStat;
@ -1913,6 +2029,8 @@
lLength *= sizeof(float64); lLength *= sizeof(float64);
break; break;
case DFNT_INT8: case DFNT_INT8:
case DFNT_CHAR:
case DFNT_UCHAR8:
lLength *= sizeof(int8); lLength *= sizeof(int8);
break; break;
case DFNT_UINT8: case DFNT_UINT8:
@ -1943,6 +2061,7 @@
NXIReportError(NXpData,"ERROR: memory exhausted in NXUallocSDS"); NXIReportError(NXpData,"ERROR: memory exhausted in NXUallocSDS");
return NX_ERROR; return NX_ERROR;
} }
memset(*pData,0,lLength);
return NX_OK; return NX_OK;
} }

View File

@ -49,6 +49,12 @@
char *alias, void *pData); char *alias, void *pData);
NXstatus NXDgetdef(NXhandle file, NXdict dict, char *pDefString, void *pData); NXstatus NXDgetdef(NXhandle file, NXdict dict, char *pDefString, void *pData);
NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
int dimension[], int *iType);
NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
int dimension[], int *iType);
NXstatus NXDaliaslink(NXhandle file, NXdict dict, NXstatus NXDaliaslink(NXhandle file, NXdict dict,
char *pAlias1, char *pAlias2); char *pAlias1, char *pAlias2);
NXstatus NXDdeflink(NXhandle file, NXdict dict, NXstatus NXDdeflink(NXhandle file, NXdict dict,

View File

@ -364,5 +364,5 @@ sample Bi2212 #1, th vs SGU=-12.5
sample setAccess 2 sample setAccess 2
title TopsiTupsiTapsi title TopsiTupsiTapsi
title setAccess 2 title setAccess 2
starttime 2000-02-18 16:40:55 starttime 2000-02-21 09:08:52
starttime setAccess 2 starttime setAccess 2

View File

@ -5,9 +5,9 @@
# Mark Koennecke, October 1997 # Mark Koennecke, October 1997
# Requires a sics scan command called xxxscan # Requires a sics scan command called xxxscan
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
set home /home/koenneck/sics/tcl set home /data/koenneck/src/sics/tcl
set datapath /home/koenneck/tmp set datapath /data/koenneck/src/tmp
set recoverfil /home/koenneck/tmp/recover.bin set recoverfil /data/koenneck/src/tmp/recover.bin
source $home/utils.tcl source $home/utils.tcl

View File

@ -10,10 +10,7 @@
rename scan stscan rename scan stscan
#-------- a home for this, everything else is in relation to this #-------- a home for this, everything else is in relation to this
set shome /home/koenneck set shome /data/koenneck/src
#set auto_path "/data/koenneck/src/sics/tcl"
#source $auto_path/tcl8/topsicom.tcl
# first all the server options are set # first all the server options are set