1/**
2 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3 * storing and accessing finite element mesh data.
4 *
5 * Copyright 2004 Sandia Corporation. Under the terms of Contract
6 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7 * retains certain rights in this software.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 */1516#include<stdlib.h>17#include<string.h>18#include<H5Ipublic.h>19#include<H5Tpublic.h>20#include"file-handle.h"21#include"status.h"22#include"util.h"2324#define FILE_HANDLE_MAGIC 0xFEEDFEED2526intmhdf_check_valid_file( FileHandle* handle, mhdf_Status* status )
27 {
28if( !handle )
29 {
30mhdf_setFail( status, "NULL file handle." );
31return0;
32 }
3334if( handle->magic != FILE_HANDLE_MAGIC )
35 {
36mhdf_setFail( status, "Invalid file handle." );
37return0;
38 }
3940return1;
41 }
4243FileHandle* mhdf_alloc_FileHandle( hid_t hdf_table, hid_t id_type, mhdf_Status* status )
44 {
45 FileHandle* rval;
4647/* check that id_type is sane */48if( id_type == -1 )
49 {
50 id_type = H5T_NATIVE_ULONG;
51 }
52elseif( H5T_INTEGER != H5Tget_class( id_type ) )
53 {
54mhdf_setFail( status, "Invalid ID type: not integer class" );
55return0;
56 }
5758 rval = (FileHandle*)mhdf_malloc( sizeof( FileHandle ), status );
59if( !rval ) returnNULL;
6061 rval->magic = FILE_HANDLE_MAGIC;
62 rval->hdf_handle = hdf_table;
63 rval->open_handle_count = 0;
64 rval->id_type = id_type;
65 rval->max_id = 0L;
66return rval;
67 }