A C function which can retrieve BUFR products from an unblocked binary file. The return value must be checked after calling the function.
Products are delivered one per call to a user array.
The format and arguments for the function are:
long readbufr( FILE * file, char * buffer, long * bufr_len)
file | C file pointer |
buffer | Buffer big enough to hold the product, or NULL. If this parameter is a NULL pointer, the function will pass back the length of the next BUFR product and will position the file on the byte following the end of the product pointer |
bufr_len | Size of the buffer on input; changes to become the size in BYTES of the product read. If end-of-file is hit, the value is returned unchanged (i.e. when the function return code is -1) |
0 | A BUFR product has been successfully read |
-1 | End-of-file is hit before a product is read. (Note that EOF does not cause a program fail. This value must be explicitly caught by the caller to avoid looping at EOF) |
-2 | Error in the file-handling (e.g. if the file contains a truncated product) |
-3 | The size of buffer is not sufficient for the product. In this case, the buffer is filled with bytes from the product and the file is positioned at the beginning of the following product, if any. |
-4 | The user buffer is too small to allow any processing of the product at all (e.g. less than 8 bytes long) |
-5 | The BUFR product did not have the 7777 terminator in its expected place. This means the product has been seriously corrupted. |