summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Ef.c
blob: 80be2435f3b836ed379789c253630ad118f36e5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html.  If you do not have     *
 * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* This files contains C stubs for H5E Fortran APIs */

#include "H5f90.h"


/*----------------------------------------------------------------------------
 * Name:        h5eclear_c
 * Purpose:     Call H5Eclear to clear the error stack for the current thread
 * Inputs:      
 * Outputs:     
 * Returns:     0 on success, -1 on failure
 * Programmer:  Xiangyang Su
 *              Wednesday, March 29, 2000
 * Modifications:
 *---------------------------------------------------------------------------*/

int_f 
nh5eclear_c( )
{
  int ret_val = -1;
  herr_t status;

  /*
   * Call H5Eclear function.
   */
  status = H5Eclear_stack(H5E_DEFAULT); 
  if(status < 0) return ret_val;
  ret_val = 0;
  return ret_val;
}   

/*----------------------------------------------------------------------------
 * Name:        h5eprint_c1
 * Purpose:     Call H5Eprint to print the error stack in a default manner.
 * Inputs:      name - file name
 *              namelen - length of name
 * Outputs:     
 * Returns:     0 on success, -1 on failure
 * Programmer:  Xiangyang Su
 *              Wednesday, March 29, 2000
 * Modifications: Bug fix: Added call to close the file with the error messages
 *                EP 11/26/01
 *---------------------------------------------------------------------------*/
int_f
nh5eprint_c1(_fcd name, int_f* namelen)
{
  int ret_val = -1;
  herr_t status;
  FILE * file;
  char* c_name;
  int c_namelen;
  c_namelen = *namelen;
  c_name = (char*)HD5f2cstring(name, c_namelen);
  if(c_name == NULL) return ret_val;
  file = fopen(c_name, "a");
       if(!file) goto DONE;
  /*
   * Call H5Eprint function.
   */
  status = H5Eprint_stack(H5E_DEFAULT, file);
  if (status >=0 ) ret_val = 0;
  fclose(file);

DONE:
  HDfree(c_name); 
  return ret_val;
}  


/*----------------------------------------------------------------------------
 * Name:        h5eprint_c2
 * Purpose:     Call H5Eprint to print the error stack to stderr
 *              in a default manner.
 * Inputs:     
 * Outputs:     
 * Returns:     0 on success, -1 on failure
 * Programmer:  Xiangyang Su
 *              Wednesday, March 29, 2000
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5eprint_c2()
{
  int ret_val = -1;
  herr_t status;

  /*
   * Call H5Eprint function.
   */
  status = H5Eprint_stack(H5E_DEFAULT, NULL);
  if(status >= 0) ret_val = 0;
  return ret_val;
}  

/*----------------------------------------------------------------------------
 * Name:        h5eget_major_c
 * Purpose:     Call H5Eget_major to get a character string 
 *              describing an error specified by a major error number.
 * Inputs:      error_no - Major error number
 * Outputs:     name - character string describing the error
 * Returns:     0 on success, -1 on failure
 * Programmer:  Xiangyang Su
 *              Wednesday, March 29, 2000
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5eget_major_c(int_f* error_no, _fcd name)
{
  int ret_val = -1;
  char c_name[H5E_LEN];
  hid_t c_error_no;
  c_error_no = (hid_t)*error_no;

  /*
   * Call H5Eget_major function.
   */
  H5Eget_msg(c_error_no, NULL, c_name, H5E_LEN);
  HD5packFstring((char*)c_name, _fcdtocp(name), strlen(c_name)); 
  
  if(!strcmp(c_name, "Invalid major error number")) return ret_val;
  ret_val = 0;
  return ret_val;
}  

/*----------------------------------------------------------------------------
 * Name:        h5eget_minor_c
 * Purpose:     Call H5Eget_minor to get a character string 
 *              describing an error specified by a minor error number.
 * Inputs:      error_no - Major error number
 * Outputs:     name - character string describing the error
 * Returns:     0 on success, -1 on failure
 * Programmer:  Xiangyang Su
 *              Wednesday, March 29, 2000
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5eget_minor_c(int_f* error_no, _fcd name)
{
  int ret_val = -1;
  char c_name[H5E_LEN];
  hid_t c_error_no;
  c_error_no = (hid_t)*error_no;

  /*
   * Call H5Eget_minor function.
   */
  H5Eget_msg(c_error_no, NULL, c_name, H5E_LEN);
  HD5packFstring((char*)c_name, _fcdtocp(name), strlen(c_name)); 
  
  if(!strcmp(c_name, "Invalid minor error number")) return ret_val;
  ret_val = 0;
  return ret_val;
}  

/*----------------------------------------------------------------------------
 * Name:        h5eset_auto_c
 * Purpose:     Call H5Eset_auto to turn automatic error printing on or off.
 * Inputs:      printflag - flag to turn automatic error printing on or off.
 * Outputs:    
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Friday, November 17, 2000
 * Modifications:  major bug fix. Function never disabled printing.
 *---------------------------------------------------------------------------*/
int_f
nh5eset_auto_c(int_f* printflag)
{
  int ret_val = -1;
  herr_t status;

  if (*printflag == 1)
    status = H5Eset_auto_stack(H5E_DEFAULT, (H5E_auto_t)H5Eprint, stderr);
  if (*printflag == 0)
    status = H5Eset_auto_stack(H5E_DEFAULT, NULL,NULL);
  if (status >= 0) ret_val = 0;
  return ret_val;
}