bufr.c File Reference

Main OPERA BUFR library functions. More...

#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "desc.h"
#include "bufr.h"
#include "bitio.h"
#include "rlenc.h"

Go to the source code of this file.

Functions

void bufr_clean (void)
int bufr_create_msg (dd *descs, int ndescs, varfl *vals, void **datasec, void **ddsec, size_t *datasecl, size_t *ddescl)
 Creates section 3 and 4 of BUFR message from arrays of data and data descriptors.
int bufr_encode_sections34 (dd *descs, int ndescs, varfl *vals, bufr_t *msg)
 Creates section 3 and 4 of BUFR message from arrays of data and data descriptors.
int bufr_read_file (bufr_t *msg, char *file)
 This functions reads the encoded BUFR-message to a binary file.
int bufr_get_sections (char *bm, int len, bufr_t *msg)
 Calculates the section length of a BUFR message and allocates memory for each section.
int bufr_out_descsec (dd *descp, int ndescs, int desch)
 Write descriptor section of a BUFR message to the bitsream.
int bufr_open_descsec_w ()
 Open bitstream for section 3 for writing and set default values.
void bufr_close_descsec_w (bufr_t *bufr, int desch)
 Write length of section 3 and close bitstream.
int setup_sec0125 (char *sec[], size_t secl[], sect_1_t s1)
int save_sections (char **sec, size_t *secl, char *buffile)
int bufr_parse_new (dd *descs, int start, int end, int(*inputfkt)(varfl *val, int ind), int(*outputfkt)(varfl val, int ind), int callback_all_descs)
 Parse data descriptors and call user defined functions for each data element or for each descriptor.
int bufr_parse (dd *descs, int start, int end, varfl *vals, unsigned *vali, int(*userfkt)(varfl val, int ind))
 Parse data descriptors and call user-function for each element.
int bufr_parse_in (dd *descs, int start, int end, int(*inputfkt)(varfl *val, int ind), int callback_descs)
 Parse data descriptors and call user defined input function for each element or for each descriptor.
int bufr_parse_out (dd *descs, int start, int end, int(*outputfkt)(varfl val, int ind), int callback_all_descs)
 Parse data descriptors and call user defined output function for each element or for each descriptor.
void bufr_sect_1_from_file (sect_1_t *s1, char *file)
 Reads section 1 from a file and stores data read in s1.
int bufr_encode_sections0125 (sect_1_t *s1, bufr_t *msg)
 This function creates sections 0, 1, 2 and 5.
int bufr_write_file (bufr_t *msg, char *file)
 This functions saves the encoded BUFR-message to a binary file.
void bufr_free_data (bufr_t *msg)
 Frees memory allocated for a BUFR message.
int bufr_check_fxy (dd *d, int ff, int xx, int yy)
 Tests equality of descriptor d with (f,x,y).
int bufr_decode_sections01 (sect_1_t *s1, bufr_t *msg)
 This function decodes sections 0 and 1.
int bufr_sect_1_to_file (sect_1_t *s1, char *file)
 Writes section 1 data to an ASCII file.
int bufr_read_msg (void *datasec, void *ddsec, size_t datasecl, size_t ddescl, dd **descr, int *ndescs, varfl **vals, size_t *nvals)
 Decode BUFR data and descriptor section and write values and descriptors to arrays.
int bufr_in_descsec (dd **descs, int ndescs, int desch)
 Read descriptor section of a BUFR message from the bitsream.
int bufr_open_descsec_r (bufr_t *msg)
 Open bitstream of section 3 for reading.
void bufr_close_descsec_r (int desch)
 close bitstream for section 3
int val_to_array (varfl **vals, varfl v, size_t *nvals)
int bufr_val_to_array (varfl **vals, varfl v, int *nv)
 Store a value to an array of floats.
int bufr_desc_to_array (dd *descs, dd d, int *ndescs)
 Store a descriptor to an array.
int bufr_get_ndescs (bufr_t *msg)
 Calculate number of data descriptors in a BUFR message.
void bufr_get_date_time (long *year, long *mon, long *day, long *hour, long *min)
 Recall date/time info of the last BUFR-message created.
int bufr_open_datasect_w ()
 Opens bitstream for section 4 writing.
int bufr_open_datasect_r (bufr_t *msg)
 Opens bitstream for reading section 4.
void bufr_close_datasect_w (bufr_t *msg)
 Closes bitstream for section 4 and adds data to BUFR message.
void bufr_close_datasect_r ()
 Closes bitstream for section 4.
int bufr_val_from_global (varfl *val, int ind)
 Get one value from global array of values.
int bufr_val_to_global (varfl val, int ind)
 Write one value to global array of values.
bufrval_tbufr_open_val_array ()
 Opens global array of values for read/write.
void bufr_close_val_array ()
 Closes global array of values and frees all memory.


Detailed Description

This file contains all functions used for encoding and decoding data to BUFR format.

Definition in file bufr.c.


Function Documentation

int bufr_create_msg ( dd descs,
int  ndescs,
varfl vals,
void **  datasec,
void **  ddsec,
size_t *  datasecl,
size_t *  ddescl 
)

Deprecated:
Use bufr_encode_sections34 instead.

This function codes data from an array data descriptors descs and an array of varfl-values vals to a data section and a data descripor section of a BUFR message. Memory for both sections is allocated in this function and must be freed by the calling functions.

Parameters:
[in] descs Data-descriptors corresponding to vals. For each descriptor there must be a data-vaule stored in vals. descs may also include replication factors and sequence descriptors. In that case there must be a larger number of vals then of descs.
[in] ndescs Number of data descriptos contained in descs.
[in] vals Data-values to be coded in the data section. For each entry in descs there must be an entry in vals. If there are relication factors in descs, of course there must be as much vals as definded by the replication factor.
[out] datasec Is where the data-section (section 4) is stored. The memory-area for the data-section is allocated by this function and must be freed by the calling function.
[out] ddsec Is where the data-descriptor-section (section 3) in stored. The memory needed is allocated by this function and must be freed by the calling function.
[out] datasecl Number of bytes in datasec.
[out] ddescl Number of bytes in ddsec.
Returns:
The return-value is 1 if data was successfully stored, 0 if not.
See also:
bufr_read_msg, bufr_data_from_file

Definition at line 224 of file bufr.c.


Generated on Tue Dec 18 16:52:45 2007 for OPERA BUFR software by  doxygen 1.5.4