gbits.c(3)
gbits.c π β bestie's guide to packing & unpacking bits β¨
okay so this is a page from the Library Functions Manual (yes, that kind of manual, the gbits.c(3) one) and it's literally all about cramming numbers into bit strings and pulling them back out again. no cap. let's get into it π«Ά
πΈ NAME πΈ
gbits.c β functions to pack and unpack bits to/from a packed bit string.
β¨ SYNOPSIS β¨
#include 'grib2_int.h'
π Functions π
void g2c_gbit_int (unsigned char *in, int *iout, int iskip, int nbits)β extract arbitrary size values from a packed bit string, right justifying each value in the unpackedioutarray.int g2c_gbits_int (unsigned char *in, int *iout, int iskip, int nbits, int nskip, int n)β extract arbitrary size values from a packed bit string, right justifying each value in the unpackedioutarray.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 unpackedioutarray.void gbits (unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)β unpack arbitrary size values from a packed bit string, right justifying each value in the unpackedioutarray.void sbit (unsigned char *out, g2int *in, g2int iskip, g2int nbits)β store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.void sbits (unsigned char *out, g2int *in, g2int nbits, g2int nskip, g2int n)β store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
wait no, let me not do that to you π the last one is:
void sbits (unsigned char *out, g2int *in, g2int iskip, g2int nbits, g2int nskip, g2int n)β store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
ok phew. anyway π
π¦ Detailed Description π¦
functions to pack and unpack bits to/from a packed bit string. that's the whole vibe. it's giving bit-shuffling excellence β¨
Author: NOAA Programmer
Definition in file gbits.c.
π Function Documentation π
π void g2c_gbit_int (unsigned char * in, int * iout, int iskip, int nbits)
extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array. this is similar to gbit(), but with int types instead of g2int. so like, the same energy but a glow-up on the types π
Parameters
inβ pointer to character array input.ioutβ pointer that gets the unpacked array output.iskipβ initial number of bits to skip.nbitsβ number of bits to take.
Author: NOAA Programmer
Definition at line 113 of file gbits.c.
References g2c_gbits_int().
π int g2c_gbits_int (unsigned char * in, int * iout, int iskip, int nbits, int nskip, int n)
extract arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array. this is similar to gbits(), but with int types instead of g2int. twin but make it int fr fr π«Ά
Parameters
inβ Pointer to character array input.ioutβ Pointer that gets the unpacked array output.iskipβ Initial number of bits to skip.nbitsβ Number of bits to take.nskipβ Additional number of bits to skip on each iteration.nβ Number of iterations.
Returns
G2C_NOERRORβ No error.G2C_ENOMEMβ Out of memory.
Author: Ed Hartnett
Date: 8/31/22
Definition at line 137 of file gbits.c.
References G2C_EINVAL, G2C_ENOMEM, G2C_NOERROR, and gbits().
Referenced by g2c_gbit_int().
β 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 array. the O.G. version. iconic, honestly π
Parameters
inβ pointer to character array input.ioutβ pointer that gets the unpacked array output.iskipβ initial number of bits to skip.nbitsβ number of bits to take.
Author: NOAA Programmer
Definition at line 20 of file gbits.c.
References gbits().
Referenced by comunpack(), g2_addfield(), g2_addgrid(), g2_addlocal(), g2_getfld(), g2_gribend(), g2_info(), g2_unpack1(), g2_unpack2(), g2_unpack3(), g2_unpack4(), g2_unpack5(), g2_unpack6(), g2c_check_msg(), g2c_unpack7_int(), and seekgb().
not it being referenced by SIXTEEN other functions π main character energy fr
π§ void gbits (unsigned char * in, g2int * iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array. this is the one that does the actual heavy lifting, lowkey the backbone of the whole file π
Parameters
inβ Pointer to character array input.ioutβ Pointer that gets the unpacked array output.iskipβ Initial number of bits to skip.nbitsβ Number of bits to take.nskipβ Additional number of bits to skip on each iteration.nβ Number of iterations.
Author: NOAA Programmer
Definition at line 57 of file gbits.c.
Referenced by aecunpack_int(), comunpack(), g2_unpack3(), g2_unpack4(), g2_unpack6(), g2c_gbits_int(), gbit(), pngunpack_int(), simunpack(), and specunpack().
π void sbit (unsigned char * out, g2int * in, g2int iskip, g2int nbits)
store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array. this is the packer β it's the reverse direction bestie, we're SQUISHING now π«Έβ¨
Parameters
outβ Pointer to packed array output. Must be allocated large enough to hold output.inβ Pointer that gets the unpacked array input.iskipβ Initial number of bits to skip.nbitsβ Number of bits to pack.
Author: NOAA Programmer
Definition at line 38 of file gbits.c.
References sbits().
Referenced by compack(), g2_addfield(), g2_addgrid(), g2_addlocal(), g2_create(), g2_gribend(), misspack(), and simpack().
πΈ void sbits (unsigned char * out, g2int * in, g2int iskip, g2int nbits, g2int nskip, g2int n)
store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array. the full-service packing experience, skips and iterations included π
Parameters
outβ Pointer to packed array output. Must be allocated large enough to hold output.inβ Pointer that gets the unpacked array input.iskipβ Initial number of bits to skip.nbitsβ Number of bits to pack.nskipβ Additional number of bits to skip on each iteration.nβ Number of iterations.
Author: NOAA Programmer
Definition at line 178 of file gbits.c.
Referenced by aecpack_int(), compack(), g2_addfield(), g2_addgrid(), jpcpack_int(), misspack(), pngpack_int(), sbit(), and simpack().
π« Author π«
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
okay and that's the whole page bestie, no crumbs left π this one came from NCEPLIBS-g2c, Version 2.3.0, and it's the gbits.c(3) page β go pack some bits, you absolute legend πβ¨π¦
π¦ 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