void traverse_product() { int result; result = coda_open(traverse_info.file_name, &traverse_info.pf); if (result != 0 && coda_errno == CODA_ERROR_FILE_OPEN) { /* maybe not enough memory space to map the file in memory => * temporarily disable memory mapping of files and try again */ coda_set_option_use_mmap(0); result = coda_open(traverse_info.file_name, &traverse_info.pf); coda_set_option_use_mmap(1); } if (result != 0) { handle_coda_error(); } if (coda_cursor_set_product(&traverse_info.cursor, traverse_info.pf) != 0) { handle_coda_error(); } if (coda_get_product_root_type(traverse_info.pf, &traverse_info.type[traverse_info.current_depth]) != 0) { handle_coda_error(); } traverse_data(); coda_close(traverse_info.pf); traverse_info.pf = NULL; }
static int get_product_group_availability(coda_product *product, const char *group_name, int *group_available) { coda_type *root_type; long num_fields; long i; if (coda_get_product_root_type(product, &root_type) != 0) { harp_set_error(HARP_ERROR_CODA, NULL); return -1; } if (coda_type_get_num_record_fields(root_type, &num_fields) != 0) { harp_set_error(HARP_ERROR_CODA, NULL); return -1; } for (i = 0; i < num_fields; i++) { const char *field_name; if (coda_type_get_record_field_real_name(root_type, i, &field_name) != 0) { harp_set_error(HARP_ERROR_CODA, NULL); return -1; } if (strcmp(field_name, group_name) == 0) { *group_available = 1; return 0; } } *group_available = 0; return 0; }