util.c(3)
π util.c β NAME π
okay so bestie, welcome to util.c β it's the internal utility functions for the g2c library. that's it, that's the vibe. it's the lil backstage crew that keeps the whole show running, and we're gonna meet every single one of them. no skips. β¨
(it's a section 3 manual page from the Library Functions Manual, iykyk π )
π¦ SYNOPSIS πΈ
#include 'grib2_int.h'
#include <stdarg.h>
β Functions β
EXTERN_MUTEX (m)β if pthreads are enabled, use externally-defined mutex for thread-safety. that's the whole thing. tiny but mighty. πͺ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 (m )
If pthreads are enabled, use externally-defined mutex for thread-safety.
that's it bestie, that's the function. short queen behavior. π
π§ int g2c_check_msg (unsigned char * cgrib, g2int * lencurr, int verbose, int from)
okay so this one actually does stuff. Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already terminated with '7777'.
now here's the spicy part: on rare occasions, the last 4 bytes of section 7 (the data section) can literally 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 πΈ
cgribβ Buffer that contains the GRIB message.lencurrβ Pointer that gets the length of the GRIB message.verboseβ If non-zero, print any error messages tostdout.fromβ Mapping of where this function was called from.1= Fromg2_addlocal()2= Fromg2_addgrid()3= Fromg2_addfield()4= Fromg2_gribend()
β Returns β
G2C_NOERRORβ No error.G2C_ENOTGRIBβ GRIB header not found.G2C_EMSGCOMPLETEβ GRIB message already complete.
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().
π int g2c_set_log_level (int new_level)
Use this to set the global log level. Settings, bestie, listen up:
-1turn off all logging.0show only errors.1output useful as verbose to utilities.2or3shows 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. π like, full ghost mode. zero effect. not a single log line. so don't come crying to me if it's silent, okay?? π
π Parameters π
new_levelβ The 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().
π Author π
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
and that's the whole page bestie!! this little manual page is from NCEPLIBS-g2c, and it's tagged as Version 2.3.0, dated... well, it's the util.c(3) page, section 3, and you just read all of it. π
slay. go log something. or don't, if logging wasn't enabled at build time. πβ¨
π¦ where this page comes from
- ubuntu resolute: libg2c-dev 2.3.0-4 Β· LGPL-3.0-only
- ubuntu stonking: libg2c-dev 2.3.0-7 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms