43 unsigned char G = 0x47;
44 unsigned char R = 0x52;
45 unsigned char I = 0x49;
46 unsigned char B = 0x42;
47 unsigned char seven = 0x37;
50 static int last_from = 0;
52 assert(cgrib && lencurr);
55 if (cgrib[0] != G || cgrib[1] != R || cgrib[2] != I || cgrib[3] != B)
58 printf(
"GRIB not found in given message. A call to routine g2_create() "
59 "is required to to initialize GRIB messge.\n");
68 gbit(cgrib, lencurr, 96, 32);
71 if (cgrib[*lencurr - 4] == seven && cgrib[*lencurr - 3] == seven &&
72 cgrib[*lencurr - 2] == seven && cgrib[*lencurr - 1] == seven)
76 if (from == 4 && last_from == 3)
83 printf(
"GRIB message already complete. Cannot add new section.\n");
100int g2_log_level = -1;
117g2_log(
int severity,
const char *fmt, ...)
125 if (severity > g2_log_level)
131 fprintf(f,
"ERROR: ");
132 for (t = 0; t < severity; t++)
137 vfprintf(f, fmt, argp);
169 g2_log_level = new_level;
171 LOG((1,
"log_level changed to %d", g2_log_level));
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout ...
#define G2C_ENOTGRIB
GRIB header not found.
#define G2C_EMSGCOMPLETE
GRIB message already complete.
int64_t g2int
Long integer type.
#define G2C_NOERROR
No error.
Header file with internal function prototypes NCEPLIBS-g2c library.
#define MUTEX_UNLOCK(m)
Pthreads not enabled, so do nothing.
#define LOG(e)
Ignore logging to stdout.
#define MUTEX_LOCK(m)
Pthreads not enabled, so do nothing.
#define EXTERN_MUTEX(m)
Pthreads not enabled, so do nothing.
int g2c_set_log_level(int new_level)
Use this to set the global log level.
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 termi...