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

# doc(3)

This file reads the GRIB2 CSV files.

Part of [g2ccsv.c(3)](/g2ccsv.c/3.md).

## NAME

g2ccsv.c - This file reads the GRIB2 CSV files.

## SYNOPSIS

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

### Functions

int **g2c\_csv\_init** ()\
 Initialize tables from 'CodeFlag.txt'.  static char \* **g2c\_csv\_strsep** (char \*\*stringp, const char \*delim)\
 Implementation of strsep for code portability.  int **g2c\_find\_desc** (char \*title, int code, char \*desc)\
 Given a table title and an integer code, find a description.  int **g2c\_find\_desc\_str** (char \*title, char \*code, char \*desc)\
 Given a table title and a code, find a description.  **G2C\_CODE\_ENTRY\_T** \* **g2c\_find\_entry** (char \*desc, **G2C\_CODE\_TABLE\_T** \*table)\
 Find an entry in a table given a description.  **G2C\_CODE\_TABLE\_T** \* **g2c\_find\_table** (char \*key)\
 Find a table given a key.  void **g2c\_free\_tables** ()\
 Free table memory.  void **g2c\_print\_tables** ()\
 Print the table data.

### Variables

FILE \* **doc**\
 Contains the parsed CSV document.  **G2C\_CODE\_TABLE\_T** \* **g2c\_table** = NULL\
 Pointer to the list of code tables.

## Detailed Description

This file reads the GRIB2 CSV files.

**Author**

Ed Hartnett

**Date**

8/25/22

Definition in file **g2ccsv.c**.

## Function Documentation

### int g2c\_csv\_init ()

Initialize tables from 'CodeFlag.txt'.

**Returns**

- •

  **G2C\_NOERROR** No error.

**Author**

Alyson Stahl

**Date**

8/2/24

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

References **doc**, **g2c\_csv\_strsep()**, **G2C\_ECSV**, **G2C\_ENAMETOOLONG**, **G2C\_ENOMEM**, **g2c\_find\_table()**, **G2C\_MAX\_GRIB\_CODE\_LEN**, **G2C\_MAX\_GRIB\_DESC\_LEN**, **G2C\_MAX\_GRIB\_LEVEL\_DESC\_LEN**, **G2C\_MAX\_GRIB\_STATUS\_LEN**, **G2C\_MAX\_GRIB\_TITLE\_LEN**, **G2C\_NOERROR**, and **g2c\_table**.

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

### static char \* g2c\_csv\_strsep (char \*\* stringp, const char \* delim)` [static]`

Implementation of strsep for code portability. Extracts first token in string given a delimiter.

**Parameters**

*stringp* The address of a pointer to string to be separated. This value is overwritten with the value past the delimiter. \
 *delim* Characters that delimit the tokens.

**Author**

Alyson Stahl

**Date**

11/6/24

**Returns**

a pointer to the original value of stringp

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

Referenced by **g2c\_csv\_init()**.

### int g2c\_find\_desc (char \* title, int code, char \* desc)

Given a table title and an integer code, find a description.

**Parameters**

*title* Title of table. \
 *code* Code to search for as an int. \
 *desc* Pointer that gets a copy of the description. Must be allocated to **G2C\_MAX\_GRIB\_DESC\_LEN** + 1.

**Author**

Ed Hartnett

**Date**

8/28/22

**Returns**

0 for success, error code otherwise.

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

References **g2c\_find\_desc\_str()**, and **G2C\_MAX\_GRIB\_CODE\_LEN**.

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

### int g2c\_find\_desc\_str (char \* title, char \* code, char \* desc)

Given a table title and a code, find a description.

**Parameters**

*title* Title of table. \
 *code* Code to search for. \
 *desc* Pointer that gets a copy of the description. Must be allocated to **G2C\_MAX\_GRIB\_DESC\_LEN** + 1.

**Author**

Ed Hartnett

**Date**

8/28/22

**Returns**

0 for success, error code otherwise.

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

References **G2C\_EINVAL**, **G2C\_ENOTFOUND**, **G2C\_MAX\_GRIB\_CODE\_LEN**, **G2C\_MAX\_GRIB\_TITLE\_LEN**, **G2C\_NOERROR**, and **g2c\_table**.

Referenced by **g2c\_find\_desc()**.

### G2C\_CODE\_ENTRY\_T \* g2c\_find\_entry (char \* desc, G2C\_CODE\_TABLE\_T \* table)

Find an entry in a table given a description.

**Parameters**

*desc* The description of the entry to find. \
 *table* A pointer to the table to search.

**Author**

Ed Hartnett

**Date**

8/29/22

**Returns**

a pointer to the matching entry, or NULL if not found.

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

References **G2C\_MAX\_GRIB\_DESC\_LEN**.

### G2C\_CODE\_TABLE\_T \* g2c\_find\_table (char \* key)

Find a table given a key.

**Parameters**

*key* The table title to find.

**Author**

Ed Hartnett

**Date**

8/28/22

**Returns**

a pointer to the matching code table, or NULL if not found.

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

References **G2C\_MAX\_GRIB\_TITLE\_LEN**, and **g2c\_table**.

Referenced by **g2c\_csv\_init()**.

### void g2c\_free\_tables ()

Free table memory.

**Author**

Ed Hartnett

**Date**

8/28/22

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

References **g2c\_table**.

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

### void g2c\_print\_tables ()

Print the table data.

**Author**

Ed Hartnett

**Date**

8/28/22

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

References **g2c\_table**.

## Variable Documentation

### FILE\* doc

Contains the parsed CSV document.

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

Referenced by **g2c\_csv\_init()**.

### G2C\_CODE\_TABLE\_T\* g2c\_table = NULL

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.
