NCEPLIBS-g2c 2.3.0
Loading...
Searching...
No Matches
util.c File Reference

Internal utility functions for the g2c library. More...

#include "grib2_int.h"
#include <stdarg.h>

Go to the source code of this file.

Functions

 EXTERN_MUTEX (m)
 If pthreads are enabled, use externally-defined mutex for thread-safety.
int g2c_check_msg (unsigned char *cgrib, g2int *lencurr, int verbose, int from)
 Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already terminated with '7777'.
int g2c_set_log_level (int new_level)
 Use this to set the global log level.

Detailed Description

Internal utility functions for the g2c library.

Author
Ed Hartnett
Date
Nov 11, 2021

Definition in file util.c.

Function Documentation

◆ EXTERN_MUTEX()

EXTERN_MUTEX ( m )

If pthreads are enabled, use externally-defined mutex for thread-safety.

◆ g2c_check_msg()

int g2c_check_msg ( unsigned char * cgrib,
g2int * lencurr,
int verbose,
int from )

Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already terminated with '7777'.

On rare occasions, the last 4 bytes of section 7 (data section) can be the GRIB terminating string of '7777'. This function accommodates for this by tracking which function called g2c_check_msg() via the from argument (see below).

Parameters
cgribBuffer that contains the GRIB message.
lencurrPointer that gets the length of the GRIB message.
verboseIf non-zero, print any error messages to stdout.
fromMapping of where this function was called from.
Returns
Author
Ed Hartnett
Date
Nov 11, 2021
Author
Eric Engle

Definition at line 41 of file util.c.

References G2C_EMSGCOMPLETE, G2C_ENOTGRIB, G2C_NOERROR, gbit(), MUTEX_LOCK, and MUTEX_UNLOCK.

Referenced by g2_addfield(), g2_addgrid(), g2_addlocal(), and g2_gribend().

◆ g2c_set_log_level()

int g2c_set_log_level ( int new_level)

Use this to set the global log level.

Settings:

  • -1 turn off all logging.
  • 0 show only errors.
  • 1 output useful as verbose to utilities.
  • 2 or 3 shows some/all calls to top-level functions.
  • 4+ ever greater levels of detail.

If logging is not enabled when building NCEPLIBS-g2c, this function will do nothing.

Parameters
new_levelThe new logging level.
Returns
G2C_NOERROR No error.
Author
Ed Hartnett

Definition at line 165 of file util.c.

References G2C_NOERROR, and LOG.

Referenced by main().