10 #define BITSHIFT_15 15
11 #define BITSHIFT_31 31
12 #define BITSHIFT_63 63
47 long long int *i64var = NULL;
48 unsigned long long int int64_be, int64_tmp;
49 unsigned int int_be, int_tmp;
50 unsigned short short_be, short_tmp;
51 unsigned char byte_be, byte_tmp;
55 if (!f || !var || g2ctype < G2C_BYTE || g2ctype >
G2C_UINT64)
68 if (g2ctype ==
G2C_BYTE && *bvar < 0)
70 byte_tmp = -1 * *bvar;
90 short_tmp = -1 * *svar;
97 short_be = ntohs(short_tmp);
108 if (g2ctype ==
G2C_INT && *ivar < 0)
110 int_tmp = -1 * *ivar;
117 int_be = ntohl(int_tmp);
130 int64_tmp = -1 * *i64var;
137 int64_be =
ntoh64(int64_tmp);
146 if ((fwrite(void_be, type_len, 1, f)) != 1)
152 if ((fread(void_be, type_len, 1, f)) != 1)
172 *svar = htons(short_be);
184 *ivar = htonl(int_be);
196 *i64var =
hton64(int64_be);
423 my_byte = *template_value;
427 *template_value = my_byte;
431 unsigned char my_ubyte;
433 my_ubyte = *template_value;
437 *template_value = my_ubyte;
446 my_short = *template_value;
450 *template_value = my_short;
454 unsigned short my_ushort;
456 my_ushort = *template_value;
460 *template_value = my_ushort;
469 my_int = *template_value;
473 *template_value = my_int;
477 unsigned int my_uint;
479 my_uint = *template_value;
483 *template_value = my_uint;
int g2c_file_io_ushort(FILE *f, int write, unsigned short *var)
Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and b...
int g2c_file_io_byte(FILE *f, int write, char *var)
Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-...
#define BITSHIFT_7
7 bits.
int g2c_file_io_template(FILE *f, int rw_flag, int map, long long int *template_value)
Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion betwee...
int g2c_file_io_ulonglong(FILE *f, int write, unsigned long long *var)
Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native a...
#define BITSHIFT_15
15 bits.
int g2c_file_io(FILE *f, int write, int g2ctype, void *var)
Read or write a big-endian integer type to an open file, with conversion between native and big-endia...
int g2c_file_io_short(FILE *f, int write, short *var)
Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big...
#define BITSHIFT_63
63 bits.
#define BITSHIFT_31
31 bits.
int g2c_file_io_ubyte(FILE *f, int write, unsigned char *var)
Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and bi...
int g2c_file_io_longlong(FILE *f, int write, long long *var)
Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and...
int g2c_file_io_uint(FILE *f, int write, unsigned int *var)
Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native ...
int g2c_file_io_int(FILE *f, int write, int *var)
Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native an...
#define G2C_SHORT
signed 2 byte integer
#define G2C_USHORT
unsigned 2-byte int
#define G2C_EFILE
File I/O error.
#define G2C_INT64
signed 8-byte int
#define G2C_EINVAL
Invalid input.
#define G2C_UINT64
unsigned 8-byte int
#define G2C_BYTE
signed 1 byte integer
#define G2C_EBADTEMPLATE
Template problem.
#define G2C_INT
signed 4 byte integer
#define G2C_UINT
unsigned 4-byte int
#define G2C_UBYTE
unsigned 1 byte int
#define G2C_NOERROR
No error.
#define G2C_EBADTYPE
Type not found.
Header file with internal function prototypes NCEPLIBS-g2c library.
#define FOUR_BYTES
Four bytes.
#define ntoh64(y)
Byte swap 64-bit ints.
#define TWO_BYTES
Two bytes.
#define ONE_BYTE
One byte.
#define EIGHT_BYTES
Eight bytes.
#define hton64(y)
Byte swap 64-bit ints.