g2cio.c(3)
π g2cio.c β the g2c library's file I/O girlies π
okay so bestie, welcome to g2cio.c(3) from the Library Functions Manual β this is the page about all the file I/O functions for the g2c library, and honestly? it's giving "let me read and write your GRIB2 files for you, no cap." π¦
β¨ NAME β¨
g2cio.c β File I/O functions for the g2c library.
πΈ SYNOPSIS πΈ
#include 'grib2_int.h'
π Macros
#define BITSHIFT_15 15β 15 bits.#define BITSHIFT_31 31β 31 bits.#define BITSHIFT_63 63β 63 bits.#define BITSHIFT_7 7β 7 bits.
π§ Functions
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-endian format.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-endian format, and special GRIB2 handling of negative numbers.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 and big-endian format, and special GRIB2 handling of negative numbers.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 big-endian format, and special GRIB2 handling of negative numbers.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-endian format, and special GRIB2 handling of negative numbers.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 between native and big-endian format, and handling of GRIB negative numbers.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 big-endian format.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 and big-endian format.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 and big-endian format.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 big-endian format.
π Detailed Description π
File I/O functions for the g2c library.
Author Ed Hartnett
Date Nov 11, 2022
Definition in file g2cio.c.
π₯ Macro Definition Documentation π₯
β #define BITSHIFT_15 15
15 bits.
Definition at line 10 of file g2cio.c.
Referenced by g2c_file_io().
β #define BITSHIFT_31 31
31 bits.
Definition at line 11 of file g2cio.c.
Referenced by g2c_file_io().
β #define BITSHIFT_63 63
63 bits.
Definition at line 12 of file g2cio.c.
Referenced by g2c_file_io().
β #define BITSHIFT_7 7
7 bits.
Definition at line 9 of file g2cio.c.
Referenced by g2c_file_io().
okay and that's where part 1 wraps, bestie β the function documentation is coming up next and it's a whole other vibe, so stay tuned π
β¨ Function Documentation β¨
okay bestie, this is where the actual functions live. buckle up, it's giving big-endian conversion realness π
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-endian format. and GRIB2 does negative numbers in its own iconic little 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! π
This function takes the excitement out of GRIB2 negative numbers. no cap.
Parameters
fβ Pointer to the openFILE.writeβ Non-zero if function should write, otherwise function will read.g2ctypeβ The type to be read or written.varβ Pointer to the int to be written, or pointer to the storage that gets the int read.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett
Date
11/7/22
Definition at line
Definition at line 41 of file g2cio.c.
References
BITSHIFT_15BITSHIFT_31BITSHIFT_63BITSHIFT_7EIGHT_BYTESFOUR_BYTESG2C_BYTEG2C_EBADTYPEG2C_EFILEG2C_EINVALG2C_INTG2C_INT64G2C_NOERRORG2C_SHORTG2C_UBYTEG2C_UINTG2C_UINT64G2C_USHORThton64ntoh64ONE_BYTETWO_BYTES
Referenced by
g2c_file_io_byte()g2c_file_io_int()g2c_file_io_longlong()g2c_file_io_short()g2c_file_io_ubyte()g2c_file_io_uint()g2c_file_io_ulonglong()g2c_file_io_ushort()
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-endian format, and special GRIB2 handling of negative numbers. it's giving byte-sized drama π¦
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the byte.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 316 of file g2cio.c.
References
G2C_BYTEg2c_file_io()
Referenced by
g2c_file_io_template()
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 and big-endian format, and special GRIB2 handling of negative numbers. literally the int of it all β¨
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the int.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/7/22
Definition at line
Definition at line 230 of file g2cio.c.
References
g2c_file_io()G2C_INT
Referenced by
g2c_file_io_template()
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 big-endian format, and special GRIB2 handling of negative numbers. big int energy, fr fr π
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the long long.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 359 of file g2cio.c.
References
g2c_file_io()G2C_INT64
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-endian format, and special GRIB2 handling of negative numbers. short king behavior π
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the short.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 273 of file g2cio.c.
References
g2c_file_io()G2C_SHORT
Referenced by
g2c_file_io_template()g2c_rw_section1_metadata()g2c_start_index_record()g2c_start_index_record_lf()
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 between native and big-endian format, and handling of GRIB negative numbers. This is for template values. π
With template values, if the map value is negative, then the template value may be negative.
Parameters
fβ Pointer to the openFILE.rw_flagβ Non-zero if function should write, otherwise function will read.mapβ The map value for this template item.template_valueβ Pointer to the template value to be written, or pointer to the storage that gets the templage value read.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/7/22
Definition at line
Definition at line 408 of file g2cio.c.
References
FOUR_BYTESG2C_EBADTEMPLATEg2c_file_io_byte()g2c_file_io_int()g2c_file_io_short()g2c_file_io_ubyte()g2c_file_io_uint()g2c_file_io_ushort()G2C_NOERRORONE_BYTETWO_BYTES
Referenced by
g2c_rw_section3_metadata()g2c_rw_section4_metadata()g2c_rw_section5_metadata()
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 big-endian format. unsigned and unbothered πΈ
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the unsigned byte.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 337 of file g2cio.c.
References
g2c_file_io()G2C_UBYTE
Referenced by
g2c_file_io_template()g2c_open_index()g2c_rw_section1_metadata()g2c_rw_section3_metadata()g2c_rw_section6_metadata()g2c_start_index1_record()g2c_start_index_record()g2c_start_index_record_lf()g2c_write_index()read_msg_metadata()
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 and big-endian format. no negative numbers, just vibes β¨
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the unsigned int.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/7/22
Definition at line
Definition at line 251 of file g2cio.c.
References
g2c_file_io()G2C_UINT
Referenced by
g2c_file_io_template()g2c_open_index()g2c_rw_section1_metadata()g2c_rw_section3_metadata()g2c_rw_section5_metadata()g2c_start_index1_record()g2c_start_index_record()g2c_start_index_record_lf()g2c_write_index()read_msg_metadata()
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 and big-endian format. huge unsigned energy, bestie π
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the unsigned long long.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 380 of file g2cio.c.
References
g2c_file_io()G2C_UINT64
Referenced by
g2c_start_index_record()g2c_start_index_record_lf()
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 big-endian format. short but unsigned, a whole mood π
Parameters
fβ Pointer to the open GRIB2FILE.writeβ Non-zero to write, zero to read.varβ Pointer to the unsigned short.
Returns
:: G2C_NOERRORβ No error.:: G2C_EINVALβ Invalid input.:: G2C_EFILEβ Error reading/writing file.
Author
Ed Hartnett 11/13/22
Definition at line
Definition at line 294 of file g2cio.c.
References
g2c_file_io()G2C_USHORT
Referenced by
g2c_file_io_template()g2c_rw_section3_metadata()g2c_rw_section4_metadata()g2c_rw_section5_metadata()
Author
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
byeee bestie, this was NCEPLIBS-g2c Version 2.3.0, page g2cio.c(3) πβ¨
π¦ where this page comes from
- ubuntu resolute: libg2c-dev 2.3.0-4 Β· LGPL-3.0-only
- ubuntu stonking: libg2c-dev 2.3.0-7 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms