bufr2synop 0.24.0
bufrdeco_utils.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2017 by Guillermo Ballester Valor *
3 * gbv@ogimet.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20/*!
21 \file bufrdeco_utils.c
22 \brief This file has the code of useful routines for library bufrdeco
23*/
24#include "bufrdeco.h"
25
26uint8_t bitf[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; /*!< Mask a single bit of a byte */
27uint8_t biti[8] = {0xFF,0x7f,0x3f,0x1F,0x0F,0x07,0x03,0x01}; /*!< Mask remaining bits in a byte (less significant) */
28uint8_t bitk[8] = {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; /*!< Mask first bits in a byte (most significant) */
29
30/*!
31 \fn size_t get_bits_as_char_array ( char *target, uint8_t *has_data, uint8_t *source, size_t *bit0_offset, size_t bit_length )
32 \brief Get a string from an array of bits
33 \param target string as result
34 \param has_data Output flags to check whether is missing data. If 0 then data is missing, othewise has data
35 \param source array of uint8_t elements. Most significant bit of first element is the bit offest reference
36 \param bit0_offset Bit offset
37 \param bit_length Lenght (in bits) for the chunck to extract
38 \return If returns the amount of bits readed. 0 if problems. It also update bits_offset with the new bits.
39*/
40buf_t get_bits_as_char_array2 ( char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length )
41{
42 buf_t i, j;
43 buf_t r, d, nc;
44 uint8_t *c;
45
46 //bufrdeco_assert (has_data != NULL && source != NULL && target != NULL && bit0_offset != NULL);
47
48 if ( bit_length % 8 )
49 return 0; // bit_length needs to be divisible by 8
50
51 nc = bit_length / 8;
52 *has_data = 0; // marc if no missing data is present
53 for ( j = 0; j < nc ; j++ )
54 {
55 r = 8;
56 d = 0;
57 * ( target + j ) = 0;
58 do
59 {
60 c = source + ( *bit0_offset + d ) / 8;
61 i = ( *bit0_offset + d ) % 8;
62 if ( *c & bitf[i] )
63 * ( target + j ) += ( 1U << ( r - 1 ) );
64 else
65 *has_data = 1;
66 d += 1;
67 r -= 1;
68 }
69 while ( r > 0 );
70 *bit0_offset += 8; // update bit0_offset
71 }
72 * ( target + nc ) = '\0';
73 return bit_length;
74}
75
76/*!
77 \fn size_t get_bits_as_char_array ( char *target, uint8_t *has_data, uint8_t *source, size_t *bit0_offset, size_t bit_length )
78 \brief get a sequence of bits in data section 4 from a BUFR reports to get an array of chars
79 \param target string with the resulting array
80 \param has_data if 1 then has data, if 0 what we got is missing data
81 \param source buffer of uint8_t which is actually the data section 4.
82 \param bit0_offset bit offset of first bit of first char
83 \param bit_length number of bits to extract. Obviously this will be divisible by 8
84 \return If returns the amount of bits readed. 0 if problems. It also update bit0_offset with the new bits.
85*/
86buf_t get_bits_as_char_array ( char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length )
87{
88 buf_t i, j, k;
89 buf_t nc;
90 uint8_t *c;
91
92 //bufrdeco_assert (has_data != NULL && source != NULL && target != NULL && bit0_offset != NULL);
93
94 if ( bit_length % 8 )
95 return 0; // bit_length needs to be divisible by 8
96
97 //printf("bit_length=%lu\n", bit_length);
98
99 nc = bit_length / 8;
100 i = ( *bit0_offset ) % 8;
101 k = 8 - i;
102 *has_data = 0; // marc if no missing data is present
103 for ( j = 0; j < nc ; j++ )
104 {
105 c = source + ( *bit0_offset ) / 8;
106 * ( target + j ) = ( *c & biti[i] );
107 if ( i )
108 {
109 * ( target + j ) <<= i;
110 * ( target + j ) |= ( ( * ( c + 1 ) & bitk[i - 1] ) >> k );
111 }
112 if ( * ( target + j ) != -1 )
113 *has_data = 1;
114 //printf("%c", * ( target + j ) );
115 *bit0_offset += 8; // update bit0_offset
116 }
117 * ( target + nc ) = '\0';
118 return bit_length;
119}
120
121/*!
122 \fn size_t get_bits_as_uint32_t2 ( uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length )
123 \brief Read bits from an array of uint8_t and set them as an uint32_t
124 \param target uint32_t pointer where to set the result
125 \param has_data Output flags to check whether is missing data. If 0 then data is missing, othewise has data
126 \param source array of uint8_t elements. Most significant bit of first element is the bit offset reference
127 \param bit0_offset Bit offset
128 \param bit_length Lenght (in bits) for the chunck to extract
129 \return If returns the amount of bits readed. 0 if problems. It also update bits_offset with the new bits.
130
131 This is a version which extract bit a bit. For more than about 8 bits should be used the algorithm in
132 \ref get_bits_as_uint32_t
133
134*/
135uint32_t get_bits_as_uint32_t2 ( uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length )
136{
137 buf_t i;
138 buf_t r, d;
139 uint8_t *c;
140
141 //bufrdeco_assert (has_data != NULL && source != NULL && target != NULL && bit0_offset != NULL);
142
143 if ( bit_length > 32 || bit_length == 0 )
144 return 0;
145
146 r = bit_length;
147 d = 0;
148 *target = 0;
149 *has_data = 0;
150
151 do
152 {
153 c = source + ( *bit0_offset + d ) / 8;
154 i = ( *bit0_offset + d ) % 8;
155 if ( *c & bitf[i] )
156 *target += ( 1U << ( r - 1 ) );
157 else
158 *has_data = 1;
159 d += 1;
160 r -= 1;
161 }
162 while ( r > 0 );
163 *bit0_offset += bit_length; // update bit0_offset
164
165 return bit_length;
166}
167
168
169/*!
170 \fn size_t get_bits_as_uint32_t ( uint32_t *target, uint8_t *has_data, uint8_t *source, size_t *bit0_offset, size_t bit_length )
171 \brief Read bits from an array of uint8_t and set them as an uint32_t
172 \param target uint32_t pointer where to set the result
173 \param has_data Output flags to check whether is missing data. If 0 then data is missing, othewise has data
174 \param source array of uint8_t elements. Most significant bit of first element is the bit offset reference
175 \param bit0_offset Bit offset
176 \param bit_length Lenght (in bits) for the chunck to extract
177 \return If returns the amount of bits readed. 0 if problems. It also update bits_offset with the new bits.
178
179 If bil_length is less than 8 then it uses version 2 \ref get_bits_as_uint32_t2
180
181*/
182uint32_t get_bits_as_uint32_t ( uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length )
183{
184 int i;
185 uint8_t *c;
186 uint64_t x;
187
188 //bufrdeco_assert (has_data != NULL && source != NULL && target != NULL && bit0_offset != NULL);
189
190 if ( bit_length > 32 || bit_length == 0 )
191 return 0;
192
193 if ( bit_length < 8 )
194 return get_bits_as_uint32_t2 ( target, has_data, source, bit0_offset, bit_length );
195
196 *target = 0;
197 *has_data = 0; // marc if no missing data is present
198 c = source + ( *bit0_offset ) / 8;
199 i = ( *bit0_offset ) % 8;
200 x = ( ( uint64_t ) ( *c & biti[i] ) << 32 ) + ( ( uint64_t ) ( * ( c + 1 ) ) << 24 ) + ( ( uint64_t ) ( * ( c + 2 ) ) << 16 ) +
201 ( ( uint64_t ) ( * ( c + 3 ) ) << 8 ) + ( uint64_t ) ( * ( c + 4 ) ); // 40 - i bits
202 x >>= ( 40 - i - bit_length );
203 *target = ( uint32_t ) x;
204 if ( ( 1UL << bit_length ) != ( x + 1UL ) )
205 *has_data = 1;
206
207 *bit0_offset += bit_length; // update bit0_offset
208 return bit_length;
209}
210
211
212/*!
213 \fn int get_table_b_reference_from_uint32_t ( int32_t *target, uint8_t bits, uint32_t source )
214 \brief Get an int32_t from bits according with bufr criteria to change the reference of a descritor. Most significant bit in source is sign
215 \param target int32_t as result
216 \param bits number of bits to consider
217 \param source uint32_T with the data to transform
218 \return If success return 0, 1 otherwise
219*/
220// most significant of bits is the sign
221int get_table_b_reference_from_uint32_t ( int32_t *target, uint8_t bits, uint32_t source )
222{
223 uint32_t mask = 1;
224
225 //bufrdeco_assert (target != NULL);
226
227
228 if ( bits > 32 || bits == 0 )
229 return 1;
230
231 if ( bits > 1 )
232 mask = ( ( uint32_t ) 1 << ( bits - 1 ) );
233
234 if ( mask & source )
235 {
236 // case of negative number
237 *target = - ( int32_t ) ( source - mask );
238 }
239 else
240 *target = ( int32_t ) ( source );
241 return 0;
242}
243
244/*!
245 \fn uint32_t two_bytes_to_uint32(const uint8_t *source)
246 \brief returns the uint32_t value from an array of two bytes, most significant first
247 \param source pointer to source uint8_t
248 \return the uint32_t resulting
249*/
250uint32_t two_bytes_to_uint32 ( const uint8_t *source )
251{
252
253 //bufrdeco_assert (source != NULL);
254
255 return ( ( uint32_t ) source[1] + ( uint32_t ) source[0] * 256 );
256}
257
258
259/*!
260 \fn uint32_t three_bytes_to_uint32(const uint8_t *source)
261 \brief returns the uint32_t value from an array of three bytes, most significant first
262 \param source pointer to source uint8_t
263 \return the uint32_t resulting
264*/
265uint32_t three_bytes_to_uint32 ( const uint8_t *source )
266{
267 //bufrdeco_assert (source != NULL);
268 return ( ( uint32_t ) source[2] + ( uint32_t ) source[1] * 256 + ( uint32_t ) source[0] * 65536 );
269}
270
271/*!
272 \fn int uint32_t_to_descriptor(struct bufr_descriptor *d, uint32_t id)
273 \brief parse an integer with a descriptor fom bufr ECWMF libary
274 \param d pointer to a struct \ref bufr_descriptor where to set the result on output
275 \param id integer with the descriptor from ewcwf
276 \return the resulting uint32_t
277*/
278int uint32_t_to_descriptor ( struct bufr_descriptor *d, uint32_t id )
279{
280 //bufrdeco_assert (d != NULL);
281
282 d->f = id / 100000;
283 d->x = ( id % 100000 ) / 1000;
284 d->y = id % 1000;
285 sprintf ( d->c, "%06u", id );
286 return 0;
287}
288
289/*!
290 \fn int two_bytes_to_descriptor (struct bufr_descriptor *d, const uint8_t *source)
291 \brief set a struct \ref bufr_descriptor from two consecutive bytes in bufr file
292 \param source pointer to first byte (most significant)
293 \param d pointer to the resulting descriptor
294
295 \return 0 if all is OK. 1 otherwise
296 */
297int two_bytes_to_descriptor ( struct bufr_descriptor *d, const uint8_t *source )
298{
299 //bufrdeco_assert (source != NULL && d != NULL);
300
301 d->y = source[1];
302 d->x = source[0] & 0x3f;
303 d->f = ( source[0] >> 6 ) & 0x03;
304 sprintf ( d->c, "%u%02u%03u", d->f, d->x, d->y );
305 return 0;
306}
307
308/*!
309 \fn char * bufr_charray_to_string(char *s, char *buf, size_t size)
310 \brief get a null termitated c-string from an array of unsigned chars
311 \param s resulting string
312 \param buf pointer to first element in array
313 \param size number of chars in array
314 \result the resulting s string
315*/
316char * bufr_charray_to_string ( char *s, char *buf, size_t size )
317{
318 //bufrdeco_assert (s != NULL && buf != NULL);
319
320 // copy
321 memcpy ( s , buf, size );
322 // add final string mark
323 s[size] = '\0';
324 return s;
325}
326
327/*!
328 \fn char * bufr_adjust_string(char *s)
329 \brief Supress trailing blanks of a string
330 \param s string to process
331 \result the resulting s string
332*/
333char * bufr_adjust_string ( char *s )
334{
335 size_t l;
336
337 //bufrdeco_assert (s != NULL);
338
339 l = strlen ( s );
340 while ( l && s[--l] == ' ' )
341 s[l] = '\0';
342 return s;
343}
344
345/*!
346 \fn int is_a_delayed_descriptor ( struct bufr_descriptor *d )
347 \brief check if a descriptor is a delayed descriptor
348 \param d pointer to a struct \ref bufr_descriptor to check
349 \return If is a delayed desccriptor return 1, 0 otherwise.
350*/
352{
353 //bufrdeco_assert (d != NULL);
354
355 if ( ( d->f == 0 ) &&
356 ( d->x == 31 ) &&
357 ( d->y == 1 || d->y == 2 || d->y == 11 || d->y == 12 ) )
358 return 1;
359 else
360 return 0;
361}
362
363/*!
364 \fn int is_a_short_delayed_descriptor ( struct bufr_descriptor *d )
365 \brief check if a descriptor is a short delayed descriptor
366 \param d pointer to a struct \ref bufr_descriptor to check
367 \return If is a delayed descriptor return 1, 0 otherwise.
368*/
370{
371 //bufrdeco_assert (d != NULL);
372
373 if ( ( d->f == 0 ) &&
374 ( d->x == 31 ) &&
375 ( d->y == 0 ) )
376 return 1;
377 else
378 return 0;
379}
380
381
382/*!
383 \fn int is_a_local_descriptor ( struct bufr_descriptor *d )
384 \brief check if a descriptor is a local descriptor
385 \param d pointer to a struct \ref bufr_descriptor to check
386 \return If is a local desccriptor return 1, 0 otherwise.
387*/
389{
390 //bufrdeco_assert (d != NULL);
391
392 if ( ( d->f == 0 ) &&
393 ( d->x >= 48 ) &&
394 ( d->x <= 63 ) )
395 return 1;
396 else
397 return 0;
398}
399
400/*!
401 \fn char *get_formatted_value_from_escale ( char *fmt, size_t dim, int32_t escale, double val )
402 \brief gets a string with formatted value depending of scale
403 \param fmt The output target string
404 \param dim Size of available space (bytes) to write the result
405 \param escale value scale in descriptor
406 \param val double to printf
407 \return the resulting fmt string
408 This version use 17 width for number plus a final space
409*/
410char *get_formatted_value_from_escale ( char *fmt, size_t dim, int32_t escale, double val )
411{
412 char aux[32];
413 //bufrdeco_assert (fmt != NULL);
414
415 if ( escale >= 0 )
416 {
417 sprintf ( aux, "%%17.%dlf " , escale );
418 snprintf ( fmt, dim, aux, val );
419 }
420 else
421 snprintf ( fmt, dim, "%17.0lf " , val );
422 return fmt;
423}
424
425/*!
426 \fn char *get_formatted_value_from_escale2 ( char *fmt, size_t dim, int32_t escale, double val )
427 \brief gets a string with formatted value depending of scale
428 \param fmt The output target string
429 \param dim Size of available space (bytes) to write the result
430 \param escale value scale in descriptor
431 \param val double to printf
432 \return the resulting fmt string
433
434 Differs from get_formatted_value_from_escale that no blanks are written
435 */
436char *get_formatted_value_from_escale2 ( char *fmt, size_t dim, int32_t escale, double val )
437{
438 char aux[32];
439 //bufrdeco_assert (fmt != NULL);
440
441 if ( escale >= 0 )
442 {
443 sprintf ( aux, "%%.%dlf" , escale );
444 snprintf ( fmt, dim, aux, val );
445 }
446 else
447 snprintf ( fmt, dim, "%.0lf" , val );
448 return fmt;
449}
450
451
452/*!
453 \fn int bufrdeco_add_to_bitmap( struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by )
454 \brief Push a bitmap element in a \ref bufrdeco_bitmap
455 \param bm target struct \ref bufrdeco_bitmap where to push
456 \param index_to index of the \ref bufrdeco_bitmap which this is bitmapping to
457 \param index_by index of the \ref bufrdeco_bitmap which this is bitmapped by
458
459 \return If no space to push returns 1, otherwise 0
460*/
461int bufrdeco_add_to_bitmap ( struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by )
462{
463 //bufrdeco_assert (bm != NULL);
464
466 {
467 bm->bitmap_to[bm->nb] = index_to;
468 bm->bitmaped_by[bm->nb] = index_by;
469 ( bm->nb )++;
470 return 0;
471 }
472 return 1;
473}
474
475/*!
476 * \fn int get_bitmaped_info ( struct bufrdeco_bitmap_related_vars *brv, uint32_t target, struct bufrdeco *b )
477 * \brief Get bitmap info searching into bitmaps
478 * \param brv pointer to struct \ref bufrdeco_bitmap_related_vars where to set the results
479 * \param target The key to find in array of bitmaps
480 * \param b pointer to the current struct \ref bufrdeco
481 *
482 * \return If found the target return 0, othewise return 1
483 */
484int get_bitmaped_info ( struct bufrdeco_bitmap_related_vars *brv, uint32_t target, struct bufrdeco *b )
485{
486 size_t i, j, k;
487 uint32_t delta;
488 struct bufrdeco_bitmap *bm;
489
490 //bufrdeco_assert (b != NULL && brv != NULL);
491
492 brv->target = target;
493 for ( i = 0; i < b->bitmap.nba ; i++ )
494 {
495 bm = b->bitmap.bmap[i];
496 for ( j = 0; j < bm->nb ; j++ )
497 {
498 if ( bm->bitmap_to[j] == target )
499 {
500 brv->nba = i;
501 brv->nb = j;
502 brv->bitmaped_by = bm->bitmaped_by[j];
503 delta = bm->bitmaped_by[j] - bm->bitmaped_by[0];
504 // quality data
505 if (bm->nq)
506 {
507 for (k = 0; k < bm->nq; k++)
508 {
509 brv->qualified_by[k] = bm->quality[k] + delta;
510 }
511 }
512
513 // substituded
514 if (bm->subs)
515 brv->substituted = bm->subs + delta;
516
517 if (bm->retain )
518 brv->retained = bm->retain + delta;
519
520 if (bm->ns1)
521 {
522 for (k = 0; k < bm->ns1; k++)
523 {
524 brv->stat1[k] = bm->stat1[k] + delta;
525 brv->stat1_desc[k] = bm->stat1[k];
526 }
527 }
528
529 if (bm->nds)
530 {
531 for (k = 0; k < bm->nds; k++)
532 {
533 brv->dstat[k] = bm->dstat[k] + delta;
534 brv->stat1_desc[k] = bm->dstat[k];
535 }
536 }
537
538 return 0;
539 }
540 else if ( b->bitmap.bmap[i]->bitmap_to[j] > target )
541 break;
542 }
543 }
544 return 1;
545}
546
547
548/*!
549 * \fn int bufr_write_subset_offset_bits (FILE *f , struct bufrdeco_subset_bit_offsets *off)
550 * \brief Write offset bit array for subsets in a non-compressed bufr
551 * \param f file pointer opened by caller
552 * \param off pointer to the struct \ref bufrdeco_subset_bit_offsets with the data to write into file
553 * \return if success return 0, otherwise 1
554 */
556{
557 size_t wrote;
558
559 //bufrdeco_assert (off != NULL && f != NULL );
560
561 wrote = fwrite( &(off->nr), sizeof (buf_t ), 1, f);
562 bufrdeco_assert_with_return_val (wrote == 1, 1);
563
564 wrote = fwrite( &(off->ofs[0]), sizeof (buf_t ), off->nr, f);
565 bufrdeco_assert_with_return_val (wrote == off->nr, 1);
566
567 return 0;
568}
569
570/*!
571 * \fn int bufr_read_subset_offset_bits (FILE *f , struct bufrdeco_subset_bit_offsets *off)
572 * \brief Write offset bit array for subsets in a non-compressed bufr
573 * \param f file pointer opened by caller
574 * \param off pointer to the struct \ref bufrdeco_subset_bit_offsets with the data to write into file
575 * \return if success return 0, otherwise 1
576 */
578{
579 size_t readed;
580
581 //bufrdeco_assert (off != NULL && f != NULL );
582
583 readed = fread( &(off->nr), sizeof (buf_t ), 1, f);
584 bufrdeco_assert_with_return_val (readed == 1, 1);
585
586 readed = fread( &(off->ofs[0]), sizeof (buf_t ), off->nr, f);
587 bufrdeco_assert_with_return_val (readed == off->nr, 1);
588
589 return 0;
590}
Include header file for bufrdeco library.
uint32_t buf_t
Type to set offsets and dimension of arrays or counters used in bufrdeco.
Definition: bufrdeco.h:346
#define bufrdeco_assert_with_return_val(__my_expr__, __returnval__)
Check a expression and returns a given value if it fails.
Definition: bufrdeco.h:385
#define BUFR_MAX_BITMAP_PRESENT_DATA
Max number of data present in a bitmap definition.
Definition: bufrdeco.h:232
buf_t get_bits_as_char_array(char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
uint32_t two_bytes_to_uint32(const uint8_t *source)
returns the uint32_t value from an array of two bytes, most significant first
uint32_t three_bytes_to_uint32(const uint8_t *source)
returns the uint32_t value from an array of three bytes, most significant first
int get_table_b_reference_from_uint32_t(int32_t *target, uint8_t bits, uint32_t source)
Get an int32_t from bits according with bufr criteria to change the reference of a descritor....
int uint32_t_to_descriptor(struct bufr_descriptor *d, uint32_t id)
parse an integer with a descriptor fom bufr ECWMF libary
int is_a_local_descriptor(struct bufr_descriptor *d)
check if a descriptor is a local descriptor
int bufrdeco_add_to_bitmap(struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by)
Push a bitmap element in a bufrdeco_bitmap.
int bufr_write_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
char * bufr_charray_to_string(char *s, char *buf, size_t size)
get a null termitated c-string from an array of unsigned chars
char * get_formatted_value_from_escale2(char *fmt, size_t dim, int32_t escale, double val)
gets a string with formatted value depending of scale
buf_t get_bits_as_char_array2(char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
int bufr_read_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
char * get_formatted_value_from_escale(char *fmt, size_t dim, int32_t escale, double val)
gets a string with formatted value depending of scale
uint8_t biti[8]
uint32_t get_bits_as_uint32_t(uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
int is_a_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a delayed descriptor
uint32_t get_bits_as_uint32_t2(uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
Read bits from an array of uint8_t and set them as an uint32_t.
uint8_t bitf[8]
char * bufr_adjust_string(char *s)
Supress trailing blanks of a string.
int two_bytes_to_descriptor(struct bufr_descriptor *d, const uint8_t *source)
set a struct bufr_descriptor from two consecutive bytes in bufr file
int is_a_short_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a short delayed descriptor
int get_bitmaped_info(struct bufrdeco_bitmap_related_vars *brv, uint32_t target, struct bufrdeco *b)
Get bitmap info searching into bitmaps.
uint8_t bitk[8]
BUFR descriptor.
Definition: bufrdeco.h:409
char c[12]
Definition: bufrdeco.h:414
struct bufrdeco_bitmap * bmap[BUFR_MAX_BITMAPS]
Definition: bufrdeco.h:493
Stores all needed data for a bufr bitmap.
Definition: bufrdeco.h:470
buf_t bitmaped_by[BUFR_MAX_BITMAP_PRESENT_DATA]
Definition: bufrdeco.h:473
buf_t dstat[BUFR_MAX_QUALITY_DATA]
Definition: bufrdeco.h:482
buf_t stat1[BUFR_MAX_QUALITY_DATA]
Definition: bufrdeco.h:479
buf_t quality[BUFR_MAX_QUALITY_DATA]
Definition: bufrdeco.h:475
buf_t bitmap_to[BUFR_MAX_BITMAP_PRESENT_DATA]
Definition: bufrdeco.h:472
Array of offset in bits for every subset in a non-compressed bufr. Offset is counted in bits from the...
Definition: bufrdeco.h:685
buf_t ofs[BUFR_MAX_SUBSETS]
Definition: bufrdeco.h:687
This struct contains all needed data to parse and decode a BUFR file.
Definition: bufrdeco.h:965
struct bufrdeco_bitmap_array bitmap
Definition: bufrdeco.h:980