-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExports.h
executable file
·165 lines (143 loc) · 3.93 KB
/
Exports.h
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
/** © 2014, Brandon T. All Rights Reserved.
This project is licensed under the General Public License v3.
This project uses LibCurl and LibSSL.
In addition to the project's licenses, the following exception applies:
In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations including
the two.
You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the
file(s), but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. If you delete
this exception statement from all source files in the program, then
also delete it here.
Author : Brandon T.
Contact: [email protected]
**/
#ifndef EXPORTS_HPP_INCLUDED
#define EXPORTS_HPP_INCLUDED
#if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <dlfcn.h>
#include <unistd.h>
#define INVALID_SOCKET (~0)
#define SOCKET_ERROR (-1)
#endif
#ifndef __APPLE__
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#else
typedef void SSL;
typedef void SSL_CTX;
#endif
#ifndef __cplusplus
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#else
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <cerrno>
#endif
#ifdef CURL_SSL
#include "CurlSSL.h"
#endif
#ifndef __cplusplus
#if __STDC_VERSION__ >= 199901L
#define standard_c_1999
#include <stdbool.h>
#elif !defined(bool_defined)
#define bool_defined
typedef enum {false, true} bool;
#endif
#endif
#ifndef DLL_FUNC
#ifdef BUILD_DLL
#define DLL_FUNC __declspec(dllexport)
#else
#define DLL_FUNC __declspec(dllimport)
#endif
#endif
#if defined _WIN32 || defined _WIN64
extern HMODULE module;
#endif
typedef enum
{
TLS1_CLIENT_METHOD,
TLS1_SERVER_METHOD,
TLS11_CLIENT_METHOD,
TLS11_SERVER_METHOD,
SSL2_CLIENT_METHOD,
SSL2_SERVER_METHOD,
SSL3_CLIENT_METHOD,
SSL3_SERVER_METHOD,
SSL23_CLIENT_METHOD,
SSL23_SERVER_METHOD
} SSLSocketType;
#pragma pack(push, 1)
typedef struct
{
long unsigned int sock;
SSL* ssl;
SSL_CTX* ctx;
const char* address;
SSLSocketType type;
long unsigned int timeout;
unsigned short port;
#if defined __cplusplus || defined standard_c_1999
bool connected;
bool blockmode;
#else
unsigned char connected;
unsigned char blockmode;
#endif
} SSLSocket;
#pragma pack(pop)
#ifdef __cplusplus
extern "C"
{
#endif
DLL_FUNC bool CreateSocket(SSLSocket* ssl_info);
DLL_FUNC bool ConnectSocket(SSLSocket* ssl_info);
DLL_FUNC bool BindSocket(SSLSocket* ssl_info);
DLL_FUNC bool ListenSocket(SSLSocket* ssl_info);
DLL_FUNC bool SetBlockingSocket(SSLSocket* ssl_info);
DLL_FUNC bool SetTimeoutSocket(SSLSocket* ssl_info);
DLL_FUNC int SelectSocket(SSLSocket* ssl_info, bool Read);
DLL_FUNC bool CloseSocket(SSLSocket* ssl_info);
DLL_FUNC bool FreeSocket(SSLSocket* ssl_info);
DLL_FUNC bool AcceptSocket(SSLSocket* ssl_info, SSLSocket* ssl_client_info);
DLL_FUNC long int ReadSocket(SSLSocket* ssl_info, void* Buffer, unsigned int Size);
DLL_FUNC long int WriteSocket(SSLSocket* ssl_info, void* Buffer, unsigned int Size);
DLL_FUNC long int BytesPendingSocket(SSLSocket* ssl_info);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
bool InitSSL(SSLSocket* ssl_info);
bool FreeSSL(SSLSocket* ssl_info);
#ifdef DEBUG
void PrintLastError(int errorcode);
void PrintSocketInfo(SSLSocket* ssl_info);
#endif
#ifdef __cplusplus
}
#endif
#endif