Emoslib is now deprecated

A C function which can retrieve GRIB or BUFR products from an unblocked binary Unix stream such as a file or pipe. 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 readnext( char * buffer, long * len,
                     long (*read_func)(char *, long, void *), void * stream)

 

readnext input arguments
bufferBuffer 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 product and position the file on the byte following the end of the product
lenSize of the buffer on input; this changes to become the size in BYTES of the product read. If end-of-file is hit, this value is returned unchanged (ie when the function return code is -1)
read_funcFunction to read the input stream
streamData for the read function, eg a C file pointer
readnext return value
0A GRIB or BUFR product has been read successfully
-1End-of-file was hit before a product was read. (Note that EOF does not cause a program fail. This value must be explicitly detected by the caller to avoid looping at EOF)
-3The 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
-4The user buffer is too small to allow any processing of the product at all (ie less than 8 bytes long)
-5The GRIB or BUFR product did not have the 7777 terminator in its expected place. This means the product has been seriously corrupted.