Grid Community Toolkit  6.2.1653033972 (tag: v6.2.20220524)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_gsi_cert_utils.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
18 
24 #ifndef GLOBUS_I_GSI_CERT_UTILS_H
25 #define GLOBUS_I_GSI_CERT_UTILS_H
26 
27 #include "globus_gsi_cert_utils.h"
28 
29 /* DEBUG MACROS */
30 
31 #ifdef BUILD_DEBUG
32 
33 extern int globus_i_gsi_cert_utils_debug_level;
34 extern FILE * globus_i_gsi_cert_utils_debug_fstream;
35 
36 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG(_LEVEL_) \
37  (globus_i_gsi_cert_utils_debug_level >= (_LEVEL_))
38 
39 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) \
40  { \
41  if (GLOBUS_I_GSI_CERT_UTILS_DEBUG(_LEVEL_)) \
42  { \
43  globus_libc_fprintf _MESSAGE_; \
44  } \
45  }
46 
47 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \
48  { \
49  if (GLOBUS_I_GSI_CERT_UTILS_DEBUG(_LEVEL_)) \
50  { \
51  char * _tmp_str_ = \
52  globus_common_create_nstring _MESSAGE_; \
53  globus_libc_fprintf(globus_i_gsi_cert_utils_debug_fstream, \
54  "%s", _tmp_str_); \
55  globus_libc_free(_tmp_str_); \
56  } \
57  }
58 
59 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_PRINT(_LEVEL_, _MESSAGE_) \
60  { \
61  if (GLOBUS_I_GSI_CERT_UTILS_DEBUG(_LEVEL_)) \
62  { \
63  globus_libc_fprintf(globus_i_gsi_cert_utils_debug_fstream, \
64  _MESSAGE_); \
65  } \
66  }
67 
68 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_PRINT_OBJECT(_LEVEL_, \
69  _OBJ_NAME_, \
70  _OBJ_) \
71  { \
72  if (GLOBUS_I_GSI_CERT_UTILS_DEBUG(_LEVEL_)) \
73  { \
74  _OBJ_NAME_##_print_fp(globus_i_gsi_cert_utils_debug_fstream, \
75  _OBJ_); \
76  } \
77  }
78 
79 #else
80 
81 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_FPRINTF(_LEVEL_, _MESSAGE_) {}
82 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) {}
83 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_PRINT(_LEVEL_, _MESSAGE_) {}
84 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_PRINT_OBJECT(_LEVEL_, \
85  _OBJ_NAME_, _OBJ_) {}
86 
87 #endif
88 
89 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_ENTER \
90  GLOBUS_I_GSI_CERT_UTILS_DEBUG_FPRINTF( \
91  1, (globus_i_gsi_cert_utils_debug_fstream, \
92  "%s entering\n", _function_name_))
93 
94 #define GLOBUS_I_GSI_CERT_UTILS_DEBUG_EXIT \
95  GLOBUS_I_GSI_CERT_UTILS_DEBUG_FPRINTF( \
96  2, (globus_i_gsi_cert_utils_debug_fstream, \
97  "%s exiting\n", _function_name_))
98 
99 /* ERROR MACROS */
100 
101 extern char * globus_l_gsi_cert_utils_error_strings[];
102 
103 #define GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT(_RESULT_, \
104  _ERRORTYPE_, _ERRSTR_) \
105  { \
106  char * _tmp_str_ = \
107  globus_common_create_string _ERRSTR_; \
108  _RESULT_ = globus_i_gsi_cert_utils_openssl_error_result(_ERRORTYPE_, \
109  __FILE__, \
110  _function_name_, \
111  __LINE__, \
112  _tmp_str_, \
113  NULL); \
114  globus_libc_free(_tmp_str_); \
115  }
116 
117 #define GLOBUS_GSI_CERT_UTILS_ERROR_RESULT(_RESULT_, _ERRORTYPE_, _ERRSTR_) \
118  { \
119  char * _tmp_str_ = \
120  globus_common_create_string _ERRSTR_; \
121  _RESULT_ = globus_i_gsi_cert_utils_error_result(_ERRORTYPE_, \
122  __FILE__, \
123  _function_name_, \
124  __LINE__, \
125  _tmp_str_, \
126  NULL); \
127  globus_libc_free(_tmp_str_); \
128  }
129 
130 #define GLOBUS_GSI_CERT_UTILS_ERROR_CHAIN_RESULT(_TOP_RESULT_, _ERRORTYPE_) \
131  _TOP_RESULT_ = globus_i_gsi_cert_utils_error_chain_result(_TOP_RESULT_, \
132  _ERRORTYPE_, \
133  __FILE__, \
134  _function_name_, \
135  __LINE__, \
136  NULL, \
137  NULL)
138 
139 #define GLOBUS_GSI_CERT_UTILS_OPENSSL_LONG_ERROR_RESULT(_RESULT_, \
140  _ERRORTYPE_, \
141  _ERRSTR_, \
142  _LONG_DESC_) \
143  { \
144  char * _tmp_str_ = \
145  globus_common_create_string _ERRSTR_; \
146  _RESULT_ = globus_i_gsi_cert_utils_openssl_error_result( \
147  _ERRORTYPE_, \
148  __FILE__, \
149  _function_name_, \
150  __LINE__, \
151  _tmp_str_, \
152  _LONG_DESC_); \
153  globus_libc_free(_tmp_str_); \
154  }
155 
156 #define GLOBUS_GSI_CERT_UTILS_LONG_ERROR_RESULT(_RESULT_, \
157  _ERRORTYPE_, \
158  _ERRSTR_, \
159  _LONG_DESC_) \
160  { \
161  char * _tmp_str_ = \
162  globus_common_create_string _ERRSTR_; \
163  _RESULT_ = globus_i_gsi_cert_utils_error_result(_ERRORTYPE_, \
164  __FILE__, \
165  _function_name_, \
166  __LINE__, \
167  _tmp_str_, \
168  _LONG_DESC_); \
169  globus_libc_free(_tmp_str_); \
170  }
171 
172 #define GLOBUS_GSI_CERT_UTILS_LONG_ERROR_CHAIN_RESULT(_TOP_RESULT_, \
173  _ERRORTYPE_, \
174  _LONG_DESC_) \
175  _TOP_RESULT_ = globus_i_gsi_cert_utils_error_chain_result(_TOP_RESULT_, \
176  _ERRORTYPE_, \
177  __FILE__, \
178  _function_name_, \
179  __LINE__, \
180  NULL, \
181  _LONG_DESC_)
182 
183 #define GLOBUS_GSI_CERT_UTILS_MALLOC_ERROR(_MIN_RESULT_) \
184  { \
185  char * _tmp_str_ = \
186  globus_l_gsi_cert_utils_error_strings[ \
187  GLOBUS_GSI_CERT_UTILS_ERROR_OUT_OF_MEMORY]; \
188  _MIN_RESULT_ = globus_error_put( \
189  globus_error_wrap_errno_error( \
190  GLOBUS_GSI_CERT_UTILS_MODULE, \
191  errno, \
192  GLOBUS_GSI_CERT_UTILS_ERROR_OUT_OF_MEMORY, \
193  __FILE__, \
194  _function_name_, \
195  __LINE__, \
196  "%s", \
197  _tmp_str_)); \
198  }
199 
201 globus_i_gsi_cert_utils_openssl_error_result(
202  int error_type,
203  const char * filename,
204  const char * function_name,
205  int line_number,
206  const char * short_desc,
207  const char * long_desc);
208 
210 globus_i_gsi_cert_utils_error_result(
211  int error_type,
212  const char * filename,
213  const char * function_name,
214  int line_number,
215  const char * short_desc,
216  const char * long_desc);
217 
219 globus_i_gsi_cert_utils_error_chain_result(
220  globus_result_t chain_result,
221  int error_type,
222  const char * filename,
223  const char * function_name,
224  int line_number,
225  const char * short_desc,
226  const char * long_desc);
227 
228 EXTERN_C_END
229 
230 #endif /* GLOBUS_I_GSI_CERT_UTILS_H */
231 
232 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
Globus GSI Cert Utils Library.
uint32_t globus_result_t
Definition: globus_types.h:99