Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-SFIRE.git] / external / io_grib1 / WGRIB / readgrib.c
blob27c6dd16c7b5b9cb2bd76c260073393e8cac6555
1 /*
2 * read_grib.c
4 * reads grib message
6 * input: pos, byte position of grib message
7 * len_grib, length of grib message
8 * output: *buffer, grib message
10 * note: call seek_grib first
12 * v1.0 9/94 Wesley Ebisuzaki
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <stddef.h>
18 #include "grib.h"
20 int read_grib(FILE *file, long pos, long len_grib, unsigned char *buffer) {
22 int i;
25 if (fseek(file, pos, SEEK_SET) == -1) {
26 return 0;
29 i = fread(buffer, sizeof (unsigned char), len_grib, file);
30 return (i == len_grib);