1 /*
2  * %CopyrightBegin%
3  *
4  * Copyright Ericsson AB 2010-2020. All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * %CopyrightEnd%
19  */
20 
21 #ifndef E_COMMON_H__
22 #define E_COMMON_H__ 1
23 
24 #ifdef __WIN32__
25 #  include <windows.h>
26 #endif
27 
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <limits.h>
32 #include <stdint.h>
33 
34 #include <erl_nif.h>
35 #include "openssl_config.h"
36 #include "atoms.h"
37 
38 
39 /* All nif functions return a valid value or throws an exception */
40 #define EXCP(Env, Id, Str)  enif_raise_exception((Env), \
41                                 enif_make_tuple3((Env), \
42                                                  (Id),  \
43                                                  enif_make_tuple2((Env), \
44                                                                   enif_make_string((Env),__FILE__,(ERL_NIF_LATIN1)), \
45                                                                   enif_make_int((Env), __LINE__)), \
46                                                  enif_make_string((Env),(Str),(ERL_NIF_LATIN1)) ))
47 
48 #define EXCP_NOTSUP(Env, Str) EXCP((Env), atom_notsup, (Str))
49 #define EXCP_BADARG(Env, Str) EXCP((Env), atom_badarg, (Str))
50 #define EXCP_ERROR(Env, Str)  EXCP((Env), atom_error, (Str))
51 
52 #endif /* E_COMMON_H__ */
53