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

# g2\_unpack2.c(3)

Unpack Section 2 (Local Use Section) of a GRIB2 message.

## NAME

g2\_unpack2.c - Unpack Section 2 (Local Use Section) of a GRIB2 message.

## SYNOPSIS

`#include 'grib2_int.h'`\
 `#include <stdio.h>`\
 `#include <stdlib.h>`\

### Functions

**g2int** **g2\_unpack2** (unsigned char \*cgrib, **g2int** \*iofst, **g2int** \*lencsec2, unsigned char \*\*csec2)\
 Unpack `Section 2 (Local Use Section)` of a GRIB2 message.

## Detailed Description

Unpack Section 2 (Local Use Section) of a GRIB2 message.

**Author**

Stephen Gilbert

**Date**

2002-10-31

Definition in file **g2\_unpack2.c**.

## Function Documentation

### g2int g2\_unpack2 (unsigned char \* cgrib, g2int \* iofst, g2int \* lencsec2, unsigned char \*\* csec2)

Unpack `Section 2 (Local Use Section)` of a GRIB2 message.

### Program History Log

Date   Programmer   Comments    2002-10-31   Gilbert   Initial    2008-12-23   Wesley   Initialize lencsec2 Length of Local Use data    2010-08-05   Vuong   If section 2 has zero length, ierr=0

**Parameters**

*cgrib* char array containing Section 2 of the GRIB2 message. \
 *iofst* Pointer that contains the bit offset for the beginning of Section 2 in cgrib. The modified version will be returned. \
 *lencsec2* Length (in octets) of Local Use data. \
 *csec2* Pointer to a pointer that will get an allocated array containing local use data. This memory must be freed by the caller.

**Returns**

- •

  **G2\_NO\_ERROR** No error.

- •

  **G2\_UNPACK\_BAD\_SEC** Array passed had incorrect section number.

- •

  **G2\_UNPACK\_NO\_MEM** Memory allocation error.

**Author**

Stephen Gilbert

**Date**

2002-10-31

Definition at line **37** of file **g2\_unpack2.c**.

References **G2\_NO\_ERROR**, **G2\_UNPACK\_BAD\_SEC**, **G2\_UNPACK\_NO\_MEM**, and **gbit()**.

Referenced by **g2\_getfld()**.

## Author

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