Message offsets: rework interface

This commit is contained in:
Shahram Najm 2020-11-30 15:51:25 +00:00
parent 8078e5a6f1
commit 664732b639
1 changed files with 5 additions and 7 deletions

View File

@ -17,29 +17,26 @@ int main(int argc, char* argv[])
{ {
char *filename; char *filename;
int err = 0; int err = 0;
size_t num_messages = 0, i =0; int num_messages = 0, i =0;
off_t* offsets = NULL; off_t* offsets = NULL;
codes_context* c = codes_context_get_default(); codes_context* c = codes_context_get_default();
const int strict_mode = 1; const int strict_mode = 1;
FILE* fp;
/* Usage: prog file */ /* Usage: prog file */
assert(argc == 2); assert(argc == 2);
filename = argv[1]; filename = argv[1];
fp = fopen(filename, "rb"); err = codes_extract_offsets_malloc(c, filename, PRODUCT_GRIB, &offsets, &num_messages, strict_mode);
assert(fp);
err = codes_extract_offsets_malloc(c, fp, PRODUCT_GRIB, &offsets, &num_messages, strict_mode);
assert(!err); assert(!err);
for (i = 0; i < num_messages; ++i) { for (i = 0; i < num_messages; ++i) {
printf("Message %lu: %lu\n", i, offsets[i]); printf("Message #%d: %lu\n", i, offsets[i]);
} }
free(offsets); free(offsets);
return 0; return 0;
} }
#endif #endif
#if 1
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
char *filename, *keys; char *filename, *keys;
@ -87,3 +84,4 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
#endif