mirror of https://github.com/tp4a/teleport
temp.
parent
7e7c63253a
commit
5155d4ff5d
|
@ -1,155 +1,158 @@
|
||||||
#ifndef __LIB_EX_PLATFORM_H__
|
#ifndef __LIB_EX_PLATFORM_H__
|
||||||
#define __LIB_EX_PLATFORM_H__
|
#define __LIB_EX_PLATFORM_H__
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
# define EX_OS_WIN32
|
# define EX_OS_WIN32
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
# define EX_OS_LINUX
|
# define EX_OS_LINUX
|
||||||
# define EX_OS_UNIX
|
# define EX_OS_UNIX
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
# define EX_OS_MACOS
|
# define EX_OS_MACOS
|
||||||
# define EX_OS_UNIX
|
# define EX_OS_UNIX
|
||||||
#else
|
#else
|
||||||
# error unsupported platform.
|
# error unsupported platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// compiler
|
// compiler
|
||||||
#ifdef EX_OS_WIN32
|
#ifdef EX_OS_WIN32
|
||||||
# ifndef _MSC_VER
|
# ifndef _MSC_VER
|
||||||
# error need VisualStudio on Windows.
|
# error need VisualStudio on Windows.
|
||||||
# endif
|
# endif
|
||||||
# if _MSC_VER < 1900 // need VisualStudio 2015 and above.
|
# if _MSC_VER < 1900 // need VisualStudio 2015 and above.
|
||||||
# error need VisualStudio 2015 and above.
|
# error need VisualStudio 2015 and above.
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EX_OS_WIN32
|
#ifdef EX_OS_WIN32
|
||||||
# if !defined(UNICODE) && !defined(_UNICODE)
|
# if !defined(UNICODE) && !defined(_UNICODE)
|
||||||
# error "Does not support `Multi-Byte Character Set` on Windows."
|
# error "Does not support `Multi-Byte Character Set` on Windows."
|
||||||
# endif
|
# endif
|
||||||
# ifdef _DEBUG
|
# ifdef _DEBUG
|
||||||
# ifndef EX_DEBUG
|
# ifndef EX_DEBUG
|
||||||
# define EX_DEBUG
|
# define EX_DEBUG
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EX_OS_MACOS
|
#ifdef EX_OS_MACOS
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
# define EX_DEBUG
|
# define EX_DEBUG
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef EX_OS_WIN32
|
#ifdef EX_OS_WIN32
|
||||||
# ifndef _WIN32_WINNT
|
# ifndef _WIN32_WINNT
|
||||||
# define _WIN32_WINNT 0x0502 // 0x0502 = WinServer2003 (libuv need this) 0x0501 = WinXP, 0x0500 = Win2000
|
# define _WIN32_WINNT 0x0502 // 0x0502 = WinServer2003 (libuv need this) 0x0501 = WinXP, 0x0500 = Win2000
|
||||||
# endif
|
# endif
|
||||||
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
# define _CRT_RAND_S // for rand_s().
|
# define _CRT_RAND_S // for rand_s().
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <tchar.h>
|
# include <tchar.h>
|
||||||
# include <shlwapi.h>
|
# include <shlwapi.h>
|
||||||
# include <shellapi.h>
|
# include <shellapi.h>
|
||||||
# define _CSTDIO_
|
# define _CSTDIO_
|
||||||
# define _CSTRING_
|
# define _CSTRING_
|
||||||
# define _CWCHAR_
|
# define _CWCHAR_
|
||||||
# include <strsafe.h>
|
# include <strsafe.h>
|
||||||
# include <WinSock2.h>
|
# include <WinSock2.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
#else
|
#else
|
||||||
# include <locale.h>
|
# include <locale.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h> // free()
|
# include <stdlib.h> // free()
|
||||||
# include <stdarg.h> // va_start()
|
# include <stdarg.h> // va_start()
|
||||||
# include <unistd.h> // readlink()
|
# include <unistd.h> // readlink()
|
||||||
# include <wchar.h>
|
# include <fcntl.h> // O_RDONLY, etc.
|
||||||
# include <sys/stat.h>
|
# include <errno.h>
|
||||||
# include <sys/types.h>
|
# include <wchar.h>
|
||||||
# include <sys/socket.h>
|
# include <sys/stat.h>
|
||||||
# include <netinet/in.h>
|
# include <sys/types.h>
|
||||||
#endif
|
# include <sys/socket.h>
|
||||||
#ifdef EX_OS_MACOS
|
# include <netinet/in.h>
|
||||||
# include <mach-o/dyld.h> // for _NSGetExecutablePath
|
#endif
|
||||||
# ifndef _T
|
|
||||||
# define _T(x) L##x
|
#ifdef EX_OS_MACOS
|
||||||
# endif
|
# include <mach-o/dyld.h> // for _NSGetExecutablePath
|
||||||
#endif
|
# ifndef _T
|
||||||
|
# define _T(x) L##x
|
||||||
|
# endif
|
||||||
/*
|
#endif
|
||||||
* On Windows PATH_MAX does not exist but MAX_PATH does.
|
|
||||||
* WinAPI MAX_PATH limit is only 256. MSVCR fuctions does not have this limit.
|
|
||||||
* Redefine PATH_MAX for Windows to support longer path names.
|
/*
|
||||||
*/
|
* On Windows PATH_MAX does not exist but MAX_PATH does.
|
||||||
#if defined(EX_OS_WIN32)
|
* WinAPI MAX_PATH limit is only 256. MSVCR fuctions does not have this limit.
|
||||||
# ifdef PATH_MAX
|
* Redefine PATH_MAX for Windows to support longer path names.
|
||||||
# undef PATH_MAX /* On Windows override PATH_MAX if defined. */
|
*/
|
||||||
# endif
|
#if defined(EX_OS_WIN32)
|
||||||
# define PATH_MAX 1024
|
# ifdef PATH_MAX
|
||||||
#elif defined(EX_OS_LINUX)
|
# undef PATH_MAX /* On Windows override PATH_MAX if defined. */
|
||||||
# ifndef PATH_MAX
|
# endif
|
||||||
# define PATH_MAX 1024
|
# define PATH_MAX 1024
|
||||||
# endif
|
#elif defined(EX_OS_LINUX)
|
||||||
#elif defined(EX_OS_MACOS)
|
# ifndef PATH_MAX
|
||||||
# define PATH_MAX 1024 /* Recommended value for OSX. */
|
# define PATH_MAX 1024
|
||||||
#endif
|
# endif
|
||||||
|
#elif defined(EX_OS_MACOS)
|
||||||
// assert
|
# define PATH_MAX 1024 /* Recommended value for OSX. */
|
||||||
#ifdef EX_DEBUG
|
#endif
|
||||||
# define ASSERT(exp)
|
|
||||||
# define CHECK(exp) do { if (!(exp)) abort(); } while (0)
|
// assert
|
||||||
//# define DEBUG_CHECKS (0)
|
#ifdef EX_DEBUG
|
||||||
#else
|
# define ASSERT(exp)
|
||||||
# include <assert.h>
|
# define CHECK(exp) do { if (!(exp)) abort(); } while (0)
|
||||||
# define ASSERT(exp) assert(exp)
|
//# define DEBUG_CHECKS (0)
|
||||||
# define CHECK(exp) assert(exp)
|
#else
|
||||||
//# define DEBUG_CHECKS (1)
|
# include <assert.h>
|
||||||
#endif
|
# define ASSERT(exp) assert(exp)
|
||||||
|
# define CHECK(exp) assert(exp)
|
||||||
#define UNREACHABLE() CHECK(!"Unreachable code reached.")
|
//# define DEBUG_CHECKS (1)
|
||||||
|
#endif
|
||||||
#ifndef UNUSED
|
|
||||||
# if defined(_MSC_VER)
|
#define UNREACHABLE() CHECK(!"Unreachable code reached.")
|
||||||
# define UNUSED(x) (void)(x)
|
|
||||||
# elif defined(__GUNC__)
|
#ifndef UNUSED
|
||||||
# defined UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
# if defined(_MSC_VER)
|
||||||
# elif defined(__LCLINT__)
|
# define UNUSED(x) (void)(x)
|
||||||
# define UNUSED(x) /*@unused@*/ x
|
# elif defined(__GUNC__)
|
||||||
# elif defined(__cplusplus)
|
# defined UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
||||||
# define UNUSED(x)
|
# elif defined(__LCLINT__)
|
||||||
# else
|
# define UNUSED(x) /*@unused@*/ x
|
||||||
# define UNUSED(x) (void)(x)
|
# elif defined(__cplusplus)
|
||||||
# endif
|
# define UNUSED(x)
|
||||||
#endif
|
# else
|
||||||
|
# define UNUSED(x) (void)(x)
|
||||||
/* check endian */
|
# endif
|
||||||
#if !(defined(L_ENDIAN) || defined(B_ENDIAN))
|
#endif
|
||||||
# if !defined(__BYTE_ORDER) && defined(__linux__)
|
|
||||||
# include <endian.h>
|
/* check endian */
|
||||||
# endif
|
#if !(defined(L_ENDIAN) || defined(B_ENDIAN))
|
||||||
|
# if !defined(__BYTE_ORDER) && defined(__linux__)
|
||||||
# if defined(BYTE_ORDER)
|
# include <endian.h>
|
||||||
# if BYTE_ORDER == BIG_ENDIAN
|
# endif
|
||||||
# define B_ENDIAN
|
|
||||||
# else
|
# if defined(BYTE_ORDER)
|
||||||
# define L_ENDIAN
|
# if BYTE_ORDER == BIG_ENDIAN
|
||||||
# endif
|
# define B_ENDIAN
|
||||||
# endif
|
# else
|
||||||
|
# define L_ENDIAN
|
||||||
# if !(defined(L_ENDIAN) || defined(B_ENDIAN))
|
# endif
|
||||||
# if defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__hppa__)
|
# endif
|
||||||
# define B_ENDIAN
|
|
||||||
# else
|
# if !(defined(L_ENDIAN) || defined(B_ENDIAN))
|
||||||
# define L_ENDIAN
|
# if defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__hppa__)
|
||||||
# endif
|
# define B_ENDIAN
|
||||||
# endif
|
# else
|
||||||
#endif
|
# define L_ENDIAN
|
||||||
|
# endif
|
||||||
#ifdef EX_OS_WIN32
|
# endif
|
||||||
# pragma comment(lib, "shlwapi.lib")
|
#endif
|
||||||
#endif
|
|
||||||
|
#ifdef EX_OS_WIN32
|
||||||
|
# pragma comment(lib, "shlwapi.lib")
|
||||||
#endif // __LIB_EX_PLATFORM_H__
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __LIB_EX_PLATFORM_H__
|
||||||
|
|
|
@ -190,7 +190,7 @@ FILE *ex_fopen(const ex_wstr &filename, const wchar_t *mode) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* ex_fopen(const ex_astr& filename, const char* mode) {
|
FILE* ex_fopen(const ex_astr& filename, const char* mode) {
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
#ifdef EX_OS_WIN32
|
#ifdef EX_OS_WIN32
|
||||||
errno_t err = 0;
|
errno_t err = 0;
|
||||||
|
@ -200,10 +200,10 @@ FILE* ex_fopen(const ex_astr& filename, const char* mode) {
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
f = fopen(filename.c_str(), mode.c_str());
|
f = fopen(filename.c_str(), mode);
|
||||||
return f;
|
return f;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ex_read_text_file(const ex_wstr &strFileName, ex_astr& file_content) {
|
bool ex_read_text_file(const ex_wstr &strFileName, ex_astr& file_content) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool SshProxy::init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshProxy::timer(void) {
|
void SshProxy::timer(void) {
|
||||||
EXLOGV("[ssh] on-timer.\n");
|
// EXLOGV("[ssh] on-timer.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshProxy::_thread_loop(void)
|
void SshProxy::_thread_loop(void)
|
||||||
|
|
Loading…
Reference in New Issue