-
Notifications
You must be signed in to change notification settings - Fork 0
/
ga-win32.h
133 lines (117 loc) · 3.62 KB
/
ga-win32.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
/*
* Copyright (c) 2013 Chun-Ying Huang
* Modification Copyright (c) 2021 me(github.com/am009)
*
* This file is part of GamingAnywhere (GA).
*
* GA is free software; you can redistribute it and/or modify it
* under the terms of the 3-clause BSD License as published by the
* Free Software Foundation: http://directory.fsf.org/wiki/License:BSD_3Clause
*
* GA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the 3-clause BSD License along with GA;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* @file
* GamingAnywhere's common functions for Windows: headers
*/
#ifndef __GA_WIN32_H__
#define __GA_WIN32_H__
#ifdef WIN32
/////////////////////////////////////////////////////////////////////////
#include <winsock2.h>
#include <ws2ipdef.h>
#include <windows.h>
#include <process.h> // _getpid
#include <winerror.h> // FAILED() macro
#define VK_PRETENDED_LCONTROL 0x98 // L_CONTROL key: 162
#define VK_PRETENDED_LALT 0x99 // L_ALT key: 164
#ifdef WIN32
#define USE_GA_WIN32_MACRO
#endif
#ifdef USE_GA_WIN32_MACRO
// bzero
#ifndef bzero
#define bzero(m,n) ZeroMemory(m, n) /**< Mapping bzero() to ZeroMemory() */
#endif
// bcopy
#ifndef bcopy
#define bcopy(s,d,n) CopyMemory(d, s, n) /**< Mapping bcopy() to CopyMemory() */
#endif
// strncasecmp
#ifndef strncasecmp
#define strncasecmp(a,b,n) _strnicmp(a,b,n) /**< Mapping strncasecmp() to _strnicmp() */
#endif
// strcasecmp
#ifndef strcasecmp
#define strcasecmp(a,b) _stricmp(a,b) /**< Mapping strcasecmp() to _stricmp() */
#endif
// strdup
#ifndef strdup
#define strdup(s) _strdup(s) /**< Mapping strdup() to _strdup() */
#endif
// strtok_r
#ifndef strtok_r
#define strtok_r(s,d,v) strtok_s(s,d,v) /**< Mapping strtok_r() to strtok_s() */
#endif
// snprintf
#ifndef snprintf
#define snprintf(b,n,f,...) _snprintf_s(b,n,_TRUNCATE,f,__VA_ARGS__) /**< Mapping snprintf() to _snprintf_s() */
#endif
// vsnprintf
#ifndef vsnprintf
#define vsnprintf(b,n,f,ap) vsnprintf_s(b,n,_TRUNCATE,f,ap) /**< Mapping vsnprintf() to vsnprintf_s() */
#endif
// strncpy
#ifndef strncpy
#define strncpy(d,s,n) strncpy_s(d,n,s,_TRUNCATE) /**< Mapping strncpy() to strncpy_s() */
#endif
// getpid
#ifndef getpid
#define getpid _getpid
#endif
// gmtimr_r
#if !defined(MSYS)
#ifndef gmtime_r
#define gmtime_r(pt,ptm) gmtime_s(ptm,pt) /**< Mapping gmtime_r() to gmtime_s() */
#endif
#endif
// dlopen
#ifndef dlopen
#define dlopen(f,opt) LoadLibrary(f) /**< Mapping dlopen() to LoadLibrary() */
#endif
// dlsym
#ifndef dlsym
#define dlsym(h,name) GetProcAddress(h,name) /**< Mapping dlsym() to GetProcAddress() */
#endif
// dlclose
#ifndef dlclose
#define dlclose(h) FreeLibrary(h) /**< Mapping dlclose() to FreeLibrary() */
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
struct WIN32IMAGE {
int width;
int height;
int bytes_per_line;
};
EXPORT int gettimeofday(struct timeval *tv, void *tz);
EXPORT int usleep(long long waitTime);
EXPORT int read(SOCKET fd, void *buf, int count);
EXPORT int write(SOCKET fd, const void *buf, int count);
EXPORT int close(SOCKET fd);
EXPORT char *dlerror();
EXPORT void ga_win32_fill_bitmap_info(BITMAPINFO *pinfo, int w, int h, int bitsPerPixel);
EXPORT long long pcdiff_us(LARGE_INTEGER t1, LARGE_INTEGER t2, LARGE_INTEGER freq);
EXPORT int ga_set_process_dpi_aware();
LPSTR PrintError(int ErrorCode);
#endif /* USE_GA_WIN32_MACRO */
/////////////////////////////////////////////////////////////////////////
#endif /* WIN32 */
#endif