kodi
os_port.h
1 /*****************************************************************
2 |
3 | abstraction layer for axTLS
4 |
5 | Copyright (c) 2002-2008, Axiomatic Systems, LLC.
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of Axiomatic Systems nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY AXIOMATIC SYSTEMS ''AS IS'' AND ANY
20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL AXIOMATIC SYSTEMS BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30  ****************************************************************/
31 
32 #ifndef _OS_PORT_H_
33 #define _OS_PORT_H_
34 
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #if defined(WIN32)
39 #include <windows.h>
40 #include <malloc.h>
41 typedef UINT8 uint8_t;
42 typedef INT8 int8_t;
43 typedef UINT16 uint16_t;
44 typedef INT16 int16_t;
45 typedef UINT32 uint32_t;
46 typedef INT32 int32_t;
47 typedef UINT64 uint64_t;
48 typedef INT64 int64_t;
49 #else
50 #include <stdint.h>
51 #endif
52 
53 /*----------------------------------------------------------------------
54 | types
55 +---------------------------------------------------------------------*/
56 typedef struct SSL_SOCKET SSL_SOCKET;
57 
58 struct SSL_SOCKET {
59  int (*Read)(SSL_SOCKET* self, void* buffer, unsigned int size);
60  int (*Write)(SSL_SOCKET* self, const void* buffer, unsigned int size);
61 };
62 
63 typedef struct {
64  uint32_t year; /* year */
65  uint32_t month; /* month of the year (1-12) */
66  uint32_t day; /* day of the month (1-31) */
67  uint32_t hours; /* hours (0-23) */
68  uint32_t minutes; /* minutes (0-59) */
69  uint32_t seconds; /* seconds (0-59) */
70 } SSL_DateTime;
71 int SSL_DateTime_Before(const SSL_DateTime* t1, const SSL_DateTime* t2);
72 void SSL_DateTime_Now(SSL_DateTime* now);
73 uint64_t SSL_GetRandomSeed();
74 
75 #define STDCALL
76 #define EXP_FUNC
77 
78 #if defined(__cplusplus)
79 typedef class NPT_Mutex* SSL_CTX_MUTEX_TYPE;
80 #else
81 typedef void* SSL_CTX_MUTEX_TYPE;
82 #endif
83 void SSL_Mutex_Create(SSL_CTX_MUTEX_TYPE* mutex);
84 void SSL_Mutex_Destroy(SSL_CTX_MUTEX_TYPE mutex);
85 void SSL_Mutex_Lock(SSL_CTX_MUTEX_TYPE mutex);
86 void SSL_Mutex_Unlock(SSL_CTX_MUTEX_TYPE mutex);
87 #define SSL_CTX_MUTEX_INIT(_mutex) SSL_Mutex_Create(&_mutex)
88 #define SSL_CTX_MUTEX_DESTROY(_mutex) do {SSL_Mutex_Destroy(_mutex); _mutex = NULL; } while(0)
89 #define SSL_CTX_LOCK(_mutex) SSL_Mutex_Lock(_mutex)
90 #define SSL_CTX_UNLOCK(_mutex) SSL_Mutex_Unlock(_mutex)
91 
92 #define TTY_FLUSH()
93 #define SOCKET_BLOCK(X)
94 #define SOCKET_READ(s,b,z) (s)->Read((s), (b), (z))
95 #define SOCKET_WRITE(s,b,z) (s)->Write((s), (b), (z))
96 
97 void SSL_Sha256_ComputeDigest(const unsigned char* buffer, unsigned int buffer_length, unsigned char* digest);
98 
99 #endif /* _OS_PORT_H_ */
Definition: NptThreads.h:76
Definition: os_port.h:58
Definition: os_port.h:63