---
name: "g2cutil.c"
section: "3"
platform: "linux"
package: "libg2c-dev"
version: "2.1.0-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/g2cutil.c"
---

# g2cutil.c(3)

Internal utility functions for the NCEPLIBS-g2c library for the new g2c API.

## NAME

g2cutil.c - Internal utility functions for the NCEPLIBS-g2c library for the new g2c API.

## SYNOPSIS

`#include 'grib2_int.h'`\
 `#include <stdarg.h>`\

### Functions

int **g2c\_log\_file** (int g2cid)\
 Print a summary of the contents of an open GRIB2 file.  int **g2c\_log\_section** (**G2C\_SECTION\_INFO\_T** \*sec)\
 Log info about a section.  int **g2c\_log\_section1** (**G2C\_MESSAGE\_INFO\_T** \*msg)\
 Log section 0 information.  const char \* **g2c\_strerror** (int g2cerr)\
 Given an error code, return an error message.

### Variables

**G2C\_FILE\_INFO\_T** **g2c\_file** \[**G2C\_MAX\_FILES**+1\]\
 Global file information.  **G2C\_CODE\_TABLE\_T** \* **g2c\_table**\
 Pointer to the list of code tables.

## Detailed Description

Internal utility functions for the NCEPLIBS-g2c library for the new g2c API.

**Author**

Ed Hartnett

**Date**

Oct 11, 2023

Definition in file **g2cutil.c**.

## Function Documentation

### int g2c\_log\_file (int g2cid)

Print a summary of the contents of an open GRIB2 file. If the NCEPLIBS-g2c library is built without the LOGGING option, this function will do nothing.

**Parameters**

*g2cid* The file ID, returned by **g2c\_open()** or g2c\_create().

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_EBADID** g2cid not found.

**Author**

Ed Hartnett 8/22/22

Definition at line **189** of file **g2cutil.c**.

References **g2c\_message\_info::bytes\_in\_msg**, **g2c\_message\_info::bytes\_to\_msg**, **g2c\_message\_info::center**, **g2c\_message\_info::day**, **g2c\_csv\_init()**, **G2C\_EBADID**, **g2c\_file**, **g2c\_free\_tables()**, **g2c\_log\_section()**, **g2c\_log\_section1()**, **G2C\_NOERROR**, **g2c\_table**, **g2c\_message\_info::hour**, **g2c\_message\_info::local\_version**, **LOG**, **g2c\_message\_info::master\_version**, **g2c\_message\_info::minute**, **g2c\_message\_info::month**, **g2c\_message\_info::msg\_num**, **g2c\_message\_info::next**, **g2c\_section\_info::next**, **g2c\_message\_info::num\_fields**, **g2c\_message\_info::num\_local**, **g2c\_message\_info::sec**, **g2c\_message\_info::sec1\_len**, **g2c\_message\_info::second**, **g2c\_message\_info::sig\_ref\_time**, **g2c\_message\_info::status**, **g2c\_message\_info::subcenter**, **g2c\_message\_info::type**, and **g2c\_message\_info::year**.

Referenced by **read\_metadata()**.

### int g2c\_log\_section (G2C\_SECTION\_INFO\_T \* sec)

Log info about a section.

**Parameters**

*sec* Pointer to **G2C\_SECTION\_INFO\_T**.

**Returns**

- •

  **G2C\_NOERROR** No error.

**Author**

Ed Hartnett 10/20/22

Definition at line **152** of file **g2cutil.c**.

References **g2c\_section\_info::bytes\_to\_sec**, **g2c\_message\_info::discipline**, **G2C\_MAX\_NOAA\_ABBREV\_LEN**, **G2C\_NOERROR**, **g2c\_param\_abbrev()**, **LOG**, **g2c\_section\_info::msg**, **g2c\_section\_info::sec\_id**, **g2c\_section\_info::sec\_len**, **g2c\_section\_info::sec\_num**, and **g2c\_section\_info::template**.

Referenced by **g2c\_log\_file()**.

### int g2c\_log\_section1 (G2C\_MESSAGE\_INFO\_T \* msg)

Log section 0 information.

**Parameters**

*msg* Pointer to **G2C\_MESSAGE\_INFO\_T** which contains section 0 information.

**Returns**

- •

  **G2C\_NOERROR** No error.

**Author**

Ed Hartnett

**Date**

10/16/22

Definition at line **101** of file **g2cutil.c**.

References **g2c\_message\_info::center**, **g2c\_message\_info::day**, **g2c\_message\_info::discipline**, **g2c\_csv\_init()**, **g2c\_find\_desc()**, **G2C\_MAX\_GRIB\_DESC\_LEN**, **G2C\_NOERROR**, **g2c\_message\_info::hour**, **g2c\_message\_info::local\_version**, **LOG**, **g2c\_message\_info::master\_version**, **g2c\_message\_info::minute**, **g2c\_message\_info::month**, **g2c\_message\_info::second**, **g2c\_message\_info::sig\_ref\_time**, **g2c\_message\_info::status**, **g2c\_message\_info::subcenter**, **g2c\_message\_info::type**, and **g2c\_message\_info::year**.

Referenced by **g2c\_log\_file()**, and **g2c\_open\_index()**.

### const char \* g2c\_strerror (int g2cerr)

Given an error code, return an error message.

**Parameters**

*g2cerr* An error number returned by one of the g2c\_\* functions.

**Returns**

The error message.

**Author**

Ed Hartnett

Definition at line **29** of file **g2cutil.c**.

References **G2C\_EBADEND**, **G2C\_EBADID**, **G2C\_EBADSECTION**, **G2C\_EBADTEMPLATE**, **G2C\_EBADTYPE**, **G2C\_EFILE**, **G2C\_EINVAL**, **G2C\_EJPEG**, **G2C\_EMSG**, **G2C\_EMSGCOMPLETE**, **G2C\_ENAMETOOLONG**, **G2C\_ENOEND**, **G2C\_ENOMEM**, **G2C\_ENOMSG**, **G2C\_ENOPARAM**, **G2C\_ENOPRODUCT**, **G2C\_ENOSECTION**, **G2C\_ENOTEMPLATE**, **G2C\_ENOTFOUND**, **G2C\_ENOTGRIB**, **G2C\_ENOTGRIB2**, **G2C\_EPNG**, **G2C\_ETOOMANYFILES**, **G2C\_EXML**, and **G2C\_NOERROR**.

## Variable Documentation

### G2C\_FILE\_INFO\_T g2c\_file\[G2C\_MAX\_FILES+1\]` [extern]`

Global file information.

Definition at line **10** of file **g2cfile.c**.

Referenced by **find\_available\_g2cid()**, **free\_metadata()**, **g2c\_add\_file()**, **g2c\_close()**, **g2c\_find\_msg2()**, **g2c\_get\_msg()**, **g2c\_log\_file()**, **g2c\_seekmsg()**, and **read\_metadata()**.

### G2C\_CODE\_TABLE\_T\* g2c\_table` [extern]`

Pointer to the list of code tables.

Definition at line **16** of file **g2ccsv.c**.

Referenced by **g2c\_csv\_init()**, **g2c\_find\_desc\_str()**, **g2c\_find\_table()**, **g2c\_free\_tables()**, **g2c\_log\_file()**, and **g2c\_print\_tables()**.

## Author

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
