- Fix to various drivers due to changes in rs232controller
- hkl now searches psi in .5 steps - first point of fastscan is driven normally SKIPPED: psi/amor2t.c psi/amor2t.h psi/amor2t.i psi/amor2t.tex psi/amor2t.w psi/dornier2.c psi/el734hp.c psi/nxamor.c psi/slsmagnet.c psi/sps.c
This commit is contained in:
144
napi.c
144
napi.c
@@ -23,12 +23,13 @@
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
static const char* rscid = "$Id: napi.c,v 1.11 2005/06/22 07:10:00 koennecke Exp $"; /* Revision interted by CVS */
|
||||
static const char* rscid = "$Id: napi.c,v 1.12 2005/09/07 13:51:12 koennecke Exp $"; /* Revision interted by CVS */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include "napi.h"
|
||||
@@ -157,13 +158,27 @@ static int determineFileType(CONSTCHAR *filename)
|
||||
iFortifyScope = Fortify_EnterScope();
|
||||
Fortify_CheckAllMemory();
|
||||
*/
|
||||
*gHandle = NULL;
|
||||
|
||||
/*
|
||||
allocate data
|
||||
*/
|
||||
*gHandle = NULL;
|
||||
fHandle = (pNexusFunction)malloc(sizeof(NexusFunction));
|
||||
if (fHandle == NULL) {
|
||||
NXIReportError (NXpData,"ERROR: no memory to create Function structure");
|
||||
return NX_ERROR;
|
||||
}
|
||||
memset(fHandle, 0, sizeof(NexusFunction)); /* so any functions we miss are NULL */
|
||||
|
||||
/*
|
||||
test the strip flag. Elimnate it for the rest of the tests to work
|
||||
*/
|
||||
fHandle->stripFlag = 1;
|
||||
if(am & NXACC_NOSTRIP){
|
||||
fHandle->stripFlag = 0;
|
||||
am -= NXACC_NOSTRIP;
|
||||
}
|
||||
|
||||
if (am==NXACC_CREATE) {
|
||||
/* HDF4 will be used ! */
|
||||
hdf_type=1;
|
||||
@@ -306,7 +321,16 @@ static int determineFileType(CONSTCHAR *filename)
|
||||
int rank, int dimensions[])
|
||||
{
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxmakedata(pFunc->pNexusData, name, datatype, rank, dimensions);
|
||||
if ( (datatype == NX_CHAR) && (rank > 1) )
|
||||
{
|
||||
NXIReportError (NXpData,
|
||||
"ERROR: multi-dimensional NX_CHAR arrays are not supported by the NeXus library");
|
||||
return NX_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pFunc->nxmakedata(pFunc->pNexusData, name, datatype, rank, dimensions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +340,16 @@ static int determineFileType(CONSTCHAR *filename)
|
||||
int rank, int dimensions[],int compress_type, int chunk_size[])
|
||||
{
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxcompmakedata (pFunc->pNexusData, name, datatype, rank, dimensions, compress_type, chunk_size);
|
||||
if ( (datatype == NX_CHAR) && (rank > 1) )
|
||||
{
|
||||
NXIReportError (NXpData,
|
||||
"ERROR: multi-dimensional NX_CHAR arrays are not supported by the NeXus library");
|
||||
return NX_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pFunc->nxcompmakedata (pFunc->pNexusData, name, datatype, rank, dimensions, compress_type, chunk_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -419,27 +452,32 @@ static int determineFileType(CONSTCHAR *filename)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
NXstatus CALLING_STYLE NXmalloc (void** data, int rank, int dimensions[], int datatype)
|
||||
NXstatus CALLING_STYLE NXmalloc (void** data, int rank,
|
||||
int dimensions[], int datatype)
|
||||
{
|
||||
int i;
|
||||
size_t size = 1;
|
||||
*data = NULL;
|
||||
for(i=0; i<rank; i++)
|
||||
size *= dimensions[i];
|
||||
if ((datatype == NX_CHAR) || (datatype == NX_INT8) || (datatype == NX_UINT8)) {
|
||||
/* size is correct already */
|
||||
if ((datatype == NX_CHAR) || (datatype == NX_INT8)
|
||||
|| (datatype == NX_UINT8)) {
|
||||
/* allow for terminating \0 */
|
||||
size += 1;
|
||||
}
|
||||
else if ((datatype == NX_INT16) || (datatype == NX_UINT16)) {
|
||||
size *= 2;
|
||||
}
|
||||
else if ((datatype == NX_INT32) || (datatype == NX_UINT32) || (datatype == NX_FLOAT32)) {
|
||||
else if ((datatype == NX_INT32) || (datatype == NX_UINT32)
|
||||
|| (datatype == NX_FLOAT32)) {
|
||||
size *= 4;
|
||||
}
|
||||
else if (datatype == NX_FLOAT64) {
|
||||
size *= 8;
|
||||
}
|
||||
else {
|
||||
NXIReportError (NXpData, "ERROR: NXmalloc - unknown data type in array");
|
||||
NXIReportError (NXpData,
|
||||
"ERROR: NXmalloc - unknown data type in array");
|
||||
return NX_ERROR;
|
||||
}
|
||||
*data = (void*)malloc(size);
|
||||
@@ -472,28 +510,105 @@ static int determineFileType(CONSTCHAR *filename)
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxgetnextentry(pFunc->pNexusData, name, nxclass, datatype);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
** TRIM.C - Remove leading, trailing, & excess embedded spaces
|
||||
**
|
||||
** public domain by Bob Stout
|
||||
*/
|
||||
#define NUL '\0'
|
||||
|
||||
static char *nxitrim(char *str)
|
||||
{
|
||||
char *ibuf = str, *obuf = str;
|
||||
int i = 0, cnt = 0;
|
||||
|
||||
/*
|
||||
** Trap NULL
|
||||
*/
|
||||
|
||||
if (str)
|
||||
{
|
||||
/*
|
||||
** Remove leading spaces (from RMLEAD.C)
|
||||
*/
|
||||
|
||||
for (ibuf = str; *ibuf && isspace(*ibuf); ++ibuf)
|
||||
;
|
||||
str = ibuf;
|
||||
|
||||
/*
|
||||
** Remove trailing spaces (from RMTRAIL.C)
|
||||
*/
|
||||
i = strlen(str);
|
||||
while (--i >= 0)
|
||||
{
|
||||
if (!isspace(str[i]))
|
||||
break;
|
||||
}
|
||||
str[++i] = NUL;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
NXstatus CALLING_STYLE NXgetdata (NXhandle fid, void *data)
|
||||
{
|
||||
int status, type, rank, iDim[NX_MAXRANK];
|
||||
char *pPtr, *pPtr2;
|
||||
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxgetdata(pFunc->pNexusData, data);
|
||||
status = pFunc->nxgetinfo(pFunc->pNexusData, &rank, iDim, &type); /* unstripped size if string */
|
||||
if ( (type == NX_CHAR) && (pFunc->stripFlag == 1) )
|
||||
{
|
||||
pPtr = (char*)malloc(iDim[0]+1);
|
||||
memset(pPtr, 0, iDim[0]+1);
|
||||
status = pFunc->nxgetdata(pFunc->pNexusData, pPtr);
|
||||
pPtr2 = nxitrim(pPtr);
|
||||
strncpy((char*)data, pPtr2, strlen(pPtr2)); /* not NULL terminated by default */
|
||||
free(pPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = pFunc->nxgetdata(pFunc->pNexusData, data);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
NXstatus CALLING_STYLE NXgetinfo (NXhandle fid, int *rank, int dimension[], int *iType)
|
||||
NXstatus CALLING_STYLE NXgetinfo (NXhandle fid, int *rank,
|
||||
int dimension[], int *iType)
|
||||
{
|
||||
int status;
|
||||
char *pPtr = NULL;
|
||||
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxgetinfo(pFunc->pNexusData, rank, dimension, iType);
|
||||
status = pFunc->nxgetinfo(pFunc->pNexusData, rank, dimension, iType);
|
||||
/*
|
||||
the length of a string may be trimmed....
|
||||
*/
|
||||
if(*iType == NX_CHAR && pFunc->stripFlag == 1){
|
||||
pPtr = (char *)malloc((dimension[0]+1)*sizeof(char));
|
||||
if(pPtr != NULL){
|
||||
memset(pPtr,0,(dimension[0]+1)*sizeof(char));
|
||||
pFunc->nxgetdata(pFunc->pNexusData, pPtr);
|
||||
dimension[0] = strlen(nxitrim(pPtr));
|
||||
free(pPtr);
|
||||
}
|
||||
}
|
||||
if ( (*iType == NX_CHAR) && (*rank > 1) )
|
||||
{
|
||||
NXIReportError(NXpData,
|
||||
"WARNING: multi-dimensional character arrays are not really supported");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
NXstatus CALLING_STYLE NXgetslab (NXhandle fid, void *data, int iStart[], int iSize[])
|
||||
NXstatus CALLING_STYLE NXgetslab (NXhandle fid, void *data,
|
||||
int iStart[], int iSize[])
|
||||
{
|
||||
pNexusFunction pFunc = (pNexusFunction)fid;
|
||||
return pFunc->nxgetslab(pFunc->pNexusData, data, iStart, iSize);
|
||||
@@ -754,7 +869,6 @@ static NXstatus stepOneUp(NXhandle hfil, char *name)
|
||||
{
|
||||
return NX_OK;
|
||||
}
|
||||
|
||||
|
||||
NXinitgroupdir(hfil);
|
||||
while(NXgetnextentry(hfil,name2,xclass,&datatype) != NX_EOD)
|
||||
|
||||
Reference in New Issue
Block a user