Mesh Oriented datABase
(version 5.5.1)
An array-based unstructured mesh library
file-handle.c
Go to the documentation of this file.
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
*/
15
16
#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
"
23
24
#define FILE_HANDLE_MAGIC 0xFEEDFEED
25
26
int
mhdf_check_valid_file
(
FileHandle
* handle,
mhdf_Status
* status )
27
{
28
if
( !handle )
29
{
30
mhdf_setFail
( status,
"NULL file handle."
);
31
return
0;
32
}
33
34
if
( handle->
magic
!=
FILE_HANDLE_MAGIC
)
35
{
36
mhdf_setFail
( status,
"Invalid file handle."
);
37
return
0;
38
}
39
40
return
1;
41
}
42
43
FileHandle
*
mhdf_alloc_FileHandle
( hid_t hdf_table, hid_t id_type,
mhdf_Status
* status )
44
{
45
FileHandle
* rval;
46
47
/* check that id_type is sane */
48
if
( id_type == -1 )
49
{
50
id_type = H5T_NATIVE_ULONG;
51
}
52
else
if
( H5T_INTEGER != H5Tget_class( id_type ) )
53
{
54
mhdf_setFail
( status,
"Invalid ID type: not integer class"
);
55
return
0;
56
}
57
58
rval = (
FileHandle
*)
mhdf_malloc
(
sizeof
(
FileHandle
), status );
59
if
( !rval )
return
NULL;
60
61
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;
66
return
rval;
67
}
src
io
mhdf
src
file-handle.c
Generated on Sun Dec 22 2024 02:06:22 for Mesh Oriented datABase by
1.9.1.