Skip to content

Commit d547d59

Browse files
committed
Moved non-Fortran internal API to a new napi_internal.h
Lots of code was using NXIprintlink so I moved that back to napi.h NXsummary and NXbrowse use NXMDisableErrorReporting: including napi_internal.h in NXsummary/main.cpp and NXbrowse.c
1 parent 19d7696 commit d547d59

10 files changed

Lines changed: 179 additions & 130 deletions

File tree

applications/NXbrowse/NXbrowse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <string.h>
3434
#include <stdlib.h>
3535
#include "napi.h"
36+
#include "napi_internal.h" /* for NXM{En,Dis}ableErrorReporting */
3637
#include "napiconfig.h"
3738
static char *my_readline(const char *prompt)
3839
{

applications/NXsummary/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "preferences.hpp"
3838
#include "string_util.hpp"
3939
#include "tclap/CmdLine.h"
40+
#include "napi_internal.h" // needed for NXMDisableErrorReporting
4041

4142
using std::cerr;
4243
using std::cout;

include/napi.h

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -849,138 +849,8 @@ extern const char* NXgetversion();
849849
extern NXstatus NXfree(void** data);
850850

851851

852-
/*-----------------------------------------------------------------------
853-
NAPI internals
854-
------------------------------------------------------------------------*/
855-
/**
856-
* Retrieve information about the currently open dataset. In contrast to the main function below,
857-
* this function does not try to find out about the size of strings properly.
858-
* \param handle A NeXus file handle as initialized by NXopen.
859-
* \param rank A pointer to an integer which will be filled with the rank of
860-
* the dataset.
861-
* \param dimension An array which will be initialized with the size of the dataset in any of its
862-
* dimensions. The array must have at least the size of rank.
863-
* \param datatype A pointer to an integer which be set to the NeXus data type code for this dataset.
864-
* \return NX_OK on success, NX_ERROR in the case of an error.
865-
* \ingroup c_metadata
866-
*/
867-
extern NXstatus NXgetrawinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
868-
869-
/**
870-
* @copydoc NXgetrawinfo
871-
*/
872-
extern NXstatus NXgetrawinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
873-
874-
/** \typedef void (*ErrFunc)(void *data, char *text)
875-
* All NeXus error reporting happens through this special function, the
876-
* ErrFunc. The NeXus-API allows to replace this error reporting function
877-
* through a user defined implementation. The default error function prints to stderr. User
878-
* defined ones may pop up dialog boxes or whatever.
879-
* \param data A pointer to some user defined data structure
880-
* \param text The text of the error message to display.
881-
*/
882-
typedef void (*ErrFunc)(void *data, char *text);
883-
884-
/**
885-
* Set a global error function.
886-
* Not threadsafe.
887-
* \param pData A pointer to a user defined data structure which be passed to
888-
* the error display function.
889-
* \param newErr The new error display function.
890-
*/
891-
extern void NXMSetError(void *pData, ErrFunc newErr);
892-
893-
/**
894-
* Set an error function for the current thread.
895-
* When used this overrides anything set in NXMSetError (for the current thread).
896-
* Use this method in threaded applications.
897-
* \param pData A pointer to a user defined data structure which be passed to
898-
* the error display function.
899-
* \param newErr The new error display function.
900-
*/
901-
extern void NXMSetTError(void *pData, ErrFunc newErr);
902-
903-
/**
904-
* Retrieve the current error display function
905-
* \return The current error display function.
906-
*/
907-
extern ErrFunc NXMGetError();
908-
909-
/**
910-
* Suppress error reports from the NeXus-API
911-
*/
912-
extern void NXMDisableErrorReporting();
913-
914-
/**
915-
* Enable error reports from the NeXus-API
916-
*/
917-
extern void NXMEnableErrorReporting();
918-
919-
/**
920-
* Dispatches the error message to the error function defined by NXMSetTError
921-
*/
922-
extern void NXReportError(char *text);
923-
924-
/**
925-
* Do not use, first parameter should be set by NXMSetTError
926-
*/
927-
extern void NXIReportError(void *pData,char *text);
928-
/* extern void *NXpData; */
929-
extern char *NXIformatNeXusTime();
930852
extern NXstatus NXIprintlink(NXhandle fid, NXlink* link);
931853

932-
/**
933-
* A function for setting the default cache size for HDF-5
934-
* \ingroup c_init
935-
*/
936-
extern NXstatus NXsetcache(long newVal);
937-
938-
typedef struct {
939-
NXhandle pNexusData;
940-
NXstatus ( *nxreopen)(NXhandle pOrigHandle, NXhandle* pNewHandle);
941-
NXstatus ( *nxclose)(NXhandle* pHandle);
942-
NXstatus ( *nxflush)(NXhandle* pHandle);
943-
NXstatus ( *nxmakegroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
944-
NXstatus ( *nxopengroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
945-
NXstatus ( *nxclosegroup)(NXhandle handle);
946-
NXstatus ( *nxmakedata64) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
947-
NXstatus ( *nxcompmakedata64) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
948-
NXstatus ( *nxcompress) (NXhandle handle, int compr_type);
949-
NXstatus ( *nxopendata) (NXhandle handle, CONSTCHAR* label);
950-
NXstatus ( *nxclosedata)(NXhandle handle);
951-
NXstatus ( *nxputdata)(NXhandle handle, const void* data);
952-
NXstatus ( *nxputattr)(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
953-
NXstatus ( *nxputattra)(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType);
954-
NXstatus ( *nxputslab64)(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
955-
NXstatus ( *nxgetdataID)(NXhandle handle, NXlink* pLink);
956-
NXstatus ( *nxmakelink)(NXhandle handle, NXlink* pLink);
957-
NXstatus ( *nxmakenamedlink)(NXhandle handle, CONSTCHAR *newname, NXlink* pLink);
958-
NXstatus ( *nxgetdata)(NXhandle handle, void* data);
959-
NXstatus ( *nxgetinfo64)(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
960-
NXstatus ( *nxgetnextentry)(NXhandle handle, NXname name, NXname nxclass, int* datatype);
961-
NXstatus ( *nxgetslab64)(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
962-
NXstatus ( *nxgetnextattr)(NXhandle handle, NXname pName, int *iLength, int *iType);
963-
NXstatus ( *nxgetnextattra)(NXhandle handle, NXname pName, int *rank, int dim[], int *iType);
964-
NXstatus ( *nxgetattr)(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
965-
NXstatus ( *nxgetattra)(NXhandle handle, char* name, void* data);
966-
NXstatus ( *nxgetattrainfo)(NXhandle handle, NXname pName, int *rank, int dim[], int *iType);
967-
NXstatus ( *nxgetattrinfo)(NXhandle handle, int* no_items);
968-
NXstatus ( *nxgetgroupID)(NXhandle handle, NXlink* pLink);
969-
NXstatus ( *nxgetgroupinfo)(NXhandle handle, int* no_items, NXname name, NXname nxclass);
970-
NXstatus ( *nxsameID)(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID);
971-
NXstatus ( *nxinitgroupdir)(NXhandle handle);
972-
NXstatus ( *nxinitattrdir)(NXhandle handle);
973-
NXstatus ( *nxsetnumberformat)(NXhandle handle, int type, char *format);
974-
NXstatus ( *nxprintlink)(NXhandle handle, NXlink* link);
975-
NXstatus ( *nxnativeexternallink)(NXhandle handle, CONSTCHAR* name, CONSTCHAR* externalfile, CONSTCHAR* remotetarget);
976-
NXstatus ( *nxnativeinquirefile)(NXhandle handle, char* externalfile, const int filenamelength);
977-
NXstatus ( *nxnativeisexternallink)(NXhandle handle, CONSTCHAR* name, char* url, int urllen);
978-
int stripFlag;
979-
int checkNameSyntax;
980-
} NexusFunction, *pNexusFunction;
981-
/*---------------------*/
982-
extern long nx_cacheSize;
983-
984854
#ifdef __cplusplus
985855
};
986856
#endif /* __cplusplus */

include/napi_internal.h

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*---------------------------------------------------------------------------
2+
NeXus - Neutron & X-ray Common Data Format
3+
4+
Application Program Interface Header File
5+
6+
Copyright (C) 2015 NeXus International Advisory Committee
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
22+
For further information, see <http://www.nexusformat.org>
23+
24+
----------------------------------------------------------------------------*/
25+
26+
#ifndef NEXUS_INTERNAL_API
27+
#define NEXUS_INTERNAL_API
28+
29+
#include <napi.h>
30+
31+
/*-----------------------------------------------------------------------
32+
NAPI internals
33+
------------------------------------------------------------------------*/
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif /* __cplusplus */
38+
39+
/**
40+
* Retrieve information about the currently open dataset. In contrast to the main function below,
41+
* this function does not try to find out about the size of strings properly.
42+
* \param handle A NeXus file handle as initialized by NXopen.
43+
* \param rank A pointer to an integer which will be filled with the rank of
44+
* the dataset.
45+
* \param dimension An array which will be initialized with the size of the dataset in any of its
46+
* dimensions. The array must have at least the size of rank.
47+
* \param datatype A pointer to an integer which be set to the NeXus data type code for this dataset.
48+
* \return NX_OK on success, NX_ERROR in the case of an error.
49+
* \ingroup c_metadata
50+
*/
51+
extern NXstatus NXgetrawinfo(NXhandle handle, int* rank, int dimension[], int* datatype);
52+
53+
/**
54+
* @copydoc NXgetrawinfo
55+
*/
56+
extern NXstatus NXgetrawinfo64(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
57+
58+
/** \typedef void (*ErrFunc)(void *data, char *text)
59+
* All NeXus error reporting happens through this special function, the
60+
* ErrFunc. The NeXus-API allows to replace this error reporting function
61+
* through a user defined implementation. The default error function prints to stderr. User
62+
* defined ones may pop up dialog boxes or whatever.
63+
* \param data A pointer to some user defined data structure
64+
* \param text The text of the error message to display.
65+
*/
66+
typedef void (*ErrFunc)(void *data, char *text);
67+
68+
/**
69+
* Set a global error function.
70+
* Not threadsafe.
71+
* \param pData A pointer to a user defined data structure which be passed to
72+
* the error display function.
73+
* \param newErr The new error display function.
74+
*/
75+
extern void NXMSetError(void *pData, ErrFunc newErr);
76+
77+
/**
78+
* Set an error function for the current thread.
79+
* When used this overrides anything set in NXMSetError (for the current thread).
80+
* Use this method in threaded applications.
81+
* \param pData A pointer to a user defined data structure which be passed to
82+
* the error display function.
83+
* \param newErr The new error display function.
84+
*/
85+
extern void NXMSetTError(void *pData, ErrFunc newErr);
86+
87+
/**
88+
* Retrieve the current error display function
89+
* \return The current error display function.
90+
*/
91+
extern ErrFunc NXMGetError();
92+
93+
/**
94+
* Suppress error reports from the NeXus-API
95+
*/
96+
extern void NXMDisableErrorReporting();
97+
98+
/**
99+
* Enable error reports from the NeXus-API
100+
*/
101+
extern void NXMEnableErrorReporting();
102+
103+
/**
104+
* Dispatches the error message to the error function defined by NXMSetTError
105+
*/
106+
extern void NXReportError(char *text);
107+
108+
/**
109+
* Do not use, first parameter should be set by NXMSetTError
110+
*/
111+
extern void NXIReportError(void *pData,char *text);
112+
/* extern void *NXpData; */
113+
extern char *NXIformatNeXusTime();
114+
115+
/**
116+
* A function for setting the default cache size for HDF-5
117+
* \ingroup c_init
118+
*/
119+
extern NXstatus NXsetcache(long newVal);
120+
121+
typedef struct {
122+
NXhandle pNexusData;
123+
NXstatus ( *nxreopen)(NXhandle pOrigHandle, NXhandle* pNewHandle);
124+
NXstatus ( *nxclose)(NXhandle* pHandle);
125+
NXstatus ( *nxflush)(NXhandle* pHandle);
126+
NXstatus ( *nxmakegroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
127+
NXstatus ( *nxopengroup) (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass);
128+
NXstatus ( *nxclosegroup)(NXhandle handle);
129+
NXstatus ( *nxmakedata64) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[]);
130+
NXstatus ( *nxcompmakedata64) (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int64_t dim[], int comp_typ, int64_t bufsize[]);
131+
NXstatus ( *nxcompress) (NXhandle handle, int compr_type);
132+
NXstatus ( *nxopendata) (NXhandle handle, CONSTCHAR* label);
133+
NXstatus ( *nxclosedata)(NXhandle handle);
134+
NXstatus ( *nxputdata)(NXhandle handle, const void* data);
135+
NXstatus ( *nxputattr)(NXhandle handle, CONSTCHAR* name, const void* data, int iDataLen, int iType);
136+
NXstatus ( *nxputattra)(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType);
137+
NXstatus ( *nxputslab64)(NXhandle handle, const void* data, const int64_t start[], const int64_t size[]);
138+
NXstatus ( *nxgetdataID)(NXhandle handle, NXlink* pLink);
139+
NXstatus ( *nxmakelink)(NXhandle handle, NXlink* pLink);
140+
NXstatus ( *nxmakenamedlink)(NXhandle handle, CONSTCHAR *newname, NXlink* pLink);
141+
NXstatus ( *nxgetdata)(NXhandle handle, void* data);
142+
NXstatus ( *nxgetinfo64)(NXhandle handle, int* rank, int64_t dimension[], int* datatype);
143+
NXstatus ( *nxgetnextentry)(NXhandle handle, NXname name, NXname nxclass, int* datatype);
144+
NXstatus ( *nxgetslab64)(NXhandle handle, void* data, const int64_t start[], const int64_t size[]);
145+
NXstatus ( *nxgetnextattr)(NXhandle handle, NXname pName, int *iLength, int *iType);
146+
NXstatus ( *nxgetnextattra)(NXhandle handle, NXname pName, int *rank, int dim[], int *iType);
147+
NXstatus ( *nxgetattr)(NXhandle handle, char* name, void* data, int* iDataLen, int* iType);
148+
NXstatus ( *nxgetattra)(NXhandle handle, char* name, void* data);
149+
NXstatus ( *nxgetattrainfo)(NXhandle handle, NXname pName, int *rank, int dim[], int *iType);
150+
NXstatus ( *nxgetattrinfo)(NXhandle handle, int* no_items);
151+
NXstatus ( *nxgetgroupID)(NXhandle handle, NXlink* pLink);
152+
NXstatus ( *nxgetgroupinfo)(NXhandle handle, int* no_items, NXname name, NXname nxclass);
153+
NXstatus ( *nxsameID)(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID);
154+
NXstatus ( *nxinitgroupdir)(NXhandle handle);
155+
NXstatus ( *nxinitattrdir)(NXhandle handle);
156+
NXstatus ( *nxsetnumberformat)(NXhandle handle, int type, char *format);
157+
NXstatus ( *nxprintlink)(NXhandle handle, NXlink* link);
158+
NXstatus ( *nxnativeexternallink)(NXhandle handle, CONSTCHAR* name, CONSTCHAR* externalfile, CONSTCHAR* remotetarget);
159+
NXstatus ( *nxnativeinquirefile)(NXhandle handle, char* externalfile, const int filenamelength);
160+
NXstatus ( *nxnativeisexternallink)(NXhandle handle, CONSTCHAR* name, char* url, int urllen);
161+
int stripFlag;
162+
int checkNameSyntax;
163+
} NexusFunction, *pNexusFunction;
164+
/*---------------------*/
165+
extern long nx_cacheSize;
166+
167+
#ifdef __cplusplus
168+
};
169+
#endif /* __cplusplus */
170+
171+
#endif /* NEXUS_INTERNAL_API */

src/napi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <stdarg.h>
3333

3434
#include <napi.h>
35+
#include <napi_internal.h>
3536
#include <nxconfig.h>
3637
#include "nxstack.h"
3738

src/napi4.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <time.h>
3636

3737
#include "napi.h"
38+
#include "napi_internal.h"
3839
#include "napi4.h"
3940

4041

src/napi5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <time.h>
3434

3535
#include "napi.h"
36+
#include "napi_internal.h"
3637
#include "napi5.h"
3738

3839
#ifdef H5_VERSION_GE

src/napiu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <string.h>
3131
#include <time.h>
3232
#include "napiu.h"
33+
#include "napi_internal.h"
3334

3435
#define DO_GLOBAL(__name) \
3536
if (__name != NULL) \

src/nxstack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdlib.h>
2727
#include <string.h>
2828
#include <napi.h>
29+
#include <napi_internal.h>
2930
#include "nxstack.h"
3031

3132
/*-----------------------------------------------------------------------

src/nxxml.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <stdint.h>
3131
#include <mxml.h>
3232
#include <napi.h>
33+
#include <napi_internal.h>
3334
#include <nxxml.h>
3435
#include "nxio.h"
3536
#include "nxdataset.h"

0 commit comments

Comments
 (0)