2017-03-09 08:01:10 +08:00
|
|
|
/*********************************************************************
|
2018-12-07 05:24:28 +08:00
|
|
|
* Copyright 2018, UCAR/Unidata
|
2017-03-09 08:01:10 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef D4UTIL_H
|
|
|
|
#define D4UTIL_H 1
|
|
|
|
|
|
|
|
#ifdef HAVE_MEMMOVE
|
|
|
|
#define d4memmove(dst,src,n) memmove(dst,src,n)
|
|
|
|
#else
|
|
|
|
#define d4memmove(dst,src,n) localmemmove(dst,src,n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This is intended to be big enough to work as
|
|
|
|
an offset/position/size for a file or a memory block.
|
|
|
|
*/
|
|
|
|
typedef unsigned long long d4size_t;
|
|
|
|
|
2022-11-16 11:29:21 +08:00
|
|
|
/* Define a counted memory marker */
|
2017-03-09 08:01:10 +08:00
|
|
|
typedef struct D4blob {d4size_t size; void* memory;} D4blob;
|
|
|
|
|
2022-11-16 11:29:21 +08:00
|
|
|
#define OFFSET2BLOB(blob,offset) do{(blob).size = ((offset)->limit - (offset)->base); (blob).memory = (offset)->base; }while(0)
|
|
|
|
#define BLOB2OFFSET(offset,blob) do{\
|
|
|
|
(offset)->base = (blob).memory; \
|
|
|
|
(offset)->limit = ((char*)(blob).memory) + (blob).size; \
|
|
|
|
(offset)->offset = (offset)->base; \
|
|
|
|
} while(0)
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
/**************************************************/
|
|
|
|
|
|
|
|
/* signature: void swapinline16(void* ip) */
|
|
|
|
#define swapinline16(ip) \
|
|
|
|
{ \
|
2021-07-10 16:12:21 +08:00
|
|
|
char b[2]; \
|
2017-03-09 08:01:10 +08:00
|
|
|
char* src = (char*)(ip); \
|
2021-07-10 16:12:21 +08:00
|
|
|
b[0] = src[1]; \
|
|
|
|
b[1] = src[0]; \
|
|
|
|
memcpy(ip, b, 2); \
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signature: void swapinline32(void* ip) */
|
|
|
|
#define swapinline32(ip) \
|
|
|
|
{ \
|
2021-07-10 16:12:21 +08:00
|
|
|
char b[4]; \
|
2017-03-09 08:01:10 +08:00
|
|
|
char* src = (char*)(ip); \
|
2021-07-10 16:12:21 +08:00
|
|
|
b[0] = src[3]; \
|
|
|
|
b[1] = src[2]; \
|
|
|
|
b[2] = src[1]; \
|
|
|
|
b[3] = src[0]; \
|
|
|
|
memcpy(ip, b, 4); \
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signature: void swapinline64(void* ip) */
|
|
|
|
#define swapinline64(ip) \
|
|
|
|
{ \
|
2021-07-10 16:12:21 +08:00
|
|
|
char b[8]; \
|
2017-03-09 08:01:10 +08:00
|
|
|
char* src = (char*)(ip); \
|
2021-07-10 16:12:21 +08:00
|
|
|
b[0] = src[7]; \
|
|
|
|
b[1] = src[6]; \
|
|
|
|
b[2] = src[5]; \
|
|
|
|
b[3] = src[4]; \
|
|
|
|
b[4] = src[3]; \
|
|
|
|
b[5] = src[2]; \
|
|
|
|
b[6] = src[1]; \
|
|
|
|
b[7] = src[0]; \
|
|
|
|
memcpy(ip, b, 8); \
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************/
|
|
|
|
/* Define the NCD4node.data.flags */
|
|
|
|
|
|
|
|
#define HASNIL (0) /* no flags set */
|
|
|
|
#define HASSEQ (1) /* transitively contains sequence(s)*/
|
|
|
|
#define HASSTR (2) /* transitively contains strings */
|
|
|
|
#define HASOPFIX (4) /* transitively contains fixed size opaques */
|
|
|
|
#define HASOPVAR (8) /* transitively contains variable size opaques */
|
|
|
|
#define LEAFSEQ (16) /* mark leaf sequences */
|
|
|
|
#define HASANY (HASNIL|HASSEQ|HASSTR|HASOPTFIX|HASOPVAR)
|
|
|
|
/***************************************************/
|
|
|
|
|
|
|
|
extern int ncd4__testurl(const char* parth, char** basename);
|
|
|
|
|
|
|
|
#endif /*D4UTIL_H*/
|