.TH "g2cio.c" 3 "Version 2.2.0" "NCEPLIBS-g2c" \" -*- nroff -*-
.ad l
.nh
.SH NAME
g2cio.c \- File I/O functions for the g2c library\&.  

.SH SYNOPSIS
.br
.PP
\fC#include 'grib2_int\&.h'\fP
.br

.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBBITSHIFT_15\fP   15"
.br
.RI "15 bits\&. "
.ti -1c
.RI "#define \fBBITSHIFT_31\fP   31"
.br
.RI "31 bits\&. "
.ti -1c
.RI "#define \fBBITSHIFT_63\fP   63"
.br
.RI "63 bits\&. "
.ti -1c
.RI "#define \fBBITSHIFT_7\fP   7"
.br
.RI "7 bits\&. "
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBg2c_file_io\fP (FILE *f, int write, int g2ctype, void *var)"
.br
.RI "Read or write a big-endian integer type to an open file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_byte\fP (FILE *f, int write, char *var)"
.br
.RI "Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_int\fP (FILE *f, int write, int *var)"
.br
.RI "Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_longlong\fP (FILE *f, int write, long long *var)"
.br
.RI "Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_short\fP (FILE *f, int write, short *var)"
.br
.RI "Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_template\fP (FILE *f, int rw_flag, int map, long long int *template_value)"
.br
.RI "Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion between native and big-endian format, and handling of GRIB negative numbers\&. "
.ti -1c
.RI "int \fBg2c_file_io_ubyte\fP (FILE *f, int write, unsigned char *var)"
.br
.RI "Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_uint\fP (FILE *f, int write, unsigned int *var)"
.br
.RI "Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_ulonglong\fP (FILE *f, int write, unsigned long long *var)"
.br
.RI "Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native and big-endian format\&. "
.ti -1c
.RI "int \fBg2c_file_io_ushort\fP (FILE *f, int write, unsigned short *var)"
.br
.RI "Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and big-endian format\&. "
.in -1c
.SH "Detailed Description"
.PP 
File I/O functions for the g2c library\&. 


.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
Nov 11, 2022 
.RE
.PP

.PP
Definition in file \fBg2cio\&.c\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define BITSHIFT_15   15"

.PP
15 bits\&. 
.PP
Definition at line \fB10\fP of file \fBg2cio\&.c\fP\&.
.SS "#define BITSHIFT_31   31"

.PP
31 bits\&. 
.PP
Definition at line \fB11\fP of file \fBg2cio\&.c\fP\&.
.SS "#define BITSHIFT_63   63"

.PP
63 bits\&. 
.PP
Definition at line \fB12\fP of file \fBg2cio\&.c\fP\&.
.SS "#define BITSHIFT_7   7"

.PP
7 bits\&. 
.PP
Definition at line \fB9\fP of file \fBg2cio\&.c\fP\&.
.SH "Function Documentation"
.PP 
.SS "int g2c_file_io (FILE * f, int write, int g2ctype, void * var)"

.PP
Read or write a big-endian integer type to an open file, with conversion between native and big-endian format\&. GRIB2 handles negative numbers in a special way\&. Instead of storing two-compliments, like every other programmer and computing organization in the world, GRIB2 flips the first bit, then stores the rest of the int as an unsigned number in the remaining 31 bits\&. How exciting!
.PP
This function takes the excitement out of GRIB2 negative numbers\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open FILE\&. 
.br
\fIwrite\fP Non-zero if function should write, otherwise function will read\&. 
.br
\fIg2ctype\fP The type to be read or written\&. 
.br
\fIvar\fP Pointer to the int to be written, or pointer to the storage that gets the int read\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 
.RE
.PP
\fBDate\fP
.RS 4
11/7/22 
.RE
.PP

.PP
Definition at line \fB41\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBBITSHIFT_15\fP, \fBBITSHIFT_31\fP, \fBBITSHIFT_63\fP, \fBBITSHIFT_7\fP, \fBEIGHT_BYTES\fP, \fBFOUR_BYTES\fP, \fBG2C_BYTE\fP, \fBG2C_EBADTYPE\fP, \fBG2C_EFILE\fP, \fBG2C_EINVAL\fP, \fBG2C_INT\fP, \fBG2C_INT64\fP, \fBG2C_NOERROR\fP, \fBG2C_SHORT\fP, \fBG2C_UBYTE\fP, \fBG2C_UINT\fP, \fBG2C_UINT64\fP, \fBG2C_USHORT\fP, \fBhton64\fP, \fBntoh64\fP, \fBONE_BYTE\fP, and \fBTWO_BYTES\fP\&.
.PP
Referenced by \fBg2c_file_io_byte()\fP, \fBg2c_file_io_int()\fP, \fBg2c_file_io_longlong()\fP, \fBg2c_file_io_short()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ulonglong()\fP, and \fBg2c_file_io_ushort()\fP\&.
.SS "int g2c_file_io_byte (FILE * f, int write, char * var)"

