31 printf(
"%s\n", t->title);
32 for (e = t->entry; e; e = e->next)
33 printf(
"code %s desc %s status %s\n", e->code, e->desc, e->status);
59 for (e = t->entry; e; e = e_next)
94 for (t =
g2c_table; !found && t; t = t->next)
96 if (!strncmp(title, t->title, strlen(title)))
101 for (e = t->entry; e; e = e->next)
103 if (!strncmp(code, e->code, strlen(code)))
105 strcpy(desc, e->desc);
135 sprintf(str_code,
"%d", code);
173 for (e = table->entry; e; e = e->next)
191 const int max_line_size = 500;
192 const int num_columns = 9;
194 char *buf, *tmp, *key;
195 char line[max_line_size];
205 if (!(
doc = fopen(
"CodeFlag.txt",
"r")))
209 buf = fgets(line, max_line_size,
doc);
213 while ((buf = fgets(line, max_line_size,
doc)) != NULL)
216 while (buf != NULL && i < num_columns)
222 tmp = strsep(&buf,
"\"");
223 tmp = strsep(&buf,
"\"");
224 key = strdup((
const char *)tmp);
225 tmp = strsep(&buf,
",");
229 tmp = strsep(&buf,
",");
230 key = strdup((
const char *)tmp);
243 my_table = new_table;
263 for (e = my_table->entry; e->next; e = e->next)
268 my_table->entry = new_entry;
302 for (; g->next; g = g->next)
FILE * doc
Contains the parsed CSV document.
int g2c_find_desc_str(char *title, char *code, char *desc)
Given a table title and a code, find a description.
int g2c_find_desc(char *title, int code, char *desc)
Given a table title and an integer code, find a description.
int g2c_csv_init()
Initialize tables from "CodeFlag.txt".
G2C_CODE_TABLE_T * g2c_find_table(char *key)
Find a table given a key.
void g2c_free_tables()
Free table memory.
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_table
Pointer to the list of code tables.
void g2c_print_tables()
Print the table data.
#define G2C_MAX_GRIB_TITLE_LEN
Maximum length of code table title.
#define G2C_MAX_GRIB_DESC_LEN
Maximum length of code description.
#define G2C_ECSV
CSV error.
#define G2C_ENAMETOOLONG
Name too long.
#define G2C_ENOMEM
Out of memory.
#define G2C_ENOTFOUND
Table or entry not found.
#define G2C_MAX_GRIB_STATUS_LEN
Maximum length of code status.
#define G2C_EINVAL
Invalid input.
#define G2C_MAX_GRIB_CODE_LEN
Maximum length of code.
#define G2C_MAX_GRIB_LEVEL_DESC_LEN
Maximum length of level description.
#define G2C_NOERROR
No error.
Header file with internal function prototypes NCEPLIBS-g2c library.
An entry in a GRIB2 code table.