From 9a7084ed23536225a4ee1e3a50197c72ec30eeb8 Mon Sep 17 00:00:00 2001 From: cvs Date: Mon, 21 Feb 2000 08:11:15 +0000 Subject: [PATCH] Cleaned up Makefiles after port to Linux, updated nxdict and napi --- Makefile | 48 ++++---- danu.dat | 2 +- fowrite.c | 2 +- hardsup/Makefile | 12 +- napi.c | 294 +++++++++++++++++++++++++++++++++++------------ napi.h | 29 +++-- nxdict.c | 147 +++++++++++++++++++++--- nxdict.h | 6 + sicsstatus.tcl | 2 +- tcl/topsicom.tcl | 6 +- test.tcl | 5 +- 11 files changed, 423 insertions(+), 130 deletions(-) diff --git a/Makefile b/Makefile index 3f33c20e..55d23c64 100644 --- a/Makefile +++ b/Makefile @@ -5,19 +5,20 @@ #--------------------------------------------------------------------------- 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 = -#CC=cc -CC=gcc + TCLOBJ=initcl.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= #DIFIL= #DIFOBJ=difrac.o -Ldifrac -ldif -lfor - -#---- for Linux +#---- DIFOBJ=difrac.o -Ldifrac -ldif DIFIL= difrac.o @@ -48,24 +49,31 @@ VELOOBJ = velo.o velosim.o velodorn.o velodornier.o .SUFFIXES: .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 -#CFLAGS = -I/data/koenneck/include -DFORTIFY -Ihardsup -g -std1 -warnprotos -c -#CFLAGS = -I/data/koenneck/include -Ihardsup -std1 -warnprotos -c -#LIBS = -L/data/koenneck/lib -Lhardsup -lhlib -ltcl7.6 -lmfhdf -ldf \ -# /data/koenneck/lib/libjpeg.a -lz -lm -ll -lc - -# for cygnus -#CFLAGS = -I../HDF411/include -Ihardsup -DFORTIFY -DCYGNUS -g -c -#LIBS= -L../HDF411/lib -Lhardsup -lhlib -ltcl80 \ +#------- for cygnus +#HDFROOT=../HDF411 +#CC=gcc +#EXTRA= +#CFLAGS = -I$(HDFROOT)/include -Ihardsup -DFORTIFY -DCYGNUS -g -c +#LIBS= -L$(HDFROOT)/lib -Lhardsup -lhlib -ltcl80 \ # -lmfhdf -ldf -ljpeg -lz -lm -# for linux -CFLAGS = -I/usr/local/include -Ihardsup -fwritable-strings -DCYGNUS -g -c -LIBS= -L/usr/local/lib -Lhardsup -L /home/koenneck/tcl76/lib -lhlib -ltcl7.6 \ - -lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl -#EXTRA= -EXTRA=nintf.o +#---------- for linux +#HDFROOT=/usr/local +#TCLROOT=/home/koenneck/tcl76 +#CC=gcc +#CFLAGS = -I$(HDFROOT)/include -Ihardsup -fwritable-strings -DCYGNUS -g -c +#LIBS= -L$(HDFROOT)/lib -Lhardsup -L$(TCLROOT)/lib -lhlib \ +# -ltcl7.6 -lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl +#EXTRA=nintf.o .c.o: diff --git a/danu.dat b/danu.dat index b14580da..02815604 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 50 + 537199956 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/fowrite.c b/fowrite.c index 1cd51414..2b2f241b 100644 --- a/fowrite.c +++ b/fowrite.c @@ -34,7 +34,7 @@ pHistMem pHist; int iNew; time_t tUpdate; - int iInterval; + int iInterval; int iEnd; SConnection *pCon; char *pFile; diff --git a/hardsup/Makefile b/hardsup/Makefile index 83832343..b3d6b9e6 100644 --- a/hardsup/Makefile +++ b/hardsup/Makefile @@ -3,21 +3,25 @@ # # Mark Koennecke, November 1996 #-------------------------------------------------------------------------- -#CC=cc -CC= gcc OBJ= el734_utility.o asynsrv_utility.o stredit.o \ strjoin.o geterrno.o el737_utility.o sinqhm.o serialsinq.o \ itc4util.o dillutil.o table.o el755_utility.o el755_errorlog.o \ makeprint.o #---------- 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 -#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 #CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c + #------------ for CYGNUS toolchain on Win32 +#CC=gcc #CFLAGS= -I. -I../ -DCYGNUS -g -c + .c.o: $(CC) $(CFLAGS) $*.c diff --git a/napi.c b/napi.c index 9747699c..cf530a32 100644 --- a/napi.c +++ b/napi.c @@ -3,7 +3,7 @@ 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 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 #include @@ -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; } +#elif defined(__MWERKS__) + gmt_offset = difftime (timer, mktime(gmtime(&timer))); #else gmt_offset = time_info->tm_gmtoff; #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; } - NXstatus NXfcompress(NXhandle fid, int *compr_type) - { - return NXcompress(fid,*compr_type); - } - NXstatus NXfmakedata(NXhandle fid, char *name, int *pDatatype, int *pRank, int dimensions[]) { @@ -716,7 +713,8 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* int32 iNew; char pBuffer[256]; int i, iRet; - + int32 myDim[MAX_VAR_DIMS]; + pFile = NXIassert (fid); @@ -761,7 +759,14 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* return NX_ERROR; } } - + + /* 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 */ if (pFile->iCurrentSDS != 0) { 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 */ - iNew = SDcreate (pFile->iSID, (char*)name, datatype, rank, (int32*)dimensions); + iNew = SDcreate (pFile->iSID, (char*)name, (int32)datatype, + (int32)rank, myDim); if (iNew < 0) { sprintf (pBuffer, "ERROR: cannot create SDS %s, check arguments", 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 NXclosedata (NXhandle fid) { @@ -889,7 +944,10 @@ 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[]) { pNexusFile pFile; - + int32 myStart[MAX_VAR_DIMS], mySize[MAX_VAR_DIMS]; + int32 i, iRank, iType, iAtt; + NXname pBuffer; + pFile = NXIassert (fid); /* check if there is an SDS open */ @@ -897,9 +955,31 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* NXIReportError (NXpData, "ERROR: no SDS open"); return NX_ERROR; } - /* actually read */ - SDreaddata (pFile->iCurrentSDS, (int32*)iStart, NULL, (int32*)iSize, data); - return NX_OK; + + /* 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; + } + else + { + /* read directly */ + SDreaddata (pFile->iCurrentSDS, (int32*)iStart, NULL, + (int32*)iSize, data); + return NX_OK; + } } @@ -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; } - 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 NXputslab (NXhandle fid, void *data, int iStart[], int iSize[]) { pNexusFile pFile; 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); @@ -1071,10 +1109,32 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* for (i = 0; i < MAX_VAR_DIMS; i++) { iStride[i] = 1; } - - /* actually write */ - iRet = SDwritedata (pFile->iCurrentSDS, (int32*)iStart, - (int32*)iStride, (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 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) { NXIReportError (NXpData, "ERROR: writing slab failed"); 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) { /* SDS attribute */ - iRet = SDsetattr (pFile->iCurrentSDS, (char*)name, iType, - datalen, data); + iRet = SDsetattr (pFile->iCurrentSDS, (char*)name, (int32)iType, + (int32)datalen, data); } else { /* global attribute */ - iRet = SDsetattr (pFile->iSID, (char*)name, iType, - datalen, data); + iRet = SDsetattr (pFile->iSID, (char*)name, (int32)iType, + (int32)datalen, data); } 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; NXname pBuffer; - int32 iAtt; + int32 iAtt, myDim[MAX_VAR_DIMS], i, iRank, mType; 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; } /* read information */ - SDgetinfo (pFile->iCurrentSDS, pBuffer, (int32*)rank, (int32*)dimension, - (int32*)iType, &iAtt); + SDgetinfo (pFile->iCurrentSDS, pBuffer, &iRank, myDim, + &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; } + /*-------------------------------------------------------------------------*/ + 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) { pNexusFile pFile; @@ -1206,7 +1338,7 @@ static const char* rscid = "$Id: napi.c,v 1.1 2000/02/07 10:38:56 cvs Exp $"; /* } else { /* unidentified */ strcpy (name, "UNKNOWN"); strcpy (nxclass, "UNKNOWN"); - *datatype = pFile->iStack[iStackPtr].iTagDir[iCurDir]; + *datatype = pFile->iStack[iStackPtr].iTagDir[iCurDir]; pFile->iStack[pFile->iStackPtr].iCurDir++; return NX_OK; } @@ -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 */ } + /*-------------------------------------------------------------------------*/ + 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 @@ -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 */ } - NXstatus 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; return NX_OK; } + diff --git a/napi.h b/napi.h index e9457603..e4f1bca9 100644 --- a/napi.h +++ b/napi.h @@ -3,7 +3,7 @@ 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 modify it under the terms of the GNU Lesser General Public @@ -33,14 +33,14 @@ For further information, see - $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 #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 */ # define CONSTCHAR const char @@ -119,6 +119,7 @@ typedef char NXname[VGNAMELENMAX]; #define NX_CHAR DFNT_CHAR8 /* 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_RLE COMP_CODE_RLE #define NX_COMP_HUF COMP_CODE_SKPHUFF @@ -166,7 +167,11 @@ extern "C" { # define NXputattr MANGLE(nxiputattr) # define NXputdim MANGLE(nxiputdim) # define NXgetinfo MANGLE(nxigetinfo) +# define NXgetgroupinfo MANGLE(nxigetgroupinfo) +# define NXinitgroupdir MANGLE(nxiinitgroupdir) # define NXgetnextentry MANGLE(nxigetnextentry) +# define NXgetattrinfo MANGLE(nxigetattrinfo) +# define NXinitattrdir MANGLE(nxiinitattrdir) # define NXgetnextattr MANGLE(nxigetnextattr) # define NXgetgroupID MANGLE(nxigetgroupid) # define NXgetdataID MANGLE(nxigetdataid) @@ -177,7 +182,7 @@ extern "C" { # define NXfopen MANGLE(nxifopen) # define NXfclose MANGLE(nxifclose) # define NXfmakedata MANGLE(nxifmakedata) -# define NXfcompress MANGLE(nxfcompress) +# define NXfcompress MANGLE(nxifcompress) # define NXfputattr MANGLE(nxifputattr) #elif defined(_WIN32) /* @@ -186,7 +191,7 @@ extern "C" { /* # define MANGLE(__arg) __stdcall CONCAT(__arg,_) */ /* # define MANGLE(__arg) CONCAT(__arg,_) */ # define MANGLE(__arg) __stdcall __arg -# define NXopen NXIOPEN_ +# define NXopen NXIOPEN_ # define NXclose NXICLOSE_ # define NXmakegroup MANGLE(NXIMAKEGROUP) # define NXopengroup MANGLE(NXIOPENGROUP) @@ -204,7 +209,11 @@ extern "C" { # define NXputattr NXIPUTATTR_ # define NXputdim MANGLE(NXIPUTDIM) # define NXgetinfo MANGLE(NXIGETINFO) +# define NXgetgroupinfo MANGLE(NXIGETGROUPINFO) +# define NXinitgroupdir MANGLE(NXIINITGROUPDIR) # define NXgetnextentry MANGLE(NXIGETNEXTENTRY) +# define NXgetattrinfo MANGLE(NXIGETATTRINFO) +# define NXinitattrdir MANGLE(NXIINITATTRDIR) # define NXgetnextattr MANGLE(NXIGETNEXTATTR) # define NXgetgroupID MANGLE(NXIGETGROUPID) # define NXgetdataID MANGLE(NXIGETDATAID) @@ -214,9 +223,9 @@ extern "C" { /* FORTRAN helpers - for NeXus internal use only */ # define NXfopen MANGLE(NXIFOPEN) # define NXfclose MANGLE(NXIFCLOSE) -# define NXfmakedata MANGLE(NXIFMAKEDATA) -# define NXfcompress MANGLE(NXIFCOMPRESS) -# define NXfputattr MANGLE(NXIFPUTATTR) +# define NXfmakedata MANGLE(NXIFMAKEDATA) +# define NXfcompress MANGLE(NXIFCOMPRESS) +# define NXfputattr MANGLE(NXIFPUTATTR) #else # error Cannot compile - unknown operating system #endif @@ -245,7 +254,11 @@ extern "C" { NXstatus NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); 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 NXgetattrinfo(NXhandle handle, int* no_items); + NXstatus NXinitattrdir(NXhandle handle); NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); NXstatus NXgetgroupID(NXhandle handle, NXlink* pLink); diff --git a/nxdict.c b/nxdict.c index 27ccdeed..7dc51116 100644 --- a/nxdict.c +++ b/nxdict.c @@ -41,7 +41,7 @@ extern void *NXpData; extern void (*NXIReportError)(void *pData, char *pBuffer); /*--------------------------------------------------------------------------*/ -#define DEFDEBUG 1 +/*#define DEFDEBUG 1*/ /* define DEFDEBUG when you wish to print your definition strings before action. This can help a lot to resolve mysteries when working with dictionaries. @@ -665,10 +665,13 @@ #define DCLOSE 11 #define DATTR 12 #define DEND 13 +#define DLZW 14 +#define DHUF 15 +#define DRLE 16 /*----------------- Keywords ----------------------------------------*/ - static TokDat TokenList[8] = { + static TokDat TokenList[11] = { {"SDS",DSDS}, {"NXLINK",DLINK}, {"NXVGROUP",DGROUP}, @@ -676,6 +679,9 @@ {"-type",DTYPE}, {"-rank",DRANK}, {"-attr",DATTR}, + {"-LZW",DLZW}, + {"-HUF",DHUF}, + {"-RLE",DRLE}, {NULL,0} }; /*-----------------------------------------------------------------------*/ @@ -744,7 +750,7 @@ sStat->pToken[i] = '\0'; /*--------- 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) { @@ -988,6 +994,7 @@ {"DFNT_UINT16",DFNT_UINT16}, {"DFNT_INT32",DFNT_INT32}, {"DFNT_UINT32",DFNT_UINT32}, + {"DFNT_CHAR",DFNT_CHAR}, {NULL,-122} }; @@ -1033,6 +1040,7 @@ { int iType = DFNT_FLOAT32; int iRank = 1; + int iCompress = 0; int32 iDim[MAX_VAR_DIMS]; int iList; int iRet, iStat; @@ -1103,6 +1111,15 @@ return iRet; } break; + case DLZW: + iCompress = NX_COMP_LZW; + break; + case DRLE: + iCompress = NX_COMP_RLE; + break; + case DHUF: + iCompress = NX_COMP_HUF; + break; case DEND: break; default: @@ -1150,6 +1167,15 @@ LLDdelete(iList); 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 */ iRet = LLDnodePtr2First(iList); while(iRet != 0) @@ -1221,7 +1247,7 @@ #line 1034 "nxdict.w" - static int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse) + int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse) { int iRet; char pError[256]; @@ -1278,7 +1304,7 @@ #line 1576 "nxdict.w" - static NXstatus NXDIUnwind(NXhandle hFil, int iDepth) + NXstatus NXDIUnwind(NXhandle hFil, int iDepth) { int i, iRet; @@ -1514,6 +1540,9 @@ return iStat; } + + + #line 2416 "nxdict.w" /*------------------------------------------------------------------------*/ @@ -1553,8 +1582,95 @@ #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" NXstatus NXDdeflink(NXhandle hFil, NXdict dict, @@ -1706,7 +1822,7 @@ iDate = time(NULL); psTime = localtime(&iDate); 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, @@ -1723,7 +1839,7 @@ /* store global attributes */ iStat = NXputattr(pFile,"file_name",filename, - strlen(filename)+1,DFNT_INT8); + strlen(filename)+1,NX_CHAR); if(iStat == NX_ERROR) { return NX_ERROR; @@ -1732,7 +1848,7 @@ /* write creation time */ SNXFormatTime(pBueffel,512); iStat = NXputattr(pFile,"file_time",pBueffel, - strlen(pBueffel)+1,DFNT_INT8); + strlen(pBueffel)+1,NX_CHAR); if(iStat == NX_ERROR) { return NX_ERROR; @@ -1740,7 +1856,7 @@ /* instrument name */ iStat = NXputattr(pFile,"instrument",instrument, - strlen(instrument)+1,DFNT_INT8); + strlen(instrument)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1748,7 +1864,7 @@ /* owner */ iStat = NXputattr(pFile,"owner",owner, - strlen(owner)+1,DFNT_INT8); + strlen(owner)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1756,7 +1872,7 @@ /* Adress */ iStat = NXputattr(pFile,"owner_adress",adress, - strlen(adress)+1,DFNT_INT8); + strlen(adress)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1764,7 +1880,7 @@ /* phone */ iStat = NXputattr(pFile,"owner_telephone_number",phone, - strlen(phone)+1,DFNT_INT8); + strlen(phone)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1772,7 +1888,7 @@ /* fax */ iStat = NXputattr(pFile,"owner_fax_number",fax, - strlen(fax)+1,DFNT_INT8); + strlen(fax)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1780,7 +1896,7 @@ /* email */ iStat = NXputattr(pFile,"owner_email",email, - strlen(email)+1,DFNT_INT8); + strlen(email)+1,NX_CHAR); if(iStat == NX_ERROR) { return iStat; @@ -1913,6 +2029,8 @@ lLength *= sizeof(float64); break; case DFNT_INT8: + case DFNT_CHAR: + case DFNT_UCHAR8: lLength *= sizeof(int8); break; case DFNT_UINT8: @@ -1943,6 +2061,7 @@ NXIReportError(NXpData,"ERROR: memory exhausted in NXUallocSDS"); return NX_ERROR; } + memset(*pData,0,lLength); return NX_OK; } diff --git a/nxdict.h b/nxdict.h index 17dc1a0f..606f7fb6 100644 --- a/nxdict.h +++ b/nxdict.h @@ -48,7 +48,13 @@ NXstatus NXDgetalias(NXhandle file, NXdict dict, char *alias, 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, char *pAlias1, char *pAlias2); NXstatus NXDdeflink(NXhandle file, NXdict dict, diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 514403d6..d529599e 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -364,5 +364,5 @@ sample Bi2212 #1, th vs SGU=-12.5 sample setAccess 2 title TopsiTupsiTapsi title setAccess 2 -starttime 2000-02-18 16:40:55 +starttime 2000-02-21 09:08:52 starttime setAccess 2 diff --git a/tcl/topsicom.tcl b/tcl/topsicom.tcl index 23f4343f..a5ed517c 100644 --- a/tcl/topsicom.tcl +++ b/tcl/topsicom.tcl @@ -5,9 +5,9 @@ # Mark Koennecke, October 1997 # Requires a sics scan command called xxxscan #---------------------------------------------------------------------------- -set home /home/koenneck/sics/tcl -set datapath /home/koenneck/tmp -set recoverfil /home/koenneck/tmp/recover.bin +set home /data/koenneck/src/sics/tcl +set datapath /data/koenneck/src/tmp +set recoverfil /data/koenneck/src/tmp/recover.bin source $home/utils.tcl diff --git a/test.tcl b/test.tcl index 8685514f..a5c9a986 100644 --- a/test.tcl +++ b/test.tcl @@ -10,10 +10,7 @@ rename scan stscan #-------- a home for this, everything else is in relation to this -set shome /home/koenneck - -#set auto_path "/data/koenneck/src/sics/tcl" -#source $auto_path/tcl8/topsicom.tcl +set shome /data/koenneck/src # first all the server options are set