Initial import to Tizen
[profile/ivi/python-pyOpenSSL.git] / OpenSSL / ssl / ssl.h
1 /*
2  * ssl.h
3  *
4  * Copyright (C) AB Strakt
5  * See LICENSE for details.
6  *
7  * Export functions and exceptions from the SSL sub module.
8  * See the file RATIONALE for a short explanation of why this module was written.
9  *
10  * Reviewed 2001-07-23
11  *
12  */
13 #ifndef PyOpenSSL_SSL_H_
14 #define PyOpenSSL_SSL_H_
15
16 #include <Python.h>
17 #include <pythread.h>
18 #include "context.h"
19 #include "connection.h"
20 #include "../util.h"
21 #include "../crypto/crypto.h"
22
23 extern PyObject *ssl_Error,               /* Base class              */
24                 *ssl_ZeroReturnError,     /* Used with SSL_get_erorr */
25                 *ssl_WantReadError,       /* ...                     */
26                 *ssl_WantWriteError,      /* ...                     */
27                 *ssl_WantX509LookupError, /* ...                     */
28                 *ssl_SysCallError;        /* Uses (errno,errstr)     */
29
30 #define ssl_Context_New_NUM       0
31 #define ssl_Context_New_RETURN    ssl_ContextObj *
32 #define ssl_Context_New_PROTO     (int method)
33
34 #define ssl_Connection_New_NUM    1
35 #define ssl_Connection_New_RETURN ssl_ConnectionObj *
36 #define ssl_Connection_New_PROTO  (ssl_ContextObj *ctx, PyObject *sock)
37
38 #define ssl_API_pointers          2
39
40 #ifdef WITH_THREAD
41 extern int _pyOpenSSL_tstate_key;
42 #endif /* WITH_THREAD */
43
44 #ifdef SSL_MODULE
45
46 extern ssl_Context_New_RETURN    ssl_Context_New    ssl_Context_New_PROTO;
47 extern ssl_Connection_New_RETURN ssl_Connection_New ssl_Connection_New_PROTO;
48
49 extern crypto_X509Obj* (*new_x509)(X509*, int);
50 extern crypto_X509NameObj* (*new_x509name)(X509_NAME*, int);
51 extern crypto_X509StoreObj* (*new_x509store)(X509_STORE*, int);
52
53 #else /* SSL_MODULE */
54
55 extern void **ssl_API;
56
57 #define ssl_Context_New \
58  (*(ssl_Context_New_RETURN (*)ssl_Context_New_PROTO) ssl_API[ssl_Context_New_NUM])
59 #define ssl_Connection_New \
60  (*(ssl_Connection_New_RETURN (*)ssl_Connection_New_PROTO) ssl_API[ssl_Connection_New_NUM])
61
62 #define import_SSL() \
63 { \
64   PyObject *module = PyImport_ImportModule("OpenSSL.SSL"); \
65   if (module != NULL) { \
66     PyObject *module_dict = PyModule_GetDict(module); \
67     PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
68     if (PyCObject_Check(c_api_object)) { \
69       ssl_API = (void **)PyCObject_AsVoidPtr(c_api_object); \
70     } \
71   } \
72 }
73
74 #endif /* SSL_MODULE */
75
76 #endif /* PyOpenSSL_SSL_H_ */