.PP
Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the byte\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB316\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBG2C_BYTE\fP, and \fBg2c_file_io()\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP\&.
.SS "int g2c_file_io_int (FILE * f, int write, int * var)"

.PP
Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the int\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB230\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_INT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP\&.
.SS "int g2c_file_io_longlong (FILE * f, int write, long long * var)"

.PP
Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the long long\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB359\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_INT64\fP\&.
.SS "int g2c_file_io_short (FILE * f, int write, short * var)"

.PP
Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the short\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB273\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_SHORT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_start_index_record()\fP, and \fBg2c_start_index_record_lf()\fP\&.
.SS "int g2c_file_io_template (FILE * f, int rw_flag, int map, long long int * template_value)"

.PP
Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion between native and big-endian format, and handling of GRIB negative numbers\&. This is for template values\&.
.PP
With template values, if the map value is negative, then the template value may be negative\&.
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open FILE\&. 
.br
\fIrw_flag\fP Non-zero if function should write, otherwise function will read\&. 
.br
\fImap\fP The map value for this template item\&. 
.br
\fItemplate_value\fP Pointer to the template value to be written, or pointer to the storage that gets the templage value read\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB408\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBFOUR_BYTES\fP, \fBG2C_EBADTEMPLATE\fP, \fBg2c_file_io_byte()\fP, \fBg2c_file_io_int()\fP, \fBg2c_file_io_short()\fP, \fBg2c_file_io_ubyte()\fP, \fBg2c_file_io_uint()\fP, \fBg2c_file_io_ushort()\fP, \fBG2C_NOERROR\fP, \fBONE_BYTE\fP, and \fBTWO_BYTES\fP\&.
.PP
Referenced by \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, and \fBg2c_rw_section5_metadata()\fP\&.
.SS "int g2c_file_io_ubyte (FILE * f, int write, unsigned char * var)"

.PP
Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned byte\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB337\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UBYTE\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_open_index()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section6_metadata()\fP, \fBg2c_start_index1_record()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBg2c_write_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "int g2c_file_io_uint (FILE * f, int write, unsigned int * var)"

.PP
Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned int\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/7/22 
.RE
.PP

.PP
Definition at line \fB251\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UINT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_open_index()\fP, \fBg2c_rw_section1_metadata()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section5_metadata()\fP, \fBg2c_start_index1_record()\fP, \fBg2c_start_index_record()\fP, \fBg2c_start_index_record_lf()\fP, \fBg2c_write_index()\fP, and \fBread_msg_metadata()\fP\&.
.SS "int g2c_file_io_ulonglong (FILE * f, int write, unsigned long long * var)"

.PP
Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned long long\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB380\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_UINT64\fP\&.
.PP
Referenced by \fBg2c_start_index_record()\fP, and \fBg2c_start_index_record_lf()\fP\&.
.SS "int g2c_file_io_ushort (FILE * f, int write, unsigned short * var)"

.PP
Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and big-endian format\&. 
.PP
\fBParameters\fP
.RS 4
\fIf\fP Pointer to the open GRIB2 FILE\&. 
.br
\fIwrite\fP Non-zero to write, zero to read\&. 
.br
\fIvar\fP Pointer to the unsigned short\&.
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
:: G2C_NOERROR No error\&.
.IP "\(bu" 2
:: G2C_EINVAL Invalid input\&.
.IP "\(bu" 2
:: G2C_EFILE Error reading/writing file\&.
.PP
.RE
.PP
\fBAuthor\fP
.RS 4
Ed Hartnett 11/13/22 
.RE
.PP

.PP
Definition at line \fB294\fP of file \fBg2cio\&.c\fP\&.
.PP
References \fBg2c_file_io()\fP, and \fBG2C_USHORT\fP\&.
.PP
Referenced by \fBg2c_file_io_template()\fP, \fBg2c_rw_section3_metadata()\fP, \fBg2c_rw_section4_metadata()\fP, and \fBg2c_rw_section5_metadata()\fP\&.
.SH "Author"
.PP 
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code\&.
