g2cio.c(3)

πŸ“¦
version 2.3.0 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 open FILE.
  • 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_15
  • BITSHIFT_31
  • BITSHIFT_63
  • BITSHIFT_7
  • EIGHT_BYTES
  • FOUR_BYTES
  • G2C_BYTE
  • G2C_EBADTYPE
  • G2C_EFILE
  • G2C_EINVAL
  • G2C_INT
  • G2C_INT64
  • G2C_NOERROR
  • G2C_SHORT
  • G2C_UBYTE
  • G2C_UINT
  • G2C_UINT64
  • G2C_USHORT
  • hton64
  • ntoh64
  • ONE_BYTE
  • TWO_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 GRIB2 FILE.
  • 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_BYTE
  • g2c_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 GRIB2 FILE.
  • 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 GRIB2 FILE.
  • 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 GRIB2 FILE.
  • 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 open FILE.
  • 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_BYTES
  • G2C_EBADTEMPLATE
  • g2c_file_io_byte()
  • g2c_file_io_int()
  • g2c_file_io_short()
  • g2c_file_io_ubyte()
  • g2c_file_io_uint()
  • g2c_file_io_ushort()
  • G2C_NOERROR
  • ONE_BYTE
  • TWO_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 GRIB2 FILE.
  • 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 GRIB2 FILE.
  • 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 GRIB2 FILE.
  • 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 GRIB2 FILE.
  • 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