Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
openssl_compat.h
Go to the documentation of this file.
1
5#pragma once
6
7#ifndef __STDC_WANT_LIB_EXT1__
11 #define __STDC_WANT_LIB_EXT1__ 1
12#endif
13
14#include <lwip/opt.h>
15#include <stdio.h>
16#include <string.h>
17#include <sys/stat.h>
18#include <sys/time.h>
19#include <time.h>
20#include <unistd.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
35 ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
36
46 ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags);
47
58 int lwip_select(int maxfdp1, struct fd_set *readset, struct fd_set *writeset, struct fd_set *exceptset, struct timeval *timeout);
59
60#ifndef LWIP_SOCKET_OFFSET
64 #define LWIP_SOCKET_OFFSET 0
65#endif
66
67#ifndef FD_SETSIZE
71 #define FD_SETSIZE MEMP_NUM_NETCONN
72#endif
73
74#ifndef FD_SET
78 typedef struct fd_set {
79 unsigned char fd_bits[(FD_SETSIZE + 7) / 8];
81
85 #define FD_SET(n, p) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] = (unsigned char) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] | (1u << (((n) - LWIP_SOCKET_OFFSET) & 7))))
86
90 #define FD_CLR(n, p) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] = (unsigned char) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] & ~(1u << (((n) - LWIP_SOCKET_OFFSET) & 7))))
91
95 #define FD_ISSET(n, p) (((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] & (1u << (((n) - LWIP_SOCKET_OFFSET) & 7))) != 0)
96
100 #define FD_ZERO(p) memset((void *) (p), 0, sizeof(*(p)))
101#endif
102
103#ifndef select
107 #define select(maxfdp1, readset, writeset, exceptset, timeout) lwip_select(maxfdp1, readset, writeset, exceptset, timeout)
108#endif
109
110#ifndef F_OK
114 #define F_OK 0
115#endif
116
117#ifndef R_OK
121 #define R_OK 4
122#endif
123
124#ifndef W_OK
128 #define W_OK 2
129#endif
130
131#ifndef X_OK
135 #define X_OK 1
136#endif
137
138#ifndef AF_UNIX
142 #define AF_UNIX (-1)
143#endif
144
146#define access moonlight_nxdk_openssl_access
148#define fileno moonlight_nxdk_openssl_fileno
150#define read moonlight_nxdk_openssl_read
152#define write moonlight_nxdk_openssl_write
154#define close moonlight_nxdk_openssl_close
156#define _close moonlight_nxdk_openssl__close
158#define open moonlight_nxdk_openssl_open
160#define _open moonlight_nxdk_openssl__open
162#define fdopen moonlight_nxdk_openssl_fdopen
164#define _fdopen moonlight_nxdk_openssl__fdopen
166#define _unlink moonlight_nxdk_openssl__unlink
168#define chmod moonlight_nxdk_openssl_chmod
170#define getuid moonlight_nxdk_openssl_getuid
172#define geteuid moonlight_nxdk_openssl_geteuid
174#define getgid moonlight_nxdk_openssl_getgid
176#define getegid moonlight_nxdk_openssl_getegid
177
181 static inline int moonlight_nxdk_openssl_access(const char *path, int mode) {
182 (void) path;
183 (void) mode;
184 return -1;
185 }
186
190 static inline int moonlight_nxdk_openssl_fileno(FILE *stream) {
191 (void) stream;
192 return -1;
193 }
194
198 static inline ssize_t moonlight_nxdk_openssl_read(int fd, void *buffer, size_t count) {
199 return lwip_recv(fd, buffer, count, 0);
200 }
201
205 static inline ssize_t moonlight_nxdk_openssl_write(int fd, const void *buffer, size_t count) {
206 return lwip_send(fd, buffer, count, 0);
207 }
208
212 static inline int moonlight_nxdk_openssl_close(int fd) {
213 (void) fd;
214 return -1;
215 }
216
220 static inline int moonlight_nxdk_openssl__close(int fd) {
221 return moonlight_nxdk_openssl_close(fd);
222 }
223
227 static inline int moonlight_nxdk_openssl_open(const char *path, int flags, ...) {
228 (void) path;
229 (void) flags;
230 return -1;
231 }
232
236 static inline int moonlight_nxdk_openssl__open(const char *path, int flags, ...) {
237 (void) path;
238 (void) flags;
239 return -1;
240 }
241
245 static inline FILE *moonlight_nxdk_openssl_fdopen(int fd, const char *mode) {
246 (void) fd;
247 (void) mode;
248 return NULL;
249 }
250
254 static inline FILE *moonlight_nxdk_openssl__fdopen(int fd, const char *mode) {
255 return moonlight_nxdk_openssl_fdopen(fd, mode);
256 }
257
261 static inline int moonlight_nxdk_openssl__unlink(const char *path) {
262 (void) path;
263 return -1;
264 }
265
269 static inline int moonlight_nxdk_openssl_chmod(const char *path, int mode) {
270 (void) path;
271 (void) mode;
272 return -1;
273 }
274
278 static inline unsigned int moonlight_nxdk_openssl_getuid(void) {
279 return 0;
280 }
281
285 static inline unsigned int moonlight_nxdk_openssl_geteuid(void) {
286 return 0;
287 }
288
292 static inline unsigned int moonlight_nxdk_openssl_getgid(void) {
293 return 0;
294 }
295
299 static inline unsigned int moonlight_nxdk_openssl_getegid(void) {
300 return 0;
301 }
302
306 static inline int moonlight_nxdk_openssl_gmtime_s(struct tm *result, const time_t *timer) {
307 return gmtime_s(timer, result);
308 }
309
311#define gmtime_s moonlight_nxdk_openssl_gmtime_s
312
313#ifdef __cplusplus
314}
315#endif
ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags)
Send bytes through the lwIP socket backend.
#define FD_SETSIZE
Maximum number of sockets tracked by the compatibility fd_set.
Definition openssl_compat.h:71
struct fd_set fd_set
Minimal socket descriptor set used by the lwIP-backed select shim.
ssize_t lwip_recv(int s, void *mem, size_t len, int flags)
Receive bytes through the lwIP socket backend.
#define gmtime_s
Redirect gmtime_s to the nxdk OpenSSL compatibility shim.
Definition openssl_compat.h:311
int lwip_select(int maxfdp1, struct fd_set *readset, struct fd_set *writeset, struct fd_set *exceptset, struct timeval *timeout)
Wait for lwIP socket readiness using the nxdk select implementation.
Minimal socket descriptor set used by the lwIP-backed select shim.
Definition openssl_compat.h:78
unsigned char fd_bits[(MEMP_NUM_NETCONN+7)/8]
Bitset storing tracked socket descriptors relative to LWIP_SOCKET_OFFSET.
Definition openssl_compat.h:79